documentation.d.ts 3.1 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813678146781567816678176781867819678206782167822678236782467825678266782767828678296783067831678326783367834678356783667837678386783967840678416784267843678446784567846678476784867849678506785167852678536785467855678566785767858678596786067861678626786367864678656786667867678686786967870678716787267873678746787567876678776787867879678806788167882678836788467885678866788767888678896789067891678926789367894678956789667897678986789967900679016790267903679046790567906679076790867909679106791167912679136791467915679166791767918679196792067921679226792367924679256792667927679286792967930679316793267933679346793567936679376793867939679406794167942679436794467945679466794767948679496795067951679526795367954679556795667957679586795967960679616796267963679646796567966679676796867969679706797167972679736797467975679766797767978679796798067981679826798367984679856798667987679886798967990679916799267993679946799567996679976799867999680006800168002680036800468005680066800768008680096801068011680126801368014680156801668017680186801968020680216802268023680246802568026680276802868029680306803168032680336803468035680366803768038680396804068041680426804368044680456804668047680486804968050680516805268053680546805568056680576805868059680606806168062680636806468065680666806768068680696807068071680726807368074680756807668077680786807968080680816808268083680846808568086680876808868089680906809168092680936809468095680966809768098680996810068101681026810368104681056810668107681086810968110681116811268113681146811568116681176811868119681206812168122681236812468125681266812768128681296813068131681326813368134681356813668137681386813968140681416814268143681446814568146681476814868149681506815168152681536815468155681566815768158681596816068161681626816368164681656816668167681686816968170681716817268173681746817568176681776817868179681806818168182681836818468185681866818768188681896819068191681926819368194681956819668197681986819968200682016820268203682046820568206682076820868209682106821168212682136821468215682166821768218682196822068221682226822368224682256822668227682286822968230682316823268233682346823568236682376823868239682406824168242682436824468245682466824768248682496825068251682526825368254682556825668257682586825968260682616826268263682646826568266682676826868269682706827168272682736827468275682766827768278682796828068281682826828368284682856828668287682886828968290682916829268293682946829568296682976829868299683006830168302683036830468305683066830768308683096831068311683126831368314683156831668317683186831968320683216832268323683246832568326683276832868329683306833168332683336833468335683366833768338683396834068341683426834368344683456834668347683486834968350683516835268353683546835568356683576835868359683606836168362683636836468365683666836768368683696837068371683726837368374683756837668377683786837968380683816838268383683846838568386683876838868389683906839168392683936839468395683966839768398683996840068401684026840368404684056840668407684086840968410684116841268413684146841568416684176841868419684206842168422684236842468425684266842768428684296843068431684326843368434684356843668437684386843968440684416844268443684446844568446684476844868449684506845168452684536845468455684566845768458684596846068461684626846368464684656846668467684686846968470684716847268473684746847568476684776847868479684806848168482684836848468485684866848768488684896849068491684926849368494684956849668497684986849968500685016850268503685046850568506685076850868509685106851168512685136851468515685166851768518685196852068521685226852368524685256852668527685286852968530685316853268533685346853568536685376853868539685406854168542685436854468545685466854768548685496855068551685526855368554685556855668557685586855968560685616856268563685646856568566685676856868569685706857168572685736857468575685766857768578685796858068581685826858368584685856858668587685886858968590685916859268593685946859568596685976859868599686006860168602686036860468605686066860768608686096861068611686126861368614686156861668617686186861968620686216862268623686246862568626686276862868629686306863168632686336863468635686366863768638686396864068641686426864368644686456864668647686486864968650686516865268653686546865568656686576865868659686606866168662686636866468665686666866768668686696867068671686726867368674686756867668677686786867968680686816868268683686846868568686686876868868689686906869168692686936869468695686966869768698686996870068701687026870368704687056870668707687086870968710687116871268713687146871568716687176871868719687206872168722687236872468725687266872768728687296873068731687326873368734687356873668737687386873968740687416874268743687446874568746687476874868749687506875168752687536875468755687566875768758687596876068761687626876368764687656876668767687686876968770687716877268773687746877568776687776877868779687806878168782687836878468785687866878768788687896879068791687926879368794687956879668797687986879968800688016880268803688046880568806688076880868809688106881168812688136881468815688166881768818688196882068821688226882368824688256882668827688286882968830688316883268833688346883568836688376883868839688406884168842688436884468845688466884768848688496885068851688526885368854688556885668857688586885968860688616886268863688646886568866688676886868869688706887168872688736887468875688766887768878688796888068881688826888368884688856888668887688886888968890688916889268893688946889568896688976889868899689006890168902689036890468905689066890768908689096891068911689126891368914689156891668917689186891968920689216892268923689246892568926689276892868929689306893168932689336893468935689366893768938689396894068941689426894368944689456894668947689486894968950689516895268953689546895568956689576895868959689606896168962689636896468965689666896768968689696897068971689726897368974689756897668977689786897968980689816898268983689846898568986689876898868989689906899168992689936899468995689966899768998689996900069001690026900369004690056900669007690086900969010690116901269013690146901569016690176901869019690206902169022690236902469025690266902769028690296903069031690326903369034690356903669037690386903969040690416904269043690446904569046690476904869049690506905169052690536905469055690566905769058690596906069061690626906369064690656906669067690686906969070690716907269073690746907569076690776907869079690806908169082690836908469085690866908769088690896909069091690926909369094690956909669097690986909969100691016910269103691046910569106691076910869109691106911169112691136911469115691166911769118691196912069121691226912369124691256912669127691286912969130691316913269133691346913569136691376913869139691406914169142691436914469145691466914769148691496915069151691526915369154691556915669157691586915969160691616916269163691646916569166691676916869169691706917169172691736917469175691766917769178691796918069181691826918369184691856918669187691886918969190691916919269193691946919569196691976919869199692006920169202692036920469205692066920769208692096921069211692126921369214692156921669217692186921969220692216922269223692246922569226692276922869229692306923169232692336923469235692366923769238692396924069241692426924369244692456924669247692486924969250692516925269253692546925569256692576925869259692606926169262692636926469265692666926769268692696927069271692726927369274692756927669277692786927969280692816928269283692846928569286692876928869289692906929169292692936929469295692966929769298692996930069301693026930369304693056930669307693086930969310693116931269313693146931569316693176931869319693206932169322693236932469325693266932769328693296933069331693326933369334693356933669337693386933969340693416934269343693446934569346693476934869349693506935169352693536935469355693566935769358693596936069361693626936369364693656936669367693686936969370693716937269373693746937569376693776937869379693806938169382693836938469385693866938769388693896939069391693926939369394693956939669397693986939969400694016940269403694046940569406694076940869409694106941169412694136941469415694166941769418694196942069421694226942369424694256942669427694286942969430694316943269433694346943569436694376943869439694406944169442694436944469445694466944769448694496945069451694526945369454694556945669457694586945969460694616946269463694646946569466694676946869469694706947169472694736947469475694766947769478694796948069481694826948369484694856948669487694886948969490694916949269493694946949569496694976949869499695006950169502695036950469505695066950769508695096951069511695126951369514695156951669517695186951969520695216952269523695246952569526695276952869529695306953169532695336953469535695366953769538695396954069541695426954369544695456954669547695486954969550695516955269553695546955569556695576955869559695606956169562695636956469565695666956769568695696957069571695726957369574695756957669577695786957969580695816958269583695846958569586695876958869589695906959169592695936959469595695966959769598695996960069601696026960369604696056960669607696086960969610696116961269613696146961569616696176961869619696206962169622696236962469625696266962769628696296963069631696326963369634696356963669637696386963969640696416964269643696446964569646696476964869649696506965169652696536965469655696566965769658696596966069661696626966369664696656966669667696686966969670696716967269673696746967569676696776967869679696806968169682696836968469685696866968769688696896969069691696926969369694696956969669697696986969969700697016970269703697046970569706697076970869709697106971169712697136971469715697166971769718697196972069721697226972369724697256972669727697286972969730697316973269733697346973569736697376973869739697406974169742697436974469745697466974769748697496975069751697526975369754697556975669757697586975969760697616976269763697646976569766697676976869769697706977169772697736977469775697766977769778697796978069781697826978369784697856978669787697886978969790697916979269793697946979569796697976979869799698006980169802698036980469805698066980769808698096981069811698126981369814698156981669817698186981969820698216982269823698246982569826698276982869829698306983169832698336983469835698366983769838698396984069841698426984369844698456984669847698486984969850698516985269853698546985569856698576985869859698606986169862698636986469865698666986769868698696987069871698726987369874698756987669877698786987969880698816988269883698846988569886698876988869889698906989169892698936989469895698966989769898698996990069901699026990369904699056990669907699086990969910699116991269913699146991569916699176991869919699206992169922699236992469925699266992769928699296993069931699326993369934699356993669937699386993969940699416994269943699446994569946699476994869949699506995169952699536995469955699566995769958699596996069961699626996369964699656996669967699686996969970699716997269973699746997569976699776997869979699806998169982699836998469985699866998769988699896999069991699926999369994699956999669997699986999970000700017000270003700047000570006700077000870009700107001170012700137001470015700167001770018700197002070021700227002370024700257002670027700287002970030700317003270033700347003570036700377003870039700407004170042700437004470045700467004770048700497005070051700527005370054700557005670057700587005970060700617006270063700647006570066700677006870069700707007170072700737007470075700767007770078700797008070081700827008370084700857008670087700887008970090700917009270093700947009570096700977009870099701007010170102701037010470105701067010770108701097011070111701127011370114701157011670117701187011970120701217012270123701247012570126701277012870129701307013170132701337013470135701367013770138701397014070141701427014370144701457014670147701487014970150701517015270153701547015570156701577015870159701607016170162701637016470165701667016770168701697017070171701727017370174701757017670177701787017970180701817018270183701847018570186701877018870189701907019170192701937019470195701967019770198701997020070201702027020370204702057020670207702087020970210702117021270213702147021570216702177021870219702207022170222702237022470225702267022770228702297023070231702327023370234702357023670237702387023970240702417024270243702447024570246702477024870249702507025170252702537025470255702567025770258702597026070261702627026370264702657026670267702687026970270702717027270273702747027570276702777027870279702807028170282702837028470285702867028770288702897029070291702927029370294702957029670297702987029970300703017030270303703047030570306703077030870309703107031170312703137031470315703167031770318703197032070321703227032370324703257032670327703287032970330703317033270333703347033570336703377033870339703407034170342703437034470345703467034770348703497035070351703527035370354703557035670357703587035970360703617036270363703647036570366703677036870369703707037170372703737037470375703767037770378703797038070381703827038370384703857038670387703887038970390703917039270393703947039570396703977039870399704007040170402704037040470405704067040770408704097041070411704127041370414704157041670417704187041970420704217042270423704247042570426704277042870429704307043170432704337043470435704367043770438704397044070441704427044370444704457044670447704487044970450704517045270453704547045570456704577045870459704607046170462704637046470465704667046770468704697047070471704727047370474704757047670477704787047970480704817048270483704847048570486704877048870489704907049170492704937049470495704967049770498704997050070501705027050370504705057050670507705087050970510705117051270513705147051570516705177051870519705207052170522705237052470525705267052770528705297053070531705327053370534705357053670537705387053970540705417054270543705447054570546705477054870549705507055170552705537055470555705567055770558705597056070561705627056370564705657056670567705687056970570705717057270573705747057570576705777057870579705807058170582705837058470585705867058770588705897059070591705927059370594705957059670597705987059970600706017060270603706047060570606706077060870609706107061170612706137061470615706167061770618706197062070621706227062370624706257062670627706287062970630706317063270633706347063570636706377063870639706407064170642706437064470645706467064770648706497065070651706527065370654706557065670657706587065970660706617066270663706647066570666706677066870669706707067170672706737067470675706767067770678706797068070681706827068370684706857068670687706887068970690706917069270693706947069570696706977069870699707007070170702707037070470705707067070770708707097071070711707127071370714707157071670717707187071970720707217072270723707247072570726707277072870729707307073170732707337073470735707367073770738707397074070741707427074370744707457074670747707487074970750707517075270753707547075570756707577075870759707607076170762707637076470765707667076770768707697077070771707727077370774707757077670777707787077970780707817078270783707847078570786707877078870789707907079170792707937079470795707967079770798707997080070801708027080370804708057080670807708087080970810708117081270813708147081570816708177081870819708207082170822708237082470825708267082770828708297083070831708327083370834708357083670837708387083970840708417084270843708447084570846708477084870849708507085170852708537085470855708567085770858708597086070861708627086370864708657086670867708687086970870708717087270873708747087570876708777087870879708807088170882708837088470885708867088770888708897089070891708927089370894708957089670897708987089970900709017090270903709047090570906709077090870909709107091170912709137091470915709167091770918709197092070921709227092370924709257092670927709287092970930709317093270933709347093570936709377093870939709407094170942709437094470945709467094770948709497095070951709527095370954709557095670957709587095970960709617096270963709647096570966709677096870969709707097170972709737097470975709767097770978709797098070981709827098370984709857098670987709887098970990709917099270993709947099570996709977099870999710007100171002710037100471005710067100771008710097101071011710127101371014710157101671017710187101971020710217102271023710247102571026710277102871029710307103171032710337103471035710367103771038710397104071041710427104371044710457104671047710487104971050710517105271053710547105571056710577105871059710607106171062710637106471065710667106771068710697107071071710727107371074710757107671077710787107971080710817108271083710847108571086710877108871089710907109171092710937109471095710967109771098710997110071101711027110371104711057110671107711087110971110711117111271113711147111571116711177111871119711207112171122711237112471125711267112771128711297113071131711327113371134711357113671137711387113971140711417114271143711447114571146711477114871149711507115171152711537115471155711567115771158711597116071161711627116371164711657116671167711687116971170711717117271173711747117571176711777117871179711807118171182711837118471185711867118771188711897119071191711927119371194711957119671197711987119971200712017120271203712047120571206712077120871209712107121171212712137121471215712167121771218712197122071221712227122371224712257122671227712287122971230712317123271233712347123571236712377123871239712407124171242712437124471245712467124771248712497125071251712527125371254712557125671257712587125971260712617126271263712647126571266712677126871269712707127171272712737127471275712767127771278712797128071281712827128371284712857128671287712887128971290712917129271293712947129571296712977129871299713007130171302713037130471305713067130771308713097131071311713127131371314713157131671317713187131971320713217132271323713247132571326713277132871329713307133171332713337133471335713367133771338713397134071341713427134371344713457134671347713487134971350713517135271353713547135571356713577135871359713607136171362713637136471365713667136771368713697137071371713727137371374713757137671377713787137971380713817138271383713847138571386713877138871389713907139171392713937139471395713967139771398713997140071401714027140371404714057140671407714087140971410714117141271413714147141571416714177141871419714207142171422714237142471425714267142771428714297143071431714327143371434714357143671437714387143971440714417144271443714447144571446714477144871449714507145171452714537145471455714567145771458714597146071461714627146371464714657146671467714687146971470714717147271473714747147571476714777147871479714807148171482714837148471485714867148771488714897149071491714927149371494714957149671497714987149971500715017150271503715047150571506715077150871509715107151171512715137151471515715167151771518715197152071521715227152371524715257152671527715287152971530715317153271533715347153571536715377153871539715407154171542715437154471545715467154771548715497155071551715527155371554715557155671557715587155971560715617156271563715647156571566715677156871569715707157171572715737157471575715767157771578715797158071581715827158371584715857158671587715887158971590715917159271593715947159571596715977159871599716007160171602716037160471605716067160771608716097161071611716127161371614716157161671617716187161971620716217162271623716247162571626716277162871629716307163171632716337163471635716367163771638716397164071641716427164371644716457164671647716487164971650716517165271653716547165571656716577165871659716607166171662716637166471665716667166771668716697167071671716727167371674716757167671677716787167971680716817168271683716847168571686716877168871689716907169171692716937169471695716967169771698716997170071701717027170371704717057170671707717087170971710717117171271713717147171571716717177171871719717207172171722717237172471725717267172771728717297173071731717327173371734717357173671737717387173971740717417174271743717447174571746717477174871749717507175171752717537175471755717567175771758717597176071761717627176371764717657176671767717687176971770717717177271773717747177571776717777177871779717807178171782717837178471785717867178771788717897179071791717927179371794717957179671797717987179971800718017180271803718047180571806718077180871809718107181171812718137181471815718167181771818718197182071821718227182371824718257182671827718287182971830718317183271833718347183571836718377183871839718407184171842718437184471845718467184771848718497185071851718527185371854718557185671857718587185971860718617186271863718647186571866718677186871869718707187171872718737187471875718767187771878718797188071881718827188371884718857188671887718887188971890718917189271893718947189571896718977189871899719007190171902719037190471905719067190771908719097191071911719127191371914719157191671917719187191971920719217192271923719247192571926719277192871929719307193171932719337193471935719367193771938719397194071941719427194371944719457194671947719487194971950719517195271953719547195571956719577195871959719607196171962719637196471965719667196771968719697197071971719727197371974719757197671977719787197971980719817198271983719847198571986719877198871989719907199171992719937199471995719967199771998719997200072001720027200372004720057200672007720087200972010720117201272013720147201572016720177201872019720207202172022720237202472025720267202772028720297203072031720327203372034720357203672037720387203972040720417204272043720447204572046720477204872049720507205172052720537205472055720567205772058720597206072061720627206372064720657206672067720687206972070720717207272073720747207572076720777207872079720807208172082720837208472085720867208772088720897209072091720927209372094720957209672097720987209972100721017210272103721047210572106721077210872109721107211172112721137211472115721167211772118721197212072121721227212372124721257212672127721287212972130721317213272133721347213572136721377213872139721407214172142721437214472145721467214772148721497215072151721527215372154721557215672157721587215972160721617216272163721647216572166721677216872169721707217172172721737217472175721767217772178721797218072181721827218372184721857218672187721887218972190721917219272193721947219572196721977219872199722007220172202722037220472205722067220772208722097221072211722127221372214722157221672217722187221972220722217222272223722247222572226722277222872229722307223172232722337223472235722367223772238722397224072241722427224372244722457224672247722487224972250722517225272253722547225572256722577225872259722607226172262722637226472265722667226772268722697227072271722727227372274722757227672277722787227972280722817228272283722847228572286722877228872289722907229172292722937229472295722967229772298722997230072301723027230372304723057230672307723087230972310723117231272313723147231572316723177231872319723207232172322723237232472325723267232772328723297233072331723327233372334723357233672337723387233972340723417234272343723447234572346723477234872349723507235172352723537235472355723567235772358723597236072361723627236372364723657236672367723687236972370723717237272373723747237572376723777237872379723807238172382723837238472385723867238772388723897239072391723927239372394723957239672397723987239972400724017240272403724047240572406724077240872409724107241172412724137241472415724167241772418724197242072421724227242372424724257242672427724287242972430724317243272433724347243572436724377243872439724407244172442724437244472445724467244772448724497245072451724527245372454724557245672457724587245972460724617246272463724647246572466724677246872469724707247172472724737247472475724767247772478724797248072481724827248372484724857248672487724887248972490724917249272493724947249572496724977249872499725007250172502725037250472505725067250772508725097251072511725127251372514725157251672517725187251972520725217252272523725247252572526725277252872529725307253172532725337253472535725367253772538725397254072541725427254372544725457254672547725487254972550725517255272553725547255572556725577255872559725607256172562725637256472565725667256772568725697257072571725727257372574725757257672577725787257972580725817258272583725847258572586725877258872589725907259172592725937259472595725967259772598725997260072601726027260372604726057260672607726087260972610726117261272613726147261572616726177261872619726207262172622726237262472625726267262772628726297263072631726327263372634726357263672637726387263972640726417264272643726447264572646726477264872649726507265172652726537265472655726567265772658726597266072661726627266372664726657266672667726687266972670726717267272673726747267572676726777267872679726807268172682726837268472685726867268772688726897269072691726927269372694726957269672697726987269972700727017270272703727047270572706727077270872709727107271172712727137271472715727167271772718727197272072721727227272372724727257272672727727287272972730727317273272733727347273572736727377273872739727407274172742727437274472745727467274772748727497275072751727527275372754727557275672757727587275972760727617276272763727647276572766727677276872769727707277172772727737277472775727767277772778727797278072781727827278372784727857278672787727887278972790727917279272793727947279572796727977279872799728007280172802728037280472805728067280772808728097281072811728127281372814728157281672817728187281972820728217282272823728247282572826728277282872829728307283172832728337283472835728367283772838728397284072841728427284372844728457284672847728487284972850728517285272853728547285572856728577285872859728607286172862728637286472865728667286772868728697287072871728727287372874728757287672877728787287972880728817288272883728847288572886728877288872889728907289172892728937289472895728967289772898728997290072901729027290372904729057290672907729087290972910729117291272913729147291572916729177291872919729207292172922729237292472925729267292772928729297293072931729327293372934729357293672937729387293972940729417294272943729447294572946729477294872949729507295172952729537295472955729567295772958729597296072961729627296372964729657296672967729687296972970729717297272973729747297572976729777297872979729807298172982729837298472985729867298772988729897299072991729927299372994729957299672997729987299973000730017300273003730047300573006730077300873009730107301173012730137301473015730167301773018730197302073021730227302373024730257302673027730287302973030730317303273033730347303573036730377303873039730407304173042730437304473045730467304773048730497305073051730527305373054730557305673057730587305973060730617306273063730647306573066730677306873069730707307173072730737307473075730767307773078730797308073081730827308373084730857308673087730887308973090730917309273093730947309573096730977309873099731007310173102731037310473105731067310773108731097311073111731127311373114731157311673117731187311973120731217312273123731247312573126731277312873129731307313173132731337313473135731367313773138731397314073141731427314373144731457314673147731487314973150731517315273153731547315573156731577315873159731607316173162731637316473165731667316773168731697317073171731727317373174731757317673177731787317973180731817318273183731847318573186731877318873189731907319173192731937319473195731967319773198731997320073201732027320373204732057320673207732087320973210732117321273213732147321573216732177321873219732207322173222732237322473225732267322773228732297323073231732327323373234732357323673237732387323973240732417324273243732447324573246732477324873249732507325173252732537325473255732567325773258732597326073261732627326373264732657326673267732687326973270732717327273273732747327573276732777327873279732807328173282732837328473285732867328773288732897329073291732927329373294732957329673297732987329973300733017330273303733047330573306733077330873309733107331173312733137331473315733167331773318733197332073321733227332373324733257332673327733287332973330733317333273333733347333573336733377333873339733407334173342733437334473345733467334773348733497335073351733527335373354733557335673357733587335973360733617336273363733647336573366733677336873369733707337173372733737337473375733767337773378733797338073381733827338373384733857338673387733887338973390733917339273393733947339573396733977339873399734007340173402734037340473405734067340773408734097341073411734127341373414734157341673417734187341973420734217342273423734247342573426734277342873429734307343173432734337343473435734367343773438734397344073441734427344373444734457344673447734487344973450734517345273453734547345573456734577345873459734607346173462734637346473465734667346773468734697347073471734727347373474734757347673477734787347973480734817348273483734847348573486734877348873489734907349173492734937349473495734967349773498734997350073501735027350373504735057350673507735087350973510735117351273513735147351573516735177351873519735207352173522735237352473525735267352773528735297353073531735327353373534735357353673537735387353973540735417354273543735447354573546735477354873549735507355173552735537355473555735567355773558735597356073561735627356373564735657356673567735687356973570735717357273573735747357573576735777357873579735807358173582735837358473585735867358773588735897359073591735927359373594735957359673597735987359973600736017360273603736047360573606736077360873609736107361173612736137361473615736167361773618736197362073621736227362373624736257362673627736287362973630736317363273633736347363573636736377363873639736407364173642736437364473645736467364773648736497365073651736527365373654736557365673657736587365973660736617366273663736647366573666736677366873669736707367173672736737367473675736767367773678736797368073681736827368373684736857368673687736887368973690736917369273693736947369573696736977369873699737007370173702737037370473705737067370773708737097371073711737127371373714737157371673717737187371973720737217372273723737247372573726737277372873729737307373173732737337373473735737367373773738737397374073741737427374373744737457374673747737487374973750737517375273753737547375573756737577375873759737607376173762737637376473765737667376773768737697377073771737727377373774737757377673777737787377973780737817378273783737847378573786737877378873789737907379173792737937379473795737967379773798737997380073801738027380373804738057380673807738087380973810738117381273813738147381573816738177381873819738207382173822738237382473825738267382773828738297383073831738327383373834738357383673837738387383973840738417384273843738447384573846738477384873849738507385173852738537385473855738567385773858738597386073861738627386373864738657386673867738687386973870738717387273873738747387573876738777387873879738807388173882738837388473885738867388773888738897389073891738927389373894738957389673897738987389973900739017390273903739047390573906739077390873909739107391173912739137391473915739167391773918739197392073921739227392373924739257392673927739287392973930739317393273933739347393573936739377393873939739407394173942739437394473945739467394773948739497395073951739527395373954739557395673957739587395973960739617396273963739647396573966739677396873969739707397173972739737397473975739767397773978739797398073981739827398373984739857398673987739887398973990739917399273993739947399573996739977399873999740007400174002740037400474005740067400774008740097401074011740127401374014740157401674017740187401974020740217402274023740247402574026740277402874029740307403174032740337403474035740367403774038740397404074041740427404374044740457404674047740487404974050740517405274053740547405574056740577405874059740607406174062740637406474065740667406774068740697407074071740727407374074740757407674077740787407974080740817408274083740847408574086740877408874089740907409174092740937409474095740967409774098740997410074101741027410374104741057410674107741087410974110741117411274113741147411574116741177411874119741207412174122741237412474125741267412774128741297413074131741327413374134741357413674137741387413974140741417414274143741447414574146741477414874149741507415174152741537415474155741567415774158741597416074161741627416374164741657416674167741687416974170741717417274173741747417574176741777417874179741807418174182741837418474185741867418774188741897419074191741927419374194741957419674197741987419974200742017420274203742047420574206742077420874209742107421174212742137421474215742167421774218742197422074221742227422374224742257422674227742287422974230742317423274233742347423574236742377423874239742407424174242742437424474245742467424774248742497425074251742527425374254742557425674257742587425974260742617426274263742647426574266742677426874269742707427174272742737427474275742767427774278742797428074281742827428374284742857428674287742887428974290742917429274293742947429574296742977429874299743007430174302743037430474305743067430774308743097431074311743127431374314743157431674317743187431974320743217432274323743247432574326743277432874329743307433174332743337433474335743367433774338743397434074341743427434374344743457434674347743487434974350743517435274353743547435574356743577435874359743607436174362743637436474365743667436774368743697437074371743727437374374743757437674377743787437974380743817438274383743847438574386743877438874389743907439174392743937439474395743967439774398743997440074401744027440374404744057440674407744087440974410744117441274413744147441574416744177441874419744207442174422744237442474425744267442774428744297443074431744327443374434744357443674437744387443974440744417444274443744447444574446744477444874449744507445174452744537445474455744567445774458744597446074461744627446374464744657446674467744687446974470744717447274473744747447574476744777447874479744807448174482744837448474485744867448774488744897449074491744927449374494744957449674497744987449974500745017450274503745047450574506745077450874509745107451174512745137451474515745167451774518745197452074521745227452374524745257452674527745287452974530745317453274533745347453574536745377453874539745407454174542745437454474545745467454774548745497455074551745527455374554745557455674557745587455974560745617456274563745647456574566745677456874569745707457174572745737457474575745767457774578745797458074581745827458374584745857458674587745887458974590745917459274593745947459574596745977459874599746007460174602746037460474605746067460774608746097461074611746127461374614746157461674617746187461974620746217462274623746247462574626746277462874629746307463174632746337463474635746367463774638746397464074641746427464374644746457464674647746487464974650746517465274653746547465574656746577465874659746607466174662746637466474665746667466774668746697467074671746727467374674746757467674677746787467974680746817468274683746847468574686746877468874689746907469174692746937469474695746967469774698746997470074701747027470374704747057470674707747087470974710747117471274713747147471574716747177471874719747207472174722747237472474725747267472774728747297473074731747327473374734747357473674737747387473974740747417474274743747447474574746747477474874749747507475174752747537475474755747567475774758747597476074761747627476374764747657476674767747687476974770747717477274773747747477574776747777477874779747807478174782747837478474785747867478774788747897479074791747927479374794747957479674797747987479974800748017480274803748047480574806748077480874809748107481174812748137481474815748167481774818748197482074821748227482374824748257482674827748287482974830748317483274833748347483574836748377483874839748407484174842748437484474845748467484774848748497485074851748527485374854748557485674857748587485974860748617486274863748647486574866748677486874869748707487174872748737487474875748767487774878748797488074881748827488374884748857488674887748887488974890748917489274893748947489574896748977489874899749007490174902749037490474905749067490774908749097491074911749127491374914749157491674917749187491974920749217492274923749247492574926749277492874929749307493174932749337493474935749367493774938749397494074941749427494374944749457494674947749487494974950749517495274953749547495574956749577495874959749607496174962749637496474965749667496774968749697497074971749727497374974749757497674977749787497974980749817498274983749847498574986749877498874989749907499174992749937499474995749967499774998749997500075001750027500375004750057500675007750087500975010750117501275013750147501575016750177501875019750207502175022750237502475025750267502775028750297503075031750327503375034750357503675037750387503975040750417504275043750447504575046750477504875049750507505175052750537505475055750567505775058750597506075061750627506375064750657506675067750687506975070750717507275073750747507575076750777507875079750807508175082750837508475085750867508775088750897509075091750927509375094750957509675097750987509975100751017510275103751047510575106751077510875109751107511175112751137511475115751167511775118751197512075121751227512375124751257512675127751287512975130751317513275133751347513575136751377513875139751407514175142751437514475145751467514775148751497515075151751527515375154751557515675157751587515975160751617516275163751647516575166751677516875169751707517175172751737517475175751767517775178751797518075181751827518375184751857518675187751887518975190751917519275193751947519575196751977519875199752007520175202752037520475205752067520775208752097521075211752127521375214752157521675217752187521975220752217522275223752247522575226752277522875229752307523175232752337523475235752367523775238752397524075241752427524375244752457524675247752487524975250752517525275253752547525575256752577525875259752607526175262752637526475265752667526775268752697527075271752727527375274752757527675277752787527975280752817528275283752847528575286752877528875289752907529175292752937529475295752967529775298752997530075301753027530375304753057530675307753087530975310753117531275313753147531575316753177531875319753207532175322753237532475325753267532775328753297533075331753327533375334753357533675337753387533975340753417534275343753447534575346753477534875349753507535175352753537535475355753567535775358753597536075361753627536375364753657536675367753687536975370753717537275373753747537575376753777537875379753807538175382753837538475385753867538775388753897539075391753927539375394753957539675397753987539975400754017540275403754047540575406754077540875409754107541175412754137541475415754167541775418754197542075421754227542375424754257542675427754287542975430754317543275433754347543575436754377543875439754407544175442754437544475445754467544775448754497545075451754527545375454754557545675457754587545975460754617546275463754647546575466754677546875469754707547175472754737547475475754767547775478754797548075481754827548375484754857548675487754887548975490754917549275493754947549575496754977549875499755007550175502755037550475505755067550775508755097551075511755127551375514755157551675517755187551975520755217552275523755247552575526755277552875529755307553175532755337553475535755367553775538755397554075541755427554375544755457554675547755487554975550755517555275553755547555575556755577555875559755607556175562755637556475565755667556775568755697557075571755727557375574755757557675577755787557975580755817558275583
  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. * Helper to manipulate strings
  379. */
  380. export class StringTools {
  381. /**
  382. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  383. * @param str Source string
  384. * @param suffix Suffix to search for in the source string
  385. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  386. */
  387. static EndsWith(str: string, suffix: string): boolean;
  388. /**
  389. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  390. * @param str Source string
  391. * @param suffix Suffix to search for in the source string
  392. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  393. */
  394. static StartsWith(str: string, suffix: string): boolean;
  395. /**
  396. * Decodes a buffer into a string
  397. * @param buffer The buffer to decode
  398. * @returns The decoded string
  399. */
  400. static Decode(buffer: Uint8Array | Uint16Array): string;
  401. /**
  402. * Encode a buffer to a base64 string
  403. * @param buffer defines the buffer to encode
  404. * @returns the encoded string
  405. */
  406. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  407. }
  408. }
  409. declare module BABYLON {
  410. /**
  411. * Class containing a set of static utilities functions for deep copy.
  412. */
  413. export class DeepCopier {
  414. /**
  415. * Tries to copy an object by duplicating every property
  416. * @param source defines the source object
  417. * @param destination defines the target object
  418. * @param doNotCopyList defines a list of properties to avoid
  419. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  420. */
  421. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  422. }
  423. }
  424. declare module BABYLON {
  425. /**
  426. * Class containing a set of static utilities functions for precision date
  427. */
  428. export class PrecisionDate {
  429. /**
  430. * Gets either window.performance.now() if supported or Date.now() else
  431. */
  432. static readonly Now: number;
  433. }
  434. }
  435. declare module BABYLON {
  436. /** @hidden */
  437. export class _DevTools {
  438. static WarnImport(name: string): string;
  439. }
  440. }
  441. declare module BABYLON {
  442. /**
  443. * Interface used to define the mechanism to get data from the network
  444. */
  445. export interface IWebRequest {
  446. /**
  447. * Returns client's response url
  448. */
  449. responseURL: string;
  450. /**
  451. * Returns client's status
  452. */
  453. status: number;
  454. /**
  455. * Returns client's status as a text
  456. */
  457. statusText: string;
  458. }
  459. }
  460. declare module BABYLON {
  461. /**
  462. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  463. */
  464. export class WebRequest implements IWebRequest {
  465. private _xhr;
  466. /**
  467. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  468. * i.e. when loading files, where the server/service expects an Authorization header
  469. */
  470. static CustomRequestHeaders: {
  471. [key: string]: string;
  472. };
  473. /**
  474. * Add callback functions in this array to update all the requests before they get sent to the network
  475. */
  476. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  477. private _injectCustomRequestHeaders;
  478. /**
  479. * Gets or sets a function to be called when loading progress changes
  480. */
  481. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  482. /**
  483. * Returns client's state
  484. */
  485. readonly readyState: number;
  486. /**
  487. * Returns client's status
  488. */
  489. readonly status: number;
  490. /**
  491. * Returns client's status as a text
  492. */
  493. readonly statusText: string;
  494. /**
  495. * Returns client's response
  496. */
  497. readonly response: any;
  498. /**
  499. * Returns client's response url
  500. */
  501. readonly responseURL: string;
  502. /**
  503. * Returns client's response as text
  504. */
  505. readonly responseText: string;
  506. /**
  507. * Gets or sets the expected response type
  508. */
  509. responseType: XMLHttpRequestResponseType;
  510. /** @hidden */
  511. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  512. /** @hidden */
  513. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  514. /**
  515. * Cancels any network activity
  516. */
  517. abort(): void;
  518. /**
  519. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  520. * @param body defines an optional request body
  521. */
  522. send(body?: Document | BodyInit | null): void;
  523. /**
  524. * Sets the request method, request URL
  525. * @param method defines the method to use (GET, POST, etc..)
  526. * @param url defines the url to connect with
  527. */
  528. open(method: string, url: string): void;
  529. /**
  530. * Sets the value of a request header.
  531. * @param name The name of the header whose value is to be set
  532. * @param value The value to set as the body of the header
  533. */
  534. setRequestHeader(name: string, value: string): void;
  535. /**
  536. * Get the string containing the text of a particular header's value.
  537. * @param name The name of the header
  538. * @returns The string containing the text of the given header name
  539. */
  540. getResponseHeader(name: string): Nullable<string>;
  541. }
  542. }
  543. declare module BABYLON {
  544. /**
  545. * File request interface
  546. */
  547. export interface IFileRequest {
  548. /**
  549. * Raised when the request is complete (success or error).
  550. */
  551. onCompleteObservable: Observable<IFileRequest>;
  552. /**
  553. * Aborts the request for a file.
  554. */
  555. abort: () => void;
  556. }
  557. }
  558. declare module BABYLON {
  559. /**
  560. * Define options used to create a render target texture
  561. */
  562. export class RenderTargetCreationOptions {
  563. /**
  564. * Specifies is mipmaps must be generated
  565. */
  566. generateMipMaps?: boolean;
  567. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  568. generateDepthBuffer?: boolean;
  569. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  570. generateStencilBuffer?: boolean;
  571. /** Defines texture type (int by default) */
  572. type?: number;
  573. /** Defines sampling mode (trilinear by default) */
  574. samplingMode?: number;
  575. /** Defines format (RGBA by default) */
  576. format?: number;
  577. }
  578. }
  579. declare module BABYLON {
  580. /**
  581. * @hidden
  582. **/
  583. export class _TimeToken {
  584. _startTimeQuery: Nullable<WebGLQuery>;
  585. _endTimeQuery: Nullable<WebGLQuery>;
  586. _timeElapsedQuery: Nullable<WebGLQuery>;
  587. _timeElapsedQueryEnded: boolean;
  588. }
  589. }
  590. declare module BABYLON {
  591. /** Defines the cross module used constants to avoid circular dependncies */
  592. export class Constants {
  593. /** Defines that alpha blending is disabled */
  594. static readonly ALPHA_DISABLE: number;
  595. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  596. static readonly ALPHA_ADD: number;
  597. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  598. static readonly ALPHA_COMBINE: number;
  599. /** Defines that alpha blending to DEST - SRC * DEST */
  600. static readonly ALPHA_SUBTRACT: number;
  601. /** Defines that alpha blending to SRC * DEST */
  602. static readonly ALPHA_MULTIPLY: number;
  603. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  604. static readonly ALPHA_MAXIMIZED: number;
  605. /** Defines that alpha blending to SRC + DEST */
  606. static readonly ALPHA_ONEONE: number;
  607. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  608. static readonly ALPHA_PREMULTIPLIED: number;
  609. /**
  610. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  611. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  612. */
  613. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  614. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  615. static readonly ALPHA_INTERPOLATE: number;
  616. /**
  617. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  618. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  619. */
  620. static readonly ALPHA_SCREENMODE: number;
  621. /**
  622. * Defines that alpha blending to SRC + DST
  623. * Alpha will be set to SRC ALPHA + DST ALPHA
  624. */
  625. static readonly ALPHA_ONEONE_ONEONE: number;
  626. /**
  627. * Defines that alpha blending to SRC * DST ALPHA + DST
  628. * Alpha will be set to 0
  629. */
  630. static readonly ALPHA_ALPHATOCOLOR: number;
  631. /**
  632. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  633. */
  634. static readonly ALPHA_REVERSEONEMINUS: number;
  635. /**
  636. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  637. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  638. */
  639. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  640. /**
  641. * Defines that alpha blending to SRC + DST
  642. * Alpha will be set to SRC ALPHA
  643. */
  644. static readonly ALPHA_ONEONE_ONEZERO: number;
  645. /** Defines that alpha blending equation a SUM */
  646. static readonly ALPHA_EQUATION_ADD: number;
  647. /** Defines that alpha blending equation a SUBSTRACTION */
  648. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  649. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  650. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  651. /** Defines that alpha blending equation a MAX operation */
  652. static readonly ALPHA_EQUATION_MAX: number;
  653. /** Defines that alpha blending equation a MIN operation */
  654. static readonly ALPHA_EQUATION_MIN: number;
  655. /**
  656. * Defines that alpha blending equation a DARKEN operation:
  657. * It takes the min of the src and sums the alpha channels.
  658. */
  659. static readonly ALPHA_EQUATION_DARKEN: number;
  660. /** Defines that the ressource is not delayed*/
  661. static readonly DELAYLOADSTATE_NONE: number;
  662. /** Defines that the ressource was successfully delay loaded */
  663. static readonly DELAYLOADSTATE_LOADED: number;
  664. /** Defines that the ressource is currently delay loading */
  665. static readonly DELAYLOADSTATE_LOADING: number;
  666. /** Defines that the ressource is delayed and has not started loading */
  667. static readonly DELAYLOADSTATE_NOTLOADED: number;
  668. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  669. static readonly NEVER: number;
  670. /** 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 */
  671. static readonly ALWAYS: number;
  672. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  673. static readonly LESS: number;
  674. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  675. static readonly EQUAL: number;
  676. /** 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 */
  677. static readonly LEQUAL: number;
  678. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  679. static readonly GREATER: number;
  680. /** 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 */
  681. static readonly GEQUAL: number;
  682. /** 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 */
  683. static readonly NOTEQUAL: number;
  684. /** Passed to stencilOperation to specify that stencil value must be kept */
  685. static readonly KEEP: number;
  686. /** Passed to stencilOperation to specify that stencil value must be replaced */
  687. static readonly REPLACE: number;
  688. /** Passed to stencilOperation to specify that stencil value must be incremented */
  689. static readonly INCR: number;
  690. /** Passed to stencilOperation to specify that stencil value must be decremented */
  691. static readonly DECR: number;
  692. /** Passed to stencilOperation to specify that stencil value must be inverted */
  693. static readonly INVERT: number;
  694. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  695. static readonly INCR_WRAP: number;
  696. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  697. static readonly DECR_WRAP: number;
  698. /** Texture is not repeating outside of 0..1 UVs */
  699. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  700. /** Texture is repeating outside of 0..1 UVs */
  701. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  702. /** Texture is repeating and mirrored */
  703. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  704. /** ALPHA */
  705. static readonly TEXTUREFORMAT_ALPHA: number;
  706. /** LUMINANCE */
  707. static readonly TEXTUREFORMAT_LUMINANCE: number;
  708. /** LUMINANCE_ALPHA */
  709. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  710. /** RGB */
  711. static readonly TEXTUREFORMAT_RGB: number;
  712. /** RGBA */
  713. static readonly TEXTUREFORMAT_RGBA: number;
  714. /** RED */
  715. static readonly TEXTUREFORMAT_RED: number;
  716. /** RED (2nd reference) */
  717. static readonly TEXTUREFORMAT_R: number;
  718. /** RG */
  719. static readonly TEXTUREFORMAT_RG: number;
  720. /** RED_INTEGER */
  721. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  722. /** RED_INTEGER (2nd reference) */
  723. static readonly TEXTUREFORMAT_R_INTEGER: number;
  724. /** RG_INTEGER */
  725. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  726. /** RGB_INTEGER */
  727. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  728. /** RGBA_INTEGER */
  729. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  730. /** UNSIGNED_BYTE */
  731. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  732. /** UNSIGNED_BYTE (2nd reference) */
  733. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  734. /** FLOAT */
  735. static readonly TEXTURETYPE_FLOAT: number;
  736. /** HALF_FLOAT */
  737. static readonly TEXTURETYPE_HALF_FLOAT: number;
  738. /** BYTE */
  739. static readonly TEXTURETYPE_BYTE: number;
  740. /** SHORT */
  741. static readonly TEXTURETYPE_SHORT: number;
  742. /** UNSIGNED_SHORT */
  743. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  744. /** INT */
  745. static readonly TEXTURETYPE_INT: number;
  746. /** UNSIGNED_INT */
  747. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  748. /** UNSIGNED_SHORT_4_4_4_4 */
  749. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  750. /** UNSIGNED_SHORT_5_5_5_1 */
  751. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  752. /** UNSIGNED_SHORT_5_6_5 */
  753. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  754. /** UNSIGNED_INT_2_10_10_10_REV */
  755. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  756. /** UNSIGNED_INT_24_8 */
  757. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  758. /** UNSIGNED_INT_10F_11F_11F_REV */
  759. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  760. /** UNSIGNED_INT_5_9_9_9_REV */
  761. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  762. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  763. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  764. /** nearest is mag = nearest and min = nearest and mip = nearest */
  765. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  766. /** Bilinear is mag = linear and min = linear and mip = nearest */
  767. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  768. /** Trilinear is mag = linear and min = linear and mip = linear */
  769. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  770. /** nearest is mag = nearest and min = nearest and mip = linear */
  771. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  772. /** Bilinear is mag = linear and min = linear and mip = nearest */
  773. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  774. /** Trilinear is mag = linear and min = linear and mip = linear */
  775. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  776. /** mag = nearest and min = nearest and mip = nearest */
  777. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  778. /** mag = nearest and min = linear and mip = nearest */
  779. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  780. /** mag = nearest and min = linear and mip = linear */
  781. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  782. /** mag = nearest and min = linear and mip = none */
  783. static readonly TEXTURE_NEAREST_LINEAR: number;
  784. /** mag = nearest and min = nearest and mip = none */
  785. static readonly TEXTURE_NEAREST_NEAREST: number;
  786. /** mag = linear and min = nearest and mip = nearest */
  787. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  788. /** mag = linear and min = nearest and mip = linear */
  789. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  790. /** mag = linear and min = linear and mip = none */
  791. static readonly TEXTURE_LINEAR_LINEAR: number;
  792. /** mag = linear and min = nearest and mip = none */
  793. static readonly TEXTURE_LINEAR_NEAREST: number;
  794. /** Explicit coordinates mode */
  795. static readonly TEXTURE_EXPLICIT_MODE: number;
  796. /** Spherical coordinates mode */
  797. static readonly TEXTURE_SPHERICAL_MODE: number;
  798. /** Planar coordinates mode */
  799. static readonly TEXTURE_PLANAR_MODE: number;
  800. /** Cubic coordinates mode */
  801. static readonly TEXTURE_CUBIC_MODE: number;
  802. /** Projection coordinates mode */
  803. static readonly TEXTURE_PROJECTION_MODE: number;
  804. /** Skybox coordinates mode */
  805. static readonly TEXTURE_SKYBOX_MODE: number;
  806. /** Inverse Cubic coordinates mode */
  807. static readonly TEXTURE_INVCUBIC_MODE: number;
  808. /** Equirectangular coordinates mode */
  809. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  810. /** Equirectangular Fixed coordinates mode */
  811. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  812. /** Equirectangular Fixed Mirrored coordinates mode */
  813. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  814. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  815. static readonly SCALEMODE_FLOOR: number;
  816. /** Defines that texture rescaling will look for the nearest power of 2 size */
  817. static readonly SCALEMODE_NEAREST: number;
  818. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  819. static readonly SCALEMODE_CEILING: number;
  820. /**
  821. * The dirty texture flag value
  822. */
  823. static readonly MATERIAL_TextureDirtyFlag: number;
  824. /**
  825. * The dirty light flag value
  826. */
  827. static readonly MATERIAL_LightDirtyFlag: number;
  828. /**
  829. * The dirty fresnel flag value
  830. */
  831. static readonly MATERIAL_FresnelDirtyFlag: number;
  832. /**
  833. * The dirty attribute flag value
  834. */
  835. static readonly MATERIAL_AttributesDirtyFlag: number;
  836. /**
  837. * The dirty misc flag value
  838. */
  839. static readonly MATERIAL_MiscDirtyFlag: number;
  840. /**
  841. * The all dirty flag value
  842. */
  843. static readonly MATERIAL_AllDirtyFlag: number;
  844. /**
  845. * Returns the triangle fill mode
  846. */
  847. static readonly MATERIAL_TriangleFillMode: number;
  848. /**
  849. * Returns the wireframe mode
  850. */
  851. static readonly MATERIAL_WireFrameFillMode: number;
  852. /**
  853. * Returns the point fill mode
  854. */
  855. static readonly MATERIAL_PointFillMode: number;
  856. /**
  857. * Returns the point list draw mode
  858. */
  859. static readonly MATERIAL_PointListDrawMode: number;
  860. /**
  861. * Returns the line list draw mode
  862. */
  863. static readonly MATERIAL_LineListDrawMode: number;
  864. /**
  865. * Returns the line loop draw mode
  866. */
  867. static readonly MATERIAL_LineLoopDrawMode: number;
  868. /**
  869. * Returns the line strip draw mode
  870. */
  871. static readonly MATERIAL_LineStripDrawMode: number;
  872. /**
  873. * Returns the triangle strip draw mode
  874. */
  875. static readonly MATERIAL_TriangleStripDrawMode: number;
  876. /**
  877. * Returns the triangle fan draw mode
  878. */
  879. static readonly MATERIAL_TriangleFanDrawMode: number;
  880. /**
  881. * Stores the clock-wise side orientation
  882. */
  883. static readonly MATERIAL_ClockWiseSideOrientation: number;
  884. /**
  885. * Stores the counter clock-wise side orientation
  886. */
  887. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  888. /**
  889. * Nothing
  890. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  891. */
  892. static readonly ACTION_NothingTrigger: number;
  893. /**
  894. * On pick
  895. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  896. */
  897. static readonly ACTION_OnPickTrigger: number;
  898. /**
  899. * On left pick
  900. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  901. */
  902. static readonly ACTION_OnLeftPickTrigger: number;
  903. /**
  904. * On right pick
  905. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  906. */
  907. static readonly ACTION_OnRightPickTrigger: number;
  908. /**
  909. * On center pick
  910. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  911. */
  912. static readonly ACTION_OnCenterPickTrigger: number;
  913. /**
  914. * On pick down
  915. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  916. */
  917. static readonly ACTION_OnPickDownTrigger: number;
  918. /**
  919. * On double pick
  920. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  921. */
  922. static readonly ACTION_OnDoublePickTrigger: number;
  923. /**
  924. * On pick up
  925. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  926. */
  927. static readonly ACTION_OnPickUpTrigger: number;
  928. /**
  929. * On pick out.
  930. * This trigger will only be raised if you also declared a OnPickDown
  931. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  932. */
  933. static readonly ACTION_OnPickOutTrigger: number;
  934. /**
  935. * On long press
  936. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  937. */
  938. static readonly ACTION_OnLongPressTrigger: number;
  939. /**
  940. * On pointer over
  941. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  942. */
  943. static readonly ACTION_OnPointerOverTrigger: number;
  944. /**
  945. * On pointer out
  946. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  947. */
  948. static readonly ACTION_OnPointerOutTrigger: number;
  949. /**
  950. * On every frame
  951. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  952. */
  953. static readonly ACTION_OnEveryFrameTrigger: number;
  954. /**
  955. * On intersection enter
  956. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  957. */
  958. static readonly ACTION_OnIntersectionEnterTrigger: number;
  959. /**
  960. * On intersection exit
  961. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  962. */
  963. static readonly ACTION_OnIntersectionExitTrigger: number;
  964. /**
  965. * On key down
  966. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  967. */
  968. static readonly ACTION_OnKeyDownTrigger: number;
  969. /**
  970. * On key up
  971. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  972. */
  973. static readonly ACTION_OnKeyUpTrigger: number;
  974. /**
  975. * Billboard mode will only apply to Y axis
  976. */
  977. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  978. /**
  979. * Billboard mode will apply to all axes
  980. */
  981. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  982. /**
  983. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  984. */
  985. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  986. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  987. * Test order :
  988. * Is the bounding sphere outside the frustum ?
  989. * If not, are the bounding box vertices outside the frustum ?
  990. * It not, then the cullable object is in the frustum.
  991. */
  992. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  993. /** Culling strategy : Bounding Sphere Only.
  994. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  995. * It's also less accurate than the standard because some not visible objects can still be selected.
  996. * Test : is the bounding sphere outside the frustum ?
  997. * If not, then the cullable object is in the frustum.
  998. */
  999. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1000. /** Culling strategy : Optimistic Inclusion.
  1001. * This in an inclusion test first, then the standard exclusion test.
  1002. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1003. * 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.
  1004. * Anyway, it's as accurate as the standard strategy.
  1005. * Test :
  1006. * Is the cullable object bounding sphere center in the frustum ?
  1007. * If not, apply the default culling strategy.
  1008. */
  1009. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1010. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1011. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1012. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1013. * 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.
  1014. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1015. * Test :
  1016. * Is the cullable object bounding sphere center in the frustum ?
  1017. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1018. */
  1019. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1020. /**
  1021. * No logging while loading
  1022. */
  1023. static readonly SCENELOADER_NO_LOGGING: number;
  1024. /**
  1025. * Minimal logging while loading
  1026. */
  1027. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1028. /**
  1029. * Summary logging while loading
  1030. */
  1031. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1032. /**
  1033. * Detailled logging while loading
  1034. */
  1035. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1036. }
  1037. }
  1038. declare module BABYLON {
  1039. /**
  1040. * This represents the required contract to create a new type of texture loader.
  1041. */
  1042. export interface IInternalTextureLoader {
  1043. /**
  1044. * Defines wether the loader supports cascade loading the different faces.
  1045. */
  1046. supportCascades: boolean;
  1047. /**
  1048. * This returns if the loader support the current file information.
  1049. * @param extension defines the file extension of the file being loaded
  1050. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1051. * @param fallback defines the fallback internal texture if any
  1052. * @param isBase64 defines whether the texture is encoded as a base64
  1053. * @param isBuffer defines whether the texture data are stored as a buffer
  1054. * @returns true if the loader can load the specified file
  1055. */
  1056. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  1057. /**
  1058. * Transform the url before loading if required.
  1059. * @param rootUrl the url of the texture
  1060. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1061. * @returns the transformed texture
  1062. */
  1063. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  1064. /**
  1065. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  1066. * @param rootUrl the url of the texture
  1067. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1068. * @returns the fallback texture
  1069. */
  1070. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  1071. /**
  1072. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  1073. * @param data contains the texture data
  1074. * @param texture defines the BabylonJS internal texture
  1075. * @param createPolynomials will be true if polynomials have been requested
  1076. * @param onLoad defines the callback to trigger once the texture is ready
  1077. * @param onError defines the callback to trigger in case of error
  1078. */
  1079. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1080. /**
  1081. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  1082. * @param data contains the texture data
  1083. * @param texture defines the BabylonJS internal texture
  1084. * @param callback defines the method to call once ready to upload
  1085. */
  1086. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1087. }
  1088. }
  1089. declare module BABYLON {
  1090. /**
  1091. * Class used to store and describe the pipeline context associated with an effect
  1092. */
  1093. export interface IPipelineContext {
  1094. /**
  1095. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1096. */
  1097. isAsync: boolean;
  1098. /**
  1099. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1100. */
  1101. isReady: boolean;
  1102. /** @hidden */
  1103. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1104. }
  1105. }
  1106. declare module BABYLON {
  1107. /**
  1108. * Class used to store gfx data (like WebGLBuffer)
  1109. */
  1110. export class DataBuffer {
  1111. /**
  1112. * Gets or sets the number of objects referencing this buffer
  1113. */
  1114. references: number;
  1115. /** Gets or sets the size of the underlying buffer */
  1116. capacity: number;
  1117. /**
  1118. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1119. */
  1120. is32Bits: boolean;
  1121. /**
  1122. * Gets the underlying buffer
  1123. */
  1124. readonly underlyingResource: any;
  1125. }
  1126. }
  1127. declare module BABYLON {
  1128. /** @hidden */
  1129. export interface IShaderProcessor {
  1130. attributeProcessor?: (attribute: string) => string;
  1131. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1132. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1133. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1134. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1135. lineProcessor?: (line: string, isFragment: boolean) => string;
  1136. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1137. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1138. }
  1139. }
  1140. declare module BABYLON {
  1141. /** @hidden */
  1142. export interface ProcessingOptions {
  1143. defines: string[];
  1144. indexParameters: any;
  1145. isFragment: boolean;
  1146. shouldUseHighPrecisionShader: boolean;
  1147. supportsUniformBuffers: boolean;
  1148. shadersRepository: string;
  1149. includesShadersStore: {
  1150. [key: string]: string;
  1151. };
  1152. processor?: IShaderProcessor;
  1153. version: string;
  1154. platformName: string;
  1155. lookForClosingBracketForUniformBuffer?: boolean;
  1156. }
  1157. }
  1158. declare module BABYLON {
  1159. /** @hidden */
  1160. export class ShaderCodeNode {
  1161. line: string;
  1162. children: ShaderCodeNode[];
  1163. additionalDefineKey?: string;
  1164. additionalDefineValue?: string;
  1165. isValid(preprocessors: {
  1166. [key: string]: string;
  1167. }): boolean;
  1168. process(preprocessors: {
  1169. [key: string]: string;
  1170. }, options: ProcessingOptions): string;
  1171. }
  1172. }
  1173. declare module BABYLON {
  1174. /** @hidden */
  1175. export class ShaderCodeCursor {
  1176. private _lines;
  1177. lineIndex: number;
  1178. readonly currentLine: string;
  1179. readonly canRead: boolean;
  1180. lines: string[];
  1181. }
  1182. }
  1183. declare module BABYLON {
  1184. /** @hidden */
  1185. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1186. process(preprocessors: {
  1187. [key: string]: string;
  1188. }, options: ProcessingOptions): string;
  1189. }
  1190. }
  1191. declare module BABYLON {
  1192. /** @hidden */
  1193. export class ShaderDefineExpression {
  1194. isTrue(preprocessors: {
  1195. [key: string]: string;
  1196. }): boolean;
  1197. }
  1198. }
  1199. declare module BABYLON {
  1200. /** @hidden */
  1201. export class ShaderCodeTestNode extends ShaderCodeNode {
  1202. testExpression: ShaderDefineExpression;
  1203. isValid(preprocessors: {
  1204. [key: string]: string;
  1205. }): boolean;
  1206. }
  1207. }
  1208. declare module BABYLON {
  1209. /** @hidden */
  1210. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1211. define: string;
  1212. not: boolean;
  1213. constructor(define: string, not?: boolean);
  1214. isTrue(preprocessors: {
  1215. [key: string]: string;
  1216. }): boolean;
  1217. }
  1218. }
  1219. declare module BABYLON {
  1220. /** @hidden */
  1221. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1222. leftOperand: ShaderDefineExpression;
  1223. rightOperand: ShaderDefineExpression;
  1224. isTrue(preprocessors: {
  1225. [key: string]: string;
  1226. }): boolean;
  1227. }
  1228. }
  1229. declare module BABYLON {
  1230. /** @hidden */
  1231. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1232. leftOperand: ShaderDefineExpression;
  1233. rightOperand: ShaderDefineExpression;
  1234. isTrue(preprocessors: {
  1235. [key: string]: string;
  1236. }): boolean;
  1237. }
  1238. }
  1239. declare module BABYLON {
  1240. /** @hidden */
  1241. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1242. define: string;
  1243. operand: string;
  1244. testValue: string;
  1245. constructor(define: string, operand: string, testValue: string);
  1246. isTrue(preprocessors: {
  1247. [key: string]: string;
  1248. }): boolean;
  1249. }
  1250. }
  1251. declare module BABYLON {
  1252. /**
  1253. * Class used to enable access to offline support
  1254. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1255. */
  1256. export interface IOfflineProvider {
  1257. /**
  1258. * Gets a boolean indicating if scene must be saved in the database
  1259. */
  1260. enableSceneOffline: boolean;
  1261. /**
  1262. * Gets a boolean indicating if textures must be saved in the database
  1263. */
  1264. enableTexturesOffline: boolean;
  1265. /**
  1266. * Open the offline support and make it available
  1267. * @param successCallback defines the callback to call on success
  1268. * @param errorCallback defines the callback to call on error
  1269. */
  1270. open(successCallback: () => void, errorCallback: () => void): void;
  1271. /**
  1272. * Loads an image from the offline support
  1273. * @param url defines the url to load from
  1274. * @param image defines the target DOM image
  1275. */
  1276. loadImage(url: string, image: HTMLImageElement): void;
  1277. /**
  1278. * Loads a file from offline support
  1279. * @param url defines the URL to load from
  1280. * @param sceneLoaded defines a callback to call on success
  1281. * @param progressCallBack defines a callback to call when progress changed
  1282. * @param errorCallback defines a callback to call on error
  1283. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1284. */
  1285. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1286. }
  1287. }
  1288. declare module BABYLON {
  1289. /**
  1290. * Class used to help managing file picking and drag'n'drop
  1291. * File Storage
  1292. */
  1293. export class FilesInputStore {
  1294. /**
  1295. * List of files ready to be loaded
  1296. */
  1297. static FilesToLoad: {
  1298. [key: string]: File;
  1299. };
  1300. }
  1301. }
  1302. declare module BABYLON {
  1303. /**
  1304. * Class used to define a retry strategy when error happens while loading assets
  1305. */
  1306. export class RetryStrategy {
  1307. /**
  1308. * Function used to defines an exponential back off strategy
  1309. * @param maxRetries defines the maximum number of retries (3 by default)
  1310. * @param baseInterval defines the interval between retries
  1311. * @returns the strategy function to use
  1312. */
  1313. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1314. }
  1315. }
  1316. declare module BABYLON {
  1317. /**
  1318. * @ignore
  1319. * Application error to support additional information when loading a file
  1320. */
  1321. export abstract class BaseError extends Error {
  1322. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1323. }
  1324. }
  1325. declare module BABYLON {
  1326. /** @ignore */
  1327. export class LoadFileError extends BaseError {
  1328. request?: WebRequest;
  1329. file?: File;
  1330. /**
  1331. * Creates a new LoadFileError
  1332. * @param message defines the message of the error
  1333. * @param request defines the optional web request
  1334. * @param file defines the optional file
  1335. */
  1336. constructor(message: string, object?: WebRequest | File);
  1337. }
  1338. /** @ignore */
  1339. export class RequestFileError extends BaseError {
  1340. request: WebRequest;
  1341. /**
  1342. * Creates a new LoadFileError
  1343. * @param message defines the message of the error
  1344. * @param request defines the optional web request
  1345. */
  1346. constructor(message: string, request: WebRequest);
  1347. }
  1348. /** @ignore */
  1349. export class ReadFileError extends BaseError {
  1350. file: File;
  1351. /**
  1352. * Creates a new ReadFileError
  1353. * @param message defines the message of the error
  1354. * @param file defines the optional file
  1355. */
  1356. constructor(message: string, file: File);
  1357. }
  1358. /**
  1359. * @hidden
  1360. */
  1361. export class FileTools {
  1362. /**
  1363. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1364. */
  1365. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1366. /**
  1367. * Gets or sets the base URL to use to load assets
  1368. */
  1369. static BaseUrl: string;
  1370. /**
  1371. * Default behaviour for cors in the application.
  1372. * It can be a string if the expected behavior is identical in the entire app.
  1373. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1374. */
  1375. static CorsBehavior: string | ((url: string | string[]) => string);
  1376. /**
  1377. * Gets or sets a function used to pre-process url before using them to load assets
  1378. */
  1379. static PreprocessUrl: (url: string) => string;
  1380. /**
  1381. * Removes unwanted characters from an url
  1382. * @param url defines the url to clean
  1383. * @returns the cleaned url
  1384. */
  1385. private static _CleanUrl;
  1386. /**
  1387. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1388. * @param url define the url we are trying
  1389. * @param element define the dom element where to configure the cors policy
  1390. */
  1391. static SetCorsBehavior(url: string | string[], element: {
  1392. crossOrigin: string | null;
  1393. }): void;
  1394. /**
  1395. * Loads an image as an HTMLImageElement.
  1396. * @param input url string, ArrayBuffer, or Blob to load
  1397. * @param onLoad callback called when the image successfully loads
  1398. * @param onError callback called when the image fails to load
  1399. * @param offlineProvider offline provider for caching
  1400. * @param mimeType optional mime type
  1401. * @returns the HTMLImageElement of the loaded image
  1402. */
  1403. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1404. /**
  1405. * Reads a file from a File object
  1406. * @param file defines the file to load
  1407. * @param onSuccess defines the callback to call when data is loaded
  1408. * @param onProgress defines the callback to call during loading process
  1409. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1410. * @param onError defines the callback to call when an error occurs
  1411. * @returns a file request object
  1412. */
  1413. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1414. /**
  1415. * Loads a file from a url
  1416. * @param url url to load
  1417. * @param onSuccess callback called when the file successfully loads
  1418. * @param onProgress callback called while file is loading (if the server supports this mode)
  1419. * @param offlineProvider defines the offline provider for caching
  1420. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1421. * @param onError callback called when the file fails to load
  1422. * @returns a file request object
  1423. */
  1424. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1425. /**
  1426. * Loads a file
  1427. * @param url url to load
  1428. * @param onSuccess callback called when the file successfully loads
  1429. * @param onProgress callback called while file is loading (if the server supports this mode)
  1430. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1431. * @param onError callback called when the file fails to load
  1432. * @param onOpened callback called when the web request is opened
  1433. * @returns a file request object
  1434. */
  1435. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1436. /**
  1437. * Checks if the loaded document was accessed via `file:`-Protocol.
  1438. * @returns boolean
  1439. */
  1440. static IsFileURL(): boolean;
  1441. }
  1442. }
  1443. declare module BABYLON {
  1444. /** @hidden */
  1445. export class ShaderProcessor {
  1446. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1447. private static _ProcessPrecision;
  1448. private static _ExtractOperation;
  1449. private static _BuildSubExpression;
  1450. private static _BuildExpression;
  1451. private static _MoveCursorWithinIf;
  1452. private static _MoveCursor;
  1453. private static _EvaluatePreProcessors;
  1454. private static _PreparePreProcessors;
  1455. private static _ProcessShaderConversion;
  1456. private static _ProcessIncludes;
  1457. }
  1458. }
  1459. declare module BABYLON {
  1460. /**
  1461. * @hidden
  1462. */
  1463. export interface IColor4Like {
  1464. r: float;
  1465. g: float;
  1466. b: float;
  1467. a: float;
  1468. }
  1469. /**
  1470. * @hidden
  1471. */
  1472. export interface IColor3Like {
  1473. r: float;
  1474. g: float;
  1475. b: float;
  1476. }
  1477. /**
  1478. * @hidden
  1479. */
  1480. export interface IVector4Like {
  1481. x: float;
  1482. y: float;
  1483. z: float;
  1484. w: float;
  1485. }
  1486. /**
  1487. * @hidden
  1488. */
  1489. export interface IVector3Like {
  1490. x: float;
  1491. y: float;
  1492. z: float;
  1493. }
  1494. /**
  1495. * @hidden
  1496. */
  1497. export interface IVector2Like {
  1498. x: float;
  1499. y: float;
  1500. }
  1501. /**
  1502. * @hidden
  1503. */
  1504. export interface IMatrixLike {
  1505. toArray(): DeepImmutable<Float32Array>;
  1506. updateFlag: int;
  1507. }
  1508. /**
  1509. * @hidden
  1510. */
  1511. export interface IViewportLike {
  1512. x: float;
  1513. y: float;
  1514. width: float;
  1515. height: float;
  1516. }
  1517. /**
  1518. * @hidden
  1519. */
  1520. export interface IPlaneLike {
  1521. normal: IVector3Like;
  1522. d: float;
  1523. normalize(): void;
  1524. }
  1525. }
  1526. declare module BABYLON {
  1527. /**
  1528. * Interface used to define common properties for effect fallbacks
  1529. */
  1530. export interface IEffectFallbacks {
  1531. /**
  1532. * Removes the defines that should be removed when falling back.
  1533. * @param currentDefines defines the current define statements for the shader.
  1534. * @param effect defines the current effect we try to compile
  1535. * @returns The resulting defines with defines of the current rank removed.
  1536. */
  1537. reduce(currentDefines: string, effect: Effect): string;
  1538. /**
  1539. * Removes the fallback from the bound mesh.
  1540. */
  1541. unBindMesh(): void;
  1542. /**
  1543. * Checks to see if more fallbacks are still availible.
  1544. */
  1545. hasMoreFallbacks: boolean;
  1546. }
  1547. }
  1548. declare module BABYLON {
  1549. /**
  1550. * Class used to evalaute queries containing `and` and `or` operators
  1551. */
  1552. export class AndOrNotEvaluator {
  1553. /**
  1554. * Evaluate a query
  1555. * @param query defines the query to evaluate
  1556. * @param evaluateCallback defines the callback used to filter result
  1557. * @returns true if the query matches
  1558. */
  1559. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1560. private static _HandleParenthesisContent;
  1561. private static _SimplifyNegation;
  1562. }
  1563. }
  1564. declare module BABYLON {
  1565. /**
  1566. * Class used to store custom tags
  1567. */
  1568. export class Tags {
  1569. /**
  1570. * Adds support for tags on the given object
  1571. * @param obj defines the object to use
  1572. */
  1573. static EnableFor(obj: any): void;
  1574. /**
  1575. * Removes tags support
  1576. * @param obj defines the object to use
  1577. */
  1578. static DisableFor(obj: any): void;
  1579. /**
  1580. * Gets a boolean indicating if the given object has tags
  1581. * @param obj defines the object to use
  1582. * @returns a boolean
  1583. */
  1584. static HasTags(obj: any): boolean;
  1585. /**
  1586. * Gets the tags available on a given object
  1587. * @param obj defines the object to use
  1588. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1589. * @returns the tags
  1590. */
  1591. static GetTags(obj: any, asString?: boolean): any;
  1592. /**
  1593. * Adds tags to an object
  1594. * @param obj defines the object to use
  1595. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1596. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1597. */
  1598. static AddTagsTo(obj: any, tagsString: string): void;
  1599. /**
  1600. * @hidden
  1601. */
  1602. static _AddTagTo(obj: any, tag: string): void;
  1603. /**
  1604. * Removes specific tags from a specific object
  1605. * @param obj defines the object to use
  1606. * @param tagsString defines the tags to remove
  1607. */
  1608. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1609. /**
  1610. * @hidden
  1611. */
  1612. static _RemoveTagFrom(obj: any, tag: string): void;
  1613. /**
  1614. * Defines if tags hosted on an object match a given query
  1615. * @param obj defines the object to use
  1616. * @param tagsQuery defines the tag query
  1617. * @returns a boolean
  1618. */
  1619. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1620. }
  1621. }
  1622. declare module BABYLON {
  1623. /**
  1624. * Scalar computation library
  1625. */
  1626. export class Scalar {
  1627. /**
  1628. * Two pi constants convenient for computation.
  1629. */
  1630. static TwoPi: number;
  1631. /**
  1632. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1633. * @param a number
  1634. * @param b number
  1635. * @param epsilon (default = 1.401298E-45)
  1636. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1637. */
  1638. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1639. /**
  1640. * Returns a string : the upper case translation of the number i to hexadecimal.
  1641. * @param i number
  1642. * @returns the upper case translation of the number i to hexadecimal.
  1643. */
  1644. static ToHex(i: number): string;
  1645. /**
  1646. * Returns -1 if value is negative and +1 is value is positive.
  1647. * @param value the value
  1648. * @returns the value itself if it's equal to zero.
  1649. */
  1650. static Sign(value: number): number;
  1651. /**
  1652. * Returns the value itself if it's between min and max.
  1653. * Returns min if the value is lower than min.
  1654. * Returns max if the value is greater than max.
  1655. * @param value the value to clmap
  1656. * @param min the min value to clamp to (default: 0)
  1657. * @param max the max value to clamp to (default: 1)
  1658. * @returns the clamped value
  1659. */
  1660. static Clamp(value: number, min?: number, max?: number): number;
  1661. /**
  1662. * the log2 of value.
  1663. * @param value the value to compute log2 of
  1664. * @returns the log2 of value.
  1665. */
  1666. static Log2(value: number): number;
  1667. /**
  1668. * Loops the value, so that it is never larger than length and never smaller than 0.
  1669. *
  1670. * This is similar to the modulo operator but it works with floating point numbers.
  1671. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1672. * With t = 5 and length = 2.5, the result would be 0.0.
  1673. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1674. * @param value the value
  1675. * @param length the length
  1676. * @returns the looped value
  1677. */
  1678. static Repeat(value: number, length: number): number;
  1679. /**
  1680. * Normalize the value between 0.0 and 1.0 using min and max values
  1681. * @param value value to normalize
  1682. * @param min max to normalize between
  1683. * @param max min to normalize between
  1684. * @returns the normalized value
  1685. */
  1686. static Normalize(value: number, min: number, max: number): number;
  1687. /**
  1688. * Denormalize the value from 0.0 and 1.0 using min and max values
  1689. * @param normalized value to denormalize
  1690. * @param min max to denormalize between
  1691. * @param max min to denormalize between
  1692. * @returns the denormalized value
  1693. */
  1694. static Denormalize(normalized: number, min: number, max: number): number;
  1695. /**
  1696. * Calculates the shortest difference between two given angles given in degrees.
  1697. * @param current current angle in degrees
  1698. * @param target target angle in degrees
  1699. * @returns the delta
  1700. */
  1701. static DeltaAngle(current: number, target: number): number;
  1702. /**
  1703. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1704. * @param tx value
  1705. * @param length length
  1706. * @returns The returned value will move back and forth between 0 and length
  1707. */
  1708. static PingPong(tx: number, length: number): number;
  1709. /**
  1710. * Interpolates between min and max with smoothing at the limits.
  1711. *
  1712. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1713. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1714. * @param from from
  1715. * @param to to
  1716. * @param tx value
  1717. * @returns the smooth stepped value
  1718. */
  1719. static SmoothStep(from: number, to: number, tx: number): number;
  1720. /**
  1721. * Moves a value current towards target.
  1722. *
  1723. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1724. * Negative values of maxDelta pushes the value away from target.
  1725. * @param current current value
  1726. * @param target target value
  1727. * @param maxDelta max distance to move
  1728. * @returns resulting value
  1729. */
  1730. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1731. /**
  1732. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1733. *
  1734. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1735. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1736. * @param current current value
  1737. * @param target target value
  1738. * @param maxDelta max distance to move
  1739. * @returns resulting angle
  1740. */
  1741. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1742. /**
  1743. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1744. * @param start start value
  1745. * @param end target value
  1746. * @param amount amount to lerp between
  1747. * @returns the lerped value
  1748. */
  1749. static Lerp(start: number, end: number, amount: number): number;
  1750. /**
  1751. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1752. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1753. * @param start start value
  1754. * @param end target value
  1755. * @param amount amount to lerp between
  1756. * @returns the lerped value
  1757. */
  1758. static LerpAngle(start: number, end: number, amount: number): number;
  1759. /**
  1760. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1761. * @param a start value
  1762. * @param b target value
  1763. * @param value value between a and b
  1764. * @returns the inverseLerp value
  1765. */
  1766. static InverseLerp(a: number, b: number, value: number): number;
  1767. /**
  1768. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1769. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1770. * @param value1 spline value
  1771. * @param tangent1 spline value
  1772. * @param value2 spline value
  1773. * @param tangent2 spline value
  1774. * @param amount input value
  1775. * @returns hermite result
  1776. */
  1777. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1778. /**
  1779. * Returns a random float number between and min and max values
  1780. * @param min min value of random
  1781. * @param max max value of random
  1782. * @returns random value
  1783. */
  1784. static RandomRange(min: number, max: number): number;
  1785. /**
  1786. * This function returns percentage of a number in a given range.
  1787. *
  1788. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1789. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1790. * @param number to convert to percentage
  1791. * @param min min range
  1792. * @param max max range
  1793. * @returns the percentage
  1794. */
  1795. static RangeToPercent(number: number, min: number, max: number): number;
  1796. /**
  1797. * This function returns number that corresponds to the percentage in a given range.
  1798. *
  1799. * PercentToRange(0.34,0,100) will return 34.
  1800. * @param percent to convert to number
  1801. * @param min min range
  1802. * @param max max range
  1803. * @returns the number
  1804. */
  1805. static PercentToRange(percent: number, min: number, max: number): number;
  1806. /**
  1807. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1808. * @param angle The angle to normalize in radian.
  1809. * @return The converted angle.
  1810. */
  1811. static NormalizeRadians(angle: number): number;
  1812. }
  1813. }
  1814. declare module BABYLON {
  1815. /**
  1816. * Constant used to convert a value to gamma space
  1817. * @ignorenaming
  1818. */
  1819. export const ToGammaSpace: number;
  1820. /**
  1821. * Constant used to convert a value to linear space
  1822. * @ignorenaming
  1823. */
  1824. export const ToLinearSpace = 2.2;
  1825. /**
  1826. * Constant used to define the minimal number value in Babylon.js
  1827. * @ignorenaming
  1828. */
  1829. let Epsilon: number;
  1830. }
  1831. declare module BABYLON {
  1832. /**
  1833. * Class used to represent a viewport on screen
  1834. */
  1835. export class Viewport {
  1836. /** viewport left coordinate */
  1837. x: number;
  1838. /** viewport top coordinate */
  1839. y: number;
  1840. /**viewport width */
  1841. width: number;
  1842. /** viewport height */
  1843. height: number;
  1844. /**
  1845. * Creates a Viewport object located at (x, y) and sized (width, height)
  1846. * @param x defines viewport left coordinate
  1847. * @param y defines viewport top coordinate
  1848. * @param width defines the viewport width
  1849. * @param height defines the viewport height
  1850. */
  1851. constructor(
  1852. /** viewport left coordinate */
  1853. x: number,
  1854. /** viewport top coordinate */
  1855. y: number,
  1856. /**viewport width */
  1857. width: number,
  1858. /** viewport height */
  1859. height: number);
  1860. /**
  1861. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1862. * @param renderWidth defines the rendering width
  1863. * @param renderHeight defines the rendering height
  1864. * @returns a new Viewport
  1865. */
  1866. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1867. /**
  1868. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1869. * @param renderWidth defines the rendering width
  1870. * @param renderHeight defines the rendering height
  1871. * @param ref defines the target viewport
  1872. * @returns the current viewport
  1873. */
  1874. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1875. /**
  1876. * Returns a new Viewport copied from the current one
  1877. * @returns a new Viewport
  1878. */
  1879. clone(): Viewport;
  1880. }
  1881. }
  1882. declare module BABYLON {
  1883. /**
  1884. * Class containing a set of static utilities functions for arrays.
  1885. */
  1886. export class ArrayTools {
  1887. /**
  1888. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1889. * @param size the number of element to construct and put in the array
  1890. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1891. * @returns a new array filled with new objects
  1892. */
  1893. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1894. }
  1895. }
  1896. declare module BABYLON {
  1897. /**
  1898. * Class representing a vector containing 2 coordinates
  1899. */
  1900. export class Vector2 {
  1901. /** defines the first coordinate */
  1902. x: number;
  1903. /** defines the second coordinate */
  1904. y: number;
  1905. /**
  1906. * Creates a new Vector2 from the given x and y coordinates
  1907. * @param x defines the first coordinate
  1908. * @param y defines the second coordinate
  1909. */
  1910. constructor(
  1911. /** defines the first coordinate */
  1912. x?: number,
  1913. /** defines the second coordinate */
  1914. y?: number);
  1915. /**
  1916. * Gets a string with the Vector2 coordinates
  1917. * @returns a string with the Vector2 coordinates
  1918. */
  1919. toString(): string;
  1920. /**
  1921. * Gets class name
  1922. * @returns the string "Vector2"
  1923. */
  1924. getClassName(): string;
  1925. /**
  1926. * Gets current vector hash code
  1927. * @returns the Vector2 hash code as a number
  1928. */
  1929. getHashCode(): number;
  1930. /**
  1931. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1932. * @param array defines the source array
  1933. * @param index defines the offset in source array
  1934. * @returns the current Vector2
  1935. */
  1936. toArray(array: FloatArray, index?: number): Vector2;
  1937. /**
  1938. * Copy the current vector to an array
  1939. * @returns a new array with 2 elements: the Vector2 coordinates.
  1940. */
  1941. asArray(): number[];
  1942. /**
  1943. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1944. * @param source defines the source Vector2
  1945. * @returns the current updated Vector2
  1946. */
  1947. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1948. /**
  1949. * Sets the Vector2 coordinates with the given floats
  1950. * @param x defines the first coordinate
  1951. * @param y defines the second coordinate
  1952. * @returns the current updated Vector2
  1953. */
  1954. copyFromFloats(x: number, y: number): Vector2;
  1955. /**
  1956. * Sets the Vector2 coordinates with the given floats
  1957. * @param x defines the first coordinate
  1958. * @param y defines the second coordinate
  1959. * @returns the current updated Vector2
  1960. */
  1961. set(x: number, y: number): Vector2;
  1962. /**
  1963. * Add another vector with the current one
  1964. * @param otherVector defines the other vector
  1965. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1966. */
  1967. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1968. /**
  1969. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1970. * @param otherVector defines the other vector
  1971. * @param result defines the target vector
  1972. * @returns the unmodified current Vector2
  1973. */
  1974. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1975. /**
  1976. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1977. * @param otherVector defines the other vector
  1978. * @returns the current updated Vector2
  1979. */
  1980. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1981. /**
  1982. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1983. * @param otherVector defines the other vector
  1984. * @returns a new Vector2
  1985. */
  1986. addVector3(otherVector: Vector3): Vector2;
  1987. /**
  1988. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1989. * @param otherVector defines the other vector
  1990. * @returns a new Vector2
  1991. */
  1992. subtract(otherVector: Vector2): Vector2;
  1993. /**
  1994. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  1995. * @param otherVector defines the other vector
  1996. * @param result defines the target vector
  1997. * @returns the unmodified current Vector2
  1998. */
  1999. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2000. /**
  2001. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2002. * @param otherVector defines the other vector
  2003. * @returns the current updated Vector2
  2004. */
  2005. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2006. /**
  2007. * Multiplies in place the current Vector2 coordinates by the given ones
  2008. * @param otherVector defines the other vector
  2009. * @returns the current updated Vector2
  2010. */
  2011. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2012. /**
  2013. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2014. * @param otherVector defines the other vector
  2015. * @returns a new Vector2
  2016. */
  2017. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2018. /**
  2019. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2020. * @param otherVector defines the other vector
  2021. * @param result defines the target vector
  2022. * @returns the unmodified current Vector2
  2023. */
  2024. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2025. /**
  2026. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2027. * @param x defines the first coordinate
  2028. * @param y defines the second coordinate
  2029. * @returns a new Vector2
  2030. */
  2031. multiplyByFloats(x: number, y: number): Vector2;
  2032. /**
  2033. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2034. * @param otherVector defines the other vector
  2035. * @returns a new Vector2
  2036. */
  2037. divide(otherVector: Vector2): Vector2;
  2038. /**
  2039. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2040. * @param otherVector defines the other vector
  2041. * @param result defines the target vector
  2042. * @returns the unmodified current Vector2
  2043. */
  2044. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2045. /**
  2046. * Divides the current Vector2 coordinates by the given ones
  2047. * @param otherVector defines the other vector
  2048. * @returns the current updated Vector2
  2049. */
  2050. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2051. /**
  2052. * Gets a new Vector2 with current Vector2 negated coordinates
  2053. * @returns a new Vector2
  2054. */
  2055. negate(): Vector2;
  2056. /**
  2057. * Multiply the Vector2 coordinates by scale
  2058. * @param scale defines the scaling factor
  2059. * @returns the current updated Vector2
  2060. */
  2061. scaleInPlace(scale: number): Vector2;
  2062. /**
  2063. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2064. * @param scale defines the scaling factor
  2065. * @returns a new Vector2
  2066. */
  2067. scale(scale: number): Vector2;
  2068. /**
  2069. * Scale the current Vector2 values by a factor to a given Vector2
  2070. * @param scale defines the scale factor
  2071. * @param result defines the Vector2 object where to store the result
  2072. * @returns the unmodified current Vector2
  2073. */
  2074. scaleToRef(scale: number, result: Vector2): Vector2;
  2075. /**
  2076. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2077. * @param scale defines the scale factor
  2078. * @param result defines the Vector2 object where to store the result
  2079. * @returns the unmodified current Vector2
  2080. */
  2081. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2082. /**
  2083. * Gets a boolean if two vectors are equals
  2084. * @param otherVector defines the other vector
  2085. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2086. */
  2087. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2088. /**
  2089. * Gets a boolean if two vectors are equals (using an epsilon value)
  2090. * @param otherVector defines the other vector
  2091. * @param epsilon defines the minimal distance to consider equality
  2092. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2093. */
  2094. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2095. /**
  2096. * Gets a new Vector2 from current Vector2 floored values
  2097. * @returns a new Vector2
  2098. */
  2099. floor(): Vector2;
  2100. /**
  2101. * Gets a new Vector2 from current Vector2 floored values
  2102. * @returns a new Vector2
  2103. */
  2104. fract(): Vector2;
  2105. /**
  2106. * Gets the length of the vector
  2107. * @returns the vector length (float)
  2108. */
  2109. length(): number;
  2110. /**
  2111. * Gets the vector squared length
  2112. * @returns the vector squared length (float)
  2113. */
  2114. lengthSquared(): number;
  2115. /**
  2116. * Normalize the vector
  2117. * @returns the current updated Vector2
  2118. */
  2119. normalize(): Vector2;
  2120. /**
  2121. * Gets a new Vector2 copied from the Vector2
  2122. * @returns a new Vector2
  2123. */
  2124. clone(): Vector2;
  2125. /**
  2126. * Gets a new Vector2(0, 0)
  2127. * @returns a new Vector2
  2128. */
  2129. static Zero(): Vector2;
  2130. /**
  2131. * Gets a new Vector2(1, 1)
  2132. * @returns a new Vector2
  2133. */
  2134. static One(): Vector2;
  2135. /**
  2136. * Gets a new Vector2 set from the given index element of the given array
  2137. * @param array defines the data source
  2138. * @param offset defines the offset in the data source
  2139. * @returns a new Vector2
  2140. */
  2141. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2142. /**
  2143. * Sets "result" from the given index element of the given array
  2144. * @param array defines the data source
  2145. * @param offset defines the offset in the data source
  2146. * @param result defines the target vector
  2147. */
  2148. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2149. /**
  2150. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2151. * @param value1 defines 1st point of control
  2152. * @param value2 defines 2nd point of control
  2153. * @param value3 defines 3rd point of control
  2154. * @param value4 defines 4th point of control
  2155. * @param amount defines the interpolation factor
  2156. * @returns a new Vector2
  2157. */
  2158. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2159. /**
  2160. * 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".
  2161. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2162. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2163. * @param value defines the value to clamp
  2164. * @param min defines the lower limit
  2165. * @param max defines the upper limit
  2166. * @returns a new Vector2
  2167. */
  2168. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2169. /**
  2170. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2171. * @param value1 defines the 1st control point
  2172. * @param tangent1 defines the outgoing tangent
  2173. * @param value2 defines the 2nd control point
  2174. * @param tangent2 defines the incoming tangent
  2175. * @param amount defines the interpolation factor
  2176. * @returns a new Vector2
  2177. */
  2178. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2179. /**
  2180. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2181. * @param start defines the start vector
  2182. * @param end defines the end vector
  2183. * @param amount defines the interpolation factor
  2184. * @returns a new Vector2
  2185. */
  2186. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2187. /**
  2188. * Gets the dot product of the vector "left" and the vector "right"
  2189. * @param left defines first vector
  2190. * @param right defines second vector
  2191. * @returns the dot product (float)
  2192. */
  2193. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2194. /**
  2195. * Returns a new Vector2 equal to the normalized given vector
  2196. * @param vector defines the vector to normalize
  2197. * @returns a new Vector2
  2198. */
  2199. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2200. /**
  2201. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2202. * @param left defines 1st vector
  2203. * @param right defines 2nd vector
  2204. * @returns a new Vector2
  2205. */
  2206. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2207. /**
  2208. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2209. * @param left defines 1st vector
  2210. * @param right defines 2nd vector
  2211. * @returns a new Vector2
  2212. */
  2213. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2214. /**
  2215. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2216. * @param vector defines the vector to transform
  2217. * @param transformation defines the matrix to apply
  2218. * @returns a new Vector2
  2219. */
  2220. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2221. /**
  2222. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2223. * @param vector defines the vector to transform
  2224. * @param transformation defines the matrix to apply
  2225. * @param result defines the target vector
  2226. */
  2227. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2228. /**
  2229. * Determines if a given vector is included in a triangle
  2230. * @param p defines the vector to test
  2231. * @param p0 defines 1st triangle point
  2232. * @param p1 defines 2nd triangle point
  2233. * @param p2 defines 3rd triangle point
  2234. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2235. */
  2236. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2237. /**
  2238. * Gets the distance between the vectors "value1" and "value2"
  2239. * @param value1 defines first vector
  2240. * @param value2 defines second vector
  2241. * @returns the distance between vectors
  2242. */
  2243. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2244. /**
  2245. * Returns the squared distance between the vectors "value1" and "value2"
  2246. * @param value1 defines first vector
  2247. * @param value2 defines second vector
  2248. * @returns the squared distance between vectors
  2249. */
  2250. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2251. /**
  2252. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2253. * @param value1 defines first vector
  2254. * @param value2 defines second vector
  2255. * @returns a new Vector2
  2256. */
  2257. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2258. /**
  2259. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2260. * @param p defines the middle point
  2261. * @param segA defines one point of the segment
  2262. * @param segB defines the other point of the segment
  2263. * @returns the shortest distance
  2264. */
  2265. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2266. }
  2267. /**
  2268. * Class used to store (x,y,z) vector representation
  2269. * A Vector3 is the main object used in 3D geometry
  2270. * It can represent etiher the coordinates of a point the space, either a direction
  2271. * Reminder: js uses a left handed forward facing system
  2272. */
  2273. export class Vector3 {
  2274. /**
  2275. * Defines the first coordinates (on X axis)
  2276. */
  2277. x: number;
  2278. /**
  2279. * Defines the second coordinates (on Y axis)
  2280. */
  2281. y: number;
  2282. /**
  2283. * Defines the third coordinates (on Z axis)
  2284. */
  2285. z: number;
  2286. private static _UpReadOnly;
  2287. private static _ZeroReadOnly;
  2288. /**
  2289. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2290. * @param x defines the first coordinates (on X axis)
  2291. * @param y defines the second coordinates (on Y axis)
  2292. * @param z defines the third coordinates (on Z axis)
  2293. */
  2294. constructor(
  2295. /**
  2296. * Defines the first coordinates (on X axis)
  2297. */
  2298. x?: number,
  2299. /**
  2300. * Defines the second coordinates (on Y axis)
  2301. */
  2302. y?: number,
  2303. /**
  2304. * Defines the third coordinates (on Z axis)
  2305. */
  2306. z?: number);
  2307. /**
  2308. * Creates a string representation of the Vector3
  2309. * @returns a string with the Vector3 coordinates.
  2310. */
  2311. toString(): string;
  2312. /**
  2313. * Gets the class name
  2314. * @returns the string "Vector3"
  2315. */
  2316. getClassName(): string;
  2317. /**
  2318. * Creates the Vector3 hash code
  2319. * @returns a number which tends to be unique between Vector3 instances
  2320. */
  2321. getHashCode(): number;
  2322. /**
  2323. * Creates an array containing three elements : the coordinates of the Vector3
  2324. * @returns a new array of numbers
  2325. */
  2326. asArray(): number[];
  2327. /**
  2328. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2329. * @param array defines the destination array
  2330. * @param index defines the offset in the destination array
  2331. * @returns the current Vector3
  2332. */
  2333. toArray(array: FloatArray, index?: number): Vector3;
  2334. /**
  2335. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2336. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2337. */
  2338. toQuaternion(): Quaternion;
  2339. /**
  2340. * Adds the given vector to the current Vector3
  2341. * @param otherVector defines the second operand
  2342. * @returns the current updated Vector3
  2343. */
  2344. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2345. /**
  2346. * Adds the given coordinates to the current Vector3
  2347. * @param x defines the x coordinate of the operand
  2348. * @param y defines the y coordinate of the operand
  2349. * @param z defines the z coordinate of the operand
  2350. * @returns the current updated Vector3
  2351. */
  2352. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2353. /**
  2354. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2355. * @param otherVector defines the second operand
  2356. * @returns the resulting Vector3
  2357. */
  2358. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2359. /**
  2360. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2361. * @param otherVector defines the second operand
  2362. * @param result defines the Vector3 object where to store the result
  2363. * @returns the current Vector3
  2364. */
  2365. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2366. /**
  2367. * Subtract the given vector from the current Vector3
  2368. * @param otherVector defines the second operand
  2369. * @returns the current updated Vector3
  2370. */
  2371. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2372. /**
  2373. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2374. * @param otherVector defines the second operand
  2375. * @returns the resulting Vector3
  2376. */
  2377. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2378. /**
  2379. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2380. * @param otherVector defines the second operand
  2381. * @param result defines the Vector3 object where to store the result
  2382. * @returns the current Vector3
  2383. */
  2384. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2385. /**
  2386. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2387. * @param x defines the x coordinate of the operand
  2388. * @param y defines the y coordinate of the operand
  2389. * @param z defines the z coordinate of the operand
  2390. * @returns the resulting Vector3
  2391. */
  2392. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2393. /**
  2394. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2395. * @param x defines the x coordinate of the operand
  2396. * @param y defines the y coordinate of the operand
  2397. * @param z defines the z coordinate of the operand
  2398. * @param result defines the Vector3 object where to store the result
  2399. * @returns the current Vector3
  2400. */
  2401. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2402. /**
  2403. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2404. * @returns a new Vector3
  2405. */
  2406. negate(): Vector3;
  2407. /**
  2408. * Multiplies the Vector3 coordinates by the float "scale"
  2409. * @param scale defines the multiplier factor
  2410. * @returns the current updated Vector3
  2411. */
  2412. scaleInPlace(scale: number): Vector3;
  2413. /**
  2414. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2415. * @param scale defines the multiplier factor
  2416. * @returns a new Vector3
  2417. */
  2418. scale(scale: number): Vector3;
  2419. /**
  2420. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2421. * @param scale defines the multiplier factor
  2422. * @param result defines the Vector3 object where to store the result
  2423. * @returns the current Vector3
  2424. */
  2425. scaleToRef(scale: number, result: Vector3): Vector3;
  2426. /**
  2427. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2428. * @param scale defines the scale factor
  2429. * @param result defines the Vector3 object where to store the result
  2430. * @returns the unmodified current Vector3
  2431. */
  2432. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2433. /**
  2434. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2435. * @param otherVector defines the second operand
  2436. * @returns true if both vectors are equals
  2437. */
  2438. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2439. /**
  2440. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2441. * @param otherVector defines the second operand
  2442. * @param epsilon defines the minimal distance to define values as equals
  2443. * @returns true if both vectors are distant less than epsilon
  2444. */
  2445. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2446. /**
  2447. * Returns true if the current Vector3 coordinates equals the given floats
  2448. * @param x defines the x coordinate of the operand
  2449. * @param y defines the y coordinate of the operand
  2450. * @param z defines the z coordinate of the operand
  2451. * @returns true if both vectors are equals
  2452. */
  2453. equalsToFloats(x: number, y: number, z: number): boolean;
  2454. /**
  2455. * Multiplies the current Vector3 coordinates by the given ones
  2456. * @param otherVector defines the second operand
  2457. * @returns the current updated Vector3
  2458. */
  2459. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2460. /**
  2461. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2462. * @param otherVector defines the second operand
  2463. * @returns the new Vector3
  2464. */
  2465. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2466. /**
  2467. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2468. * @param otherVector defines the second operand
  2469. * @param result defines the Vector3 object where to store the result
  2470. * @returns the current Vector3
  2471. */
  2472. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2473. /**
  2474. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2475. * @param x defines the x coordinate of the operand
  2476. * @param y defines the y coordinate of the operand
  2477. * @param z defines the z coordinate of the operand
  2478. * @returns the new Vector3
  2479. */
  2480. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2481. /**
  2482. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2483. * @param otherVector defines the second operand
  2484. * @returns the new Vector3
  2485. */
  2486. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2487. /**
  2488. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2489. * @param otherVector defines the second operand
  2490. * @param result defines the Vector3 object where to store the result
  2491. * @returns the current Vector3
  2492. */
  2493. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2494. /**
  2495. * Divides the current Vector3 coordinates by the given ones.
  2496. * @param otherVector defines the second operand
  2497. * @returns the current updated Vector3
  2498. */
  2499. divideInPlace(otherVector: Vector3): Vector3;
  2500. /**
  2501. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2502. * @param other defines the second operand
  2503. * @returns the current updated Vector3
  2504. */
  2505. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2506. /**
  2507. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2508. * @param other defines the second operand
  2509. * @returns the current updated Vector3
  2510. */
  2511. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2512. /**
  2513. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2514. * @param x defines the x coordinate of the operand
  2515. * @param y defines the y coordinate of the operand
  2516. * @param z defines the z coordinate of the operand
  2517. * @returns the current updated Vector3
  2518. */
  2519. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2520. /**
  2521. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2522. * @param x defines the x coordinate of the operand
  2523. * @param y defines the y coordinate of the operand
  2524. * @param z defines the z coordinate of the operand
  2525. * @returns the current updated Vector3
  2526. */
  2527. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2528. /**
  2529. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2530. * Check if is non uniform within a certain amount of decimal places to account for this
  2531. * @param epsilon the amount the values can differ
  2532. * @returns if the the vector is non uniform to a certain number of decimal places
  2533. */
  2534. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2535. /**
  2536. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2537. */
  2538. readonly isNonUniform: boolean;
  2539. /**
  2540. * Gets a new Vector3 from current Vector3 floored values
  2541. * @returns a new Vector3
  2542. */
  2543. floor(): Vector3;
  2544. /**
  2545. * Gets a new Vector3 from current Vector3 floored values
  2546. * @returns a new Vector3
  2547. */
  2548. fract(): Vector3;
  2549. /**
  2550. * Gets the length of the Vector3
  2551. * @returns the length of the Vector3
  2552. */
  2553. length(): number;
  2554. /**
  2555. * Gets the squared length of the Vector3
  2556. * @returns squared length of the Vector3
  2557. */
  2558. lengthSquared(): number;
  2559. /**
  2560. * Normalize the current Vector3.
  2561. * Please note that this is an in place operation.
  2562. * @returns the current updated Vector3
  2563. */
  2564. normalize(): Vector3;
  2565. /**
  2566. * Reorders the x y z properties of the vector in place
  2567. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2568. * @returns the current updated vector
  2569. */
  2570. reorderInPlace(order: string): this;
  2571. /**
  2572. * Rotates the vector around 0,0,0 by a quaternion
  2573. * @param quaternion the rotation quaternion
  2574. * @param result vector to store the result
  2575. * @returns the resulting vector
  2576. */
  2577. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2578. /**
  2579. * Rotates a vector around a given point
  2580. * @param quaternion the rotation quaternion
  2581. * @param point the point to rotate around
  2582. * @param result vector to store the result
  2583. * @returns the resulting vector
  2584. */
  2585. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2586. /**
  2587. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2588. * The cross product is then orthogonal to both current and "other"
  2589. * @param other defines the right operand
  2590. * @returns the cross product
  2591. */
  2592. cross(other: Vector3): Vector3;
  2593. /**
  2594. * Normalize the current Vector3 with the given input length.
  2595. * Please note that this is an in place operation.
  2596. * @param len the length of the vector
  2597. * @returns the current updated Vector3
  2598. */
  2599. normalizeFromLength(len: number): Vector3;
  2600. /**
  2601. * Normalize the current Vector3 to a new vector
  2602. * @returns the new Vector3
  2603. */
  2604. normalizeToNew(): Vector3;
  2605. /**
  2606. * Normalize the current Vector3 to the reference
  2607. * @param reference define the Vector3 to update
  2608. * @returns the updated Vector3
  2609. */
  2610. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2611. /**
  2612. * Creates a new Vector3 copied from the current Vector3
  2613. * @returns the new Vector3
  2614. */
  2615. clone(): Vector3;
  2616. /**
  2617. * Copies the given vector coordinates to the current Vector3 ones
  2618. * @param source defines the source Vector3
  2619. * @returns the current updated Vector3
  2620. */
  2621. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2622. /**
  2623. * Copies the given floats to the current Vector3 coordinates
  2624. * @param x defines the x coordinate of the operand
  2625. * @param y defines the y coordinate of the operand
  2626. * @param z defines the z coordinate of the operand
  2627. * @returns the current updated Vector3
  2628. */
  2629. copyFromFloats(x: number, y: number, z: number): Vector3;
  2630. /**
  2631. * Copies the given floats to the current Vector3 coordinates
  2632. * @param x defines the x coordinate of the operand
  2633. * @param y defines the y coordinate of the operand
  2634. * @param z defines the z coordinate of the operand
  2635. * @returns the current updated Vector3
  2636. */
  2637. set(x: number, y: number, z: number): Vector3;
  2638. /**
  2639. * Copies the given float to the current Vector3 coordinates
  2640. * @param v defines the x, y and z coordinates of the operand
  2641. * @returns the current updated Vector3
  2642. */
  2643. setAll(v: number): Vector3;
  2644. /**
  2645. * Get the clip factor between two vectors
  2646. * @param vector0 defines the first operand
  2647. * @param vector1 defines the second operand
  2648. * @param axis defines the axis to use
  2649. * @param size defines the size along the axis
  2650. * @returns the clip factor
  2651. */
  2652. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2653. /**
  2654. * Get angle between two vectors
  2655. * @param vector0 angle between vector0 and vector1
  2656. * @param vector1 angle between vector0 and vector1
  2657. * @param normal direction of the normal
  2658. * @return the angle between vector0 and vector1
  2659. */
  2660. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2661. /**
  2662. * Returns a new Vector3 set from the index "offset" of the given array
  2663. * @param array defines the source array
  2664. * @param offset defines the offset in the source array
  2665. * @returns the new Vector3
  2666. */
  2667. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2668. /**
  2669. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2670. * @param array defines the source array
  2671. * @param offset defines the offset in the source array
  2672. * @returns the new Vector3
  2673. * @deprecated Please use FromArray instead.
  2674. */
  2675. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2676. /**
  2677. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2678. * @param array defines the source array
  2679. * @param offset defines the offset in the source array
  2680. * @param result defines the Vector3 where to store the result
  2681. */
  2682. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2683. /**
  2684. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2685. * @param array defines the source array
  2686. * @param offset defines the offset in the source array
  2687. * @param result defines the Vector3 where to store the result
  2688. * @deprecated Please use FromArrayToRef instead.
  2689. */
  2690. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2691. /**
  2692. * Sets the given vector "result" with the given floats.
  2693. * @param x defines the x coordinate of the source
  2694. * @param y defines the y coordinate of the source
  2695. * @param z defines the z coordinate of the source
  2696. * @param result defines the Vector3 where to store the result
  2697. */
  2698. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2699. /**
  2700. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2701. * @returns a new empty Vector3
  2702. */
  2703. static Zero(): Vector3;
  2704. /**
  2705. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2706. * @returns a new unit Vector3
  2707. */
  2708. static One(): Vector3;
  2709. /**
  2710. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2711. * @returns a new up Vector3
  2712. */
  2713. static Up(): Vector3;
  2714. /**
  2715. * Gets a up Vector3 that must not be updated
  2716. */
  2717. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2718. /**
  2719. * Gets a zero Vector3 that must not be updated
  2720. */
  2721. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2722. /**
  2723. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2724. * @returns a new down Vector3
  2725. */
  2726. static Down(): Vector3;
  2727. /**
  2728. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2729. * @returns a new forward Vector3
  2730. */
  2731. static Forward(): Vector3;
  2732. /**
  2733. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2734. * @returns a new forward Vector3
  2735. */
  2736. static Backward(): Vector3;
  2737. /**
  2738. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2739. * @returns a new right Vector3
  2740. */
  2741. static Right(): Vector3;
  2742. /**
  2743. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2744. * @returns a new left Vector3
  2745. */
  2746. static Left(): Vector3;
  2747. /**
  2748. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2749. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2750. * @param vector defines the Vector3 to transform
  2751. * @param transformation defines the transformation matrix
  2752. * @returns the transformed Vector3
  2753. */
  2754. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2755. /**
  2756. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2757. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2758. * @param vector defines the Vector3 to transform
  2759. * @param transformation defines the transformation matrix
  2760. * @param result defines the Vector3 where to store the result
  2761. */
  2762. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2763. /**
  2764. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2765. * This method computes tranformed coordinates only, not transformed direction vectors
  2766. * @param x define the x coordinate of the source vector
  2767. * @param y define the y coordinate of the source vector
  2768. * @param z define the z coordinate of the source vector
  2769. * @param transformation defines the transformation matrix
  2770. * @param result defines the Vector3 where to store the result
  2771. */
  2772. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2773. /**
  2774. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2775. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2776. * @param vector defines the Vector3 to transform
  2777. * @param transformation defines the transformation matrix
  2778. * @returns the new Vector3
  2779. */
  2780. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2781. /**
  2782. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2783. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2784. * @param vector defines the Vector3 to transform
  2785. * @param transformation defines the transformation matrix
  2786. * @param result defines the Vector3 where to store the result
  2787. */
  2788. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2789. /**
  2790. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2791. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2792. * @param x define the x coordinate of the source vector
  2793. * @param y define the y coordinate of the source vector
  2794. * @param z define the z coordinate of the source vector
  2795. * @param transformation defines the transformation matrix
  2796. * @param result defines the Vector3 where to store the result
  2797. */
  2798. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2799. /**
  2800. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2801. * @param value1 defines the first control point
  2802. * @param value2 defines the second control point
  2803. * @param value3 defines the third control point
  2804. * @param value4 defines the fourth control point
  2805. * @param amount defines the amount on the spline to use
  2806. * @returns the new Vector3
  2807. */
  2808. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2809. /**
  2810. * 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"
  2811. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2812. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2813. * @param value defines the current value
  2814. * @param min defines the lower range value
  2815. * @param max defines the upper range value
  2816. * @returns the new Vector3
  2817. */
  2818. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2819. /**
  2820. * 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"
  2821. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2822. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2823. * @param value defines the current value
  2824. * @param min defines the lower range value
  2825. * @param max defines the upper range value
  2826. * @param result defines the Vector3 where to store the result
  2827. */
  2828. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2829. /**
  2830. * Checks if a given vector is inside a specific range
  2831. * @param v defines the vector to test
  2832. * @param min defines the minimum range
  2833. * @param max defines the maximum range
  2834. */
  2835. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2836. /**
  2837. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2838. * @param value1 defines the first control point
  2839. * @param tangent1 defines the first tangent vector
  2840. * @param value2 defines the second control point
  2841. * @param tangent2 defines the second tangent vector
  2842. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2843. * @returns the new Vector3
  2844. */
  2845. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2846. /**
  2847. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2848. * @param start defines the start value
  2849. * @param end defines the end value
  2850. * @param amount max defines amount between both (between 0 and 1)
  2851. * @returns the new Vector3
  2852. */
  2853. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2854. /**
  2855. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2856. * @param start defines the start value
  2857. * @param end defines the end value
  2858. * @param amount max defines amount between both (between 0 and 1)
  2859. * @param result defines the Vector3 where to store the result
  2860. */
  2861. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2862. /**
  2863. * Returns the dot product (float) between the vectors "left" and "right"
  2864. * @param left defines the left operand
  2865. * @param right defines the right operand
  2866. * @returns the dot product
  2867. */
  2868. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2869. /**
  2870. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2871. * The cross product is then orthogonal to both "left" and "right"
  2872. * @param left defines the left operand
  2873. * @param right defines the right operand
  2874. * @returns the cross product
  2875. */
  2876. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2877. /**
  2878. * Sets the given vector "result" with the cross product of "left" and "right"
  2879. * The cross product is then orthogonal to both "left" and "right"
  2880. * @param left defines the left operand
  2881. * @param right defines the right operand
  2882. * @param result defines the Vector3 where to store the result
  2883. */
  2884. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2885. /**
  2886. * Returns a new Vector3 as the normalization of the given vector
  2887. * @param vector defines the Vector3 to normalize
  2888. * @returns the new Vector3
  2889. */
  2890. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2891. /**
  2892. * Sets the given vector "result" with the normalization of the given first vector
  2893. * @param vector defines the Vector3 to normalize
  2894. * @param result defines the Vector3 where to store the result
  2895. */
  2896. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2897. /**
  2898. * Project a Vector3 onto screen space
  2899. * @param vector defines the Vector3 to project
  2900. * @param world defines the world matrix to use
  2901. * @param transform defines the transform (view x projection) matrix to use
  2902. * @param viewport defines the screen viewport to use
  2903. * @returns the new Vector3
  2904. */
  2905. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2906. /** @hidden */
  2907. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2908. /**
  2909. * Unproject from screen space to object space
  2910. * @param source defines the screen space Vector3 to use
  2911. * @param viewportWidth defines the current width of the viewport
  2912. * @param viewportHeight defines the current height of the viewport
  2913. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2914. * @param transform defines the transform (view x projection) matrix to use
  2915. * @returns the new Vector3
  2916. */
  2917. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2918. /**
  2919. * Unproject from screen space to object space
  2920. * @param source defines the screen space Vector3 to use
  2921. * @param viewportWidth defines the current width of the viewport
  2922. * @param viewportHeight defines the current height of the viewport
  2923. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2924. * @param view defines the view matrix to use
  2925. * @param projection defines the projection matrix to use
  2926. * @returns the new Vector3
  2927. */
  2928. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2929. /**
  2930. * Unproject from screen space to object space
  2931. * @param source defines the screen space Vector3 to use
  2932. * @param viewportWidth defines the current width of the viewport
  2933. * @param viewportHeight defines the current height of the viewport
  2934. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2935. * @param view defines the view matrix to use
  2936. * @param projection defines the projection matrix to use
  2937. * @param result defines the Vector3 where to store the result
  2938. */
  2939. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2940. /**
  2941. * Unproject from screen space to object space
  2942. * @param sourceX defines the screen space x coordinate to use
  2943. * @param sourceY defines the screen space y coordinate to use
  2944. * @param sourceZ defines the screen space z coordinate to use
  2945. * @param viewportWidth defines the current width of the viewport
  2946. * @param viewportHeight defines the current height of the viewport
  2947. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2948. * @param view defines the view matrix to use
  2949. * @param projection defines the projection matrix to use
  2950. * @param result defines the Vector3 where to store the result
  2951. */
  2952. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2953. /**
  2954. * Gets the minimal coordinate values between two Vector3
  2955. * @param left defines the first operand
  2956. * @param right defines the second operand
  2957. * @returns the new Vector3
  2958. */
  2959. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2960. /**
  2961. * Gets the maximal coordinate values between two Vector3
  2962. * @param left defines the first operand
  2963. * @param right defines the second operand
  2964. * @returns the new Vector3
  2965. */
  2966. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2967. /**
  2968. * Returns the distance between the vectors "value1" and "value2"
  2969. * @param value1 defines the first operand
  2970. * @param value2 defines the second operand
  2971. * @returns the distance
  2972. */
  2973. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2974. /**
  2975. * Returns the squared distance between the vectors "value1" and "value2"
  2976. * @param value1 defines the first operand
  2977. * @param value2 defines the second operand
  2978. * @returns the squared distance
  2979. */
  2980. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2981. /**
  2982. * Returns a new Vector3 located at the center between "value1" and "value2"
  2983. * @param value1 defines the first operand
  2984. * @param value2 defines the second operand
  2985. * @returns the new Vector3
  2986. */
  2987. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  2988. /**
  2989. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  2990. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  2991. * to something in order to rotate it from its local system to the given target system
  2992. * Note: axis1, axis2 and axis3 are normalized during this operation
  2993. * @param axis1 defines the first axis
  2994. * @param axis2 defines the second axis
  2995. * @param axis3 defines the third axis
  2996. * @returns a new Vector3
  2997. */
  2998. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  2999. /**
  3000. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3001. * @param axis1 defines the first axis
  3002. * @param axis2 defines the second axis
  3003. * @param axis3 defines the third axis
  3004. * @param ref defines the Vector3 where to store the result
  3005. */
  3006. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3007. }
  3008. /**
  3009. * Vector4 class created for EulerAngle class conversion to Quaternion
  3010. */
  3011. export class Vector4 {
  3012. /** x value of the vector */
  3013. x: number;
  3014. /** y value of the vector */
  3015. y: number;
  3016. /** z value of the vector */
  3017. z: number;
  3018. /** w value of the vector */
  3019. w: number;
  3020. /**
  3021. * Creates a Vector4 object from the given floats.
  3022. * @param x x value of the vector
  3023. * @param y y value of the vector
  3024. * @param z z value of the vector
  3025. * @param w w value of the vector
  3026. */
  3027. constructor(
  3028. /** x value of the vector */
  3029. x: number,
  3030. /** y value of the vector */
  3031. y: number,
  3032. /** z value of the vector */
  3033. z: number,
  3034. /** w value of the vector */
  3035. w: number);
  3036. /**
  3037. * Returns the string with the Vector4 coordinates.
  3038. * @returns a string containing all the vector values
  3039. */
  3040. toString(): string;
  3041. /**
  3042. * Returns the string "Vector4".
  3043. * @returns "Vector4"
  3044. */
  3045. getClassName(): string;
  3046. /**
  3047. * Returns the Vector4 hash code.
  3048. * @returns a unique hash code
  3049. */
  3050. getHashCode(): number;
  3051. /**
  3052. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3053. * @returns the resulting array
  3054. */
  3055. asArray(): number[];
  3056. /**
  3057. * Populates the given array from the given index with the Vector4 coordinates.
  3058. * @param array array to populate
  3059. * @param index index of the array to start at (default: 0)
  3060. * @returns the Vector4.
  3061. */
  3062. toArray(array: FloatArray, index?: number): Vector4;
  3063. /**
  3064. * Adds the given vector to the current Vector4.
  3065. * @param otherVector the vector to add
  3066. * @returns the updated Vector4.
  3067. */
  3068. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3069. /**
  3070. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3071. * @param otherVector the vector to add
  3072. * @returns the resulting vector
  3073. */
  3074. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3075. /**
  3076. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3077. * @param otherVector the vector to add
  3078. * @param result the vector to store the result
  3079. * @returns the current Vector4.
  3080. */
  3081. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3082. /**
  3083. * Subtract in place the given vector from the current Vector4.
  3084. * @param otherVector the vector to subtract
  3085. * @returns the updated Vector4.
  3086. */
  3087. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3088. /**
  3089. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3090. * @param otherVector the vector to add
  3091. * @returns the new vector with the result
  3092. */
  3093. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3094. /**
  3095. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3096. * @param otherVector the vector to subtract
  3097. * @param result the vector to store the result
  3098. * @returns the current Vector4.
  3099. */
  3100. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3101. /**
  3102. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3103. */
  3104. /**
  3105. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3106. * @param x value to subtract
  3107. * @param y value to subtract
  3108. * @param z value to subtract
  3109. * @param w value to subtract
  3110. * @returns new vector containing the result
  3111. */
  3112. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3113. /**
  3114. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3115. * @param x value to subtract
  3116. * @param y value to subtract
  3117. * @param z value to subtract
  3118. * @param w value to subtract
  3119. * @param result the vector to store the result in
  3120. * @returns the current Vector4.
  3121. */
  3122. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3123. /**
  3124. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3125. * @returns a new vector with the negated values
  3126. */
  3127. negate(): Vector4;
  3128. /**
  3129. * Multiplies the current Vector4 coordinates by scale (float).
  3130. * @param scale the number to scale with
  3131. * @returns the updated Vector4.
  3132. */
  3133. scaleInPlace(scale: number): Vector4;
  3134. /**
  3135. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3136. * @param scale the number to scale with
  3137. * @returns a new vector with the result
  3138. */
  3139. scale(scale: number): Vector4;
  3140. /**
  3141. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3142. * @param scale the number to scale with
  3143. * @param result a vector to store the result in
  3144. * @returns the current Vector4.
  3145. */
  3146. scaleToRef(scale: number, result: Vector4): Vector4;
  3147. /**
  3148. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3149. * @param scale defines the scale factor
  3150. * @param result defines the Vector4 object where to store the result
  3151. * @returns the unmodified current Vector4
  3152. */
  3153. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3154. /**
  3155. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3156. * @param otherVector the vector to compare against
  3157. * @returns true if they are equal
  3158. */
  3159. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3160. /**
  3161. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3162. * @param otherVector vector to compare against
  3163. * @param epsilon (Default: very small number)
  3164. * @returns true if they are equal
  3165. */
  3166. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3167. /**
  3168. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3169. * @param x x value to compare against
  3170. * @param y y value to compare against
  3171. * @param z z value to compare against
  3172. * @param w w value to compare against
  3173. * @returns true if equal
  3174. */
  3175. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3176. /**
  3177. * Multiplies in place the current Vector4 by the given one.
  3178. * @param otherVector vector to multiple with
  3179. * @returns the updated Vector4.
  3180. */
  3181. multiplyInPlace(otherVector: Vector4): Vector4;
  3182. /**
  3183. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3184. * @param otherVector vector to multiple with
  3185. * @returns resulting new vector
  3186. */
  3187. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3188. /**
  3189. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3190. * @param otherVector vector to multiple with
  3191. * @param result vector to store the result
  3192. * @returns the current Vector4.
  3193. */
  3194. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3195. /**
  3196. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3197. * @param x x value multiply with
  3198. * @param y y value multiply with
  3199. * @param z z value multiply with
  3200. * @param w w value multiply with
  3201. * @returns resulting new vector
  3202. */
  3203. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3204. /**
  3205. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3206. * @param otherVector vector to devide with
  3207. * @returns resulting new vector
  3208. */
  3209. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3210. /**
  3211. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3212. * @param otherVector vector to devide with
  3213. * @param result vector to store the result
  3214. * @returns the current Vector4.
  3215. */
  3216. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3217. /**
  3218. * Divides the current Vector3 coordinates by the given ones.
  3219. * @param otherVector vector to devide with
  3220. * @returns the updated Vector3.
  3221. */
  3222. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3223. /**
  3224. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3225. * @param other defines the second operand
  3226. * @returns the current updated Vector4
  3227. */
  3228. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3229. /**
  3230. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3231. * @param other defines the second operand
  3232. * @returns the current updated Vector4
  3233. */
  3234. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3235. /**
  3236. * Gets a new Vector4 from current Vector4 floored values
  3237. * @returns a new Vector4
  3238. */
  3239. floor(): Vector4;
  3240. /**
  3241. * Gets a new Vector4 from current Vector3 floored values
  3242. * @returns a new Vector4
  3243. */
  3244. fract(): Vector4;
  3245. /**
  3246. * Returns the Vector4 length (float).
  3247. * @returns the length
  3248. */
  3249. length(): number;
  3250. /**
  3251. * Returns the Vector4 squared length (float).
  3252. * @returns the length squared
  3253. */
  3254. lengthSquared(): number;
  3255. /**
  3256. * Normalizes in place the Vector4.
  3257. * @returns the updated Vector4.
  3258. */
  3259. normalize(): Vector4;
  3260. /**
  3261. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3262. * @returns this converted to a new vector3
  3263. */
  3264. toVector3(): Vector3;
  3265. /**
  3266. * Returns a new Vector4 copied from the current one.
  3267. * @returns the new cloned vector
  3268. */
  3269. clone(): Vector4;
  3270. /**
  3271. * Updates the current Vector4 with the given one coordinates.
  3272. * @param source the source vector to copy from
  3273. * @returns the updated Vector4.
  3274. */
  3275. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3276. /**
  3277. * Updates the current Vector4 coordinates with the given floats.
  3278. * @param x float to copy from
  3279. * @param y float to copy from
  3280. * @param z float to copy from
  3281. * @param w float to copy from
  3282. * @returns the updated Vector4.
  3283. */
  3284. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3285. /**
  3286. * Updates the current Vector4 coordinates with the given floats.
  3287. * @param x float to set from
  3288. * @param y float to set from
  3289. * @param z float to set from
  3290. * @param w float to set from
  3291. * @returns the updated Vector4.
  3292. */
  3293. set(x: number, y: number, z: number, w: number): Vector4;
  3294. /**
  3295. * Copies the given float to the current Vector3 coordinates
  3296. * @param v defines the x, y, z and w coordinates of the operand
  3297. * @returns the current updated Vector3
  3298. */
  3299. setAll(v: number): Vector4;
  3300. /**
  3301. * Returns a new Vector4 set from the starting index of the given array.
  3302. * @param array the array to pull values from
  3303. * @param offset the offset into the array to start at
  3304. * @returns the new vector
  3305. */
  3306. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3307. /**
  3308. * Updates the given vector "result" from the starting index of the given array.
  3309. * @param array the array to pull values from
  3310. * @param offset the offset into the array to start at
  3311. * @param result the vector to store the result in
  3312. */
  3313. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3314. /**
  3315. * Updates the given vector "result" from the starting index of the given Float32Array.
  3316. * @param array the array to pull values from
  3317. * @param offset the offset into the array to start at
  3318. * @param result the vector to store the result in
  3319. */
  3320. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3321. /**
  3322. * Updates the given vector "result" coordinates from the given floats.
  3323. * @param x float to set from
  3324. * @param y float to set from
  3325. * @param z float to set from
  3326. * @param w float to set from
  3327. * @param result the vector to the floats in
  3328. */
  3329. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3330. /**
  3331. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3332. * @returns the new vector
  3333. */
  3334. static Zero(): Vector4;
  3335. /**
  3336. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3337. * @returns the new vector
  3338. */
  3339. static One(): Vector4;
  3340. /**
  3341. * Returns a new normalized Vector4 from the given one.
  3342. * @param vector the vector to normalize
  3343. * @returns the vector
  3344. */
  3345. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3346. /**
  3347. * Updates the given vector "result" from the normalization of the given one.
  3348. * @param vector the vector to normalize
  3349. * @param result the vector to store the result in
  3350. */
  3351. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3352. /**
  3353. * Returns a vector with the minimum values from the left and right vectors
  3354. * @param left left vector to minimize
  3355. * @param right right vector to minimize
  3356. * @returns a new vector with the minimum of the left and right vector values
  3357. */
  3358. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3359. /**
  3360. * Returns a vector with the maximum values from the left and right vectors
  3361. * @param left left vector to maximize
  3362. * @param right right vector to maximize
  3363. * @returns a new vector with the maximum of the left and right vector values
  3364. */
  3365. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3366. /**
  3367. * Returns the distance (float) between the vectors "value1" and "value2".
  3368. * @param value1 value to calulate the distance between
  3369. * @param value2 value to calulate the distance between
  3370. * @return the distance between the two vectors
  3371. */
  3372. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3373. /**
  3374. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3375. * @param value1 value to calulate the distance between
  3376. * @param value2 value to calulate the distance between
  3377. * @return the distance between the two vectors squared
  3378. */
  3379. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3380. /**
  3381. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3382. * @param value1 value to calulate the center between
  3383. * @param value2 value to calulate the center between
  3384. * @return the center between the two vectors
  3385. */
  3386. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3387. /**
  3388. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3389. * This methods computes transformed normalized direction vectors only.
  3390. * @param vector the vector to transform
  3391. * @param transformation the transformation matrix to apply
  3392. * @returns the new vector
  3393. */
  3394. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3395. /**
  3396. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3397. * This methods computes transformed normalized direction vectors only.
  3398. * @param vector the vector to transform
  3399. * @param transformation the transformation matrix to apply
  3400. * @param result the vector to store the result in
  3401. */
  3402. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3403. /**
  3404. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3405. * This methods computes transformed normalized direction vectors only.
  3406. * @param x value to transform
  3407. * @param y value to transform
  3408. * @param z value to transform
  3409. * @param w value to transform
  3410. * @param transformation the transformation matrix to apply
  3411. * @param result the vector to store the results in
  3412. */
  3413. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3414. /**
  3415. * Creates a new Vector4 from a Vector3
  3416. * @param source defines the source data
  3417. * @param w defines the 4th component (default is 0)
  3418. * @returns a new Vector4
  3419. */
  3420. static FromVector3(source: Vector3, w?: number): Vector4;
  3421. }
  3422. /**
  3423. * Class used to store quaternion data
  3424. * @see https://en.wikipedia.org/wiki/Quaternion
  3425. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3426. */
  3427. export class Quaternion {
  3428. /** defines the first component (0 by default) */
  3429. x: number;
  3430. /** defines the second component (0 by default) */
  3431. y: number;
  3432. /** defines the third component (0 by default) */
  3433. z: number;
  3434. /** defines the fourth component (1.0 by default) */
  3435. w: number;
  3436. /**
  3437. * Creates a new Quaternion from the given floats
  3438. * @param x defines the first component (0 by default)
  3439. * @param y defines the second component (0 by default)
  3440. * @param z defines the third component (0 by default)
  3441. * @param w defines the fourth component (1.0 by default)
  3442. */
  3443. constructor(
  3444. /** defines the first component (0 by default) */
  3445. x?: number,
  3446. /** defines the second component (0 by default) */
  3447. y?: number,
  3448. /** defines the third component (0 by default) */
  3449. z?: number,
  3450. /** defines the fourth component (1.0 by default) */
  3451. w?: number);
  3452. /**
  3453. * Gets a string representation for the current quaternion
  3454. * @returns a string with the Quaternion coordinates
  3455. */
  3456. toString(): string;
  3457. /**
  3458. * Gets the class name of the quaternion
  3459. * @returns the string "Quaternion"
  3460. */
  3461. getClassName(): string;
  3462. /**
  3463. * Gets a hash code for this quaternion
  3464. * @returns the quaternion hash code
  3465. */
  3466. getHashCode(): number;
  3467. /**
  3468. * Copy the quaternion to an array
  3469. * @returns a new array populated with 4 elements from the quaternion coordinates
  3470. */
  3471. asArray(): number[];
  3472. /**
  3473. * Check if two quaternions are equals
  3474. * @param otherQuaternion defines the second operand
  3475. * @return true if the current quaternion and the given one coordinates are strictly equals
  3476. */
  3477. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3478. /**
  3479. * Clone the current quaternion
  3480. * @returns a new quaternion copied from the current one
  3481. */
  3482. clone(): Quaternion;
  3483. /**
  3484. * Copy a quaternion to the current one
  3485. * @param other defines the other quaternion
  3486. * @returns the updated current quaternion
  3487. */
  3488. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3489. /**
  3490. * Updates the current quaternion with the given float coordinates
  3491. * @param x defines the x coordinate
  3492. * @param y defines the y coordinate
  3493. * @param z defines the z coordinate
  3494. * @param w defines the w coordinate
  3495. * @returns the updated current quaternion
  3496. */
  3497. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3498. /**
  3499. * Updates the current quaternion from the given float coordinates
  3500. * @param x defines the x coordinate
  3501. * @param y defines the y coordinate
  3502. * @param z defines the z coordinate
  3503. * @param w defines the w coordinate
  3504. * @returns the updated current quaternion
  3505. */
  3506. set(x: number, y: number, z: number, w: number): Quaternion;
  3507. /**
  3508. * Adds two quaternions
  3509. * @param other defines the second operand
  3510. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3511. */
  3512. add(other: DeepImmutable<Quaternion>): Quaternion;
  3513. /**
  3514. * Add a quaternion to the current one
  3515. * @param other defines the quaternion to add
  3516. * @returns the current quaternion
  3517. */
  3518. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3519. /**
  3520. * Subtract two quaternions
  3521. * @param other defines the second operand
  3522. * @returns a new quaternion as the subtraction result of the given one from the current one
  3523. */
  3524. subtract(other: Quaternion): Quaternion;
  3525. /**
  3526. * Multiplies the current quaternion by a scale factor
  3527. * @param value defines the scale factor
  3528. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3529. */
  3530. scale(value: number): Quaternion;
  3531. /**
  3532. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3533. * @param scale defines the scale factor
  3534. * @param result defines the Quaternion object where to store the result
  3535. * @returns the unmodified current quaternion
  3536. */
  3537. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3538. /**
  3539. * Multiplies in place the current quaternion by a scale factor
  3540. * @param value defines the scale factor
  3541. * @returns the current modified quaternion
  3542. */
  3543. scaleInPlace(value: number): Quaternion;
  3544. /**
  3545. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3546. * @param scale defines the scale factor
  3547. * @param result defines the Quaternion object where to store the result
  3548. * @returns the unmodified current quaternion
  3549. */
  3550. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3551. /**
  3552. * Multiplies two quaternions
  3553. * @param q1 defines the second operand
  3554. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3555. */
  3556. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3557. /**
  3558. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3559. * @param q1 defines the second operand
  3560. * @param result defines the target quaternion
  3561. * @returns the current quaternion
  3562. */
  3563. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3564. /**
  3565. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3566. * @param q1 defines the second operand
  3567. * @returns the currentupdated quaternion
  3568. */
  3569. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3570. /**
  3571. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3572. * @param ref defines the target quaternion
  3573. * @returns the current quaternion
  3574. */
  3575. conjugateToRef(ref: Quaternion): Quaternion;
  3576. /**
  3577. * Conjugates in place (1-q) the current quaternion
  3578. * @returns the current updated quaternion
  3579. */
  3580. conjugateInPlace(): Quaternion;
  3581. /**
  3582. * Conjugates in place (1-q) the current quaternion
  3583. * @returns a new quaternion
  3584. */
  3585. conjugate(): Quaternion;
  3586. /**
  3587. * Gets length of current quaternion
  3588. * @returns the quaternion length (float)
  3589. */
  3590. length(): number;
  3591. /**
  3592. * Normalize in place the current quaternion
  3593. * @returns the current updated quaternion
  3594. */
  3595. normalize(): Quaternion;
  3596. /**
  3597. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3598. * @param order is a reserved parameter and is ignore for now
  3599. * @returns a new Vector3 containing the Euler angles
  3600. */
  3601. toEulerAngles(order?: string): Vector3;
  3602. /**
  3603. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3604. * @param result defines the vector which will be filled with the Euler angles
  3605. * @param order is a reserved parameter and is ignore for now
  3606. * @returns the current unchanged quaternion
  3607. */
  3608. toEulerAnglesToRef(result: Vector3): Quaternion;
  3609. /**
  3610. * Updates the given rotation matrix with the current quaternion values
  3611. * @param result defines the target matrix
  3612. * @returns the current unchanged quaternion
  3613. */
  3614. toRotationMatrix(result: Matrix): Quaternion;
  3615. /**
  3616. * Updates the current quaternion from the given rotation matrix values
  3617. * @param matrix defines the source matrix
  3618. * @returns the current updated quaternion
  3619. */
  3620. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3621. /**
  3622. * Creates a new quaternion from a rotation matrix
  3623. * @param matrix defines the source matrix
  3624. * @returns a new quaternion created from the given rotation matrix values
  3625. */
  3626. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3627. /**
  3628. * Updates the given quaternion with the given rotation matrix values
  3629. * @param matrix defines the source matrix
  3630. * @param result defines the target quaternion
  3631. */
  3632. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3633. /**
  3634. * Returns the dot product (float) between the quaternions "left" and "right"
  3635. * @param left defines the left operand
  3636. * @param right defines the right operand
  3637. * @returns the dot product
  3638. */
  3639. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3640. /**
  3641. * Checks if the two quaternions are close to each other
  3642. * @param quat0 defines the first quaternion to check
  3643. * @param quat1 defines the second quaternion to check
  3644. * @returns true if the two quaternions are close to each other
  3645. */
  3646. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3647. /**
  3648. * Creates an empty quaternion
  3649. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3650. */
  3651. static Zero(): Quaternion;
  3652. /**
  3653. * Inverse a given quaternion
  3654. * @param q defines the source quaternion
  3655. * @returns a new quaternion as the inverted current quaternion
  3656. */
  3657. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3658. /**
  3659. * Inverse a given quaternion
  3660. * @param q defines the source quaternion
  3661. * @param result the quaternion the result will be stored in
  3662. * @returns the result quaternion
  3663. */
  3664. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3665. /**
  3666. * Creates an identity quaternion
  3667. * @returns the identity quaternion
  3668. */
  3669. static Identity(): Quaternion;
  3670. /**
  3671. * Gets a boolean indicating if the given quaternion is identity
  3672. * @param quaternion defines the quaternion to check
  3673. * @returns true if the quaternion is identity
  3674. */
  3675. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3676. /**
  3677. * Creates a quaternion from a rotation around an axis
  3678. * @param axis defines the axis to use
  3679. * @param angle defines the angle to use
  3680. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3681. */
  3682. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3683. /**
  3684. * Creates a rotation around an axis and stores it into the given quaternion
  3685. * @param axis defines the axis to use
  3686. * @param angle defines the angle to use
  3687. * @param result defines the target quaternion
  3688. * @returns the target quaternion
  3689. */
  3690. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3691. /**
  3692. * Creates a new quaternion from data stored into an array
  3693. * @param array defines the data source
  3694. * @param offset defines the offset in the source array where the data starts
  3695. * @returns a new quaternion
  3696. */
  3697. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3698. /**
  3699. * Create a quaternion from Euler rotation angles
  3700. * @param x Pitch
  3701. * @param y Yaw
  3702. * @param z Roll
  3703. * @returns the new Quaternion
  3704. */
  3705. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3706. /**
  3707. * Updates a quaternion from Euler rotation angles
  3708. * @param x Pitch
  3709. * @param y Yaw
  3710. * @param z Roll
  3711. * @param result the quaternion to store the result
  3712. * @returns the updated quaternion
  3713. */
  3714. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3715. /**
  3716. * Create a quaternion from Euler rotation vector
  3717. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3718. * @returns the new Quaternion
  3719. */
  3720. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3721. /**
  3722. * Updates a quaternion from Euler rotation vector
  3723. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3724. * @param result the quaternion to store the result
  3725. * @returns the updated quaternion
  3726. */
  3727. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3728. /**
  3729. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3730. * @param yaw defines the rotation around Y axis
  3731. * @param pitch defines the rotation around X axis
  3732. * @param roll defines the rotation around Z axis
  3733. * @returns the new quaternion
  3734. */
  3735. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3736. /**
  3737. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3738. * @param yaw defines the rotation around Y axis
  3739. * @param pitch defines the rotation around X axis
  3740. * @param roll defines the rotation around Z axis
  3741. * @param result defines the target quaternion
  3742. */
  3743. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3744. /**
  3745. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3746. * @param alpha defines the rotation around first axis
  3747. * @param beta defines the rotation around second axis
  3748. * @param gamma defines the rotation around third axis
  3749. * @returns the new quaternion
  3750. */
  3751. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3752. /**
  3753. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3754. * @param alpha defines the rotation around first axis
  3755. * @param beta defines the rotation around second axis
  3756. * @param gamma defines the rotation around third axis
  3757. * @param result defines the target quaternion
  3758. */
  3759. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3760. /**
  3761. * 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)
  3762. * @param axis1 defines the first axis
  3763. * @param axis2 defines the second axis
  3764. * @param axis3 defines the third axis
  3765. * @returns the new quaternion
  3766. */
  3767. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3768. /**
  3769. * 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
  3770. * @param axis1 defines the first axis
  3771. * @param axis2 defines the second axis
  3772. * @param axis3 defines the third axis
  3773. * @param ref defines the target quaternion
  3774. */
  3775. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3776. /**
  3777. * Interpolates between two quaternions
  3778. * @param left defines first quaternion
  3779. * @param right defines second quaternion
  3780. * @param amount defines the gradient to use
  3781. * @returns the new interpolated quaternion
  3782. */
  3783. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3784. /**
  3785. * Interpolates between two quaternions and stores it into a target quaternion
  3786. * @param left defines first quaternion
  3787. * @param right defines second quaternion
  3788. * @param amount defines the gradient to use
  3789. * @param result defines the target quaternion
  3790. */
  3791. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3792. /**
  3793. * Interpolate between two quaternions using Hermite interpolation
  3794. * @param value1 defines first quaternion
  3795. * @param tangent1 defines the incoming tangent
  3796. * @param value2 defines second quaternion
  3797. * @param tangent2 defines the outgoing tangent
  3798. * @param amount defines the target quaternion
  3799. * @returns the new interpolated quaternion
  3800. */
  3801. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3802. }
  3803. /**
  3804. * Class used to store matrix data (4x4)
  3805. */
  3806. export class Matrix {
  3807. private static _updateFlagSeed;
  3808. private static _identityReadOnly;
  3809. private _isIdentity;
  3810. private _isIdentityDirty;
  3811. private _isIdentity3x2;
  3812. private _isIdentity3x2Dirty;
  3813. /**
  3814. * Gets the update flag of the matrix which is an unique number for the matrix.
  3815. * It will be incremented every time the matrix data change.
  3816. * You can use it to speed the comparison between two versions of the same matrix.
  3817. */
  3818. updateFlag: number;
  3819. private readonly _m;
  3820. /**
  3821. * Gets the internal data of the matrix
  3822. */
  3823. readonly m: DeepImmutable<Float32Array>;
  3824. /** @hidden */
  3825. _markAsUpdated(): void;
  3826. /** @hidden */
  3827. private _updateIdentityStatus;
  3828. /**
  3829. * Creates an empty matrix (filled with zeros)
  3830. */
  3831. constructor();
  3832. /**
  3833. * Check if the current matrix is identity
  3834. * @returns true is the matrix is the identity matrix
  3835. */
  3836. isIdentity(): boolean;
  3837. /**
  3838. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3839. * @returns true is the matrix is the identity matrix
  3840. */
  3841. isIdentityAs3x2(): boolean;
  3842. /**
  3843. * Gets the determinant of the matrix
  3844. * @returns the matrix determinant
  3845. */
  3846. determinant(): number;
  3847. /**
  3848. * Returns the matrix as a Float32Array
  3849. * @returns the matrix underlying array
  3850. */
  3851. toArray(): DeepImmutable<Float32Array>;
  3852. /**
  3853. * Returns the matrix as a Float32Array
  3854. * @returns the matrix underlying array.
  3855. */
  3856. asArray(): DeepImmutable<Float32Array>;
  3857. /**
  3858. * Inverts the current matrix in place
  3859. * @returns the current inverted matrix
  3860. */
  3861. invert(): Matrix;
  3862. /**
  3863. * Sets all the matrix elements to zero
  3864. * @returns the current matrix
  3865. */
  3866. reset(): Matrix;
  3867. /**
  3868. * Adds the current matrix with a second one
  3869. * @param other defines the matrix to add
  3870. * @returns a new matrix as the addition of the current matrix and the given one
  3871. */
  3872. add(other: DeepImmutable<Matrix>): Matrix;
  3873. /**
  3874. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3875. * @param other defines the matrix to add
  3876. * @param result defines the target matrix
  3877. * @returns the current matrix
  3878. */
  3879. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3880. /**
  3881. * Adds in place the given matrix to the current matrix
  3882. * @param other defines the second operand
  3883. * @returns the current updated matrix
  3884. */
  3885. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3886. /**
  3887. * Sets the given matrix to the current inverted Matrix
  3888. * @param other defines the target matrix
  3889. * @returns the unmodified current matrix
  3890. */
  3891. invertToRef(other: Matrix): Matrix;
  3892. /**
  3893. * add a value at the specified position in the current Matrix
  3894. * @param index the index of the value within the matrix. between 0 and 15.
  3895. * @param value the value to be added
  3896. * @returns the current updated matrix
  3897. */
  3898. addAtIndex(index: number, value: number): Matrix;
  3899. /**
  3900. * mutiply the specified position in the current Matrix by a value
  3901. * @param index the index of the value within the matrix. between 0 and 15.
  3902. * @param value the value to be added
  3903. * @returns the current updated matrix
  3904. */
  3905. multiplyAtIndex(index: number, value: number): Matrix;
  3906. /**
  3907. * Inserts the translation vector (using 3 floats) in the current matrix
  3908. * @param x defines the 1st component of the translation
  3909. * @param y defines the 2nd component of the translation
  3910. * @param z defines the 3rd component of the translation
  3911. * @returns the current updated matrix
  3912. */
  3913. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3914. /**
  3915. * Adds the translation vector (using 3 floats) in the current matrix
  3916. * @param x defines the 1st component of the translation
  3917. * @param y defines the 2nd component of the translation
  3918. * @param z defines the 3rd component of the translation
  3919. * @returns the current updated matrix
  3920. */
  3921. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3922. /**
  3923. * Inserts the translation vector in the current matrix
  3924. * @param vector3 defines the translation to insert
  3925. * @returns the current updated matrix
  3926. */
  3927. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3928. /**
  3929. * Gets the translation value of the current matrix
  3930. * @returns a new Vector3 as the extracted translation from the matrix
  3931. */
  3932. getTranslation(): Vector3;
  3933. /**
  3934. * Fill a Vector3 with the extracted translation from the matrix
  3935. * @param result defines the Vector3 where to store the translation
  3936. * @returns the current matrix
  3937. */
  3938. getTranslationToRef(result: Vector3): Matrix;
  3939. /**
  3940. * Remove rotation and scaling part from the matrix
  3941. * @returns the updated matrix
  3942. */
  3943. removeRotationAndScaling(): Matrix;
  3944. /**
  3945. * Multiply two matrices
  3946. * @param other defines the second operand
  3947. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3948. */
  3949. multiply(other: DeepImmutable<Matrix>): Matrix;
  3950. /**
  3951. * Copy the current matrix from the given one
  3952. * @param other defines the source matrix
  3953. * @returns the current updated matrix
  3954. */
  3955. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3956. /**
  3957. * Populates the given array from the starting index with the current matrix values
  3958. * @param array defines the target array
  3959. * @param offset defines the offset in the target array where to start storing values
  3960. * @returns the current matrix
  3961. */
  3962. copyToArray(array: Float32Array, offset?: number): Matrix;
  3963. /**
  3964. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3965. * @param other defines the second operand
  3966. * @param result defines the matrix where to store the multiplication
  3967. * @returns the current matrix
  3968. */
  3969. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3970. /**
  3971. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3972. * @param other defines the second operand
  3973. * @param result defines the array where to store the multiplication
  3974. * @param offset defines the offset in the target array where to start storing values
  3975. * @returns the current matrix
  3976. */
  3977. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3978. /**
  3979. * Check equality between this matrix and a second one
  3980. * @param value defines the second matrix to compare
  3981. * @returns true is the current matrix and the given one values are strictly equal
  3982. */
  3983. equals(value: DeepImmutable<Matrix>): boolean;
  3984. /**
  3985. * Clone the current matrix
  3986. * @returns a new matrix from the current matrix
  3987. */
  3988. clone(): Matrix;
  3989. /**
  3990. * Returns the name of the current matrix class
  3991. * @returns the string "Matrix"
  3992. */
  3993. getClassName(): string;
  3994. /**
  3995. * Gets the hash code of the current matrix
  3996. * @returns the hash code
  3997. */
  3998. getHashCode(): number;
  3999. /**
  4000. * Decomposes the current Matrix into a translation, rotation and scaling components
  4001. * @param scale defines the scale vector3 given as a reference to update
  4002. * @param rotation defines the rotation quaternion given as a reference to update
  4003. * @param translation defines the translation vector3 given as a reference to update
  4004. * @returns true if operation was successful
  4005. */
  4006. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4007. /**
  4008. * Gets specific row of the matrix
  4009. * @param index defines the number of the row to get
  4010. * @returns the index-th row of the current matrix as a new Vector4
  4011. */
  4012. getRow(index: number): Nullable<Vector4>;
  4013. /**
  4014. * Sets the index-th row of the current matrix to the vector4 values
  4015. * @param index defines the number of the row to set
  4016. * @param row defines the target vector4
  4017. * @returns the updated current matrix
  4018. */
  4019. setRow(index: number, row: Vector4): Matrix;
  4020. /**
  4021. * Compute the transpose of the matrix
  4022. * @returns the new transposed matrix
  4023. */
  4024. transpose(): Matrix;
  4025. /**
  4026. * Compute the transpose of the matrix and store it in a given matrix
  4027. * @param result defines the target matrix
  4028. * @returns the current matrix
  4029. */
  4030. transposeToRef(result: Matrix): Matrix;
  4031. /**
  4032. * Sets the index-th row of the current matrix with the given 4 x float values
  4033. * @param index defines the row index
  4034. * @param x defines the x component to set
  4035. * @param y defines the y component to set
  4036. * @param z defines the z component to set
  4037. * @param w defines the w component to set
  4038. * @returns the updated current matrix
  4039. */
  4040. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4041. /**
  4042. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4043. * @param scale defines the scale factor
  4044. * @returns a new matrix
  4045. */
  4046. scale(scale: number): Matrix;
  4047. /**
  4048. * Scale the current matrix values by a factor to a given result matrix
  4049. * @param scale defines the scale factor
  4050. * @param result defines the matrix to store the result
  4051. * @returns the current matrix
  4052. */
  4053. scaleToRef(scale: number, result: Matrix): Matrix;
  4054. /**
  4055. * Scale the current matrix values by a factor and add the result to a given matrix
  4056. * @param scale defines the scale factor
  4057. * @param result defines the Matrix to store the result
  4058. * @returns the current matrix
  4059. */
  4060. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4061. /**
  4062. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4063. * @param ref matrix to store the result
  4064. */
  4065. toNormalMatrix(ref: Matrix): void;
  4066. /**
  4067. * Gets only rotation part of the current matrix
  4068. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4069. */
  4070. getRotationMatrix(): Matrix;
  4071. /**
  4072. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4073. * @param result defines the target matrix to store data to
  4074. * @returns the current matrix
  4075. */
  4076. getRotationMatrixToRef(result: Matrix): Matrix;
  4077. /**
  4078. * Toggles model matrix from being right handed to left handed in place and vice versa
  4079. */
  4080. toggleModelMatrixHandInPlace(): void;
  4081. /**
  4082. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4083. */
  4084. toggleProjectionMatrixHandInPlace(): void;
  4085. /**
  4086. * Creates a matrix from an array
  4087. * @param array defines the source array
  4088. * @param offset defines an offset in the source array
  4089. * @returns a new Matrix set from the starting index of the given array
  4090. */
  4091. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4092. /**
  4093. * Copy the content of an array into a given matrix
  4094. * @param array defines the source array
  4095. * @param offset defines an offset in the source array
  4096. * @param result defines the target matrix
  4097. */
  4098. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4099. /**
  4100. * Stores an array into a matrix after having multiplied each component by a given factor
  4101. * @param array defines the source array
  4102. * @param offset defines the offset in the source array
  4103. * @param scale defines the scaling factor
  4104. * @param result defines the target matrix
  4105. */
  4106. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4107. /**
  4108. * Gets an identity matrix that must not be updated
  4109. */
  4110. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  4111. /**
  4112. * Stores a list of values (16) inside a given matrix
  4113. * @param initialM11 defines 1st value of 1st row
  4114. * @param initialM12 defines 2nd value of 1st row
  4115. * @param initialM13 defines 3rd value of 1st row
  4116. * @param initialM14 defines 4th value of 1st row
  4117. * @param initialM21 defines 1st value of 2nd row
  4118. * @param initialM22 defines 2nd value of 2nd row
  4119. * @param initialM23 defines 3rd value of 2nd row
  4120. * @param initialM24 defines 4th value of 2nd row
  4121. * @param initialM31 defines 1st value of 3rd row
  4122. * @param initialM32 defines 2nd value of 3rd row
  4123. * @param initialM33 defines 3rd value of 3rd row
  4124. * @param initialM34 defines 4th value of 3rd row
  4125. * @param initialM41 defines 1st value of 4th row
  4126. * @param initialM42 defines 2nd value of 4th row
  4127. * @param initialM43 defines 3rd value of 4th row
  4128. * @param initialM44 defines 4th value of 4th row
  4129. * @param result defines the target matrix
  4130. */
  4131. 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;
  4132. /**
  4133. * Creates new matrix from a list of values (16)
  4134. * @param initialM11 defines 1st value of 1st row
  4135. * @param initialM12 defines 2nd value of 1st row
  4136. * @param initialM13 defines 3rd value of 1st row
  4137. * @param initialM14 defines 4th value of 1st row
  4138. * @param initialM21 defines 1st value of 2nd row
  4139. * @param initialM22 defines 2nd value of 2nd row
  4140. * @param initialM23 defines 3rd value of 2nd row
  4141. * @param initialM24 defines 4th value of 2nd row
  4142. * @param initialM31 defines 1st value of 3rd row
  4143. * @param initialM32 defines 2nd value of 3rd row
  4144. * @param initialM33 defines 3rd value of 3rd row
  4145. * @param initialM34 defines 4th value of 3rd row
  4146. * @param initialM41 defines 1st value of 4th row
  4147. * @param initialM42 defines 2nd value of 4th row
  4148. * @param initialM43 defines 3rd value of 4th row
  4149. * @param initialM44 defines 4th value of 4th row
  4150. * @returns the new matrix
  4151. */
  4152. 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;
  4153. /**
  4154. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4155. * @param scale defines the scale vector3
  4156. * @param rotation defines the rotation quaternion
  4157. * @param translation defines the translation vector3
  4158. * @returns a new matrix
  4159. */
  4160. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4161. /**
  4162. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4163. * @param scale defines the scale vector3
  4164. * @param rotation defines the rotation quaternion
  4165. * @param translation defines the translation vector3
  4166. * @param result defines the target matrix
  4167. */
  4168. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4169. /**
  4170. * Creates a new identity matrix
  4171. * @returns a new identity matrix
  4172. */
  4173. static Identity(): Matrix;
  4174. /**
  4175. * Creates a new identity matrix and stores the result in a given matrix
  4176. * @param result defines the target matrix
  4177. */
  4178. static IdentityToRef(result: Matrix): void;
  4179. /**
  4180. * Creates a new zero matrix
  4181. * @returns a new zero matrix
  4182. */
  4183. static Zero(): Matrix;
  4184. /**
  4185. * Creates a new rotation matrix for "angle" radians around the X axis
  4186. * @param angle defines the angle (in radians) to use
  4187. * @return the new matrix
  4188. */
  4189. static RotationX(angle: number): Matrix;
  4190. /**
  4191. * Creates a new matrix as the invert of a given matrix
  4192. * @param source defines the source matrix
  4193. * @returns the new matrix
  4194. */
  4195. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4196. /**
  4197. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4198. * @param angle defines the angle (in radians) to use
  4199. * @param result defines the target matrix
  4200. */
  4201. static RotationXToRef(angle: number, result: Matrix): void;
  4202. /**
  4203. * Creates a new rotation matrix for "angle" radians around the Y axis
  4204. * @param angle defines the angle (in radians) to use
  4205. * @return the new matrix
  4206. */
  4207. static RotationY(angle: number): Matrix;
  4208. /**
  4209. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4210. * @param angle defines the angle (in radians) to use
  4211. * @param result defines the target matrix
  4212. */
  4213. static RotationYToRef(angle: number, result: Matrix): void;
  4214. /**
  4215. * Creates a new rotation matrix for "angle" radians around the Z axis
  4216. * @param angle defines the angle (in radians) to use
  4217. * @return the new matrix
  4218. */
  4219. static RotationZ(angle: number): Matrix;
  4220. /**
  4221. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4222. * @param angle defines the angle (in radians) to use
  4223. * @param result defines the target matrix
  4224. */
  4225. static RotationZToRef(angle: number, result: Matrix): void;
  4226. /**
  4227. * Creates a new rotation matrix for "angle" radians around the given axis
  4228. * @param axis defines the axis to use
  4229. * @param angle defines the angle (in radians) to use
  4230. * @return the new matrix
  4231. */
  4232. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4233. /**
  4234. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4235. * @param axis defines the axis to use
  4236. * @param angle defines the angle (in radians) to use
  4237. * @param result defines the target matrix
  4238. */
  4239. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4240. /**
  4241. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4242. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4243. * @param from defines the vector to align
  4244. * @param to defines the vector to align to
  4245. * @param result defines the target matrix
  4246. */
  4247. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4248. /**
  4249. * Creates a rotation matrix
  4250. * @param yaw defines the yaw angle in radians (Y axis)
  4251. * @param pitch defines the pitch angle in radians (X axis)
  4252. * @param roll defines the roll angle in radians (X axis)
  4253. * @returns the new rotation matrix
  4254. */
  4255. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4256. /**
  4257. * Creates a rotation matrix and stores it in a given matrix
  4258. * @param yaw defines the yaw angle in radians (Y axis)
  4259. * @param pitch defines the pitch angle in radians (X axis)
  4260. * @param roll defines the roll angle in radians (X axis)
  4261. * @param result defines the target matrix
  4262. */
  4263. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4264. /**
  4265. * Creates a scaling matrix
  4266. * @param x defines the scale factor on X axis
  4267. * @param y defines the scale factor on Y axis
  4268. * @param z defines the scale factor on Z axis
  4269. * @returns the new matrix
  4270. */
  4271. static Scaling(x: number, y: number, z: number): Matrix;
  4272. /**
  4273. * Creates a scaling matrix and stores it in a given matrix
  4274. * @param x defines the scale factor on X axis
  4275. * @param y defines the scale factor on Y axis
  4276. * @param z defines the scale factor on Z axis
  4277. * @param result defines the target matrix
  4278. */
  4279. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4280. /**
  4281. * Creates a translation matrix
  4282. * @param x defines the translation on X axis
  4283. * @param y defines the translation on Y axis
  4284. * @param z defines the translationon Z axis
  4285. * @returns the new matrix
  4286. */
  4287. static Translation(x: number, y: number, z: number): Matrix;
  4288. /**
  4289. * Creates a translation matrix and stores it in a given matrix
  4290. * @param x defines the translation on X axis
  4291. * @param y defines the translation on Y axis
  4292. * @param z defines the translationon Z axis
  4293. * @param result defines the target matrix
  4294. */
  4295. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4296. /**
  4297. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4298. * @param startValue defines the start value
  4299. * @param endValue defines the end value
  4300. * @param gradient defines the gradient factor
  4301. * @returns the new matrix
  4302. */
  4303. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4304. /**
  4305. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4306. * @param startValue defines the start value
  4307. * @param endValue defines the end value
  4308. * @param gradient defines the gradient factor
  4309. * @param result defines the Matrix object where to store data
  4310. */
  4311. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4312. /**
  4313. * Builds a new matrix whose values are computed by:
  4314. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4315. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4316. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4317. * @param startValue defines the first matrix
  4318. * @param endValue defines the second matrix
  4319. * @param gradient defines the gradient between the two matrices
  4320. * @returns the new matrix
  4321. */
  4322. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4323. /**
  4324. * Update a matrix to values which are computed by:
  4325. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4326. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4327. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4328. * @param startValue defines the first matrix
  4329. * @param endValue defines the second matrix
  4330. * @param gradient defines the gradient between the two matrices
  4331. * @param result defines the target matrix
  4332. */
  4333. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4334. /**
  4335. * 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"
  4336. * This function works in left handed mode
  4337. * @param eye defines the final position of the entity
  4338. * @param target defines where the entity should look at
  4339. * @param up defines the up vector for the entity
  4340. * @returns the new matrix
  4341. */
  4342. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4343. /**
  4344. * 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".
  4345. * This function works in left handed mode
  4346. * @param eye defines the final position of the entity
  4347. * @param target defines where the entity should look at
  4348. * @param up defines the up vector for the entity
  4349. * @param result defines the target matrix
  4350. */
  4351. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4352. /**
  4353. * 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"
  4354. * This function works in right handed mode
  4355. * @param eye defines the final position of the entity
  4356. * @param target defines where the entity should look at
  4357. * @param up defines the up vector for the entity
  4358. * @returns the new matrix
  4359. */
  4360. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4361. /**
  4362. * 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".
  4363. * This function works in right handed mode
  4364. * @param eye defines the final position of the entity
  4365. * @param target defines where the entity should look at
  4366. * @param up defines the up vector for the entity
  4367. * @param result defines the target matrix
  4368. */
  4369. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4370. /**
  4371. * Create a left-handed orthographic projection matrix
  4372. * @param width defines the viewport width
  4373. * @param height defines the viewport height
  4374. * @param znear defines the near clip plane
  4375. * @param zfar defines the far clip plane
  4376. * @returns a new matrix as a left-handed orthographic projection matrix
  4377. */
  4378. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4379. /**
  4380. * Store a left-handed orthographic projection to a given matrix
  4381. * @param width defines the viewport width
  4382. * @param height defines the viewport height
  4383. * @param znear defines the near clip plane
  4384. * @param zfar defines the far clip plane
  4385. * @param result defines the target matrix
  4386. */
  4387. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4388. /**
  4389. * Create a left-handed orthographic projection matrix
  4390. * @param left defines the viewport left coordinate
  4391. * @param right defines the viewport right coordinate
  4392. * @param bottom defines the viewport bottom coordinate
  4393. * @param top defines the viewport top coordinate
  4394. * @param znear defines the near clip plane
  4395. * @param zfar defines the far clip plane
  4396. * @returns a new matrix as a left-handed orthographic projection matrix
  4397. */
  4398. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4399. /**
  4400. * Stores a left-handed orthographic projection into a given matrix
  4401. * @param left defines the viewport left coordinate
  4402. * @param right defines the viewport right coordinate
  4403. * @param bottom defines the viewport bottom coordinate
  4404. * @param top defines the viewport top coordinate
  4405. * @param znear defines the near clip plane
  4406. * @param zfar defines the far clip plane
  4407. * @param result defines the target matrix
  4408. */
  4409. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4410. /**
  4411. * Creates a right-handed orthographic projection matrix
  4412. * @param left defines the viewport left coordinate
  4413. * @param right defines the viewport right coordinate
  4414. * @param bottom defines the viewport bottom coordinate
  4415. * @param top defines the viewport top coordinate
  4416. * @param znear defines the near clip plane
  4417. * @param zfar defines the far clip plane
  4418. * @returns a new matrix as a right-handed orthographic projection matrix
  4419. */
  4420. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4421. /**
  4422. * Stores a right-handed orthographic projection into a given matrix
  4423. * @param left defines the viewport left coordinate
  4424. * @param right defines the viewport right coordinate
  4425. * @param bottom defines the viewport bottom coordinate
  4426. * @param top defines the viewport top coordinate
  4427. * @param znear defines the near clip plane
  4428. * @param zfar defines the far clip plane
  4429. * @param result defines the target matrix
  4430. */
  4431. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4432. /**
  4433. * Creates a left-handed perspective projection matrix
  4434. * @param width defines the viewport width
  4435. * @param height defines the viewport height
  4436. * @param znear defines the near clip plane
  4437. * @param zfar defines the far clip plane
  4438. * @returns a new matrix as a left-handed perspective projection matrix
  4439. */
  4440. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4441. /**
  4442. * Creates a left-handed perspective projection matrix
  4443. * @param fov defines the horizontal field of view
  4444. * @param aspect defines the aspect ratio
  4445. * @param znear defines the near clip plane
  4446. * @param zfar defines the far clip plane
  4447. * @returns a new matrix as a left-handed perspective projection matrix
  4448. */
  4449. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4450. /**
  4451. * Stores a left-handed perspective projection into a given matrix
  4452. * @param fov defines the horizontal field of view
  4453. * @param aspect defines the aspect ratio
  4454. * @param znear defines the near clip plane
  4455. * @param zfar defines the far clip plane
  4456. * @param result defines the target matrix
  4457. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4458. */
  4459. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4460. /**
  4461. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4462. * @param fov defines the horizontal field of view
  4463. * @param aspect defines the aspect ratio
  4464. * @param znear defines the near clip plane
  4465. * @param zfar not used as infinity is used as far clip
  4466. * @param result defines the target matrix
  4467. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4468. */
  4469. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4470. /**
  4471. * Creates a right-handed perspective projection matrix
  4472. * @param fov defines the horizontal field of view
  4473. * @param aspect defines the aspect ratio
  4474. * @param znear defines the near clip plane
  4475. * @param zfar defines the far clip plane
  4476. * @returns a new matrix as a right-handed perspective projection matrix
  4477. */
  4478. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4479. /**
  4480. * Stores a right-handed perspective projection into a given matrix
  4481. * @param fov defines the horizontal field of view
  4482. * @param aspect defines the aspect ratio
  4483. * @param znear defines the near clip plane
  4484. * @param zfar defines the far clip plane
  4485. * @param result defines the target matrix
  4486. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4487. */
  4488. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4489. /**
  4490. * Stores a right-handed perspective projection into a given matrix
  4491. * @param fov defines the horizontal field of view
  4492. * @param aspect defines the aspect ratio
  4493. * @param znear defines the near clip plane
  4494. * @param zfar not used as infinity is used as far clip
  4495. * @param result defines the target matrix
  4496. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4497. */
  4498. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4499. /**
  4500. * Stores a perspective projection for WebVR info a given matrix
  4501. * @param fov defines the field of view
  4502. * @param znear defines the near clip plane
  4503. * @param zfar defines the far clip plane
  4504. * @param result defines the target matrix
  4505. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4506. */
  4507. static PerspectiveFovWebVRToRef(fov: {
  4508. upDegrees: number;
  4509. downDegrees: number;
  4510. leftDegrees: number;
  4511. rightDegrees: number;
  4512. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4513. /**
  4514. * Computes a complete transformation matrix
  4515. * @param viewport defines the viewport to use
  4516. * @param world defines the world matrix
  4517. * @param view defines the view matrix
  4518. * @param projection defines the projection matrix
  4519. * @param zmin defines the near clip plane
  4520. * @param zmax defines the far clip plane
  4521. * @returns the transformation matrix
  4522. */
  4523. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4524. /**
  4525. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4526. * @param matrix defines the matrix to use
  4527. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4528. */
  4529. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4530. /**
  4531. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4532. * @param matrix defines the matrix to use
  4533. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4534. */
  4535. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4536. /**
  4537. * Compute the transpose of a given matrix
  4538. * @param matrix defines the matrix to transpose
  4539. * @returns the new matrix
  4540. */
  4541. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4542. /**
  4543. * Compute the transpose of a matrix and store it in a target matrix
  4544. * @param matrix defines the matrix to transpose
  4545. * @param result defines the target matrix
  4546. */
  4547. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4548. /**
  4549. * Computes a reflection matrix from a plane
  4550. * @param plane defines the reflection plane
  4551. * @returns a new matrix
  4552. */
  4553. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4554. /**
  4555. * Computes a reflection matrix from a plane
  4556. * @param plane defines the reflection plane
  4557. * @param result defines the target matrix
  4558. */
  4559. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4560. /**
  4561. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4562. * @param xaxis defines the value of the 1st axis
  4563. * @param yaxis defines the value of the 2nd axis
  4564. * @param zaxis defines the value of the 3rd axis
  4565. * @param result defines the target matrix
  4566. */
  4567. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4568. /**
  4569. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4570. * @param quat defines the quaternion to use
  4571. * @param result defines the target matrix
  4572. */
  4573. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4574. }
  4575. /**
  4576. * @hidden
  4577. */
  4578. export class TmpVectors {
  4579. static Vector2: Vector2[];
  4580. static Vector3: Vector3[];
  4581. static Vector4: Vector4[];
  4582. static Quaternion: Quaternion[];
  4583. static Matrix: Matrix[];
  4584. }
  4585. }
  4586. declare module BABYLON {
  4587. /**
  4588. * Defines potential orientation for back face culling
  4589. */
  4590. export enum Orientation {
  4591. /**
  4592. * Clockwise
  4593. */
  4594. CW = 0,
  4595. /** Counter clockwise */
  4596. CCW = 1
  4597. }
  4598. /** Class used to represent a Bezier curve */
  4599. export class BezierCurve {
  4600. /**
  4601. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4602. * @param t defines the time
  4603. * @param x1 defines the left coordinate on X axis
  4604. * @param y1 defines the left coordinate on Y axis
  4605. * @param x2 defines the right coordinate on X axis
  4606. * @param y2 defines the right coordinate on Y axis
  4607. * @returns the interpolated value
  4608. */
  4609. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4610. }
  4611. /**
  4612. * Defines angle representation
  4613. */
  4614. export class Angle {
  4615. private _radians;
  4616. /**
  4617. * Creates an Angle object of "radians" radians (float).
  4618. * @param radians the angle in radians
  4619. */
  4620. constructor(radians: number);
  4621. /**
  4622. * Get value in degrees
  4623. * @returns the Angle value in degrees (float)
  4624. */
  4625. degrees(): number;
  4626. /**
  4627. * Get value in radians
  4628. * @returns the Angle value in radians (float)
  4629. */
  4630. radians(): number;
  4631. /**
  4632. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4633. * @param a defines first vector
  4634. * @param b defines second vector
  4635. * @returns a new Angle
  4636. */
  4637. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4638. /**
  4639. * Gets a new Angle object from the given float in radians
  4640. * @param radians defines the angle value in radians
  4641. * @returns a new Angle
  4642. */
  4643. static FromRadians(radians: number): Angle;
  4644. /**
  4645. * Gets a new Angle object from the given float in degrees
  4646. * @param degrees defines the angle value in degrees
  4647. * @returns a new Angle
  4648. */
  4649. static FromDegrees(degrees: number): Angle;
  4650. }
  4651. /**
  4652. * This represents an arc in a 2d space.
  4653. */
  4654. export class Arc2 {
  4655. /** Defines the start point of the arc */
  4656. startPoint: Vector2;
  4657. /** Defines the mid point of the arc */
  4658. midPoint: Vector2;
  4659. /** Defines the end point of the arc */
  4660. endPoint: Vector2;
  4661. /**
  4662. * Defines the center point of the arc.
  4663. */
  4664. centerPoint: Vector2;
  4665. /**
  4666. * Defines the radius of the arc.
  4667. */
  4668. radius: number;
  4669. /**
  4670. * Defines the angle of the arc (from mid point to end point).
  4671. */
  4672. angle: Angle;
  4673. /**
  4674. * Defines the start angle of the arc (from start point to middle point).
  4675. */
  4676. startAngle: Angle;
  4677. /**
  4678. * Defines the orientation of the arc (clock wise/counter clock wise).
  4679. */
  4680. orientation: Orientation;
  4681. /**
  4682. * Creates an Arc object from the three given points : start, middle and end.
  4683. * @param startPoint Defines the start point of the arc
  4684. * @param midPoint Defines the midlle point of the arc
  4685. * @param endPoint Defines the end point of the arc
  4686. */
  4687. constructor(
  4688. /** Defines the start point of the arc */
  4689. startPoint: Vector2,
  4690. /** Defines the mid point of the arc */
  4691. midPoint: Vector2,
  4692. /** Defines the end point of the arc */
  4693. endPoint: Vector2);
  4694. }
  4695. /**
  4696. * Represents a 2D path made up of multiple 2D points
  4697. */
  4698. export class Path2 {
  4699. private _points;
  4700. private _length;
  4701. /**
  4702. * If the path start and end point are the same
  4703. */
  4704. closed: boolean;
  4705. /**
  4706. * Creates a Path2 object from the starting 2D coordinates x and y.
  4707. * @param x the starting points x value
  4708. * @param y the starting points y value
  4709. */
  4710. constructor(x: number, y: number);
  4711. /**
  4712. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4713. * @param x the added points x value
  4714. * @param y the added points y value
  4715. * @returns the updated Path2.
  4716. */
  4717. addLineTo(x: number, y: number): Path2;
  4718. /**
  4719. * 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.
  4720. * @param midX middle point x value
  4721. * @param midY middle point y value
  4722. * @param endX end point x value
  4723. * @param endY end point y value
  4724. * @param numberOfSegments (default: 36)
  4725. * @returns the updated Path2.
  4726. */
  4727. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4728. /**
  4729. * Closes the Path2.
  4730. * @returns the Path2.
  4731. */
  4732. close(): Path2;
  4733. /**
  4734. * Gets the sum of the distance between each sequential point in the path
  4735. * @returns the Path2 total length (float).
  4736. */
  4737. length(): number;
  4738. /**
  4739. * Gets the points which construct the path
  4740. * @returns the Path2 internal array of points.
  4741. */
  4742. getPoints(): Vector2[];
  4743. /**
  4744. * Retreives the point at the distance aways from the starting point
  4745. * @param normalizedLengthPosition the length along the path to retreive the point from
  4746. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4747. */
  4748. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4749. /**
  4750. * Creates a new path starting from an x and y position
  4751. * @param x starting x value
  4752. * @param y starting y value
  4753. * @returns a new Path2 starting at the coordinates (x, y).
  4754. */
  4755. static StartingAt(x: number, y: number): Path2;
  4756. }
  4757. /**
  4758. * Represents a 3D path made up of multiple 3D points
  4759. */
  4760. export class Path3D {
  4761. /**
  4762. * an array of Vector3, the curve axis of the Path3D
  4763. */
  4764. path: Vector3[];
  4765. private _curve;
  4766. private _distances;
  4767. private _tangents;
  4768. private _normals;
  4769. private _binormals;
  4770. private _raw;
  4771. private _alignTangentsWithPath;
  4772. private readonly _pointAtData;
  4773. /**
  4774. * new Path3D(path, normal, raw)
  4775. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4776. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4777. * @param path an array of Vector3, the curve axis of the Path3D
  4778. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4779. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4780. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4781. */
  4782. constructor(
  4783. /**
  4784. * an array of Vector3, the curve axis of the Path3D
  4785. */
  4786. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4787. /**
  4788. * Returns the Path3D array of successive Vector3 designing its curve.
  4789. * @returns the Path3D array of successive Vector3 designing its curve.
  4790. */
  4791. getCurve(): Vector3[];
  4792. /**
  4793. * Returns the Path3D array of successive Vector3 designing its curve.
  4794. * @returns the Path3D array of successive Vector3 designing its curve.
  4795. */
  4796. getPoints(): Vector3[];
  4797. /**
  4798. * @returns the computed length (float) of the path.
  4799. */
  4800. length(): number;
  4801. /**
  4802. * Returns an array populated with tangent vectors on each Path3D curve point.
  4803. * @returns an array populated with tangent vectors on each Path3D curve point.
  4804. */
  4805. getTangents(): Vector3[];
  4806. /**
  4807. * Returns an array populated with normal vectors on each Path3D curve point.
  4808. * @returns an array populated with normal vectors on each Path3D curve point.
  4809. */
  4810. getNormals(): Vector3[];
  4811. /**
  4812. * Returns an array populated with binormal vectors on each Path3D curve point.
  4813. * @returns an array populated with binormal vectors on each Path3D curve point.
  4814. */
  4815. getBinormals(): Vector3[];
  4816. /**
  4817. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4818. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4819. */
  4820. getDistances(): number[];
  4821. /**
  4822. * Returns an interpolated point along this path
  4823. * @param position the position of the point along this path, from 0.0 to 1.0
  4824. * @returns a new Vector3 as the point
  4825. */
  4826. getPointAt(position: number): Vector3;
  4827. /**
  4828. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4829. * @param position the position of the point along this path, from 0.0 to 1.0
  4830. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4831. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4832. */
  4833. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4834. /**
  4835. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4836. * @param position the position of the point along this path, from 0.0 to 1.0
  4837. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4838. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4839. */
  4840. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4841. /**
  4842. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4843. * @param position the position of the point along this path, from 0.0 to 1.0
  4844. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4845. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4846. */
  4847. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4848. /**
  4849. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4850. * @param position the position of the point along this path, from 0.0 to 1.0
  4851. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4852. */
  4853. getDistanceAt(position: number): number;
  4854. /**
  4855. * Returns the array index of the previous point of an interpolated point along this path
  4856. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4857. * @returns the array index
  4858. */
  4859. getPreviousPointIndexAt(position: number): number;
  4860. /**
  4861. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  4862. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4863. * @returns the sub position
  4864. */
  4865. getSubPositionAt(position: number): number;
  4866. /**
  4867. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4868. * @param target the vector of which to get the closest position to
  4869. * @returns the position of the closest virtual point on this path to the target vector
  4870. */
  4871. getClosestPositionTo(target: Vector3): number;
  4872. /**
  4873. * Returns a sub path (slice) of this path
  4874. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4875. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4876. * @returns a sub path (slice) of this path
  4877. */
  4878. slice(start?: number, end?: number): Path3D;
  4879. /**
  4880. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4881. * @param path path which all values are copied into the curves points
  4882. * @param firstNormal which should be projected onto the curve
  4883. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4884. * @returns the same object updated.
  4885. */
  4886. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4887. private _compute;
  4888. private _getFirstNonNullVector;
  4889. private _getLastNonNullVector;
  4890. private _normalVector;
  4891. /**
  4892. * Updates the point at data for an interpolated point along this curve
  4893. * @param position the position of the point along this curve, from 0.0 to 1.0
  4894. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4895. * @returns the (updated) point at data
  4896. */
  4897. private _updatePointAtData;
  4898. /**
  4899. * Updates the point at data from the specified parameters
  4900. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4901. * @param point the interpolated point
  4902. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4903. */
  4904. private _setPointAtData;
  4905. /**
  4906. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4907. */
  4908. private _updateInterpolationMatrix;
  4909. }
  4910. /**
  4911. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4912. * A Curve3 is designed from a series of successive Vector3.
  4913. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4914. */
  4915. export class Curve3 {
  4916. private _points;
  4917. private _length;
  4918. /**
  4919. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4920. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4921. * @param v1 (Vector3) the control point
  4922. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4923. * @param nbPoints (integer) the wanted number of points in the curve
  4924. * @returns the created Curve3
  4925. */
  4926. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4927. /**
  4928. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4929. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4930. * @param v1 (Vector3) the first control point
  4931. * @param v2 (Vector3) the second control point
  4932. * @param v3 (Vector3) the end point of the Cubic Bezier
  4933. * @param nbPoints (integer) the wanted number of points in the curve
  4934. * @returns the created Curve3
  4935. */
  4936. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4937. /**
  4938. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4939. * @param p1 (Vector3) the origin point of the Hermite Spline
  4940. * @param t1 (Vector3) the tangent vector at the origin point
  4941. * @param p2 (Vector3) the end point of the Hermite Spline
  4942. * @param t2 (Vector3) the tangent vector at the end point
  4943. * @param nbPoints (integer) the wanted number of points in the curve
  4944. * @returns the created Curve3
  4945. */
  4946. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4947. /**
  4948. * Returns a Curve3 object along a CatmullRom Spline curve :
  4949. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4950. * @param nbPoints (integer) the wanted number of points between each curve control points
  4951. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4952. * @returns the created Curve3
  4953. */
  4954. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4955. /**
  4956. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4957. * A Curve3 is designed from a series of successive Vector3.
  4958. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4959. * @param points points which make up the curve
  4960. */
  4961. constructor(points: Vector3[]);
  4962. /**
  4963. * @returns the Curve3 stored array of successive Vector3
  4964. */
  4965. getPoints(): Vector3[];
  4966. /**
  4967. * @returns the computed length (float) of the curve.
  4968. */
  4969. length(): number;
  4970. /**
  4971. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4972. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4973. * curveA and curveB keep unchanged.
  4974. * @param curve the curve to continue from this curve
  4975. * @returns the newly constructed curve
  4976. */
  4977. continue(curve: DeepImmutable<Curve3>): Curve3;
  4978. private _computeLength;
  4979. }
  4980. }
  4981. declare module BABYLON {
  4982. /**
  4983. * This represents the main contract an easing function should follow.
  4984. * Easing functions are used throughout the animation system.
  4985. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4986. */
  4987. export interface IEasingFunction {
  4988. /**
  4989. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4990. * of the easing function.
  4991. * The link below provides some of the most common examples of easing functions.
  4992. * @see https://easings.net/
  4993. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4994. * @returns the corresponding value on the curve defined by the easing function
  4995. */
  4996. ease(gradient: number): number;
  4997. }
  4998. /**
  4999. * Base class used for every default easing function.
  5000. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5001. */
  5002. export class EasingFunction implements IEasingFunction {
  5003. /**
  5004. * Interpolation follows the mathematical formula associated with the easing function.
  5005. */
  5006. static readonly EASINGMODE_EASEIN: number;
  5007. /**
  5008. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5009. */
  5010. static readonly EASINGMODE_EASEOUT: number;
  5011. /**
  5012. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5013. */
  5014. static readonly EASINGMODE_EASEINOUT: number;
  5015. private _easingMode;
  5016. /**
  5017. * Sets the easing mode of the current function.
  5018. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5019. */
  5020. setEasingMode(easingMode: number): void;
  5021. /**
  5022. * Gets the current easing mode.
  5023. * @returns the easing mode
  5024. */
  5025. getEasingMode(): number;
  5026. /**
  5027. * @hidden
  5028. */
  5029. easeInCore(gradient: number): number;
  5030. /**
  5031. * Given an input gradient between 0 and 1, this returns the corresponding value
  5032. * of the easing function.
  5033. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5034. * @returns the corresponding value on the curve defined by the easing function
  5035. */
  5036. ease(gradient: number): number;
  5037. }
  5038. /**
  5039. * Easing function with a circle shape (see link below).
  5040. * @see https://easings.net/#easeInCirc
  5041. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5042. */
  5043. export class CircleEase extends EasingFunction implements IEasingFunction {
  5044. /** @hidden */
  5045. easeInCore(gradient: number): number;
  5046. }
  5047. /**
  5048. * Easing function with a ease back shape (see link below).
  5049. * @see https://easings.net/#easeInBack
  5050. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5051. */
  5052. export class BackEase extends EasingFunction implements IEasingFunction {
  5053. /** Defines the amplitude of the function */
  5054. amplitude: number;
  5055. /**
  5056. * Instantiates a back ease easing
  5057. * @see https://easings.net/#easeInBack
  5058. * @param amplitude Defines the amplitude of the function
  5059. */
  5060. constructor(
  5061. /** Defines the amplitude of the function */
  5062. amplitude?: number);
  5063. /** @hidden */
  5064. easeInCore(gradient: number): number;
  5065. }
  5066. /**
  5067. * Easing function with a bouncing shape (see link below).
  5068. * @see https://easings.net/#easeInBounce
  5069. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5070. */
  5071. export class BounceEase extends EasingFunction implements IEasingFunction {
  5072. /** Defines the number of bounces */
  5073. bounces: number;
  5074. /** Defines the amplitude of the bounce */
  5075. bounciness: number;
  5076. /**
  5077. * Instantiates a bounce easing
  5078. * @see https://easings.net/#easeInBounce
  5079. * @param bounces Defines the number of bounces
  5080. * @param bounciness Defines the amplitude of the bounce
  5081. */
  5082. constructor(
  5083. /** Defines the number of bounces */
  5084. bounces?: number,
  5085. /** Defines the amplitude of the bounce */
  5086. bounciness?: number);
  5087. /** @hidden */
  5088. easeInCore(gradient: number): number;
  5089. }
  5090. /**
  5091. * Easing function with a power of 3 shape (see link below).
  5092. * @see https://easings.net/#easeInCubic
  5093. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5094. */
  5095. export class CubicEase extends EasingFunction implements IEasingFunction {
  5096. /** @hidden */
  5097. easeInCore(gradient: number): number;
  5098. }
  5099. /**
  5100. * Easing function with an elastic shape (see link below).
  5101. * @see https://easings.net/#easeInElastic
  5102. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5103. */
  5104. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5105. /** Defines the number of oscillations*/
  5106. oscillations: number;
  5107. /** Defines the amplitude of the oscillations*/
  5108. springiness: number;
  5109. /**
  5110. * Instantiates an elastic easing function
  5111. * @see https://easings.net/#easeInElastic
  5112. * @param oscillations Defines the number of oscillations
  5113. * @param springiness Defines the amplitude of the oscillations
  5114. */
  5115. constructor(
  5116. /** Defines the number of oscillations*/
  5117. oscillations?: number,
  5118. /** Defines the amplitude of the oscillations*/
  5119. springiness?: number);
  5120. /** @hidden */
  5121. easeInCore(gradient: number): number;
  5122. }
  5123. /**
  5124. * Easing function with an exponential shape (see link below).
  5125. * @see https://easings.net/#easeInExpo
  5126. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5127. */
  5128. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5129. /** Defines the exponent of the function */
  5130. exponent: number;
  5131. /**
  5132. * Instantiates an exponential easing function
  5133. * @see https://easings.net/#easeInExpo
  5134. * @param exponent Defines the exponent of the function
  5135. */
  5136. constructor(
  5137. /** Defines the exponent of the function */
  5138. exponent?: number);
  5139. /** @hidden */
  5140. easeInCore(gradient: number): number;
  5141. }
  5142. /**
  5143. * Easing function with a power shape (see link below).
  5144. * @see https://easings.net/#easeInQuad
  5145. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5146. */
  5147. export class PowerEase extends EasingFunction implements IEasingFunction {
  5148. /** Defines the power of the function */
  5149. power: number;
  5150. /**
  5151. * Instantiates an power base easing function
  5152. * @see https://easings.net/#easeInQuad
  5153. * @param power Defines the power of the function
  5154. */
  5155. constructor(
  5156. /** Defines the power of the function */
  5157. power?: number);
  5158. /** @hidden */
  5159. easeInCore(gradient: number): number;
  5160. }
  5161. /**
  5162. * Easing function with a power of 2 shape (see link below).
  5163. * @see https://easings.net/#easeInQuad
  5164. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5165. */
  5166. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5167. /** @hidden */
  5168. easeInCore(gradient: number): number;
  5169. }
  5170. /**
  5171. * Easing function with a power of 4 shape (see link below).
  5172. * @see https://easings.net/#easeInQuart
  5173. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5174. */
  5175. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5176. /** @hidden */
  5177. easeInCore(gradient: number): number;
  5178. }
  5179. /**
  5180. * Easing function with a power of 5 shape (see link below).
  5181. * @see https://easings.net/#easeInQuint
  5182. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5183. */
  5184. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5185. /** @hidden */
  5186. easeInCore(gradient: number): number;
  5187. }
  5188. /**
  5189. * Easing function with a sin shape (see link below).
  5190. * @see https://easings.net/#easeInSine
  5191. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5192. */
  5193. export class SineEase extends EasingFunction implements IEasingFunction {
  5194. /** @hidden */
  5195. easeInCore(gradient: number): number;
  5196. }
  5197. /**
  5198. * Easing function with a bezier shape (see link below).
  5199. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5200. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5201. */
  5202. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5203. /** Defines the x component of the start tangent in the bezier curve */
  5204. x1: number;
  5205. /** Defines the y component of the start tangent in the bezier curve */
  5206. y1: number;
  5207. /** Defines the x component of the end tangent in the bezier curve */
  5208. x2: number;
  5209. /** Defines the y component of the end tangent in the bezier curve */
  5210. y2: number;
  5211. /**
  5212. * Instantiates a bezier function
  5213. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5214. * @param x1 Defines the x component of the start tangent in the bezier curve
  5215. * @param y1 Defines the y component of the start tangent in the bezier curve
  5216. * @param x2 Defines the x component of the end tangent in the bezier curve
  5217. * @param y2 Defines the y component of the end tangent in the bezier curve
  5218. */
  5219. constructor(
  5220. /** Defines the x component of the start tangent in the bezier curve */
  5221. x1?: number,
  5222. /** Defines the y component of the start tangent in the bezier curve */
  5223. y1?: number,
  5224. /** Defines the x component of the end tangent in the bezier curve */
  5225. x2?: number,
  5226. /** Defines the y component of the end tangent in the bezier curve */
  5227. y2?: number);
  5228. /** @hidden */
  5229. easeInCore(gradient: number): number;
  5230. }
  5231. }
  5232. declare module BABYLON {
  5233. /**
  5234. * Class used to hold a RBG color
  5235. */
  5236. export class Color3 {
  5237. /**
  5238. * Defines the red component (between 0 and 1, default is 0)
  5239. */
  5240. r: number;
  5241. /**
  5242. * Defines the green component (between 0 and 1, default is 0)
  5243. */
  5244. g: number;
  5245. /**
  5246. * Defines the blue component (between 0 and 1, default is 0)
  5247. */
  5248. b: number;
  5249. /**
  5250. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5251. * @param r defines the red component (between 0 and 1, default is 0)
  5252. * @param g defines the green component (between 0 and 1, default is 0)
  5253. * @param b defines the blue component (between 0 and 1, default is 0)
  5254. */
  5255. constructor(
  5256. /**
  5257. * Defines the red component (between 0 and 1, default is 0)
  5258. */
  5259. r?: number,
  5260. /**
  5261. * Defines the green component (between 0 and 1, default is 0)
  5262. */
  5263. g?: number,
  5264. /**
  5265. * Defines the blue component (between 0 and 1, default is 0)
  5266. */
  5267. b?: number);
  5268. /**
  5269. * Creates a string with the Color3 current values
  5270. * @returns the string representation of the Color3 object
  5271. */
  5272. toString(): string;
  5273. /**
  5274. * Returns the string "Color3"
  5275. * @returns "Color3"
  5276. */
  5277. getClassName(): string;
  5278. /**
  5279. * Compute the Color3 hash code
  5280. * @returns an unique number that can be used to hash Color3 objects
  5281. */
  5282. getHashCode(): number;
  5283. /**
  5284. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5285. * @param array defines the array where to store the r,g,b components
  5286. * @param index defines an optional index in the target array to define where to start storing values
  5287. * @returns the current Color3 object
  5288. */
  5289. toArray(array: FloatArray, index?: number): Color3;
  5290. /**
  5291. * Returns a new Color4 object from the current Color3 and the given alpha
  5292. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5293. * @returns a new Color4 object
  5294. */
  5295. toColor4(alpha?: number): Color4;
  5296. /**
  5297. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5298. * @returns the new array
  5299. */
  5300. asArray(): number[];
  5301. /**
  5302. * Returns the luminance value
  5303. * @returns a float value
  5304. */
  5305. toLuminance(): number;
  5306. /**
  5307. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5308. * @param otherColor defines the second operand
  5309. * @returns the new Color3 object
  5310. */
  5311. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5312. /**
  5313. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5314. * @param otherColor defines the second operand
  5315. * @param result defines the Color3 object where to store the result
  5316. * @returns the current Color3
  5317. */
  5318. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5319. /**
  5320. * Determines equality between Color3 objects
  5321. * @param otherColor defines the second operand
  5322. * @returns true if the rgb values are equal to the given ones
  5323. */
  5324. equals(otherColor: DeepImmutable<Color3>): boolean;
  5325. /**
  5326. * Determines equality between the current Color3 object and a set of r,b,g values
  5327. * @param r defines the red component to check
  5328. * @param g defines the green component to check
  5329. * @param b defines the blue component to check
  5330. * @returns true if the rgb values are equal to the given ones
  5331. */
  5332. equalsFloats(r: number, g: number, b: number): boolean;
  5333. /**
  5334. * Multiplies in place each rgb value by scale
  5335. * @param scale defines the scaling factor
  5336. * @returns the updated Color3
  5337. */
  5338. scale(scale: number): Color3;
  5339. /**
  5340. * Multiplies the rgb values by scale and stores the result into "result"
  5341. * @param scale defines the scaling factor
  5342. * @param result defines the Color3 object where to store the result
  5343. * @returns the unmodified current Color3
  5344. */
  5345. scaleToRef(scale: number, result: Color3): Color3;
  5346. /**
  5347. * Scale the current Color3 values by a factor and add the result to a given Color3
  5348. * @param scale defines the scale factor
  5349. * @param result defines color to store the result into
  5350. * @returns the unmodified current Color3
  5351. */
  5352. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5353. /**
  5354. * Clamps the rgb values by the min and max values and stores the result into "result"
  5355. * @param min defines minimum clamping value (default is 0)
  5356. * @param max defines maximum clamping value (default is 1)
  5357. * @param result defines color to store the result into
  5358. * @returns the original Color3
  5359. */
  5360. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5361. /**
  5362. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5363. * @param otherColor defines the second operand
  5364. * @returns the new Color3
  5365. */
  5366. add(otherColor: DeepImmutable<Color3>): Color3;
  5367. /**
  5368. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5369. * @param otherColor defines the second operand
  5370. * @param result defines Color3 object to store the result into
  5371. * @returns the unmodified current Color3
  5372. */
  5373. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5374. /**
  5375. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5376. * @param otherColor defines the second operand
  5377. * @returns the new Color3
  5378. */
  5379. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5380. /**
  5381. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5382. * @param otherColor defines the second operand
  5383. * @param result defines Color3 object to store the result into
  5384. * @returns the unmodified current Color3
  5385. */
  5386. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5387. /**
  5388. * Copy the current object
  5389. * @returns a new Color3 copied the current one
  5390. */
  5391. clone(): Color3;
  5392. /**
  5393. * Copies the rgb values from the source in the current Color3
  5394. * @param source defines the source Color3 object
  5395. * @returns the updated Color3 object
  5396. */
  5397. copyFrom(source: DeepImmutable<Color3>): Color3;
  5398. /**
  5399. * Updates the Color3 rgb values from the given floats
  5400. * @param r defines the red component to read from
  5401. * @param g defines the green component to read from
  5402. * @param b defines the blue component to read from
  5403. * @returns the current Color3 object
  5404. */
  5405. copyFromFloats(r: number, g: number, b: number): Color3;
  5406. /**
  5407. * Updates the Color3 rgb values from the given floats
  5408. * @param r defines the red component to read from
  5409. * @param g defines the green component to read from
  5410. * @param b defines the blue component to read from
  5411. * @returns the current Color3 object
  5412. */
  5413. set(r: number, g: number, b: number): Color3;
  5414. /**
  5415. * Compute the Color3 hexadecimal code as a string
  5416. * @returns a string containing the hexadecimal representation of the Color3 object
  5417. */
  5418. toHexString(): string;
  5419. /**
  5420. * Computes a new Color3 converted from the current one to linear space
  5421. * @returns a new Color3 object
  5422. */
  5423. toLinearSpace(): Color3;
  5424. /**
  5425. * Converts current color in rgb space to HSV values
  5426. * @returns a new color3 representing the HSV values
  5427. */
  5428. toHSV(): Color3;
  5429. /**
  5430. * Converts current color in rgb space to HSV values
  5431. * @param result defines the Color3 where to store the HSV values
  5432. */
  5433. toHSVToRef(result: Color3): void;
  5434. /**
  5435. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5436. * @param convertedColor defines the Color3 object where to store the linear space version
  5437. * @returns the unmodified Color3
  5438. */
  5439. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5440. /**
  5441. * Computes a new Color3 converted from the current one to gamma space
  5442. * @returns a new Color3 object
  5443. */
  5444. toGammaSpace(): Color3;
  5445. /**
  5446. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5447. * @param convertedColor defines the Color3 object where to store the gamma space version
  5448. * @returns the unmodified Color3
  5449. */
  5450. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5451. private static _BlackReadOnly;
  5452. /**
  5453. * Convert Hue, saturation and value to a Color3 (RGB)
  5454. * @param hue defines the hue
  5455. * @param saturation defines the saturation
  5456. * @param value defines the value
  5457. * @param result defines the Color3 where to store the RGB values
  5458. */
  5459. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5460. /**
  5461. * Creates a new Color3 from the string containing valid hexadecimal values
  5462. * @param hex defines a string containing valid hexadecimal values
  5463. * @returns a new Color3 object
  5464. */
  5465. static FromHexString(hex: string): Color3;
  5466. /**
  5467. * Creates a new Color3 from the starting index of the given array
  5468. * @param array defines the source array
  5469. * @param offset defines an offset in the source array
  5470. * @returns a new Color3 object
  5471. */
  5472. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5473. /**
  5474. * Creates a new Color3 from integer values (< 256)
  5475. * @param r defines the red component to read from (value between 0 and 255)
  5476. * @param g defines the green component to read from (value between 0 and 255)
  5477. * @param b defines the blue component to read from (value between 0 and 255)
  5478. * @returns a new Color3 object
  5479. */
  5480. static FromInts(r: number, g: number, b: number): Color3;
  5481. /**
  5482. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5483. * @param start defines the start Color3 value
  5484. * @param end defines the end Color3 value
  5485. * @param amount defines the gradient value between start and end
  5486. * @returns a new Color3 object
  5487. */
  5488. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5489. /**
  5490. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5491. * @param left defines the start value
  5492. * @param right defines the end value
  5493. * @param amount defines the gradient factor
  5494. * @param result defines the Color3 object where to store the result
  5495. */
  5496. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5497. /**
  5498. * Returns a Color3 value containing a red color
  5499. * @returns a new Color3 object
  5500. */
  5501. static Red(): Color3;
  5502. /**
  5503. * Returns a Color3 value containing a green color
  5504. * @returns a new Color3 object
  5505. */
  5506. static Green(): Color3;
  5507. /**
  5508. * Returns a Color3 value containing a blue color
  5509. * @returns a new Color3 object
  5510. */
  5511. static Blue(): Color3;
  5512. /**
  5513. * Returns a Color3 value containing a black color
  5514. * @returns a new Color3 object
  5515. */
  5516. static Black(): Color3;
  5517. /**
  5518. * Gets a Color3 value containing a black color that must not be updated
  5519. */
  5520. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5521. /**
  5522. * Returns a Color3 value containing a white color
  5523. * @returns a new Color3 object
  5524. */
  5525. static White(): Color3;
  5526. /**
  5527. * Returns a Color3 value containing a purple color
  5528. * @returns a new Color3 object
  5529. */
  5530. static Purple(): Color3;
  5531. /**
  5532. * Returns a Color3 value containing a magenta color
  5533. * @returns a new Color3 object
  5534. */
  5535. static Magenta(): Color3;
  5536. /**
  5537. * Returns a Color3 value containing a yellow color
  5538. * @returns a new Color3 object
  5539. */
  5540. static Yellow(): Color3;
  5541. /**
  5542. * Returns a Color3 value containing a gray color
  5543. * @returns a new Color3 object
  5544. */
  5545. static Gray(): Color3;
  5546. /**
  5547. * Returns a Color3 value containing a teal color
  5548. * @returns a new Color3 object
  5549. */
  5550. static Teal(): Color3;
  5551. /**
  5552. * Returns a Color3 value containing a random color
  5553. * @returns a new Color3 object
  5554. */
  5555. static Random(): Color3;
  5556. }
  5557. /**
  5558. * Class used to hold a RBGA color
  5559. */
  5560. export class Color4 {
  5561. /**
  5562. * Defines the red component (between 0 and 1, default is 0)
  5563. */
  5564. r: number;
  5565. /**
  5566. * Defines the green component (between 0 and 1, default is 0)
  5567. */
  5568. g: number;
  5569. /**
  5570. * Defines the blue component (between 0 and 1, default is 0)
  5571. */
  5572. b: number;
  5573. /**
  5574. * Defines the alpha component (between 0 and 1, default is 1)
  5575. */
  5576. a: number;
  5577. /**
  5578. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5579. * @param r defines the red component (between 0 and 1, default is 0)
  5580. * @param g defines the green component (between 0 and 1, default is 0)
  5581. * @param b defines the blue component (between 0 and 1, default is 0)
  5582. * @param a defines the alpha component (between 0 and 1, default is 1)
  5583. */
  5584. constructor(
  5585. /**
  5586. * Defines the red component (between 0 and 1, default is 0)
  5587. */
  5588. r?: number,
  5589. /**
  5590. * Defines the green component (between 0 and 1, default is 0)
  5591. */
  5592. g?: number,
  5593. /**
  5594. * Defines the blue component (between 0 and 1, default is 0)
  5595. */
  5596. b?: number,
  5597. /**
  5598. * Defines the alpha component (between 0 and 1, default is 1)
  5599. */
  5600. a?: number);
  5601. /**
  5602. * Adds in place the given Color4 values to the current Color4 object
  5603. * @param right defines the second operand
  5604. * @returns the current updated Color4 object
  5605. */
  5606. addInPlace(right: DeepImmutable<Color4>): Color4;
  5607. /**
  5608. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5609. * @returns the new array
  5610. */
  5611. asArray(): number[];
  5612. /**
  5613. * Stores from the starting index in the given array the Color4 successive values
  5614. * @param array defines the array where to store the r,g,b components
  5615. * @param index defines an optional index in the target array to define where to start storing values
  5616. * @returns the current Color4 object
  5617. */
  5618. toArray(array: number[], index?: number): Color4;
  5619. /**
  5620. * Determines equality between Color4 objects
  5621. * @param otherColor defines the second operand
  5622. * @returns true if the rgba values are equal to the given ones
  5623. */
  5624. equals(otherColor: DeepImmutable<Color4>): boolean;
  5625. /**
  5626. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5627. * @param right defines the second operand
  5628. * @returns a new Color4 object
  5629. */
  5630. add(right: DeepImmutable<Color4>): Color4;
  5631. /**
  5632. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5633. * @param right defines the second operand
  5634. * @returns a new Color4 object
  5635. */
  5636. subtract(right: DeepImmutable<Color4>): Color4;
  5637. /**
  5638. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5639. * @param right defines the second operand
  5640. * @param result defines the Color4 object where to store the result
  5641. * @returns the current Color4 object
  5642. */
  5643. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5644. /**
  5645. * Creates a new Color4 with the current Color4 values multiplied by scale
  5646. * @param scale defines the scaling factor to apply
  5647. * @returns a new Color4 object
  5648. */
  5649. scale(scale: number): Color4;
  5650. /**
  5651. * Multiplies the current Color4 values by scale and stores the result in "result"
  5652. * @param scale defines the scaling factor to apply
  5653. * @param result defines the Color4 object where to store the result
  5654. * @returns the current unmodified Color4
  5655. */
  5656. scaleToRef(scale: number, result: Color4): Color4;
  5657. /**
  5658. * Scale the current Color4 values by a factor and add the result to a given Color4
  5659. * @param scale defines the scale factor
  5660. * @param result defines the Color4 object where to store the result
  5661. * @returns the unmodified current Color4
  5662. */
  5663. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5664. /**
  5665. * Clamps the rgb values by the min and max values and stores the result into "result"
  5666. * @param min defines minimum clamping value (default is 0)
  5667. * @param max defines maximum clamping value (default is 1)
  5668. * @param result defines color to store the result into.
  5669. * @returns the cuurent Color4
  5670. */
  5671. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5672. /**
  5673. * Multipy an Color4 value by another and return a new Color4 object
  5674. * @param color defines the Color4 value to multiply by
  5675. * @returns a new Color4 object
  5676. */
  5677. multiply(color: Color4): Color4;
  5678. /**
  5679. * Multipy a Color4 value by another and push the result in a reference value
  5680. * @param color defines the Color4 value to multiply by
  5681. * @param result defines the Color4 to fill the result in
  5682. * @returns the result Color4
  5683. */
  5684. multiplyToRef(color: Color4, result: Color4): Color4;
  5685. /**
  5686. * Creates a string with the Color4 current values
  5687. * @returns the string representation of the Color4 object
  5688. */
  5689. toString(): string;
  5690. /**
  5691. * Returns the string "Color4"
  5692. * @returns "Color4"
  5693. */
  5694. getClassName(): string;
  5695. /**
  5696. * Compute the Color4 hash code
  5697. * @returns an unique number that can be used to hash Color4 objects
  5698. */
  5699. getHashCode(): number;
  5700. /**
  5701. * Creates a new Color4 copied from the current one
  5702. * @returns a new Color4 object
  5703. */
  5704. clone(): Color4;
  5705. /**
  5706. * Copies the given Color4 values into the current one
  5707. * @param source defines the source Color4 object
  5708. * @returns the current updated Color4 object
  5709. */
  5710. copyFrom(source: Color4): Color4;
  5711. /**
  5712. * Copies the given float values into the current one
  5713. * @param r defines the red component to read from
  5714. * @param g defines the green component to read from
  5715. * @param b defines the blue component to read from
  5716. * @param a defines the alpha component to read from
  5717. * @returns the current updated Color4 object
  5718. */
  5719. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5720. /**
  5721. * Copies the given float values into the current one
  5722. * @param r defines the red component to read from
  5723. * @param g defines the green component to read from
  5724. * @param b defines the blue component to read from
  5725. * @param a defines the alpha component to read from
  5726. * @returns the current updated Color4 object
  5727. */
  5728. set(r: number, g: number, b: number, a: number): Color4;
  5729. /**
  5730. * Compute the Color4 hexadecimal code as a string
  5731. * @returns a string containing the hexadecimal representation of the Color4 object
  5732. */
  5733. toHexString(): string;
  5734. /**
  5735. * Computes a new Color4 converted from the current one to linear space
  5736. * @returns a new Color4 object
  5737. */
  5738. toLinearSpace(): Color4;
  5739. /**
  5740. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5741. * @param convertedColor defines the Color4 object where to store the linear space version
  5742. * @returns the unmodified Color4
  5743. */
  5744. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5745. /**
  5746. * Computes a new Color4 converted from the current one to gamma space
  5747. * @returns a new Color4 object
  5748. */
  5749. toGammaSpace(): Color4;
  5750. /**
  5751. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5752. * @param convertedColor defines the Color4 object where to store the gamma space version
  5753. * @returns the unmodified Color4
  5754. */
  5755. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5756. /**
  5757. * Creates a new Color4 from the string containing valid hexadecimal values
  5758. * @param hex defines a string containing valid hexadecimal values
  5759. * @returns a new Color4 object
  5760. */
  5761. static FromHexString(hex: string): Color4;
  5762. /**
  5763. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5764. * @param left defines the start value
  5765. * @param right defines the end value
  5766. * @param amount defines the gradient factor
  5767. * @returns a new Color4 object
  5768. */
  5769. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5770. /**
  5771. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5772. * @param left defines the start value
  5773. * @param right defines the end value
  5774. * @param amount defines the gradient factor
  5775. * @param result defines the Color4 object where to store data
  5776. */
  5777. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5778. /**
  5779. * Creates a new Color4 from a Color3 and an alpha value
  5780. * @param color3 defines the source Color3 to read from
  5781. * @param alpha defines the alpha component (1.0 by default)
  5782. * @returns a new Color4 object
  5783. */
  5784. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5785. /**
  5786. * Creates a new Color4 from the starting index element of the given array
  5787. * @param array defines the source array to read from
  5788. * @param offset defines the offset in the source array
  5789. * @returns a new Color4 object
  5790. */
  5791. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5792. /**
  5793. * Creates a new Color3 from integer values (< 256)
  5794. * @param r defines the red component to read from (value between 0 and 255)
  5795. * @param g defines the green component to read from (value between 0 and 255)
  5796. * @param b defines the blue component to read from (value between 0 and 255)
  5797. * @param a defines the alpha component to read from (value between 0 and 255)
  5798. * @returns a new Color3 object
  5799. */
  5800. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5801. /**
  5802. * Check the content of a given array and convert it to an array containing RGBA data
  5803. * If the original array was already containing count * 4 values then it is returned directly
  5804. * @param colors defines the array to check
  5805. * @param count defines the number of RGBA data to expect
  5806. * @returns an array containing count * 4 values (RGBA)
  5807. */
  5808. static CheckColors4(colors: number[], count: number): number[];
  5809. }
  5810. /**
  5811. * @hidden
  5812. */
  5813. export class TmpColors {
  5814. static Color3: Color3[];
  5815. static Color4: Color4[];
  5816. }
  5817. }
  5818. declare module BABYLON {
  5819. /**
  5820. * Defines an interface which represents an animation key frame
  5821. */
  5822. export interface IAnimationKey {
  5823. /**
  5824. * Frame of the key frame
  5825. */
  5826. frame: number;
  5827. /**
  5828. * Value at the specifies key frame
  5829. */
  5830. value: any;
  5831. /**
  5832. * The input tangent for the cubic hermite spline
  5833. */
  5834. inTangent?: any;
  5835. /**
  5836. * The output tangent for the cubic hermite spline
  5837. */
  5838. outTangent?: any;
  5839. /**
  5840. * The animation interpolation type
  5841. */
  5842. interpolation?: AnimationKeyInterpolation;
  5843. }
  5844. /**
  5845. * Enum for the animation key frame interpolation type
  5846. */
  5847. export enum AnimationKeyInterpolation {
  5848. /**
  5849. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5850. */
  5851. STEP = 1
  5852. }
  5853. }
  5854. declare module BABYLON {
  5855. /**
  5856. * Represents the range of an animation
  5857. */
  5858. export class AnimationRange {
  5859. /**The name of the animation range**/
  5860. name: string;
  5861. /**The starting frame of the animation */
  5862. from: number;
  5863. /**The ending frame of the animation*/
  5864. to: number;
  5865. /**
  5866. * Initializes the range of an animation
  5867. * @param name The name of the animation range
  5868. * @param from The starting frame of the animation
  5869. * @param to The ending frame of the animation
  5870. */
  5871. constructor(
  5872. /**The name of the animation range**/
  5873. name: string,
  5874. /**The starting frame of the animation */
  5875. from: number,
  5876. /**The ending frame of the animation*/
  5877. to: number);
  5878. /**
  5879. * Makes a copy of the animation range
  5880. * @returns A copy of the animation range
  5881. */
  5882. clone(): AnimationRange;
  5883. }
  5884. }
  5885. declare module BABYLON {
  5886. /**
  5887. * Composed of a frame, and an action function
  5888. */
  5889. export class AnimationEvent {
  5890. /** The frame for which the event is triggered **/
  5891. frame: number;
  5892. /** The event to perform when triggered **/
  5893. action: (currentFrame: number) => void;
  5894. /** Specifies if the event should be triggered only once**/
  5895. onlyOnce?: boolean | undefined;
  5896. /**
  5897. * Specifies if the animation event is done
  5898. */
  5899. isDone: boolean;
  5900. /**
  5901. * Initializes the animation event
  5902. * @param frame The frame for which the event is triggered
  5903. * @param action The event to perform when triggered
  5904. * @param onlyOnce Specifies if the event should be triggered only once
  5905. */
  5906. constructor(
  5907. /** The frame for which the event is triggered **/
  5908. frame: number,
  5909. /** The event to perform when triggered **/
  5910. action: (currentFrame: number) => void,
  5911. /** Specifies if the event should be triggered only once**/
  5912. onlyOnce?: boolean | undefined);
  5913. /** @hidden */
  5914. _clone(): AnimationEvent;
  5915. }
  5916. }
  5917. declare module BABYLON {
  5918. /**
  5919. * Interface used to define a behavior
  5920. */
  5921. export interface Behavior<T> {
  5922. /** gets or sets behavior's name */
  5923. name: string;
  5924. /**
  5925. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5926. */
  5927. init(): void;
  5928. /**
  5929. * Called when the behavior is attached to a target
  5930. * @param target defines the target where the behavior is attached to
  5931. */
  5932. attach(target: T): void;
  5933. /**
  5934. * Called when the behavior is detached from its target
  5935. */
  5936. detach(): void;
  5937. }
  5938. /**
  5939. * Interface implemented by classes supporting behaviors
  5940. */
  5941. export interface IBehaviorAware<T> {
  5942. /**
  5943. * Attach a behavior
  5944. * @param behavior defines the behavior to attach
  5945. * @returns the current host
  5946. */
  5947. addBehavior(behavior: Behavior<T>): T;
  5948. /**
  5949. * Remove a behavior from the current object
  5950. * @param behavior defines the behavior to detach
  5951. * @returns the current host
  5952. */
  5953. removeBehavior(behavior: Behavior<T>): T;
  5954. /**
  5955. * Gets a behavior using its name to search
  5956. * @param name defines the name to search
  5957. * @returns the behavior or null if not found
  5958. */
  5959. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5960. }
  5961. }
  5962. declare module BABYLON {
  5963. /**
  5964. * Defines an array and its length.
  5965. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  5966. */
  5967. export interface ISmartArrayLike<T> {
  5968. /**
  5969. * The data of the array.
  5970. */
  5971. data: Array<T>;
  5972. /**
  5973. * The active length of the array.
  5974. */
  5975. length: number;
  5976. }
  5977. /**
  5978. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  5979. */
  5980. export class SmartArray<T> implements ISmartArrayLike<T> {
  5981. /**
  5982. * The full set of data from the array.
  5983. */
  5984. data: Array<T>;
  5985. /**
  5986. * The active length of the array.
  5987. */
  5988. length: number;
  5989. protected _id: number;
  5990. /**
  5991. * Instantiates a Smart Array.
  5992. * @param capacity defines the default capacity of the array.
  5993. */
  5994. constructor(capacity: number);
  5995. /**
  5996. * Pushes a value at the end of the active data.
  5997. * @param value defines the object to push in the array.
  5998. */
  5999. push(value: T): void;
  6000. /**
  6001. * Iterates over the active data and apply the lambda to them.
  6002. * @param func defines the action to apply on each value.
  6003. */
  6004. forEach(func: (content: T) => void): void;
  6005. /**
  6006. * Sorts the full sets of data.
  6007. * @param compareFn defines the comparison function to apply.
  6008. */
  6009. sort(compareFn: (a: T, b: T) => number): void;
  6010. /**
  6011. * Resets the active data to an empty array.
  6012. */
  6013. reset(): void;
  6014. /**
  6015. * Releases all the data from the array as well as the array.
  6016. */
  6017. dispose(): void;
  6018. /**
  6019. * Concats the active data with a given array.
  6020. * @param array defines the data to concatenate with.
  6021. */
  6022. concat(array: any): void;
  6023. /**
  6024. * Returns the position of a value in the active data.
  6025. * @param value defines the value to find the index for
  6026. * @returns the index if found in the active data otherwise -1
  6027. */
  6028. indexOf(value: T): number;
  6029. /**
  6030. * Returns whether an element is part of the active data.
  6031. * @param value defines the value to look for
  6032. * @returns true if found in the active data otherwise false
  6033. */
  6034. contains(value: T): boolean;
  6035. private static _GlobalId;
  6036. }
  6037. /**
  6038. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6039. * The data in this array can only be present once
  6040. */
  6041. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6042. private _duplicateId;
  6043. /**
  6044. * Pushes a value at the end of the active data.
  6045. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6046. * @param value defines the object to push in the array.
  6047. */
  6048. push(value: T): void;
  6049. /**
  6050. * Pushes a value at the end of the active data.
  6051. * If the data is already present, it won t be added again
  6052. * @param value defines the object to push in the array.
  6053. * @returns true if added false if it was already present
  6054. */
  6055. pushNoDuplicate(value: T): boolean;
  6056. /**
  6057. * Resets the active data to an empty array.
  6058. */
  6059. reset(): void;
  6060. /**
  6061. * Concats the active data with a given array.
  6062. * This ensures no dupplicate will be present in the result.
  6063. * @param array defines the data to concatenate with.
  6064. */
  6065. concatWithNoDuplicate(array: any): void;
  6066. }
  6067. }
  6068. declare module BABYLON {
  6069. /**
  6070. * @ignore
  6071. * This is a list of all the different input types that are available in the application.
  6072. * Fo instance: ArcRotateCameraGamepadInput...
  6073. */
  6074. export var CameraInputTypes: {};
  6075. /**
  6076. * This is the contract to implement in order to create a new input class.
  6077. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6078. */
  6079. export interface ICameraInput<TCamera extends Camera> {
  6080. /**
  6081. * Defines the camera the input is attached to.
  6082. */
  6083. camera: Nullable<TCamera>;
  6084. /**
  6085. * Gets the class name of the current intput.
  6086. * @returns the class name
  6087. */
  6088. getClassName(): string;
  6089. /**
  6090. * Get the friendly name associated with the input class.
  6091. * @returns the input friendly name
  6092. */
  6093. getSimpleName(): string;
  6094. /**
  6095. * Attach the input controls to a specific dom element to get the input from.
  6096. * @param element Defines the element the controls should be listened from
  6097. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6098. */
  6099. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6100. /**
  6101. * Detach the current controls from the specified dom element.
  6102. * @param element Defines the element to stop listening the inputs from
  6103. */
  6104. detachControl(element: Nullable<HTMLElement>): void;
  6105. /**
  6106. * Update the current camera state depending on the inputs that have been used this frame.
  6107. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6108. */
  6109. checkInputs?: () => void;
  6110. }
  6111. /**
  6112. * Represents a map of input types to input instance or input index to input instance.
  6113. */
  6114. export interface CameraInputsMap<TCamera extends Camera> {
  6115. /**
  6116. * Accessor to the input by input type.
  6117. */
  6118. [name: string]: ICameraInput<TCamera>;
  6119. /**
  6120. * Accessor to the input by input index.
  6121. */
  6122. [idx: number]: ICameraInput<TCamera>;
  6123. }
  6124. /**
  6125. * This represents the input manager used within a camera.
  6126. * It helps dealing with all the different kind of input attached to a camera.
  6127. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6128. */
  6129. export class CameraInputsManager<TCamera extends Camera> {
  6130. /**
  6131. * Defines the list of inputs attahed to the camera.
  6132. */
  6133. attached: CameraInputsMap<TCamera>;
  6134. /**
  6135. * Defines the dom element the camera is collecting inputs from.
  6136. * This is null if the controls have not been attached.
  6137. */
  6138. attachedElement: Nullable<HTMLElement>;
  6139. /**
  6140. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6141. */
  6142. noPreventDefault: boolean;
  6143. /**
  6144. * Defined the camera the input manager belongs to.
  6145. */
  6146. camera: TCamera;
  6147. /**
  6148. * Update the current camera state depending on the inputs that have been used this frame.
  6149. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6150. */
  6151. checkInputs: () => void;
  6152. /**
  6153. * Instantiate a new Camera Input Manager.
  6154. * @param camera Defines the camera the input manager blongs to
  6155. */
  6156. constructor(camera: TCamera);
  6157. /**
  6158. * Add an input method to a camera
  6159. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6160. * @param input camera input method
  6161. */
  6162. add(input: ICameraInput<TCamera>): void;
  6163. /**
  6164. * Remove a specific input method from a camera
  6165. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6166. * @param inputToRemove camera input method
  6167. */
  6168. remove(inputToRemove: ICameraInput<TCamera>): void;
  6169. /**
  6170. * Remove a specific input type from a camera
  6171. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6172. * @param inputType the type of the input to remove
  6173. */
  6174. removeByType(inputType: string): void;
  6175. private _addCheckInputs;
  6176. /**
  6177. * Attach the input controls to the currently attached dom element to listen the events from.
  6178. * @param input Defines the input to attach
  6179. */
  6180. attachInput(input: ICameraInput<TCamera>): void;
  6181. /**
  6182. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6183. * @param element Defines the dom element to collect the events from
  6184. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6185. */
  6186. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6187. /**
  6188. * Detach the current manager inputs controls from a specific dom element.
  6189. * @param element Defines the dom element to collect the events from
  6190. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6191. */
  6192. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6193. /**
  6194. * Rebuild the dynamic inputCheck function from the current list of
  6195. * defined inputs in the manager.
  6196. */
  6197. rebuildInputCheck(): void;
  6198. /**
  6199. * Remove all attached input methods from a camera
  6200. */
  6201. clear(): void;
  6202. /**
  6203. * Serialize the current input manager attached to a camera.
  6204. * This ensures than once parsed,
  6205. * the input associated to the camera will be identical to the current ones
  6206. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6207. */
  6208. serialize(serializedCamera: any): void;
  6209. /**
  6210. * Parses an input manager serialized JSON to restore the previous list of inputs
  6211. * and states associated to a camera.
  6212. * @param parsedCamera Defines the JSON to parse
  6213. */
  6214. parse(parsedCamera: any): void;
  6215. }
  6216. }
  6217. declare module BABYLON {
  6218. /**
  6219. * Class used to store data that will be store in GPU memory
  6220. */
  6221. export class Buffer {
  6222. private _engine;
  6223. private _buffer;
  6224. /** @hidden */
  6225. _data: Nullable<DataArray>;
  6226. private _updatable;
  6227. private _instanced;
  6228. private _divisor;
  6229. /**
  6230. * Gets the byte stride.
  6231. */
  6232. readonly byteStride: number;
  6233. /**
  6234. * Constructor
  6235. * @param engine the engine
  6236. * @param data the data to use for this buffer
  6237. * @param updatable whether the data is updatable
  6238. * @param stride the stride (optional)
  6239. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6240. * @param instanced whether the buffer is instanced (optional)
  6241. * @param useBytes set to true if the stride in in bytes (optional)
  6242. * @param divisor sets an optional divisor for instances (1 by default)
  6243. */
  6244. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6245. /**
  6246. * Create a new VertexBuffer based on the current buffer
  6247. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6248. * @param offset defines offset in the buffer (0 by default)
  6249. * @param size defines the size in floats of attributes (position is 3 for instance)
  6250. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6251. * @param instanced defines if the vertex buffer contains indexed data
  6252. * @param useBytes defines if the offset and stride are in bytes *
  6253. * @param divisor sets an optional divisor for instances (1 by default)
  6254. * @returns the new vertex buffer
  6255. */
  6256. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6257. /**
  6258. * Gets a boolean indicating if the Buffer is updatable?
  6259. * @returns true if the buffer is updatable
  6260. */
  6261. isUpdatable(): boolean;
  6262. /**
  6263. * Gets current buffer's data
  6264. * @returns a DataArray or null
  6265. */
  6266. getData(): Nullable<DataArray>;
  6267. /**
  6268. * Gets underlying native buffer
  6269. * @returns underlying native buffer
  6270. */
  6271. getBuffer(): Nullable<DataBuffer>;
  6272. /**
  6273. * Gets the stride in float32 units (i.e. byte stride / 4).
  6274. * May not be an integer if the byte stride is not divisible by 4.
  6275. * @returns the stride in float32 units
  6276. * @deprecated Please use byteStride instead.
  6277. */
  6278. getStrideSize(): number;
  6279. /**
  6280. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6281. * @param data defines the data to store
  6282. */
  6283. create(data?: Nullable<DataArray>): void;
  6284. /** @hidden */
  6285. _rebuild(): void;
  6286. /**
  6287. * Update current buffer data
  6288. * @param data defines the data to store
  6289. */
  6290. update(data: DataArray): void;
  6291. /**
  6292. * Updates the data directly.
  6293. * @param data the new data
  6294. * @param offset the new offset
  6295. * @param vertexCount the vertex count (optional)
  6296. * @param useBytes set to true if the offset is in bytes
  6297. */
  6298. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6299. /**
  6300. * Release all resources
  6301. */
  6302. dispose(): void;
  6303. }
  6304. /**
  6305. * Specialized buffer used to store vertex data
  6306. */
  6307. export class VertexBuffer {
  6308. /** @hidden */
  6309. _buffer: Buffer;
  6310. private _kind;
  6311. private _size;
  6312. private _ownsBuffer;
  6313. private _instanced;
  6314. private _instanceDivisor;
  6315. /**
  6316. * The byte type.
  6317. */
  6318. static readonly BYTE: number;
  6319. /**
  6320. * The unsigned byte type.
  6321. */
  6322. static readonly UNSIGNED_BYTE: number;
  6323. /**
  6324. * The short type.
  6325. */
  6326. static readonly SHORT: number;
  6327. /**
  6328. * The unsigned short type.
  6329. */
  6330. static readonly UNSIGNED_SHORT: number;
  6331. /**
  6332. * The integer type.
  6333. */
  6334. static readonly INT: number;
  6335. /**
  6336. * The unsigned integer type.
  6337. */
  6338. static readonly UNSIGNED_INT: number;
  6339. /**
  6340. * The float type.
  6341. */
  6342. static readonly FLOAT: number;
  6343. /**
  6344. * Gets or sets the instance divisor when in instanced mode
  6345. */
  6346. instanceDivisor: number;
  6347. /**
  6348. * Gets the byte stride.
  6349. */
  6350. readonly byteStride: number;
  6351. /**
  6352. * Gets the byte offset.
  6353. */
  6354. readonly byteOffset: number;
  6355. /**
  6356. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6357. */
  6358. readonly normalized: boolean;
  6359. /**
  6360. * Gets the data type of each component in the array.
  6361. */
  6362. readonly type: number;
  6363. /**
  6364. * Constructor
  6365. * @param engine the engine
  6366. * @param data the data to use for this vertex buffer
  6367. * @param kind the vertex buffer kind
  6368. * @param updatable whether the data is updatable
  6369. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6370. * @param stride the stride (optional)
  6371. * @param instanced whether the buffer is instanced (optional)
  6372. * @param offset the offset of the data (optional)
  6373. * @param size the number of components (optional)
  6374. * @param type the type of the component (optional)
  6375. * @param normalized whether the data contains normalized data (optional)
  6376. * @param useBytes set to true if stride and offset are in bytes (optional)
  6377. * @param divisor defines the instance divisor to use (1 by default)
  6378. */
  6379. 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, divisor?: number);
  6380. /** @hidden */
  6381. _rebuild(): void;
  6382. /**
  6383. * Returns the kind of the VertexBuffer (string)
  6384. * @returns a string
  6385. */
  6386. getKind(): string;
  6387. /**
  6388. * Gets a boolean indicating if the VertexBuffer is updatable?
  6389. * @returns true if the buffer is updatable
  6390. */
  6391. isUpdatable(): boolean;
  6392. /**
  6393. * Gets current buffer's data
  6394. * @returns a DataArray or null
  6395. */
  6396. getData(): Nullable<DataArray>;
  6397. /**
  6398. * Gets underlying native buffer
  6399. * @returns underlying native buffer
  6400. */
  6401. getBuffer(): Nullable<DataBuffer>;
  6402. /**
  6403. * Gets the stride in float32 units (i.e. byte stride / 4).
  6404. * May not be an integer if the byte stride is not divisible by 4.
  6405. * @returns the stride in float32 units
  6406. * @deprecated Please use byteStride instead.
  6407. */
  6408. getStrideSize(): number;
  6409. /**
  6410. * Returns the offset as a multiple of the type byte length.
  6411. * @returns the offset in bytes
  6412. * @deprecated Please use byteOffset instead.
  6413. */
  6414. getOffset(): number;
  6415. /**
  6416. * Returns the number of components per vertex attribute (integer)
  6417. * @returns the size in float
  6418. */
  6419. getSize(): number;
  6420. /**
  6421. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6422. * @returns true if this buffer is instanced
  6423. */
  6424. getIsInstanced(): boolean;
  6425. /**
  6426. * Returns the instancing divisor, zero for non-instanced (integer).
  6427. * @returns a number
  6428. */
  6429. getInstanceDivisor(): number;
  6430. /**
  6431. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6432. * @param data defines the data to store
  6433. */
  6434. create(data?: DataArray): void;
  6435. /**
  6436. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6437. * This function will create a new buffer if the current one is not updatable
  6438. * @param data defines the data to store
  6439. */
  6440. update(data: DataArray): void;
  6441. /**
  6442. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6443. * Returns the directly updated WebGLBuffer.
  6444. * @param data the new data
  6445. * @param offset the new offset
  6446. * @param useBytes set to true if the offset is in bytes
  6447. */
  6448. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6449. /**
  6450. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6451. */
  6452. dispose(): void;
  6453. /**
  6454. * Enumerates each value of this vertex buffer as numbers.
  6455. * @param count the number of values to enumerate
  6456. * @param callback the callback function called for each value
  6457. */
  6458. forEach(count: number, callback: (value: number, index: number) => void): void;
  6459. /**
  6460. * Positions
  6461. */
  6462. static readonly PositionKind: string;
  6463. /**
  6464. * Normals
  6465. */
  6466. static readonly NormalKind: string;
  6467. /**
  6468. * Tangents
  6469. */
  6470. static readonly TangentKind: string;
  6471. /**
  6472. * Texture coordinates
  6473. */
  6474. static readonly UVKind: string;
  6475. /**
  6476. * Texture coordinates 2
  6477. */
  6478. static readonly UV2Kind: string;
  6479. /**
  6480. * Texture coordinates 3
  6481. */
  6482. static readonly UV3Kind: string;
  6483. /**
  6484. * Texture coordinates 4
  6485. */
  6486. static readonly UV4Kind: string;
  6487. /**
  6488. * Texture coordinates 5
  6489. */
  6490. static readonly UV5Kind: string;
  6491. /**
  6492. * Texture coordinates 6
  6493. */
  6494. static readonly UV6Kind: string;
  6495. /**
  6496. * Colors
  6497. */
  6498. static readonly ColorKind: string;
  6499. /**
  6500. * Matrix indices (for bones)
  6501. */
  6502. static readonly MatricesIndicesKind: string;
  6503. /**
  6504. * Matrix weights (for bones)
  6505. */
  6506. static readonly MatricesWeightsKind: string;
  6507. /**
  6508. * Additional matrix indices (for bones)
  6509. */
  6510. static readonly MatricesIndicesExtraKind: string;
  6511. /**
  6512. * Additional matrix weights (for bones)
  6513. */
  6514. static readonly MatricesWeightsExtraKind: string;
  6515. /**
  6516. * Deduces the stride given a kind.
  6517. * @param kind The kind string to deduce
  6518. * @returns The deduced stride
  6519. */
  6520. static DeduceStride(kind: string): number;
  6521. /**
  6522. * Gets the byte length of the given type.
  6523. * @param type the type
  6524. * @returns the number of bytes
  6525. */
  6526. static GetTypeByteLength(type: number): number;
  6527. /**
  6528. * Enumerates each value of the given parameters as numbers.
  6529. * @param data the data to enumerate
  6530. * @param byteOffset the byte offset of the data
  6531. * @param byteStride the byte stride of the data
  6532. * @param componentCount the number of components per element
  6533. * @param componentType the type of the component
  6534. * @param count the number of values to enumerate
  6535. * @param normalized whether the data is normalized
  6536. * @param callback the callback function called for each value
  6537. */
  6538. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6539. private static _GetFloatValue;
  6540. }
  6541. }
  6542. declare module BABYLON {
  6543. /**
  6544. * @hidden
  6545. */
  6546. export class IntersectionInfo {
  6547. bu: Nullable<number>;
  6548. bv: Nullable<number>;
  6549. distance: number;
  6550. faceId: number;
  6551. subMeshId: number;
  6552. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6553. }
  6554. }
  6555. declare module BABYLON {
  6556. /**
  6557. * Represens a plane by the equation ax + by + cz + d = 0
  6558. */
  6559. export class Plane {
  6560. private static _TmpMatrix;
  6561. /**
  6562. * Normal of the plane (a,b,c)
  6563. */
  6564. normal: Vector3;
  6565. /**
  6566. * d component of the plane
  6567. */
  6568. d: number;
  6569. /**
  6570. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6571. * @param a a component of the plane
  6572. * @param b b component of the plane
  6573. * @param c c component of the plane
  6574. * @param d d component of the plane
  6575. */
  6576. constructor(a: number, b: number, c: number, d: number);
  6577. /**
  6578. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6579. */
  6580. asArray(): number[];
  6581. /**
  6582. * @returns a new plane copied from the current Plane.
  6583. */
  6584. clone(): Plane;
  6585. /**
  6586. * @returns the string "Plane".
  6587. */
  6588. getClassName(): string;
  6589. /**
  6590. * @returns the Plane hash code.
  6591. */
  6592. getHashCode(): number;
  6593. /**
  6594. * Normalize the current Plane in place.
  6595. * @returns the updated Plane.
  6596. */
  6597. normalize(): Plane;
  6598. /**
  6599. * Applies a transformation the plane and returns the result
  6600. * @param transformation the transformation matrix to be applied to the plane
  6601. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6602. */
  6603. transform(transformation: DeepImmutable<Matrix>): Plane;
  6604. /**
  6605. * Calcualtte the dot product between the point and the plane normal
  6606. * @param point point to calculate the dot product with
  6607. * @returns the dot product (float) of the point coordinates and the plane normal.
  6608. */
  6609. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6610. /**
  6611. * Updates the current Plane from the plane defined by the three given points.
  6612. * @param point1 one of the points used to contruct the plane
  6613. * @param point2 one of the points used to contruct the plane
  6614. * @param point3 one of the points used to contruct the plane
  6615. * @returns the updated Plane.
  6616. */
  6617. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6618. /**
  6619. * Checks if the plane is facing a given direction
  6620. * @param direction the direction to check if the plane is facing
  6621. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6622. * @returns True is the vector "direction" is the same side than the plane normal.
  6623. */
  6624. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6625. /**
  6626. * Calculates the distance to a point
  6627. * @param point point to calculate distance to
  6628. * @returns the signed distance (float) from the given point to the Plane.
  6629. */
  6630. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6631. /**
  6632. * Creates a plane from an array
  6633. * @param array the array to create a plane from
  6634. * @returns a new Plane from the given array.
  6635. */
  6636. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6637. /**
  6638. * Creates a plane from three points
  6639. * @param point1 point used to create the plane
  6640. * @param point2 point used to create the plane
  6641. * @param point3 point used to create the plane
  6642. * @returns a new Plane defined by the three given points.
  6643. */
  6644. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6645. /**
  6646. * Creates a plane from an origin point and a normal
  6647. * @param origin origin of the plane to be constructed
  6648. * @param normal normal of the plane to be constructed
  6649. * @returns a new Plane the normal vector to this plane at the given origin point.
  6650. * Note : the vector "normal" is updated because normalized.
  6651. */
  6652. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6653. /**
  6654. * Calculates the distance from a plane and a point
  6655. * @param origin origin of the plane to be constructed
  6656. * @param normal normal of the plane to be constructed
  6657. * @param point point to calculate distance to
  6658. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6659. */
  6660. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6661. }
  6662. }
  6663. declare module BABYLON {
  6664. /**
  6665. * Class used to store bounding sphere information
  6666. */
  6667. export class BoundingSphere {
  6668. /**
  6669. * Gets the center of the bounding sphere in local space
  6670. */
  6671. readonly center: Vector3;
  6672. /**
  6673. * Radius of the bounding sphere in local space
  6674. */
  6675. radius: number;
  6676. /**
  6677. * Gets the center of the bounding sphere in world space
  6678. */
  6679. readonly centerWorld: Vector3;
  6680. /**
  6681. * Radius of the bounding sphere in world space
  6682. */
  6683. radiusWorld: number;
  6684. /**
  6685. * Gets the minimum vector in local space
  6686. */
  6687. readonly minimum: Vector3;
  6688. /**
  6689. * Gets the maximum vector in local space
  6690. */
  6691. readonly maximum: Vector3;
  6692. private _worldMatrix;
  6693. private static readonly TmpVector3;
  6694. /**
  6695. * Creates a new bounding sphere
  6696. * @param min defines the minimum vector (in local space)
  6697. * @param max defines the maximum vector (in local space)
  6698. * @param worldMatrix defines the new world matrix
  6699. */
  6700. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6701. /**
  6702. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6703. * @param min defines the new minimum vector (in local space)
  6704. * @param max defines the new maximum vector (in local space)
  6705. * @param worldMatrix defines the new world matrix
  6706. */
  6707. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6708. /**
  6709. * Scale the current bounding sphere by applying a scale factor
  6710. * @param factor defines the scale factor to apply
  6711. * @returns the current bounding box
  6712. */
  6713. scale(factor: number): BoundingSphere;
  6714. /**
  6715. * Gets the world matrix of the bounding box
  6716. * @returns a matrix
  6717. */
  6718. getWorldMatrix(): DeepImmutable<Matrix>;
  6719. /** @hidden */
  6720. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6721. /**
  6722. * Tests if the bounding sphere is intersecting the frustum planes
  6723. * @param frustumPlanes defines the frustum planes to test
  6724. * @returns true if there is an intersection
  6725. */
  6726. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6727. /**
  6728. * Tests if the bounding sphere center is in between the frustum planes.
  6729. * Used for optimistic fast inclusion.
  6730. * @param frustumPlanes defines the frustum planes to test
  6731. * @returns true if the sphere center is in between the frustum planes
  6732. */
  6733. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6734. /**
  6735. * Tests if a point is inside the bounding sphere
  6736. * @param point defines the point to test
  6737. * @returns true if the point is inside the bounding sphere
  6738. */
  6739. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6740. /**
  6741. * Checks if two sphere intersct
  6742. * @param sphere0 sphere 0
  6743. * @param sphere1 sphere 1
  6744. * @returns true if the speres intersect
  6745. */
  6746. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6747. }
  6748. }
  6749. declare module BABYLON {
  6750. /**
  6751. * Class used to store bounding box information
  6752. */
  6753. export class BoundingBox implements ICullable {
  6754. /**
  6755. * Gets the 8 vectors representing the bounding box in local space
  6756. */
  6757. readonly vectors: Vector3[];
  6758. /**
  6759. * Gets the center of the bounding box in local space
  6760. */
  6761. readonly center: Vector3;
  6762. /**
  6763. * Gets the center of the bounding box in world space
  6764. */
  6765. readonly centerWorld: Vector3;
  6766. /**
  6767. * Gets the extend size in local space
  6768. */
  6769. readonly extendSize: Vector3;
  6770. /**
  6771. * Gets the extend size in world space
  6772. */
  6773. readonly extendSizeWorld: Vector3;
  6774. /**
  6775. * Gets the OBB (object bounding box) directions
  6776. */
  6777. readonly directions: Vector3[];
  6778. /**
  6779. * Gets the 8 vectors representing the bounding box in world space
  6780. */
  6781. readonly vectorsWorld: Vector3[];
  6782. /**
  6783. * Gets the minimum vector in world space
  6784. */
  6785. readonly minimumWorld: Vector3;
  6786. /**
  6787. * Gets the maximum vector in world space
  6788. */
  6789. readonly maximumWorld: Vector3;
  6790. /**
  6791. * Gets the minimum vector in local space
  6792. */
  6793. readonly minimum: Vector3;
  6794. /**
  6795. * Gets the maximum vector in local space
  6796. */
  6797. readonly maximum: Vector3;
  6798. private _worldMatrix;
  6799. private static readonly TmpVector3;
  6800. /**
  6801. * @hidden
  6802. */
  6803. _tag: number;
  6804. /**
  6805. * Creates a new bounding box
  6806. * @param min defines the minimum vector (in local space)
  6807. * @param max defines the maximum vector (in local space)
  6808. * @param worldMatrix defines the new world matrix
  6809. */
  6810. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6811. /**
  6812. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6813. * @param min defines the new minimum vector (in local space)
  6814. * @param max defines the new maximum vector (in local space)
  6815. * @param worldMatrix defines the new world matrix
  6816. */
  6817. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6818. /**
  6819. * Scale the current bounding box by applying a scale factor
  6820. * @param factor defines the scale factor to apply
  6821. * @returns the current bounding box
  6822. */
  6823. scale(factor: number): BoundingBox;
  6824. /**
  6825. * Gets the world matrix of the bounding box
  6826. * @returns a matrix
  6827. */
  6828. getWorldMatrix(): DeepImmutable<Matrix>;
  6829. /** @hidden */
  6830. _update(world: DeepImmutable<Matrix>): void;
  6831. /**
  6832. * Tests if the bounding box is intersecting the frustum planes
  6833. * @param frustumPlanes defines the frustum planes to test
  6834. * @returns true if there is an intersection
  6835. */
  6836. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6837. /**
  6838. * Tests if the bounding box is entirely inside the frustum planes
  6839. * @param frustumPlanes defines the frustum planes to test
  6840. * @returns true if there is an inclusion
  6841. */
  6842. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6843. /**
  6844. * Tests if a point is inside the bounding box
  6845. * @param point defines the point to test
  6846. * @returns true if the point is inside the bounding box
  6847. */
  6848. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6849. /**
  6850. * Tests if the bounding box intersects with a bounding sphere
  6851. * @param sphere defines the sphere to test
  6852. * @returns true if there is an intersection
  6853. */
  6854. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6855. /**
  6856. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6857. * @param min defines the min vector to use
  6858. * @param max defines the max vector to use
  6859. * @returns true if there is an intersection
  6860. */
  6861. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6862. /**
  6863. * Tests if two bounding boxes are intersections
  6864. * @param box0 defines the first box to test
  6865. * @param box1 defines the second box to test
  6866. * @returns true if there is an intersection
  6867. */
  6868. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6869. /**
  6870. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6871. * @param minPoint defines the minimum vector of the bounding box
  6872. * @param maxPoint defines the maximum vector of the bounding box
  6873. * @param sphereCenter defines the sphere center
  6874. * @param sphereRadius defines the sphere radius
  6875. * @returns true if there is an intersection
  6876. */
  6877. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6878. /**
  6879. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6880. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6881. * @param frustumPlanes defines the frustum planes to test
  6882. * @return true if there is an inclusion
  6883. */
  6884. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6885. /**
  6886. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6887. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6888. * @param frustumPlanes defines the frustum planes to test
  6889. * @return true if there is an intersection
  6890. */
  6891. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6892. }
  6893. }
  6894. declare module BABYLON {
  6895. /** @hidden */
  6896. export class Collider {
  6897. /** Define if a collision was found */
  6898. collisionFound: boolean;
  6899. /**
  6900. * Define last intersection point in local space
  6901. */
  6902. intersectionPoint: Vector3;
  6903. /**
  6904. * Define last collided mesh
  6905. */
  6906. collidedMesh: Nullable<AbstractMesh>;
  6907. private _collisionPoint;
  6908. private _planeIntersectionPoint;
  6909. private _tempVector;
  6910. private _tempVector2;
  6911. private _tempVector3;
  6912. private _tempVector4;
  6913. private _edge;
  6914. private _baseToVertex;
  6915. private _destinationPoint;
  6916. private _slidePlaneNormal;
  6917. private _displacementVector;
  6918. /** @hidden */
  6919. _radius: Vector3;
  6920. /** @hidden */
  6921. _retry: number;
  6922. private _velocity;
  6923. private _basePoint;
  6924. private _epsilon;
  6925. /** @hidden */
  6926. _velocityWorldLength: number;
  6927. /** @hidden */
  6928. _basePointWorld: Vector3;
  6929. private _velocityWorld;
  6930. private _normalizedVelocity;
  6931. /** @hidden */
  6932. _initialVelocity: Vector3;
  6933. /** @hidden */
  6934. _initialPosition: Vector3;
  6935. private _nearestDistance;
  6936. private _collisionMask;
  6937. collisionMask: number;
  6938. /**
  6939. * Gets the plane normal used to compute the sliding response (in local space)
  6940. */
  6941. readonly slidePlaneNormal: Vector3;
  6942. /** @hidden */
  6943. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6944. /** @hidden */
  6945. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6946. /** @hidden */
  6947. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6948. /** @hidden */
  6949. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6950. /** @hidden */
  6951. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6952. /** @hidden */
  6953. _getResponse(pos: Vector3, vel: Vector3): void;
  6954. }
  6955. }
  6956. declare module BABYLON {
  6957. /**
  6958. * Interface for cullable objects
  6959. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  6960. */
  6961. export interface ICullable {
  6962. /**
  6963. * Checks if the object or part of the object is in the frustum
  6964. * @param frustumPlanes Camera near/planes
  6965. * @returns true if the object is in frustum otherwise false
  6966. */
  6967. isInFrustum(frustumPlanes: Plane[]): boolean;
  6968. /**
  6969. * Checks if a cullable object (mesh...) is in the camera frustum
  6970. * Unlike isInFrustum this cheks the full bounding box
  6971. * @param frustumPlanes Camera near/planes
  6972. * @returns true if the object is in frustum otherwise false
  6973. */
  6974. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6975. }
  6976. /**
  6977. * Info for a bounding data of a mesh
  6978. */
  6979. export class BoundingInfo implements ICullable {
  6980. /**
  6981. * Bounding box for the mesh
  6982. */
  6983. readonly boundingBox: BoundingBox;
  6984. /**
  6985. * Bounding sphere for the mesh
  6986. */
  6987. readonly boundingSphere: BoundingSphere;
  6988. private _isLocked;
  6989. private static readonly TmpVector3;
  6990. /**
  6991. * Constructs bounding info
  6992. * @param minimum min vector of the bounding box/sphere
  6993. * @param maximum max vector of the bounding box/sphere
  6994. * @param worldMatrix defines the new world matrix
  6995. */
  6996. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6997. /**
  6998. * Recreates the entire bounding info from scratch as if we call the constructor in place
  6999. * @param min defines the new minimum vector (in local space)
  7000. * @param max defines the new maximum vector (in local space)
  7001. * @param worldMatrix defines the new world matrix
  7002. */
  7003. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7004. /**
  7005. * min vector of the bounding box/sphere
  7006. */
  7007. readonly minimum: Vector3;
  7008. /**
  7009. * max vector of the bounding box/sphere
  7010. */
  7011. readonly maximum: Vector3;
  7012. /**
  7013. * If the info is locked and won't be updated to avoid perf overhead
  7014. */
  7015. isLocked: boolean;
  7016. /**
  7017. * Updates the bounding sphere and box
  7018. * @param world world matrix to be used to update
  7019. */
  7020. update(world: DeepImmutable<Matrix>): void;
  7021. /**
  7022. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7023. * @param center New center of the bounding info
  7024. * @param extend New extend of the bounding info
  7025. * @returns the current bounding info
  7026. */
  7027. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7028. /**
  7029. * Scale the current bounding info by applying a scale factor
  7030. * @param factor defines the scale factor to apply
  7031. * @returns the current bounding info
  7032. */
  7033. scale(factor: number): BoundingInfo;
  7034. /**
  7035. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7036. * @param frustumPlanes defines the frustum to test
  7037. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7038. * @returns true if the bounding info is in the frustum planes
  7039. */
  7040. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7041. /**
  7042. * Gets the world distance between the min and max points of the bounding box
  7043. */
  7044. readonly diagonalLength: number;
  7045. /**
  7046. * Checks if a cullable object (mesh...) is in the camera frustum
  7047. * Unlike isInFrustum this cheks the full bounding box
  7048. * @param frustumPlanes Camera near/planes
  7049. * @returns true if the object is in frustum otherwise false
  7050. */
  7051. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7052. /** @hidden */
  7053. _checkCollision(collider: Collider): boolean;
  7054. /**
  7055. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7056. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7057. * @param point the point to check intersection with
  7058. * @returns if the point intersects
  7059. */
  7060. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7061. /**
  7062. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7063. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7064. * @param boundingInfo the bounding info to check intersection with
  7065. * @param precise if the intersection should be done using OBB
  7066. * @returns if the bounding info intersects
  7067. */
  7068. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7069. }
  7070. }
  7071. declare module BABYLON {
  7072. /**
  7073. * Extracts minimum and maximum values from a list of indexed positions
  7074. * @param positions defines the positions to use
  7075. * @param indices defines the indices to the positions
  7076. * @param indexStart defines the start index
  7077. * @param indexCount defines the end index
  7078. * @param bias defines bias value to add to the result
  7079. * @return minimum and maximum values
  7080. */
  7081. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7082. minimum: Vector3;
  7083. maximum: Vector3;
  7084. };
  7085. /**
  7086. * Extracts minimum and maximum values from a list of positions
  7087. * @param positions defines the positions to use
  7088. * @param start defines the start index in the positions array
  7089. * @param count defines the number of positions to handle
  7090. * @param bias defines bias value to add to the result
  7091. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7092. * @return minimum and maximum values
  7093. */
  7094. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7095. minimum: Vector3;
  7096. maximum: Vector3;
  7097. };
  7098. }
  7099. declare module BABYLON {
  7100. /** @hidden */
  7101. export class WebGLDataBuffer extends DataBuffer {
  7102. private _buffer;
  7103. constructor(resource: WebGLBuffer);
  7104. readonly underlyingResource: any;
  7105. }
  7106. }
  7107. declare module BABYLON {
  7108. /** @hidden */
  7109. export class WebGLPipelineContext implements IPipelineContext {
  7110. engine: ThinEngine;
  7111. program: Nullable<WebGLProgram>;
  7112. context?: WebGLRenderingContext;
  7113. vertexShader?: WebGLShader;
  7114. fragmentShader?: WebGLShader;
  7115. isParallelCompiled: boolean;
  7116. onCompiled?: () => void;
  7117. transformFeedback?: WebGLTransformFeedback | null;
  7118. readonly isAsync: boolean;
  7119. readonly isReady: boolean;
  7120. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7121. }
  7122. }
  7123. declare module BABYLON {
  7124. interface ThinEngine {
  7125. /**
  7126. * Create an uniform buffer
  7127. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7128. * @param elements defines the content of the uniform buffer
  7129. * @returns the webGL uniform buffer
  7130. */
  7131. createUniformBuffer(elements: FloatArray): DataBuffer;
  7132. /**
  7133. * Create a dynamic uniform buffer
  7134. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7135. * @param elements defines the content of the uniform buffer
  7136. * @returns the webGL uniform buffer
  7137. */
  7138. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7139. /**
  7140. * Update an existing uniform buffer
  7141. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7142. * @param uniformBuffer defines the target uniform buffer
  7143. * @param elements defines the content to update
  7144. * @param offset defines the offset in the uniform buffer where update should start
  7145. * @param count defines the size of the data to update
  7146. */
  7147. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7148. /**
  7149. * Bind an uniform buffer to the current webGL context
  7150. * @param buffer defines the buffer to bind
  7151. */
  7152. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7153. /**
  7154. * Bind a buffer to the current webGL context at a given location
  7155. * @param buffer defines the buffer to bind
  7156. * @param location defines the index where to bind the buffer
  7157. */
  7158. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7159. /**
  7160. * Bind a specific block at a given index in a specific shader program
  7161. * @param pipelineContext defines the pipeline context to use
  7162. * @param blockName defines the block name
  7163. * @param index defines the index where to bind the block
  7164. */
  7165. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7166. }
  7167. }
  7168. declare module BABYLON {
  7169. /**
  7170. * Uniform buffer objects.
  7171. *
  7172. * Handles blocks of uniform on the GPU.
  7173. *
  7174. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7175. *
  7176. * For more information, please refer to :
  7177. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7178. */
  7179. export class UniformBuffer {
  7180. private _engine;
  7181. private _buffer;
  7182. private _data;
  7183. private _bufferData;
  7184. private _dynamic?;
  7185. private _uniformLocations;
  7186. private _uniformSizes;
  7187. private _uniformLocationPointer;
  7188. private _needSync;
  7189. private _noUBO;
  7190. private _currentEffect;
  7191. /** @hidden */
  7192. _alreadyBound: boolean;
  7193. private static _MAX_UNIFORM_SIZE;
  7194. private static _tempBuffer;
  7195. /**
  7196. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7197. * This is dynamic to allow compat with webgl 1 and 2.
  7198. * You will need to pass the name of the uniform as well as the value.
  7199. */
  7200. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7201. /**
  7202. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7203. * This is dynamic to allow compat with webgl 1 and 2.
  7204. * You will need to pass the name of the uniform as well as the value.
  7205. */
  7206. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7207. /**
  7208. * Lambda to Update a single float in a uniform buffer.
  7209. * This is dynamic to allow compat with webgl 1 and 2.
  7210. * You will need to pass the name of the uniform as well as the value.
  7211. */
  7212. updateFloat: (name: string, x: number) => void;
  7213. /**
  7214. * Lambda to Update a vec2 of float in a uniform buffer.
  7215. * This is dynamic to allow compat with webgl 1 and 2.
  7216. * You will need to pass the name of the uniform as well as the value.
  7217. */
  7218. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7219. /**
  7220. * Lambda to Update a vec3 of float in a uniform buffer.
  7221. * This is dynamic to allow compat with webgl 1 and 2.
  7222. * You will need to pass the name of the uniform as well as the value.
  7223. */
  7224. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7225. /**
  7226. * Lambda to Update a vec4 of float in a uniform buffer.
  7227. * This is dynamic to allow compat with webgl 1 and 2.
  7228. * You will need to pass the name of the uniform as well as the value.
  7229. */
  7230. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7231. /**
  7232. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7233. * This is dynamic to allow compat with webgl 1 and 2.
  7234. * You will need to pass the name of the uniform as well as the value.
  7235. */
  7236. updateMatrix: (name: string, mat: Matrix) => void;
  7237. /**
  7238. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7239. * This is dynamic to allow compat with webgl 1 and 2.
  7240. * You will need to pass the name of the uniform as well as the value.
  7241. */
  7242. updateVector3: (name: string, vector: Vector3) => void;
  7243. /**
  7244. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7245. * This is dynamic to allow compat with webgl 1 and 2.
  7246. * You will need to pass the name of the uniform as well as the value.
  7247. */
  7248. updateVector4: (name: string, vector: Vector4) => void;
  7249. /**
  7250. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7251. * This is dynamic to allow compat with webgl 1 and 2.
  7252. * You will need to pass the name of the uniform as well as the value.
  7253. */
  7254. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7255. /**
  7256. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7257. * This is dynamic to allow compat with webgl 1 and 2.
  7258. * You will need to pass the name of the uniform as well as the value.
  7259. */
  7260. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7261. /**
  7262. * Instantiates a new Uniform buffer objects.
  7263. *
  7264. * Handles blocks of uniform on the GPU.
  7265. *
  7266. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7267. *
  7268. * For more information, please refer to :
  7269. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7270. * @param engine Define the engine the buffer is associated with
  7271. * @param data Define the data contained in the buffer
  7272. * @param dynamic Define if the buffer is updatable
  7273. */
  7274. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7275. /**
  7276. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7277. * or just falling back on setUniformXXX calls.
  7278. */
  7279. readonly useUbo: boolean;
  7280. /**
  7281. * Indicates if the WebGL underlying uniform buffer is in sync
  7282. * with the javascript cache data.
  7283. */
  7284. readonly isSync: boolean;
  7285. /**
  7286. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7287. * Also, a dynamic UniformBuffer will disable cache verification and always
  7288. * update the underlying WebGL uniform buffer to the GPU.
  7289. * @returns if Dynamic, otherwise false
  7290. */
  7291. isDynamic(): boolean;
  7292. /**
  7293. * The data cache on JS side.
  7294. * @returns the underlying data as a float array
  7295. */
  7296. getData(): Float32Array;
  7297. /**
  7298. * The underlying WebGL Uniform buffer.
  7299. * @returns the webgl buffer
  7300. */
  7301. getBuffer(): Nullable<DataBuffer>;
  7302. /**
  7303. * std140 layout specifies how to align data within an UBO structure.
  7304. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7305. * for specs.
  7306. */
  7307. private _fillAlignment;
  7308. /**
  7309. * Adds an uniform in the buffer.
  7310. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7311. * for the layout to be correct !
  7312. * @param name Name of the uniform, as used in the uniform block in the shader.
  7313. * @param size Data size, or data directly.
  7314. */
  7315. addUniform(name: string, size: number | number[]): void;
  7316. /**
  7317. * Adds a Matrix 4x4 to the uniform buffer.
  7318. * @param name Name of the uniform, as used in the uniform block in the shader.
  7319. * @param mat A 4x4 matrix.
  7320. */
  7321. addMatrix(name: string, mat: Matrix): void;
  7322. /**
  7323. * Adds a vec2 to the uniform buffer.
  7324. * @param name Name of the uniform, as used in the uniform block in the shader.
  7325. * @param x Define the x component value of the vec2
  7326. * @param y Define the y component value of the vec2
  7327. */
  7328. addFloat2(name: string, x: number, y: number): void;
  7329. /**
  7330. * Adds a vec3 to the uniform buffer.
  7331. * @param name Name of the uniform, as used in the uniform block in the shader.
  7332. * @param x Define the x component value of the vec3
  7333. * @param y Define the y component value of the vec3
  7334. * @param z Define the z component value of the vec3
  7335. */
  7336. addFloat3(name: string, x: number, y: number, z: number): void;
  7337. /**
  7338. * Adds a vec3 to the uniform buffer.
  7339. * @param name Name of the uniform, as used in the uniform block in the shader.
  7340. * @param color Define the vec3 from a Color
  7341. */
  7342. addColor3(name: string, color: Color3): void;
  7343. /**
  7344. * Adds a vec4 to the uniform buffer.
  7345. * @param name Name of the uniform, as used in the uniform block in the shader.
  7346. * @param color Define the rgb components from a Color
  7347. * @param alpha Define the a component of the vec4
  7348. */
  7349. addColor4(name: string, color: Color3, alpha: number): void;
  7350. /**
  7351. * Adds a vec3 to the uniform buffer.
  7352. * @param name Name of the uniform, as used in the uniform block in the shader.
  7353. * @param vector Define the vec3 components from a Vector
  7354. */
  7355. addVector3(name: string, vector: Vector3): void;
  7356. /**
  7357. * Adds a Matrix 3x3 to the uniform buffer.
  7358. * @param name Name of the uniform, as used in the uniform block in the shader.
  7359. */
  7360. addMatrix3x3(name: string): void;
  7361. /**
  7362. * Adds a Matrix 2x2 to the uniform buffer.
  7363. * @param name Name of the uniform, as used in the uniform block in the shader.
  7364. */
  7365. addMatrix2x2(name: string): void;
  7366. /**
  7367. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7368. */
  7369. create(): void;
  7370. /** @hidden */
  7371. _rebuild(): void;
  7372. /**
  7373. * Updates the WebGL Uniform Buffer on the GPU.
  7374. * If the `dynamic` flag is set to true, no cache comparison is done.
  7375. * Otherwise, the buffer will be updated only if the cache differs.
  7376. */
  7377. update(): void;
  7378. /**
  7379. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7380. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7381. * @param data Define the flattened data
  7382. * @param size Define the size of the data.
  7383. */
  7384. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7385. private _valueCache;
  7386. private _cacheMatrix;
  7387. private _updateMatrix3x3ForUniform;
  7388. private _updateMatrix3x3ForEffect;
  7389. private _updateMatrix2x2ForEffect;
  7390. private _updateMatrix2x2ForUniform;
  7391. private _updateFloatForEffect;
  7392. private _updateFloatForUniform;
  7393. private _updateFloat2ForEffect;
  7394. private _updateFloat2ForUniform;
  7395. private _updateFloat3ForEffect;
  7396. private _updateFloat3ForUniform;
  7397. private _updateFloat4ForEffect;
  7398. private _updateFloat4ForUniform;
  7399. private _updateMatrixForEffect;
  7400. private _updateMatrixForUniform;
  7401. private _updateVector3ForEffect;
  7402. private _updateVector3ForUniform;
  7403. private _updateVector4ForEffect;
  7404. private _updateVector4ForUniform;
  7405. private _updateColor3ForEffect;
  7406. private _updateColor3ForUniform;
  7407. private _updateColor4ForEffect;
  7408. private _updateColor4ForUniform;
  7409. /**
  7410. * Sets a sampler uniform on the effect.
  7411. * @param name Define the name of the sampler.
  7412. * @param texture Define the texture to set in the sampler
  7413. */
  7414. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7415. /**
  7416. * Directly updates the value of the uniform in the cache AND on the GPU.
  7417. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7418. * @param data Define the flattened data
  7419. */
  7420. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7421. /**
  7422. * Binds this uniform buffer to an effect.
  7423. * @param effect Define the effect to bind the buffer to
  7424. * @param name Name of the uniform block in the shader.
  7425. */
  7426. bindToEffect(effect: Effect, name: string): void;
  7427. /**
  7428. * Disposes the uniform buffer.
  7429. */
  7430. dispose(): void;
  7431. }
  7432. }
  7433. declare module BABYLON {
  7434. /**
  7435. * Enum that determines the text-wrapping mode to use.
  7436. */
  7437. export enum InspectableType {
  7438. /**
  7439. * Checkbox for booleans
  7440. */
  7441. Checkbox = 0,
  7442. /**
  7443. * Sliders for numbers
  7444. */
  7445. Slider = 1,
  7446. /**
  7447. * Vector3
  7448. */
  7449. Vector3 = 2,
  7450. /**
  7451. * Quaternions
  7452. */
  7453. Quaternion = 3,
  7454. /**
  7455. * Color3
  7456. */
  7457. Color3 = 4,
  7458. /**
  7459. * String
  7460. */
  7461. String = 5
  7462. }
  7463. /**
  7464. * Interface used to define custom inspectable properties.
  7465. * This interface is used by the inspector to display custom property grids
  7466. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7467. */
  7468. export interface IInspectable {
  7469. /**
  7470. * Gets the label to display
  7471. */
  7472. label: string;
  7473. /**
  7474. * Gets the name of the property to edit
  7475. */
  7476. propertyName: string;
  7477. /**
  7478. * Gets the type of the editor to use
  7479. */
  7480. type: InspectableType;
  7481. /**
  7482. * Gets the minimum value of the property when using in "slider" mode
  7483. */
  7484. min?: number;
  7485. /**
  7486. * Gets the maximum value of the property when using in "slider" mode
  7487. */
  7488. max?: number;
  7489. /**
  7490. * Gets the setp to use when using in "slider" mode
  7491. */
  7492. step?: number;
  7493. }
  7494. }
  7495. declare module BABYLON {
  7496. /**
  7497. * Class used to provide helper for timing
  7498. */
  7499. export class TimingTools {
  7500. /**
  7501. * Polyfill for setImmediate
  7502. * @param action defines the action to execute after the current execution block
  7503. */
  7504. static SetImmediate(action: () => void): void;
  7505. }
  7506. }
  7507. declare module BABYLON {
  7508. /**
  7509. * Class used to enable instatition of objects by class name
  7510. */
  7511. export class InstantiationTools {
  7512. /**
  7513. * Use this object to register external classes like custom textures or material
  7514. * to allow the laoders to instantiate them
  7515. */
  7516. static RegisteredExternalClasses: {
  7517. [key: string]: Object;
  7518. };
  7519. /**
  7520. * Tries to instantiate a new object from a given class name
  7521. * @param className defines the class name to instantiate
  7522. * @returns the new object or null if the system was not able to do the instantiation
  7523. */
  7524. static Instantiate(className: string): any;
  7525. }
  7526. }
  7527. declare module BABYLON {
  7528. /**
  7529. * Define options used to create a depth texture
  7530. */
  7531. export class DepthTextureCreationOptions {
  7532. /** Specifies whether or not a stencil should be allocated in the texture */
  7533. generateStencil?: boolean;
  7534. /** Specifies whether or not bilinear filtering is enable on the texture */
  7535. bilinearFiltering?: boolean;
  7536. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7537. comparisonFunction?: number;
  7538. /** Specifies if the created texture is a cube texture */
  7539. isCube?: boolean;
  7540. }
  7541. }
  7542. declare module BABYLON {
  7543. interface ThinEngine {
  7544. /**
  7545. * Creates a depth stencil cube texture.
  7546. * This is only available in WebGL 2.
  7547. * @param size The size of face edge in the cube texture.
  7548. * @param options The options defining the cube texture.
  7549. * @returns The cube texture
  7550. */
  7551. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7552. /**
  7553. * Creates a cube texture
  7554. * @param rootUrl defines the url where the files to load is located
  7555. * @param scene defines the current scene
  7556. * @param files defines the list of files to load (1 per face)
  7557. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7558. * @param onLoad defines an optional callback raised when the texture is loaded
  7559. * @param onError defines an optional callback raised if there is an issue to load the texture
  7560. * @param format defines the format of the data
  7561. * @param forcedExtension defines the extension to use to pick the right loader
  7562. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7563. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7564. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7565. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7566. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7567. * @returns the cube texture as an InternalTexture
  7568. */
  7569. 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;
  7570. /**
  7571. * Creates a cube texture
  7572. * @param rootUrl defines the url where the files to load is located
  7573. * @param scene defines the current scene
  7574. * @param files defines the list of files to load (1 per face)
  7575. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7576. * @param onLoad defines an optional callback raised when the texture is loaded
  7577. * @param onError defines an optional callback raised if there is an issue to load the texture
  7578. * @param format defines the format of the data
  7579. * @param forcedExtension defines the extension to use to pick the right loader
  7580. * @returns the cube texture as an InternalTexture
  7581. */
  7582. 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;
  7583. /**
  7584. * Creates a cube texture
  7585. * @param rootUrl defines the url where the files to load is located
  7586. * @param scene defines the current scene
  7587. * @param files defines the list of files to load (1 per face)
  7588. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7589. * @param onLoad defines an optional callback raised when the texture is loaded
  7590. * @param onError defines an optional callback raised if there is an issue to load the texture
  7591. * @param format defines the format of the data
  7592. * @param forcedExtension defines the extension to use to pick the right loader
  7593. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7594. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7595. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7596. * @returns the cube texture as an InternalTexture
  7597. */
  7598. 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;
  7599. /** @hidden */
  7600. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7601. /** @hidden */
  7602. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7603. /** @hidden */
  7604. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7605. /** @hidden */
  7606. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7607. /**
  7608. * @hidden
  7609. */
  7610. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7611. }
  7612. }
  7613. declare module BABYLON {
  7614. /**
  7615. * Class for creating a cube texture
  7616. */
  7617. export class CubeTexture extends BaseTexture {
  7618. private _delayedOnLoad;
  7619. /**
  7620. * The url of the texture
  7621. */
  7622. url: string;
  7623. /**
  7624. * Gets or sets the center of the bounding box associated with the cube texture.
  7625. * It must define where the camera used to render the texture was set
  7626. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7627. */
  7628. boundingBoxPosition: Vector3;
  7629. private _boundingBoxSize;
  7630. /**
  7631. * Gets or sets the size of the bounding box associated with the cube texture
  7632. * When defined, the cubemap will switch to local mode
  7633. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7634. * @example https://www.babylonjs-playground.com/#RNASML
  7635. */
  7636. /**
  7637. * Returns the bounding box size
  7638. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7639. */
  7640. boundingBoxSize: Vector3;
  7641. protected _rotationY: number;
  7642. /**
  7643. * Sets texture matrix rotation angle around Y axis in radians.
  7644. */
  7645. /**
  7646. * Gets texture matrix rotation angle around Y axis radians.
  7647. */
  7648. rotationY: number;
  7649. /**
  7650. * Are mip maps generated for this texture or not.
  7651. */
  7652. readonly noMipmap: boolean;
  7653. private _noMipmap;
  7654. private _files;
  7655. protected _forcedExtension: Nullable<string>;
  7656. private _extensions;
  7657. private _textureMatrix;
  7658. private _format;
  7659. private _createPolynomials;
  7660. /** @hidden */
  7661. _prefiltered: boolean;
  7662. /**
  7663. * Creates a cube texture from an array of image urls
  7664. * @param files defines an array of image urls
  7665. * @param scene defines the hosting scene
  7666. * @param noMipmap specifies if mip maps are not used
  7667. * @returns a cube texture
  7668. */
  7669. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7670. /**
  7671. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7672. * @param url defines the url of the prefiltered texture
  7673. * @param scene defines the scene the texture is attached to
  7674. * @param forcedExtension defines the extension of the file if different from the url
  7675. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7676. * @return the prefiltered texture
  7677. */
  7678. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7679. /**
  7680. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7681. * as prefiltered data.
  7682. * @param rootUrl defines the url of the texture or the root name of the six images
  7683. * @param scene defines the scene the texture is attached to
  7684. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7685. * @param noMipmap defines if mipmaps should be created or not
  7686. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7687. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7688. * @param onError defines a callback triggered in case of error during load
  7689. * @param format defines the internal format to use for the texture once loaded
  7690. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7691. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7692. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7693. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7694. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7695. * @return the cube texture
  7696. */
  7697. 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);
  7698. /**
  7699. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7700. */
  7701. readonly isPrefiltered: boolean;
  7702. /**
  7703. * Get the current class name of the texture useful for serialization or dynamic coding.
  7704. * @returns "CubeTexture"
  7705. */
  7706. getClassName(): string;
  7707. /**
  7708. * Update the url (and optional buffer) of this texture if url was null during construction.
  7709. * @param url the url of the texture
  7710. * @param forcedExtension defines the extension to use
  7711. * @param onLoad callback called when the texture is loaded (defaults to null)
  7712. */
  7713. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7714. /**
  7715. * Delays loading of the cube texture
  7716. * @param forcedExtension defines the extension to use
  7717. */
  7718. delayLoad(forcedExtension?: string): void;
  7719. /**
  7720. * Returns the reflection texture matrix
  7721. * @returns the reflection texture matrix
  7722. */
  7723. getReflectionTextureMatrix(): Matrix;
  7724. /**
  7725. * Sets the reflection texture matrix
  7726. * @param value Reflection texture matrix
  7727. */
  7728. setReflectionTextureMatrix(value: Matrix): void;
  7729. /**
  7730. * Parses text to create a cube texture
  7731. * @param parsedTexture define the serialized text to read from
  7732. * @param scene defines the hosting scene
  7733. * @param rootUrl defines the root url of the cube texture
  7734. * @returns a cube texture
  7735. */
  7736. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7737. /**
  7738. * Makes a clone, or deep copy, of the cube texture
  7739. * @returns a new cube texture
  7740. */
  7741. clone(): CubeTexture;
  7742. }
  7743. }
  7744. declare module BABYLON {
  7745. /**
  7746. * Manages the defines for the Material
  7747. */
  7748. export class MaterialDefines {
  7749. /** @hidden */
  7750. protected _keys: string[];
  7751. private _isDirty;
  7752. /** @hidden */
  7753. _renderId: number;
  7754. /** @hidden */
  7755. _areLightsDirty: boolean;
  7756. /** @hidden */
  7757. _areLightsDisposed: boolean;
  7758. /** @hidden */
  7759. _areAttributesDirty: boolean;
  7760. /** @hidden */
  7761. _areTexturesDirty: boolean;
  7762. /** @hidden */
  7763. _areFresnelDirty: boolean;
  7764. /** @hidden */
  7765. _areMiscDirty: boolean;
  7766. /** @hidden */
  7767. _areImageProcessingDirty: boolean;
  7768. /** @hidden */
  7769. _normals: boolean;
  7770. /** @hidden */
  7771. _uvs: boolean;
  7772. /** @hidden */
  7773. _needNormals: boolean;
  7774. /** @hidden */
  7775. _needUVs: boolean;
  7776. [id: string]: any;
  7777. /**
  7778. * Specifies if the material needs to be re-calculated
  7779. */
  7780. readonly isDirty: boolean;
  7781. /**
  7782. * Marks the material to indicate that it has been re-calculated
  7783. */
  7784. markAsProcessed(): void;
  7785. /**
  7786. * Marks the material to indicate that it needs to be re-calculated
  7787. */
  7788. markAsUnprocessed(): void;
  7789. /**
  7790. * Marks the material to indicate all of its defines need to be re-calculated
  7791. */
  7792. markAllAsDirty(): void;
  7793. /**
  7794. * Marks the material to indicate that image processing needs to be re-calculated
  7795. */
  7796. markAsImageProcessingDirty(): void;
  7797. /**
  7798. * Marks the material to indicate the lights need to be re-calculated
  7799. * @param disposed Defines whether the light is dirty due to dispose or not
  7800. */
  7801. markAsLightDirty(disposed?: boolean): void;
  7802. /**
  7803. * Marks the attribute state as changed
  7804. */
  7805. markAsAttributesDirty(): void;
  7806. /**
  7807. * Marks the texture state as changed
  7808. */
  7809. markAsTexturesDirty(): void;
  7810. /**
  7811. * Marks the fresnel state as changed
  7812. */
  7813. markAsFresnelDirty(): void;
  7814. /**
  7815. * Marks the misc state as changed
  7816. */
  7817. markAsMiscDirty(): void;
  7818. /**
  7819. * Rebuilds the material defines
  7820. */
  7821. rebuild(): void;
  7822. /**
  7823. * Specifies if two material defines are equal
  7824. * @param other - A material define instance to compare to
  7825. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7826. */
  7827. isEqual(other: MaterialDefines): boolean;
  7828. /**
  7829. * Clones this instance's defines to another instance
  7830. * @param other - material defines to clone values to
  7831. */
  7832. cloneTo(other: MaterialDefines): void;
  7833. /**
  7834. * Resets the material define values
  7835. */
  7836. reset(): void;
  7837. /**
  7838. * Converts the material define values to a string
  7839. * @returns - String of material define information
  7840. */
  7841. toString(): string;
  7842. }
  7843. }
  7844. declare module BABYLON {
  7845. /**
  7846. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7847. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7848. * 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;
  7849. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7850. */
  7851. export class ColorCurves {
  7852. private _dirty;
  7853. private _tempColor;
  7854. private _globalCurve;
  7855. private _highlightsCurve;
  7856. private _midtonesCurve;
  7857. private _shadowsCurve;
  7858. private _positiveCurve;
  7859. private _negativeCurve;
  7860. private _globalHue;
  7861. private _globalDensity;
  7862. private _globalSaturation;
  7863. private _globalExposure;
  7864. /**
  7865. * Gets the global Hue value.
  7866. * 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).
  7867. */
  7868. /**
  7869. * Sets the global Hue value.
  7870. * 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).
  7871. */
  7872. globalHue: number;
  7873. /**
  7874. * Gets the global Density value.
  7875. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7876. * Values less than zero provide a filter of opposite hue.
  7877. */
  7878. /**
  7879. * Sets the global Density value.
  7880. * 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.
  7881. * Values less than zero provide a filter of opposite hue.
  7882. */
  7883. globalDensity: number;
  7884. /**
  7885. * Gets the global Saturation value.
  7886. * 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.
  7887. */
  7888. /**
  7889. * Sets the global Saturation value.
  7890. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7891. */
  7892. globalSaturation: number;
  7893. /**
  7894. * Gets the global Exposure value.
  7895. * 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.
  7896. */
  7897. /**
  7898. * Sets the global Exposure value.
  7899. * 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.
  7900. */
  7901. globalExposure: number;
  7902. private _highlightsHue;
  7903. private _highlightsDensity;
  7904. private _highlightsSaturation;
  7905. private _highlightsExposure;
  7906. /**
  7907. * Gets the highlights Hue value.
  7908. * 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).
  7909. */
  7910. /**
  7911. * Sets the highlights Hue value.
  7912. * 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).
  7913. */
  7914. highlightsHue: number;
  7915. /**
  7916. * Gets the highlights Density value.
  7917. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7918. * Values less than zero provide a filter of opposite hue.
  7919. */
  7920. /**
  7921. * Sets the highlights Density value.
  7922. * 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.
  7923. * Values less than zero provide a filter of opposite hue.
  7924. */
  7925. highlightsDensity: number;
  7926. /**
  7927. * Gets the highlights Saturation value.
  7928. * 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.
  7929. */
  7930. /**
  7931. * Sets the highlights Saturation value.
  7932. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7933. */
  7934. highlightsSaturation: number;
  7935. /**
  7936. * Gets the highlights Exposure value.
  7937. * 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.
  7938. */
  7939. /**
  7940. * Sets the highlights Exposure value.
  7941. * 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.
  7942. */
  7943. highlightsExposure: number;
  7944. private _midtonesHue;
  7945. private _midtonesDensity;
  7946. private _midtonesSaturation;
  7947. private _midtonesExposure;
  7948. /**
  7949. * Gets the midtones Hue value.
  7950. * 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).
  7951. */
  7952. /**
  7953. * Sets the midtones Hue value.
  7954. * 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).
  7955. */
  7956. midtonesHue: number;
  7957. /**
  7958. * Gets the midtones Density value.
  7959. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7960. * Values less than zero provide a filter of opposite hue.
  7961. */
  7962. /**
  7963. * Sets the midtones Density value.
  7964. * 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.
  7965. * Values less than zero provide a filter of opposite hue.
  7966. */
  7967. midtonesDensity: number;
  7968. /**
  7969. * Gets the midtones Saturation value.
  7970. * 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.
  7971. */
  7972. /**
  7973. * Sets the midtones Saturation value.
  7974. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7975. */
  7976. midtonesSaturation: number;
  7977. /**
  7978. * Gets the midtones Exposure value.
  7979. * 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.
  7980. */
  7981. /**
  7982. * Sets the midtones Exposure value.
  7983. * 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.
  7984. */
  7985. midtonesExposure: number;
  7986. private _shadowsHue;
  7987. private _shadowsDensity;
  7988. private _shadowsSaturation;
  7989. private _shadowsExposure;
  7990. /**
  7991. * Gets the shadows Hue value.
  7992. * 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).
  7993. */
  7994. /**
  7995. * Sets the shadows Hue value.
  7996. * 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).
  7997. */
  7998. shadowsHue: number;
  7999. /**
  8000. * Gets the shadows Density value.
  8001. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8002. * Values less than zero provide a filter of opposite hue.
  8003. */
  8004. /**
  8005. * Sets the shadows Density value.
  8006. * 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.
  8007. * Values less than zero provide a filter of opposite hue.
  8008. */
  8009. shadowsDensity: number;
  8010. /**
  8011. * Gets the shadows Saturation value.
  8012. * 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.
  8013. */
  8014. /**
  8015. * Sets the shadows Saturation value.
  8016. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8017. */
  8018. shadowsSaturation: number;
  8019. /**
  8020. * Gets the shadows Exposure value.
  8021. * 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.
  8022. */
  8023. /**
  8024. * Sets the shadows Exposure value.
  8025. * 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.
  8026. */
  8027. shadowsExposure: number;
  8028. /**
  8029. * Returns the class name
  8030. * @returns The class name
  8031. */
  8032. getClassName(): string;
  8033. /**
  8034. * Binds the color curves to the shader.
  8035. * @param colorCurves The color curve to bind
  8036. * @param effect The effect to bind to
  8037. * @param positiveUniform The positive uniform shader parameter
  8038. * @param neutralUniform The neutral uniform shader parameter
  8039. * @param negativeUniform The negative uniform shader parameter
  8040. */
  8041. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8042. /**
  8043. * Prepare the list of uniforms associated with the ColorCurves effects.
  8044. * @param uniformsList The list of uniforms used in the effect
  8045. */
  8046. static PrepareUniforms(uniformsList: string[]): void;
  8047. /**
  8048. * Returns color grading data based on a hue, density, saturation and exposure value.
  8049. * @param filterHue The hue of the color filter.
  8050. * @param filterDensity The density of the color filter.
  8051. * @param saturation The saturation.
  8052. * @param exposure The exposure.
  8053. * @param result The result data container.
  8054. */
  8055. private getColorGradingDataToRef;
  8056. /**
  8057. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8058. * @param value The input slider value in range [-100,100].
  8059. * @returns Adjusted value.
  8060. */
  8061. private static applyColorGradingSliderNonlinear;
  8062. /**
  8063. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8064. * @param hue The hue (H) input.
  8065. * @param saturation The saturation (S) input.
  8066. * @param brightness The brightness (B) input.
  8067. * @result An RGBA color represented as Vector4.
  8068. */
  8069. private static fromHSBToRef;
  8070. /**
  8071. * Returns a value clamped between min and max
  8072. * @param value The value to clamp
  8073. * @param min The minimum of value
  8074. * @param max The maximum of value
  8075. * @returns The clamped value.
  8076. */
  8077. private static clamp;
  8078. /**
  8079. * Clones the current color curve instance.
  8080. * @return The cloned curves
  8081. */
  8082. clone(): ColorCurves;
  8083. /**
  8084. * Serializes the current color curve instance to a json representation.
  8085. * @return a JSON representation
  8086. */
  8087. serialize(): any;
  8088. /**
  8089. * Parses the color curve from a json representation.
  8090. * @param source the JSON source to parse
  8091. * @return The parsed curves
  8092. */
  8093. static Parse(source: any): ColorCurves;
  8094. }
  8095. }
  8096. declare module BABYLON {
  8097. /**
  8098. * Interface to follow in your material defines to integrate easily the
  8099. * Image proccessing functions.
  8100. * @hidden
  8101. */
  8102. export interface IImageProcessingConfigurationDefines {
  8103. IMAGEPROCESSING: boolean;
  8104. VIGNETTE: boolean;
  8105. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8106. VIGNETTEBLENDMODEOPAQUE: boolean;
  8107. TONEMAPPING: boolean;
  8108. TONEMAPPING_ACES: boolean;
  8109. CONTRAST: boolean;
  8110. EXPOSURE: boolean;
  8111. COLORCURVES: boolean;
  8112. COLORGRADING: boolean;
  8113. COLORGRADING3D: boolean;
  8114. SAMPLER3DGREENDEPTH: boolean;
  8115. SAMPLER3DBGRMAP: boolean;
  8116. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8117. }
  8118. /**
  8119. * @hidden
  8120. */
  8121. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8122. IMAGEPROCESSING: boolean;
  8123. VIGNETTE: boolean;
  8124. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8125. VIGNETTEBLENDMODEOPAQUE: boolean;
  8126. TONEMAPPING: boolean;
  8127. TONEMAPPING_ACES: boolean;
  8128. CONTRAST: boolean;
  8129. COLORCURVES: boolean;
  8130. COLORGRADING: boolean;
  8131. COLORGRADING3D: boolean;
  8132. SAMPLER3DGREENDEPTH: boolean;
  8133. SAMPLER3DBGRMAP: boolean;
  8134. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8135. EXPOSURE: boolean;
  8136. constructor();
  8137. }
  8138. /**
  8139. * This groups together the common properties used for image processing either in direct forward pass
  8140. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8141. * or not.
  8142. */
  8143. export class ImageProcessingConfiguration {
  8144. /**
  8145. * Default tone mapping applied in BabylonJS.
  8146. */
  8147. static readonly TONEMAPPING_STANDARD: number;
  8148. /**
  8149. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8150. * to other engines rendering to increase portability.
  8151. */
  8152. static readonly TONEMAPPING_ACES: number;
  8153. /**
  8154. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8155. */
  8156. colorCurves: Nullable<ColorCurves>;
  8157. private _colorCurvesEnabled;
  8158. /**
  8159. * Gets wether the color curves effect is enabled.
  8160. */
  8161. /**
  8162. * Sets wether the color curves effect is enabled.
  8163. */
  8164. colorCurvesEnabled: boolean;
  8165. private _colorGradingTexture;
  8166. /**
  8167. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8168. */
  8169. /**
  8170. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8171. */
  8172. colorGradingTexture: Nullable<BaseTexture>;
  8173. private _colorGradingEnabled;
  8174. /**
  8175. * Gets wether the color grading effect is enabled.
  8176. */
  8177. /**
  8178. * Sets wether the color grading effect is enabled.
  8179. */
  8180. colorGradingEnabled: boolean;
  8181. private _colorGradingWithGreenDepth;
  8182. /**
  8183. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8184. */
  8185. /**
  8186. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8187. */
  8188. colorGradingWithGreenDepth: boolean;
  8189. private _colorGradingBGR;
  8190. /**
  8191. * Gets wether the color grading texture contains BGR values.
  8192. */
  8193. /**
  8194. * Sets wether the color grading texture contains BGR values.
  8195. */
  8196. colorGradingBGR: boolean;
  8197. /** @hidden */
  8198. _exposure: number;
  8199. /**
  8200. * Gets the Exposure used in the effect.
  8201. */
  8202. /**
  8203. * Sets the Exposure used in the effect.
  8204. */
  8205. exposure: number;
  8206. private _toneMappingEnabled;
  8207. /**
  8208. * Gets wether the tone mapping effect is enabled.
  8209. */
  8210. /**
  8211. * Sets wether the tone mapping effect is enabled.
  8212. */
  8213. toneMappingEnabled: boolean;
  8214. private _toneMappingType;
  8215. /**
  8216. * Gets the type of tone mapping effect.
  8217. */
  8218. /**
  8219. * Sets the type of tone mapping effect used in BabylonJS.
  8220. */
  8221. toneMappingType: number;
  8222. protected _contrast: number;
  8223. /**
  8224. * Gets the contrast used in the effect.
  8225. */
  8226. /**
  8227. * Sets the contrast used in the effect.
  8228. */
  8229. contrast: number;
  8230. /**
  8231. * Vignette stretch size.
  8232. */
  8233. vignetteStretch: number;
  8234. /**
  8235. * Vignette centre X Offset.
  8236. */
  8237. vignetteCentreX: number;
  8238. /**
  8239. * Vignette centre Y Offset.
  8240. */
  8241. vignetteCentreY: number;
  8242. /**
  8243. * Vignette weight or intensity of the vignette effect.
  8244. */
  8245. vignetteWeight: number;
  8246. /**
  8247. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8248. * if vignetteEnabled is set to true.
  8249. */
  8250. vignetteColor: Color4;
  8251. /**
  8252. * Camera field of view used by the Vignette effect.
  8253. */
  8254. vignetteCameraFov: number;
  8255. private _vignetteBlendMode;
  8256. /**
  8257. * Gets the vignette blend mode allowing different kind of effect.
  8258. */
  8259. /**
  8260. * Sets the vignette blend mode allowing different kind of effect.
  8261. */
  8262. vignetteBlendMode: number;
  8263. private _vignetteEnabled;
  8264. /**
  8265. * Gets wether the vignette effect is enabled.
  8266. */
  8267. /**
  8268. * Sets wether the vignette effect is enabled.
  8269. */
  8270. vignetteEnabled: boolean;
  8271. private _applyByPostProcess;
  8272. /**
  8273. * Gets wether the image processing is applied through a post process or not.
  8274. */
  8275. /**
  8276. * Sets wether the image processing is applied through a post process or not.
  8277. */
  8278. applyByPostProcess: boolean;
  8279. private _isEnabled;
  8280. /**
  8281. * Gets wether the image processing is enabled or not.
  8282. */
  8283. /**
  8284. * Sets wether the image processing is enabled or not.
  8285. */
  8286. isEnabled: boolean;
  8287. /**
  8288. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8289. */
  8290. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8291. /**
  8292. * Method called each time the image processing information changes requires to recompile the effect.
  8293. */
  8294. protected _updateParameters(): void;
  8295. /**
  8296. * Gets the current class name.
  8297. * @return "ImageProcessingConfiguration"
  8298. */
  8299. getClassName(): string;
  8300. /**
  8301. * Prepare the list of uniforms associated with the Image Processing effects.
  8302. * @param uniforms The list of uniforms used in the effect
  8303. * @param defines the list of defines currently in use
  8304. */
  8305. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8306. /**
  8307. * Prepare the list of samplers associated with the Image Processing effects.
  8308. * @param samplersList The list of uniforms used in the effect
  8309. * @param defines the list of defines currently in use
  8310. */
  8311. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8312. /**
  8313. * Prepare the list of defines associated to the shader.
  8314. * @param defines the list of defines to complete
  8315. * @param forPostProcess Define if we are currently in post process mode or not
  8316. */
  8317. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8318. /**
  8319. * Returns true if all the image processing information are ready.
  8320. * @returns True if ready, otherwise, false
  8321. */
  8322. isReady(): boolean;
  8323. /**
  8324. * Binds the image processing to the shader.
  8325. * @param effect The effect to bind to
  8326. * @param overrideAspectRatio Override the aspect ratio of the effect
  8327. */
  8328. bind(effect: Effect, overrideAspectRatio?: number): void;
  8329. /**
  8330. * Clones the current image processing instance.
  8331. * @return The cloned image processing
  8332. */
  8333. clone(): ImageProcessingConfiguration;
  8334. /**
  8335. * Serializes the current image processing instance to a json representation.
  8336. * @return a JSON representation
  8337. */
  8338. serialize(): any;
  8339. /**
  8340. * Parses the image processing from a json representation.
  8341. * @param source the JSON source to parse
  8342. * @return The parsed image processing
  8343. */
  8344. static Parse(source: any): ImageProcessingConfiguration;
  8345. private static _VIGNETTEMODE_MULTIPLY;
  8346. private static _VIGNETTEMODE_OPAQUE;
  8347. /**
  8348. * Used to apply the vignette as a mix with the pixel color.
  8349. */
  8350. static readonly VIGNETTEMODE_MULTIPLY: number;
  8351. /**
  8352. * Used to apply the vignette as a replacement of the pixel color.
  8353. */
  8354. static readonly VIGNETTEMODE_OPAQUE: number;
  8355. }
  8356. }
  8357. declare module BABYLON {
  8358. /** @hidden */
  8359. export var postprocessVertexShader: {
  8360. name: string;
  8361. shader: string;
  8362. };
  8363. }
  8364. declare module BABYLON {
  8365. interface ThinEngine {
  8366. /**
  8367. * Creates a new render target texture
  8368. * @param size defines the size of the texture
  8369. * @param options defines the options used to create the texture
  8370. * @returns a new render target texture stored in an InternalTexture
  8371. */
  8372. createRenderTargetTexture(size: number | {
  8373. width: number;
  8374. height: number;
  8375. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8376. /**
  8377. * Creates a depth stencil texture.
  8378. * This is only available in WebGL 2 or with the depth texture extension available.
  8379. * @param size The size of face edge in the texture.
  8380. * @param options The options defining the texture.
  8381. * @returns The texture
  8382. */
  8383. createDepthStencilTexture(size: number | {
  8384. width: number;
  8385. height: number;
  8386. }, options: DepthTextureCreationOptions): InternalTexture;
  8387. /** @hidden */
  8388. _createDepthStencilTexture(size: number | {
  8389. width: number;
  8390. height: number;
  8391. }, options: DepthTextureCreationOptions): InternalTexture;
  8392. }
  8393. }
  8394. declare module BABYLON {
  8395. /** Defines supported spaces */
  8396. export enum Space {
  8397. /** Local (object) space */
  8398. LOCAL = 0,
  8399. /** World space */
  8400. WORLD = 1,
  8401. /** Bone space */
  8402. BONE = 2
  8403. }
  8404. /** Defines the 3 main axes */
  8405. export class Axis {
  8406. /** X axis */
  8407. static X: Vector3;
  8408. /** Y axis */
  8409. static Y: Vector3;
  8410. /** Z axis */
  8411. static Z: Vector3;
  8412. }
  8413. }
  8414. declare module BABYLON {
  8415. /**
  8416. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8417. * This is the base of the follow, arc rotate cameras and Free camera
  8418. * @see http://doc.babylonjs.com/features/cameras
  8419. */
  8420. export class TargetCamera extends Camera {
  8421. private static _RigCamTransformMatrix;
  8422. private static _TargetTransformMatrix;
  8423. private static _TargetFocalPoint;
  8424. /**
  8425. * Define the current direction the camera is moving to
  8426. */
  8427. cameraDirection: Vector3;
  8428. /**
  8429. * Define the current rotation the camera is rotating to
  8430. */
  8431. cameraRotation: Vector2;
  8432. /**
  8433. * When set, the up vector of the camera will be updated by the rotation of the camera
  8434. */
  8435. updateUpVectorFromRotation: boolean;
  8436. private _tmpQuaternion;
  8437. /**
  8438. * Define the current rotation of the camera
  8439. */
  8440. rotation: Vector3;
  8441. /**
  8442. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8443. */
  8444. rotationQuaternion: Quaternion;
  8445. /**
  8446. * Define the current speed of the camera
  8447. */
  8448. speed: number;
  8449. /**
  8450. * Add constraint to the camera to prevent it to move freely in all directions and
  8451. * around all axis.
  8452. */
  8453. noRotationConstraint: boolean;
  8454. /**
  8455. * Define the current target of the camera as an object or a position.
  8456. */
  8457. lockedTarget: any;
  8458. /** @hidden */
  8459. _currentTarget: Vector3;
  8460. /** @hidden */
  8461. _initialFocalDistance: number;
  8462. /** @hidden */
  8463. _viewMatrix: Matrix;
  8464. /** @hidden */
  8465. _camMatrix: Matrix;
  8466. /** @hidden */
  8467. _cameraTransformMatrix: Matrix;
  8468. /** @hidden */
  8469. _cameraRotationMatrix: Matrix;
  8470. /** @hidden */
  8471. _referencePoint: Vector3;
  8472. /** @hidden */
  8473. _transformedReferencePoint: Vector3;
  8474. protected _globalCurrentTarget: Vector3;
  8475. protected _globalCurrentUpVector: Vector3;
  8476. /** @hidden */
  8477. _reset: () => void;
  8478. private _defaultUp;
  8479. /**
  8480. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8481. * This is the base of the follow, arc rotate cameras and Free camera
  8482. * @see http://doc.babylonjs.com/features/cameras
  8483. * @param name Defines the name of the camera in the scene
  8484. * @param position Defines the start position of the camera in the scene
  8485. * @param scene Defines the scene the camera belongs to
  8486. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8487. */
  8488. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8489. /**
  8490. * Gets the position in front of the camera at a given distance.
  8491. * @param distance The distance from the camera we want the position to be
  8492. * @returns the position
  8493. */
  8494. getFrontPosition(distance: number): Vector3;
  8495. /** @hidden */
  8496. _getLockedTargetPosition(): Nullable<Vector3>;
  8497. private _storedPosition;
  8498. private _storedRotation;
  8499. private _storedRotationQuaternion;
  8500. /**
  8501. * Store current camera state of the camera (fov, position, rotation, etc..)
  8502. * @returns the camera
  8503. */
  8504. storeState(): Camera;
  8505. /**
  8506. * Restored camera state. You must call storeState() first
  8507. * @returns whether it was successful or not
  8508. * @hidden
  8509. */
  8510. _restoreStateValues(): boolean;
  8511. /** @hidden */
  8512. _initCache(): void;
  8513. /** @hidden */
  8514. _updateCache(ignoreParentClass?: boolean): void;
  8515. /** @hidden */
  8516. _isSynchronizedViewMatrix(): boolean;
  8517. /** @hidden */
  8518. _computeLocalCameraSpeed(): number;
  8519. /**
  8520. * Defines the target the camera should look at.
  8521. * @param target Defines the new target as a Vector or a mesh
  8522. */
  8523. setTarget(target: Vector3): void;
  8524. /**
  8525. * Return the current target position of the camera. This value is expressed in local space.
  8526. * @returns the target position
  8527. */
  8528. getTarget(): Vector3;
  8529. /** @hidden */
  8530. _decideIfNeedsToMove(): boolean;
  8531. /** @hidden */
  8532. _updatePosition(): void;
  8533. /** @hidden */
  8534. _checkInputs(): void;
  8535. protected _updateCameraRotationMatrix(): void;
  8536. /**
  8537. * 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)
  8538. * @returns the current camera
  8539. */
  8540. private _rotateUpVectorWithCameraRotationMatrix;
  8541. private _cachedRotationZ;
  8542. private _cachedQuaternionRotationZ;
  8543. /** @hidden */
  8544. _getViewMatrix(): Matrix;
  8545. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8546. /**
  8547. * @hidden
  8548. */
  8549. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8550. /**
  8551. * @hidden
  8552. */
  8553. _updateRigCameras(): void;
  8554. private _getRigCamPositionAndTarget;
  8555. /**
  8556. * Gets the current object class name.
  8557. * @return the class name
  8558. */
  8559. getClassName(): string;
  8560. }
  8561. }
  8562. declare module BABYLON {
  8563. /**
  8564. * Gather the list of keyboard event types as constants.
  8565. */
  8566. export class KeyboardEventTypes {
  8567. /**
  8568. * The keydown event is fired when a key becomes active (pressed).
  8569. */
  8570. static readonly KEYDOWN: number;
  8571. /**
  8572. * The keyup event is fired when a key has been released.
  8573. */
  8574. static readonly KEYUP: number;
  8575. }
  8576. /**
  8577. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8578. */
  8579. export class KeyboardInfo {
  8580. /**
  8581. * Defines the type of event (KeyboardEventTypes)
  8582. */
  8583. type: number;
  8584. /**
  8585. * Defines the related dom event
  8586. */
  8587. event: KeyboardEvent;
  8588. /**
  8589. * Instantiates a new keyboard info.
  8590. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8591. * @param type Defines the type of event (KeyboardEventTypes)
  8592. * @param event Defines the related dom event
  8593. */
  8594. constructor(
  8595. /**
  8596. * Defines the type of event (KeyboardEventTypes)
  8597. */
  8598. type: number,
  8599. /**
  8600. * Defines the related dom event
  8601. */
  8602. event: KeyboardEvent);
  8603. }
  8604. /**
  8605. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8606. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8607. */
  8608. export class KeyboardInfoPre extends KeyboardInfo {
  8609. /**
  8610. * Defines the type of event (KeyboardEventTypes)
  8611. */
  8612. type: number;
  8613. /**
  8614. * Defines the related dom event
  8615. */
  8616. event: KeyboardEvent;
  8617. /**
  8618. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8619. */
  8620. skipOnPointerObservable: boolean;
  8621. /**
  8622. * Instantiates a new keyboard pre info.
  8623. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8624. * @param type Defines the type of event (KeyboardEventTypes)
  8625. * @param event Defines the related dom event
  8626. */
  8627. constructor(
  8628. /**
  8629. * Defines the type of event (KeyboardEventTypes)
  8630. */
  8631. type: number,
  8632. /**
  8633. * Defines the related dom event
  8634. */
  8635. event: KeyboardEvent);
  8636. }
  8637. }
  8638. declare module BABYLON {
  8639. /**
  8640. * Manage the keyboard inputs to control the movement of a free camera.
  8641. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8642. */
  8643. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8644. /**
  8645. * Defines the camera the input is attached to.
  8646. */
  8647. camera: FreeCamera;
  8648. /**
  8649. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8650. */
  8651. keysUp: number[];
  8652. /**
  8653. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8654. */
  8655. keysDown: number[];
  8656. /**
  8657. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8658. */
  8659. keysLeft: number[];
  8660. /**
  8661. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8662. */
  8663. keysRight: number[];
  8664. private _keys;
  8665. private _onCanvasBlurObserver;
  8666. private _onKeyboardObserver;
  8667. private _engine;
  8668. private _scene;
  8669. /**
  8670. * Attach the input controls to a specific dom element to get the input from.
  8671. * @param element Defines the element the controls should be listened from
  8672. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8673. */
  8674. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8675. /**
  8676. * Detach the current controls from the specified dom element.
  8677. * @param element Defines the element to stop listening the inputs from
  8678. */
  8679. detachControl(element: Nullable<HTMLElement>): void;
  8680. /**
  8681. * Update the current camera state depending on the inputs that have been used this frame.
  8682. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8683. */
  8684. checkInputs(): void;
  8685. /**
  8686. * Gets the class name of the current intput.
  8687. * @returns the class name
  8688. */
  8689. getClassName(): string;
  8690. /** @hidden */
  8691. _onLostFocus(): void;
  8692. /**
  8693. * Get the friendly name associated with the input class.
  8694. * @returns the input friendly name
  8695. */
  8696. getSimpleName(): string;
  8697. }
  8698. }
  8699. declare module BABYLON {
  8700. /**
  8701. * Interface describing all the common properties and methods a shadow light needs to implement.
  8702. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8703. * as well as binding the different shadow properties to the effects.
  8704. */
  8705. export interface IShadowLight extends Light {
  8706. /**
  8707. * The light id in the scene (used in scene.findLighById for instance)
  8708. */
  8709. id: string;
  8710. /**
  8711. * The position the shdow will be casted from.
  8712. */
  8713. position: Vector3;
  8714. /**
  8715. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8716. */
  8717. direction: Vector3;
  8718. /**
  8719. * The transformed position. Position of the light in world space taking parenting in account.
  8720. */
  8721. transformedPosition: Vector3;
  8722. /**
  8723. * The transformed direction. Direction of the light in world space taking parenting in account.
  8724. */
  8725. transformedDirection: Vector3;
  8726. /**
  8727. * The friendly name of the light in the scene.
  8728. */
  8729. name: string;
  8730. /**
  8731. * Defines the shadow projection clipping minimum z value.
  8732. */
  8733. shadowMinZ: number;
  8734. /**
  8735. * Defines the shadow projection clipping maximum z value.
  8736. */
  8737. shadowMaxZ: number;
  8738. /**
  8739. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8740. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8741. */
  8742. computeTransformedInformation(): boolean;
  8743. /**
  8744. * Gets the scene the light belongs to.
  8745. * @returns The scene
  8746. */
  8747. getScene(): Scene;
  8748. /**
  8749. * Callback defining a custom Projection Matrix Builder.
  8750. * This can be used to override the default projection matrix computation.
  8751. */
  8752. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8753. /**
  8754. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8755. * @param matrix The materix to updated with the projection information
  8756. * @param viewMatrix The transform matrix of the light
  8757. * @param renderList The list of mesh to render in the map
  8758. * @returns The current light
  8759. */
  8760. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8761. /**
  8762. * Gets the current depth scale used in ESM.
  8763. * @returns The scale
  8764. */
  8765. getDepthScale(): number;
  8766. /**
  8767. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8768. * @returns true if a cube texture needs to be use
  8769. */
  8770. needCube(): boolean;
  8771. /**
  8772. * Detects if the projection matrix requires to be recomputed this frame.
  8773. * @returns true if it requires to be recomputed otherwise, false.
  8774. */
  8775. needProjectionMatrixCompute(): boolean;
  8776. /**
  8777. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8778. */
  8779. forceProjectionMatrixCompute(): void;
  8780. /**
  8781. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8782. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8783. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8784. */
  8785. getShadowDirection(faceIndex?: number): Vector3;
  8786. /**
  8787. * Gets the minZ used for shadow according to both the scene and the light.
  8788. * @param activeCamera The camera we are returning the min for
  8789. * @returns the depth min z
  8790. */
  8791. getDepthMinZ(activeCamera: Camera): number;
  8792. /**
  8793. * Gets the maxZ used for shadow according to both the scene and the light.
  8794. * @param activeCamera The camera we are returning the max for
  8795. * @returns the depth max z
  8796. */
  8797. getDepthMaxZ(activeCamera: Camera): number;
  8798. }
  8799. /**
  8800. * Base implementation IShadowLight
  8801. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8802. */
  8803. export abstract class ShadowLight extends Light implements IShadowLight {
  8804. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8805. protected _position: Vector3;
  8806. protected _setPosition(value: Vector3): void;
  8807. /**
  8808. * Sets the position the shadow will be casted from. Also use as the light position for both
  8809. * point and spot lights.
  8810. */
  8811. /**
  8812. * Sets the position the shadow will be casted from. Also use as the light position for both
  8813. * point and spot lights.
  8814. */
  8815. position: Vector3;
  8816. protected _direction: Vector3;
  8817. protected _setDirection(value: Vector3): void;
  8818. /**
  8819. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8820. * Also use as the light direction on spot and directional lights.
  8821. */
  8822. /**
  8823. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8824. * Also use as the light direction on spot and directional lights.
  8825. */
  8826. direction: Vector3;
  8827. private _shadowMinZ;
  8828. /**
  8829. * Gets the shadow projection clipping minimum z value.
  8830. */
  8831. /**
  8832. * Sets the shadow projection clipping minimum z value.
  8833. */
  8834. shadowMinZ: number;
  8835. private _shadowMaxZ;
  8836. /**
  8837. * Sets the shadow projection clipping maximum z value.
  8838. */
  8839. /**
  8840. * Gets the shadow projection clipping maximum z value.
  8841. */
  8842. shadowMaxZ: number;
  8843. /**
  8844. * Callback defining a custom Projection Matrix Builder.
  8845. * This can be used to override the default projection matrix computation.
  8846. */
  8847. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8848. /**
  8849. * The transformed position. Position of the light in world space taking parenting in account.
  8850. */
  8851. transformedPosition: Vector3;
  8852. /**
  8853. * The transformed direction. Direction of the light in world space taking parenting in account.
  8854. */
  8855. transformedDirection: Vector3;
  8856. private _needProjectionMatrixCompute;
  8857. /**
  8858. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8859. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8860. */
  8861. computeTransformedInformation(): boolean;
  8862. /**
  8863. * Return the depth scale used for the shadow map.
  8864. * @returns the depth scale.
  8865. */
  8866. getDepthScale(): number;
  8867. /**
  8868. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8869. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8870. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8871. */
  8872. getShadowDirection(faceIndex?: number): Vector3;
  8873. /**
  8874. * Returns the ShadowLight absolute position in the World.
  8875. * @returns the position vector in world space
  8876. */
  8877. getAbsolutePosition(): Vector3;
  8878. /**
  8879. * Sets the ShadowLight direction toward the passed target.
  8880. * @param target The point to target in local space
  8881. * @returns the updated ShadowLight direction
  8882. */
  8883. setDirectionToTarget(target: Vector3): Vector3;
  8884. /**
  8885. * Returns the light rotation in euler definition.
  8886. * @returns the x y z rotation in local space.
  8887. */
  8888. getRotation(): Vector3;
  8889. /**
  8890. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8891. * @returns true if a cube texture needs to be use
  8892. */
  8893. needCube(): boolean;
  8894. /**
  8895. * Detects if the projection matrix requires to be recomputed this frame.
  8896. * @returns true if it requires to be recomputed otherwise, false.
  8897. */
  8898. needProjectionMatrixCompute(): boolean;
  8899. /**
  8900. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8901. */
  8902. forceProjectionMatrixCompute(): void;
  8903. /** @hidden */
  8904. _initCache(): void;
  8905. /** @hidden */
  8906. _isSynchronized(): boolean;
  8907. /**
  8908. * Computes the world matrix of the node
  8909. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8910. * @returns the world matrix
  8911. */
  8912. computeWorldMatrix(force?: boolean): Matrix;
  8913. /**
  8914. * Gets the minZ used for shadow according to both the scene and the light.
  8915. * @param activeCamera The camera we are returning the min for
  8916. * @returns the depth min z
  8917. */
  8918. getDepthMinZ(activeCamera: Camera): number;
  8919. /**
  8920. * Gets the maxZ used for shadow according to both the scene and the light.
  8921. * @param activeCamera The camera we are returning the max for
  8922. * @returns the depth max z
  8923. */
  8924. getDepthMaxZ(activeCamera: Camera): number;
  8925. /**
  8926. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8927. * @param matrix The materix to updated with the projection information
  8928. * @param viewMatrix The transform matrix of the light
  8929. * @param renderList The list of mesh to render in the map
  8930. * @returns The current light
  8931. */
  8932. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8933. }
  8934. }
  8935. declare module BABYLON {
  8936. /**
  8937. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  8938. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  8939. */
  8940. export class EffectFallbacks implements IEffectFallbacks {
  8941. private _defines;
  8942. private _currentRank;
  8943. private _maxRank;
  8944. private _mesh;
  8945. /**
  8946. * Removes the fallback from the bound mesh.
  8947. */
  8948. unBindMesh(): void;
  8949. /**
  8950. * Adds a fallback on the specified property.
  8951. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8952. * @param define The name of the define in the shader
  8953. */
  8954. addFallback(rank: number, define: string): void;
  8955. /**
  8956. * Sets the mesh to use CPU skinning when needing to fallback.
  8957. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8958. * @param mesh The mesh to use the fallbacks.
  8959. */
  8960. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  8961. /**
  8962. * Checks to see if more fallbacks are still availible.
  8963. */
  8964. readonly hasMoreFallbacks: boolean;
  8965. /**
  8966. * Removes the defines that should be removed when falling back.
  8967. * @param currentDefines defines the current define statements for the shader.
  8968. * @param effect defines the current effect we try to compile
  8969. * @returns The resulting defines with defines of the current rank removed.
  8970. */
  8971. reduce(currentDefines: string, effect: Effect): string;
  8972. }
  8973. }
  8974. declare module BABYLON {
  8975. /**
  8976. * "Static Class" containing the most commonly used helper while dealing with material for
  8977. * rendering purpose.
  8978. *
  8979. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8980. *
  8981. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8982. */
  8983. export class MaterialHelper {
  8984. /**
  8985. * Bind the current view position to an effect.
  8986. * @param effect The effect to be bound
  8987. * @param scene The scene the eyes position is used from
  8988. */
  8989. static BindEyePosition(effect: Effect, scene: Scene): void;
  8990. /**
  8991. * Helps preparing the defines values about the UVs in used in the effect.
  8992. * UVs are shared as much as we can accross channels in the shaders.
  8993. * @param texture The texture we are preparing the UVs for
  8994. * @param defines The defines to update
  8995. * @param key The channel key "diffuse", "specular"... used in the shader
  8996. */
  8997. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8998. /**
  8999. * Binds a texture matrix value to its corrsponding uniform
  9000. * @param texture The texture to bind the matrix for
  9001. * @param uniformBuffer The uniform buffer receivin the data
  9002. * @param key The channel key "diffuse", "specular"... used in the shader
  9003. */
  9004. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9005. /**
  9006. * Gets the current status of the fog (should it be enabled?)
  9007. * @param mesh defines the mesh to evaluate for fog support
  9008. * @param scene defines the hosting scene
  9009. * @returns true if fog must be enabled
  9010. */
  9011. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9012. /**
  9013. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9014. * @param mesh defines the current mesh
  9015. * @param scene defines the current scene
  9016. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9017. * @param pointsCloud defines if point cloud rendering has to be turned on
  9018. * @param fogEnabled defines if fog has to be turned on
  9019. * @param alphaTest defines if alpha testing has to be turned on
  9020. * @param defines defines the current list of defines
  9021. */
  9022. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9023. /**
  9024. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9025. * @param scene defines the current scene
  9026. * @param engine defines the current engine
  9027. * @param defines specifies the list of active defines
  9028. * @param useInstances defines if instances have to be turned on
  9029. * @param useClipPlane defines if clip plane have to be turned on
  9030. */
  9031. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9032. /**
  9033. * Prepares the defines for bones
  9034. * @param mesh The mesh containing the geometry data we will draw
  9035. * @param defines The defines to update
  9036. */
  9037. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9038. /**
  9039. * Prepares the defines for morph targets
  9040. * @param mesh The mesh containing the geometry data we will draw
  9041. * @param defines The defines to update
  9042. */
  9043. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9044. /**
  9045. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9046. * @param mesh The mesh containing the geometry data we will draw
  9047. * @param defines The defines to update
  9048. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9049. * @param useBones Precise whether bones should be used or not (override mesh info)
  9050. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9051. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9052. * @returns false if defines are considered not dirty and have not been checked
  9053. */
  9054. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9055. /**
  9056. * Prepares the defines related to multiview
  9057. * @param scene The scene we are intending to draw
  9058. * @param defines The defines to update
  9059. */
  9060. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9061. /**
  9062. * Prepares the defines related to the light information passed in parameter
  9063. * @param scene The scene we are intending to draw
  9064. * @param mesh The mesh the effect is compiling for
  9065. * @param light The light the effect is compiling for
  9066. * @param lightIndex The index of the light
  9067. * @param defines The defines to update
  9068. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9069. * @param state Defines the current state regarding what is needed (normals, etc...)
  9070. */
  9071. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9072. needNormals: boolean;
  9073. needRebuild: boolean;
  9074. shadowEnabled: boolean;
  9075. specularEnabled: boolean;
  9076. lightmapMode: boolean;
  9077. }): void;
  9078. /**
  9079. * Prepares the defines related to the light information passed in parameter
  9080. * @param scene The scene we are intending to draw
  9081. * @param mesh The mesh the effect is compiling for
  9082. * @param defines The defines to update
  9083. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9084. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9085. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9086. * @returns true if normals will be required for the rest of the effect
  9087. */
  9088. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9089. /**
  9090. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9091. * @param lightIndex defines the light index
  9092. * @param uniformsList The uniform list
  9093. * @param samplersList The sampler list
  9094. * @param projectedLightTexture defines if projected texture must be used
  9095. * @param uniformBuffersList defines an optional list of uniform buffers
  9096. */
  9097. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9098. /**
  9099. * Prepares the uniforms and samplers list to be used in the effect
  9100. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9101. * @param samplersList The sampler list
  9102. * @param defines The defines helping in the list generation
  9103. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9104. */
  9105. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9106. /**
  9107. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9108. * @param defines The defines to update while falling back
  9109. * @param fallbacks The authorized effect fallbacks
  9110. * @param maxSimultaneousLights The maximum number of lights allowed
  9111. * @param rank the current rank of the Effect
  9112. * @returns The newly affected rank
  9113. */
  9114. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9115. private static _TmpMorphInfluencers;
  9116. /**
  9117. * Prepares the list of attributes required for morph targets according to the effect defines.
  9118. * @param attribs The current list of supported attribs
  9119. * @param mesh The mesh to prepare the morph targets attributes for
  9120. * @param influencers The number of influencers
  9121. */
  9122. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9123. /**
  9124. * Prepares the list of attributes required for morph targets according to the effect defines.
  9125. * @param attribs The current list of supported attribs
  9126. * @param mesh The mesh to prepare the morph targets attributes for
  9127. * @param defines The current Defines of the effect
  9128. */
  9129. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9130. /**
  9131. * Prepares the list of attributes required for bones according to the effect defines.
  9132. * @param attribs The current list of supported attribs
  9133. * @param mesh The mesh to prepare the bones attributes for
  9134. * @param defines The current Defines of the effect
  9135. * @param fallbacks The current efffect fallback strategy
  9136. */
  9137. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9138. /**
  9139. * Check and prepare the list of attributes required for instances according to the effect defines.
  9140. * @param attribs The current list of supported attribs
  9141. * @param defines The current MaterialDefines of the effect
  9142. */
  9143. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9144. /**
  9145. * Add the list of attributes required for instances to the attribs array.
  9146. * @param attribs The current list of supported attribs
  9147. */
  9148. static PushAttributesForInstances(attribs: string[]): void;
  9149. /**
  9150. * Binds the light information to the effect.
  9151. * @param light The light containing the generator
  9152. * @param effect The effect we are binding the data to
  9153. * @param lightIndex The light index in the effect used to render
  9154. */
  9155. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9156. /**
  9157. * Binds the lights information from the scene to the effect for the given mesh.
  9158. * @param light Light to bind
  9159. * @param lightIndex Light index
  9160. * @param scene The scene where the light belongs to
  9161. * @param effect The effect we are binding the data to
  9162. * @param useSpecular Defines if specular is supported
  9163. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9164. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9165. */
  9166. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9167. /**
  9168. * Binds the lights information from the scene to the effect for the given mesh.
  9169. * @param scene The scene the lights belongs to
  9170. * @param mesh The mesh we are binding the information to render
  9171. * @param effect The effect we are binding the data to
  9172. * @param defines The generated defines for the effect
  9173. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9174. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9175. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9176. */
  9177. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9178. private static _tempFogColor;
  9179. /**
  9180. * Binds the fog information from the scene to the effect for the given mesh.
  9181. * @param scene The scene the lights belongs to
  9182. * @param mesh The mesh we are binding the information to render
  9183. * @param effect The effect we are binding the data to
  9184. * @param linearSpace Defines if the fog effect is applied in linear space
  9185. */
  9186. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9187. /**
  9188. * Binds the bones information from the mesh to the effect.
  9189. * @param mesh The mesh we are binding the information to render
  9190. * @param effect The effect we are binding the data to
  9191. */
  9192. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9193. /**
  9194. * Binds the morph targets information from the mesh to the effect.
  9195. * @param abstractMesh The mesh we are binding the information to render
  9196. * @param effect The effect we are binding the data to
  9197. */
  9198. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9199. /**
  9200. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9201. * @param defines The generated defines used in the effect
  9202. * @param effect The effect we are binding the data to
  9203. * @param scene The scene we are willing to render with logarithmic scale for
  9204. */
  9205. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9206. /**
  9207. * Binds the clip plane information from the scene to the effect.
  9208. * @param scene The scene the clip plane information are extracted from
  9209. * @param effect The effect we are binding the data to
  9210. */
  9211. static BindClipPlane(effect: Effect, scene: Scene): void;
  9212. }
  9213. }
  9214. declare module BABYLON {
  9215. /** @hidden */
  9216. export var packingFunctions: {
  9217. name: string;
  9218. shader: string;
  9219. };
  9220. }
  9221. declare module BABYLON {
  9222. /** @hidden */
  9223. export var shadowMapPixelShader: {
  9224. name: string;
  9225. shader: string;
  9226. };
  9227. }
  9228. declare module BABYLON {
  9229. /** @hidden */
  9230. export var bonesDeclaration: {
  9231. name: string;
  9232. shader: string;
  9233. };
  9234. }
  9235. declare module BABYLON {
  9236. /** @hidden */
  9237. export var morphTargetsVertexGlobalDeclaration: {
  9238. name: string;
  9239. shader: string;
  9240. };
  9241. }
  9242. declare module BABYLON {
  9243. /** @hidden */
  9244. export var morphTargetsVertexDeclaration: {
  9245. name: string;
  9246. shader: string;
  9247. };
  9248. }
  9249. declare module BABYLON {
  9250. /** @hidden */
  9251. export var instancesDeclaration: {
  9252. name: string;
  9253. shader: string;
  9254. };
  9255. }
  9256. declare module BABYLON {
  9257. /** @hidden */
  9258. export var helperFunctions: {
  9259. name: string;
  9260. shader: string;
  9261. };
  9262. }
  9263. declare module BABYLON {
  9264. /** @hidden */
  9265. export var morphTargetsVertex: {
  9266. name: string;
  9267. shader: string;
  9268. };
  9269. }
  9270. declare module BABYLON {
  9271. /** @hidden */
  9272. export var instancesVertex: {
  9273. name: string;
  9274. shader: string;
  9275. };
  9276. }
  9277. declare module BABYLON {
  9278. /** @hidden */
  9279. export var bonesVertex: {
  9280. name: string;
  9281. shader: string;
  9282. };
  9283. }
  9284. declare module BABYLON {
  9285. /** @hidden */
  9286. export var shadowMapVertexShader: {
  9287. name: string;
  9288. shader: string;
  9289. };
  9290. }
  9291. declare module BABYLON {
  9292. /** @hidden */
  9293. export var depthBoxBlurPixelShader: {
  9294. name: string;
  9295. shader: string;
  9296. };
  9297. }
  9298. declare module BABYLON {
  9299. /**
  9300. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9301. */
  9302. export interface ICustomShaderOptions {
  9303. /**
  9304. * Gets or sets the custom shader name to use
  9305. */
  9306. shaderName: string;
  9307. /**
  9308. * The list of attribute names used in the shader
  9309. */
  9310. attributes?: string[];
  9311. /**
  9312. * The list of unifrom names used in the shader
  9313. */
  9314. uniforms?: string[];
  9315. /**
  9316. * The list of sampler names used in the shader
  9317. */
  9318. samplers?: string[];
  9319. /**
  9320. * The list of defines used in the shader
  9321. */
  9322. defines?: string[];
  9323. }
  9324. /**
  9325. * Interface to implement to create a shadow generator compatible with BJS.
  9326. */
  9327. export interface IShadowGenerator {
  9328. /**
  9329. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9330. * @returns The render target texture if present otherwise, null
  9331. */
  9332. getShadowMap(): Nullable<RenderTargetTexture>;
  9333. /**
  9334. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9335. * @returns The render target texture if the shadow map is present otherwise, null
  9336. */
  9337. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9338. /**
  9339. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9340. * @param subMesh The submesh we want to render in the shadow map
  9341. * @param useInstances Defines wether will draw in the map using instances
  9342. * @returns true if ready otherwise, false
  9343. */
  9344. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9345. /**
  9346. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9347. * @param defines Defines of the material we want to update
  9348. * @param lightIndex Index of the light in the enabled light list of the material
  9349. */
  9350. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9351. /**
  9352. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9353. * defined in the generator but impacting the effect).
  9354. * It implies the unifroms available on the materials are the standard BJS ones.
  9355. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9356. * @param effect The effect we are binfing the information for
  9357. */
  9358. bindShadowLight(lightIndex: string, effect: Effect): void;
  9359. /**
  9360. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9361. * (eq to shadow prjection matrix * light transform matrix)
  9362. * @returns The transform matrix used to create the shadow map
  9363. */
  9364. getTransformMatrix(): Matrix;
  9365. /**
  9366. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9367. * Cube and 2D textures for instance.
  9368. */
  9369. recreateShadowMap(): void;
  9370. /**
  9371. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9372. * @param onCompiled Callback triggered at the and of the effects compilation
  9373. * @param options Sets of optional options forcing the compilation with different modes
  9374. */
  9375. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9376. useInstances: boolean;
  9377. }>): void;
  9378. /**
  9379. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9380. * @param options Sets of optional options forcing the compilation with different modes
  9381. * @returns A promise that resolves when the compilation completes
  9382. */
  9383. forceCompilationAsync(options?: Partial<{
  9384. useInstances: boolean;
  9385. }>): Promise<void>;
  9386. /**
  9387. * Serializes the shadow generator setup to a json object.
  9388. * @returns The serialized JSON object
  9389. */
  9390. serialize(): any;
  9391. /**
  9392. * Disposes the Shadow map and related Textures and effects.
  9393. */
  9394. dispose(): void;
  9395. }
  9396. /**
  9397. * Default implementation IShadowGenerator.
  9398. * This is the main object responsible of generating shadows in the framework.
  9399. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9400. */
  9401. export class ShadowGenerator implements IShadowGenerator {
  9402. /**
  9403. * Shadow generator mode None: no filtering applied.
  9404. */
  9405. static readonly FILTER_NONE: number;
  9406. /**
  9407. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9408. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9409. */
  9410. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9411. /**
  9412. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9413. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9414. */
  9415. static readonly FILTER_POISSONSAMPLING: number;
  9416. /**
  9417. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9418. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9419. */
  9420. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9421. /**
  9422. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9423. * edge artifacts on steep falloff.
  9424. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9425. */
  9426. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9427. /**
  9428. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9429. * edge artifacts on steep falloff.
  9430. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9431. */
  9432. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9433. /**
  9434. * Shadow generator mode PCF: Percentage Closer Filtering
  9435. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9436. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9437. */
  9438. static readonly FILTER_PCF: number;
  9439. /**
  9440. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9441. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9442. * Contact Hardening
  9443. */
  9444. static readonly FILTER_PCSS: number;
  9445. /**
  9446. * Reserved for PCF and PCSS
  9447. * Highest Quality.
  9448. *
  9449. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9450. *
  9451. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9452. */
  9453. static readonly QUALITY_HIGH: number;
  9454. /**
  9455. * Reserved for PCF and PCSS
  9456. * Good tradeoff for quality/perf cross devices
  9457. *
  9458. * Execute PCF on a 3*3 kernel.
  9459. *
  9460. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9461. */
  9462. static readonly QUALITY_MEDIUM: number;
  9463. /**
  9464. * Reserved for PCF and PCSS
  9465. * The lowest quality but the fastest.
  9466. *
  9467. * Execute PCF on a 1*1 kernel.
  9468. *
  9469. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9470. */
  9471. static readonly QUALITY_LOW: number;
  9472. /** Gets or sets the custom shader name to use */
  9473. customShaderOptions: ICustomShaderOptions;
  9474. /**
  9475. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9476. */
  9477. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9478. /**
  9479. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9480. */
  9481. onAfterShadowMapRenderObservable: Observable<Effect>;
  9482. /**
  9483. * Observable triggered before a mesh is rendered in the shadow map.
  9484. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9485. */
  9486. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9487. /**
  9488. * Observable triggered after a mesh is rendered in the shadow map.
  9489. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9490. */
  9491. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9492. private _bias;
  9493. /**
  9494. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9495. */
  9496. /**
  9497. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9498. */
  9499. bias: number;
  9500. private _normalBias;
  9501. /**
  9502. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9503. */
  9504. /**
  9505. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9506. */
  9507. normalBias: number;
  9508. private _blurBoxOffset;
  9509. /**
  9510. * Gets the blur box offset: offset applied during the blur pass.
  9511. * Only useful if useKernelBlur = false
  9512. */
  9513. /**
  9514. * Sets the blur box offset: offset applied during the blur pass.
  9515. * Only useful if useKernelBlur = false
  9516. */
  9517. blurBoxOffset: number;
  9518. private _blurScale;
  9519. /**
  9520. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9521. * 2 means half of the size.
  9522. */
  9523. /**
  9524. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9525. * 2 means half of the size.
  9526. */
  9527. blurScale: number;
  9528. private _blurKernel;
  9529. /**
  9530. * Gets the blur kernel: kernel size of the blur pass.
  9531. * Only useful if useKernelBlur = true
  9532. */
  9533. /**
  9534. * Sets the blur kernel: kernel size of the blur pass.
  9535. * Only useful if useKernelBlur = true
  9536. */
  9537. blurKernel: number;
  9538. private _useKernelBlur;
  9539. /**
  9540. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9541. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9542. */
  9543. /**
  9544. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9545. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9546. */
  9547. useKernelBlur: boolean;
  9548. private _depthScale;
  9549. /**
  9550. * Gets the depth scale used in ESM mode.
  9551. */
  9552. /**
  9553. * Sets the depth scale used in ESM mode.
  9554. * This can override the scale stored on the light.
  9555. */
  9556. depthScale: number;
  9557. private _filter;
  9558. /**
  9559. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9560. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9561. */
  9562. /**
  9563. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9564. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9565. */
  9566. filter: number;
  9567. /**
  9568. * Gets if the current filter is set to Poisson Sampling.
  9569. */
  9570. /**
  9571. * Sets the current filter to Poisson Sampling.
  9572. */
  9573. usePoissonSampling: boolean;
  9574. /**
  9575. * Gets if the current filter is set to ESM.
  9576. */
  9577. /**
  9578. * Sets the current filter is to ESM.
  9579. */
  9580. useExponentialShadowMap: boolean;
  9581. /**
  9582. * Gets if the current filter is set to filtered ESM.
  9583. */
  9584. /**
  9585. * Gets if the current filter is set to filtered ESM.
  9586. */
  9587. useBlurExponentialShadowMap: boolean;
  9588. /**
  9589. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9590. * exponential to prevent steep falloff artifacts).
  9591. */
  9592. /**
  9593. * Sets the current filter to "close ESM" (using the inverse of the
  9594. * exponential to prevent steep falloff artifacts).
  9595. */
  9596. useCloseExponentialShadowMap: boolean;
  9597. /**
  9598. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9599. * exponential to prevent steep falloff artifacts).
  9600. */
  9601. /**
  9602. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9603. * exponential to prevent steep falloff artifacts).
  9604. */
  9605. useBlurCloseExponentialShadowMap: boolean;
  9606. /**
  9607. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9608. */
  9609. /**
  9610. * Sets the current filter to "PCF" (percentage closer filtering).
  9611. */
  9612. usePercentageCloserFiltering: boolean;
  9613. private _filteringQuality;
  9614. /**
  9615. * Gets the PCF or PCSS Quality.
  9616. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9617. */
  9618. /**
  9619. * Sets the PCF or PCSS Quality.
  9620. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9621. */
  9622. filteringQuality: number;
  9623. /**
  9624. * Gets if the current filter is set to "PCSS" (contact hardening).
  9625. */
  9626. /**
  9627. * Sets the current filter to "PCSS" (contact hardening).
  9628. */
  9629. useContactHardeningShadow: boolean;
  9630. private _contactHardeningLightSizeUVRatio;
  9631. /**
  9632. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9633. * Using a ratio helps keeping shape stability independently of the map size.
  9634. *
  9635. * It does not account for the light projection as it was having too much
  9636. * instability during the light setup or during light position changes.
  9637. *
  9638. * Only valid if useContactHardeningShadow is true.
  9639. */
  9640. /**
  9641. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9642. * Using a ratio helps keeping shape stability independently of the map size.
  9643. *
  9644. * It does not account for the light projection as it was having too much
  9645. * instability during the light setup or during light position changes.
  9646. *
  9647. * Only valid if useContactHardeningShadow is true.
  9648. */
  9649. contactHardeningLightSizeUVRatio: number;
  9650. private _darkness;
  9651. /** Gets or sets the actual darkness of a shadow */
  9652. darkness: number;
  9653. /**
  9654. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9655. * 0 means strongest and 1 would means no shadow.
  9656. * @returns the darkness.
  9657. */
  9658. getDarkness(): number;
  9659. /**
  9660. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9661. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9662. * @returns the shadow generator allowing fluent coding.
  9663. */
  9664. setDarkness(darkness: number): ShadowGenerator;
  9665. private _transparencyShadow;
  9666. /** Gets or sets the ability to have transparent shadow */
  9667. transparencyShadow: boolean;
  9668. /**
  9669. * Sets the ability to have transparent shadow (boolean).
  9670. * @param transparent True if transparent else False
  9671. * @returns the shadow generator allowing fluent coding
  9672. */
  9673. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9674. private _shadowMap;
  9675. private _shadowMap2;
  9676. /**
  9677. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9678. * @returns The render target texture if present otherwise, null
  9679. */
  9680. getShadowMap(): Nullable<RenderTargetTexture>;
  9681. /**
  9682. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9683. * @returns The render target texture if the shadow map is present otherwise, null
  9684. */
  9685. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9686. /**
  9687. * Gets the class name of that object
  9688. * @returns "ShadowGenerator"
  9689. */
  9690. getClassName(): string;
  9691. /**
  9692. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9693. * @param mesh Mesh to add
  9694. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9695. * @returns the Shadow Generator itself
  9696. */
  9697. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9698. /**
  9699. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9700. * @param mesh Mesh to remove
  9701. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9702. * @returns the Shadow Generator itself
  9703. */
  9704. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9705. /**
  9706. * Controls the extent to which the shadows fade out at the edge of the frustum
  9707. * Used only by directionals and spots
  9708. */
  9709. frustumEdgeFalloff: number;
  9710. private _light;
  9711. /**
  9712. * Returns the associated light object.
  9713. * @returns the light generating the shadow
  9714. */
  9715. getLight(): IShadowLight;
  9716. /**
  9717. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9718. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9719. * It might on the other hand introduce peter panning.
  9720. */
  9721. forceBackFacesOnly: boolean;
  9722. private _scene;
  9723. private _lightDirection;
  9724. private _effect;
  9725. private _viewMatrix;
  9726. private _projectionMatrix;
  9727. private _transformMatrix;
  9728. private _cachedPosition;
  9729. private _cachedDirection;
  9730. private _cachedDefines;
  9731. private _currentRenderID;
  9732. private _boxBlurPostprocess;
  9733. private _kernelBlurXPostprocess;
  9734. private _kernelBlurYPostprocess;
  9735. private _blurPostProcesses;
  9736. private _mapSize;
  9737. private _currentFaceIndex;
  9738. private _currentFaceIndexCache;
  9739. private _textureType;
  9740. private _defaultTextureMatrix;
  9741. private _storedUniqueId;
  9742. /** @hidden */
  9743. static _SceneComponentInitialization: (scene: Scene) => void;
  9744. /**
  9745. * Creates a ShadowGenerator object.
  9746. * A ShadowGenerator is the required tool to use the shadows.
  9747. * Each light casting shadows needs to use its own ShadowGenerator.
  9748. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9749. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9750. * @param light The light object generating the shadows.
  9751. * @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.
  9752. */
  9753. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9754. private _initializeGenerator;
  9755. private _initializeShadowMap;
  9756. private _initializeBlurRTTAndPostProcesses;
  9757. private _renderForShadowMap;
  9758. private _renderSubMeshForShadowMap;
  9759. private _applyFilterValues;
  9760. /**
  9761. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9762. * @param onCompiled Callback triggered at the and of the effects compilation
  9763. * @param options Sets of optional options forcing the compilation with different modes
  9764. */
  9765. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9766. useInstances: boolean;
  9767. }>): void;
  9768. /**
  9769. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9770. * @param options Sets of optional options forcing the compilation with different modes
  9771. * @returns A promise that resolves when the compilation completes
  9772. */
  9773. forceCompilationAsync(options?: Partial<{
  9774. useInstances: boolean;
  9775. }>): Promise<void>;
  9776. /**
  9777. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9778. * @param subMesh The submesh we want to render in the shadow map
  9779. * @param useInstances Defines wether will draw in the map using instances
  9780. * @returns true if ready otherwise, false
  9781. */
  9782. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9783. /**
  9784. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9785. * @param defines Defines of the material we want to update
  9786. * @param lightIndex Index of the light in the enabled light list of the material
  9787. */
  9788. prepareDefines(defines: any, lightIndex: number): void;
  9789. /**
  9790. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9791. * defined in the generator but impacting the effect).
  9792. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9793. * @param effect The effect we are binfing the information for
  9794. */
  9795. bindShadowLight(lightIndex: string, effect: Effect): void;
  9796. /**
  9797. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9798. * (eq to shadow prjection matrix * light transform matrix)
  9799. * @returns The transform matrix used to create the shadow map
  9800. */
  9801. getTransformMatrix(): Matrix;
  9802. /**
  9803. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9804. * Cube and 2D textures for instance.
  9805. */
  9806. recreateShadowMap(): void;
  9807. private _disposeBlurPostProcesses;
  9808. private _disposeRTTandPostProcesses;
  9809. /**
  9810. * Disposes the ShadowGenerator.
  9811. * Returns nothing.
  9812. */
  9813. dispose(): void;
  9814. /**
  9815. * Serializes the shadow generator setup to a json object.
  9816. * @returns The serialized JSON object
  9817. */
  9818. serialize(): any;
  9819. /**
  9820. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9821. * @param parsedShadowGenerator The JSON object to parse
  9822. * @param scene The scene to create the shadow map for
  9823. * @returns The parsed shadow generator
  9824. */
  9825. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9826. }
  9827. }
  9828. declare module BABYLON {
  9829. /**
  9830. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9831. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9832. * 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.
  9833. */
  9834. export abstract class Light extends Node {
  9835. /**
  9836. * Falloff Default: light is falling off following the material specification:
  9837. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9838. */
  9839. static readonly FALLOFF_DEFAULT: number;
  9840. /**
  9841. * Falloff Physical: light is falling off following the inverse squared distance law.
  9842. */
  9843. static readonly FALLOFF_PHYSICAL: number;
  9844. /**
  9845. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9846. * to enhance interoperability with other engines.
  9847. */
  9848. static readonly FALLOFF_GLTF: number;
  9849. /**
  9850. * Falloff Standard: light is falling off like in the standard material
  9851. * to enhance interoperability with other materials.
  9852. */
  9853. static readonly FALLOFF_STANDARD: number;
  9854. /**
  9855. * If every light affecting the material is in this lightmapMode,
  9856. * material.lightmapTexture adds or multiplies
  9857. * (depends on material.useLightmapAsShadowmap)
  9858. * after every other light calculations.
  9859. */
  9860. static readonly LIGHTMAP_DEFAULT: number;
  9861. /**
  9862. * material.lightmapTexture as only diffuse lighting from this light
  9863. * adds only specular lighting from this light
  9864. * adds dynamic shadows
  9865. */
  9866. static readonly LIGHTMAP_SPECULAR: number;
  9867. /**
  9868. * material.lightmapTexture as only lighting
  9869. * no light calculation from this light
  9870. * only adds dynamic shadows from this light
  9871. */
  9872. static readonly LIGHTMAP_SHADOWSONLY: number;
  9873. /**
  9874. * Each light type uses the default quantity according to its type:
  9875. * point/spot lights use luminous intensity
  9876. * directional lights use illuminance
  9877. */
  9878. static readonly INTENSITYMODE_AUTOMATIC: number;
  9879. /**
  9880. * lumen (lm)
  9881. */
  9882. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9883. /**
  9884. * candela (lm/sr)
  9885. */
  9886. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9887. /**
  9888. * lux (lm/m^2)
  9889. */
  9890. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9891. /**
  9892. * nit (cd/m^2)
  9893. */
  9894. static readonly INTENSITYMODE_LUMINANCE: number;
  9895. /**
  9896. * Light type const id of the point light.
  9897. */
  9898. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9899. /**
  9900. * Light type const id of the directional light.
  9901. */
  9902. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9903. /**
  9904. * Light type const id of the spot light.
  9905. */
  9906. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9907. /**
  9908. * Light type const id of the hemispheric light.
  9909. */
  9910. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9911. /**
  9912. * Diffuse gives the basic color to an object.
  9913. */
  9914. diffuse: Color3;
  9915. /**
  9916. * Specular produces a highlight color on an object.
  9917. * Note: This is note affecting PBR materials.
  9918. */
  9919. specular: Color3;
  9920. /**
  9921. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9922. * falling off base on range or angle.
  9923. * This can be set to any values in Light.FALLOFF_x.
  9924. *
  9925. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9926. * other types of materials.
  9927. */
  9928. falloffType: number;
  9929. /**
  9930. * Strength of the light.
  9931. * Note: By default it is define in the framework own unit.
  9932. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9933. */
  9934. intensity: number;
  9935. private _range;
  9936. protected _inverseSquaredRange: number;
  9937. /**
  9938. * Defines how far from the source the light is impacting in scene units.
  9939. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9940. */
  9941. /**
  9942. * Defines how far from the source the light is impacting in scene units.
  9943. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9944. */
  9945. range: number;
  9946. /**
  9947. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9948. * of light.
  9949. */
  9950. private _photometricScale;
  9951. private _intensityMode;
  9952. /**
  9953. * Gets the photometric scale used to interpret the intensity.
  9954. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9955. */
  9956. /**
  9957. * Sets the photometric scale used to interpret the intensity.
  9958. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9959. */
  9960. intensityMode: number;
  9961. private _radius;
  9962. /**
  9963. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9964. */
  9965. /**
  9966. * sets the light radius used by PBR Materials to simulate soft area lights.
  9967. */
  9968. radius: number;
  9969. private _renderPriority;
  9970. /**
  9971. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9972. * exceeding the number allowed of the materials.
  9973. */
  9974. renderPriority: number;
  9975. private _shadowEnabled;
  9976. /**
  9977. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9978. * the current shadow generator.
  9979. */
  9980. /**
  9981. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9982. * the current shadow generator.
  9983. */
  9984. shadowEnabled: boolean;
  9985. private _includedOnlyMeshes;
  9986. /**
  9987. * Gets the only meshes impacted by this light.
  9988. */
  9989. /**
  9990. * Sets the only meshes impacted by this light.
  9991. */
  9992. includedOnlyMeshes: AbstractMesh[];
  9993. private _excludedMeshes;
  9994. /**
  9995. * Gets the meshes not impacted by this light.
  9996. */
  9997. /**
  9998. * Sets the meshes not impacted by this light.
  9999. */
  10000. excludedMeshes: AbstractMesh[];
  10001. private _excludeWithLayerMask;
  10002. /**
  10003. * Gets the layer id use to find what meshes are not impacted by the light.
  10004. * Inactive if 0
  10005. */
  10006. /**
  10007. * Sets the layer id use to find what meshes are not impacted by the light.
  10008. * Inactive if 0
  10009. */
  10010. excludeWithLayerMask: number;
  10011. private _includeOnlyWithLayerMask;
  10012. /**
  10013. * Gets the layer id use to find what meshes are impacted by the light.
  10014. * Inactive if 0
  10015. */
  10016. /**
  10017. * Sets the layer id use to find what meshes are impacted by the light.
  10018. * Inactive if 0
  10019. */
  10020. includeOnlyWithLayerMask: number;
  10021. private _lightmapMode;
  10022. /**
  10023. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10024. */
  10025. /**
  10026. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10027. */
  10028. lightmapMode: number;
  10029. /**
  10030. * Shadow generator associted to the light.
  10031. * @hidden Internal use only.
  10032. */
  10033. _shadowGenerator: Nullable<IShadowGenerator>;
  10034. /**
  10035. * @hidden Internal use only.
  10036. */
  10037. _excludedMeshesIds: string[];
  10038. /**
  10039. * @hidden Internal use only.
  10040. */
  10041. _includedOnlyMeshesIds: string[];
  10042. /**
  10043. * The current light unifom buffer.
  10044. * @hidden Internal use only.
  10045. */
  10046. _uniformBuffer: UniformBuffer;
  10047. /** @hidden */
  10048. _renderId: number;
  10049. /**
  10050. * Creates a Light object in the scene.
  10051. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10052. * @param name The firendly name of the light
  10053. * @param scene The scene the light belongs too
  10054. */
  10055. constructor(name: string, scene: Scene);
  10056. protected abstract _buildUniformLayout(): void;
  10057. /**
  10058. * Sets the passed Effect "effect" with the Light information.
  10059. * @param effect The effect to update
  10060. * @param lightIndex The index of the light in the effect to update
  10061. * @returns The light
  10062. */
  10063. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10064. /**
  10065. * Sets the passed Effect "effect" with the Light textures.
  10066. * @param effect The effect to update
  10067. * @param lightIndex The index of the light in the effect to update
  10068. * @returns The light
  10069. */
  10070. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  10071. /**
  10072. * Binds the lights information from the scene to the effect for the given mesh.
  10073. * @param lightIndex Light index
  10074. * @param scene The scene where the light belongs to
  10075. * @param effect The effect we are binding the data to
  10076. * @param useSpecular Defines if specular is supported
  10077. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  10078. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  10079. */
  10080. bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  10081. /**
  10082. * Sets the passed Effect "effect" with the Light information.
  10083. * @param effect The effect to update
  10084. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10085. * @returns The light
  10086. */
  10087. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10088. /**
  10089. * Returns the string "Light".
  10090. * @returns the class name
  10091. */
  10092. getClassName(): string;
  10093. /** @hidden */
  10094. readonly _isLight: boolean;
  10095. /**
  10096. * Converts the light information to a readable string for debug purpose.
  10097. * @param fullDetails Supports for multiple levels of logging within scene loading
  10098. * @returns the human readable light info
  10099. */
  10100. toString(fullDetails?: boolean): string;
  10101. /** @hidden */
  10102. protected _syncParentEnabledState(): void;
  10103. /**
  10104. * Set the enabled state of this node.
  10105. * @param value - the new enabled state
  10106. */
  10107. setEnabled(value: boolean): void;
  10108. /**
  10109. * Returns the Light associated shadow generator if any.
  10110. * @return the associated shadow generator.
  10111. */
  10112. getShadowGenerator(): Nullable<IShadowGenerator>;
  10113. /**
  10114. * Returns a Vector3, the absolute light position in the World.
  10115. * @returns the world space position of the light
  10116. */
  10117. getAbsolutePosition(): Vector3;
  10118. /**
  10119. * Specifies if the light will affect the passed mesh.
  10120. * @param mesh The mesh to test against the light
  10121. * @return true the mesh is affected otherwise, false.
  10122. */
  10123. canAffectMesh(mesh: AbstractMesh): boolean;
  10124. /**
  10125. * Sort function to order lights for rendering.
  10126. * @param a First Light object to compare to second.
  10127. * @param b Second Light object to compare first.
  10128. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10129. */
  10130. static CompareLightsPriority(a: Light, b: Light): number;
  10131. /**
  10132. * Releases resources associated with this node.
  10133. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10134. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10135. */
  10136. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10137. /**
  10138. * Returns the light type ID (integer).
  10139. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10140. */
  10141. getTypeID(): number;
  10142. /**
  10143. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10144. * @returns the scaled intensity in intensity mode unit
  10145. */
  10146. getScaledIntensity(): number;
  10147. /**
  10148. * Returns a new Light object, named "name", from the current one.
  10149. * @param name The name of the cloned light
  10150. * @returns the new created light
  10151. */
  10152. clone(name: string): Nullable<Light>;
  10153. /**
  10154. * Serializes the current light into a Serialization object.
  10155. * @returns the serialized object.
  10156. */
  10157. serialize(): any;
  10158. /**
  10159. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10160. * This new light is named "name" and added to the passed scene.
  10161. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10162. * @param name The friendly name of the light
  10163. * @param scene The scene the new light will belong to
  10164. * @returns the constructor function
  10165. */
  10166. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10167. /**
  10168. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10169. * @param parsedLight The JSON representation of the light
  10170. * @param scene The scene to create the parsed light in
  10171. * @returns the created light after parsing
  10172. */
  10173. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10174. private _hookArrayForExcluded;
  10175. private _hookArrayForIncludedOnly;
  10176. private _resyncMeshes;
  10177. /**
  10178. * Forces the meshes to update their light related information in their rendering used effects
  10179. * @hidden Internal Use Only
  10180. */
  10181. _markMeshesAsLightDirty(): void;
  10182. /**
  10183. * Recomputes the cached photometric scale if needed.
  10184. */
  10185. private _computePhotometricScale;
  10186. /**
  10187. * Returns the Photometric Scale according to the light type and intensity mode.
  10188. */
  10189. private _getPhotometricScale;
  10190. /**
  10191. * Reorder the light in the scene according to their defined priority.
  10192. * @hidden Internal Use Only
  10193. */
  10194. _reorderLightsInScene(): void;
  10195. /**
  10196. * Prepares the list of defines specific to the light type.
  10197. * @param defines the list of defines
  10198. * @param lightIndex defines the index of the light for the effect
  10199. */
  10200. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10201. }
  10202. }
  10203. declare module BABYLON {
  10204. /**
  10205. * Interface used to define Action
  10206. */
  10207. export interface IAction {
  10208. /**
  10209. * Trigger for the action
  10210. */
  10211. trigger: number;
  10212. /** Options of the trigger */
  10213. triggerOptions: any;
  10214. /**
  10215. * Gets the trigger parameters
  10216. * @returns the trigger parameters
  10217. */
  10218. getTriggerParameter(): any;
  10219. /**
  10220. * Internal only - executes current action event
  10221. * @hidden
  10222. */
  10223. _executeCurrent(evt?: ActionEvent): void;
  10224. /**
  10225. * Serialize placeholder for child classes
  10226. * @param parent of child
  10227. * @returns the serialized object
  10228. */
  10229. serialize(parent: any): any;
  10230. /**
  10231. * Internal only
  10232. * @hidden
  10233. */
  10234. _prepare(): void;
  10235. /**
  10236. * Internal only - manager for action
  10237. * @hidden
  10238. */
  10239. _actionManager: AbstractActionManager;
  10240. /**
  10241. * Adds action to chain of actions, may be a DoNothingAction
  10242. * @param action defines the next action to execute
  10243. * @returns The action passed in
  10244. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10245. */
  10246. then(action: IAction): IAction;
  10247. }
  10248. /**
  10249. * The action to be carried out following a trigger
  10250. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10251. */
  10252. export class Action implements IAction {
  10253. /** the trigger, with or without parameters, for the action */
  10254. triggerOptions: any;
  10255. /**
  10256. * Trigger for the action
  10257. */
  10258. trigger: number;
  10259. /**
  10260. * Internal only - manager for action
  10261. * @hidden
  10262. */
  10263. _actionManager: ActionManager;
  10264. private _nextActiveAction;
  10265. private _child;
  10266. private _condition?;
  10267. private _triggerParameter;
  10268. /**
  10269. * An event triggered prior to action being executed.
  10270. */
  10271. onBeforeExecuteObservable: Observable<Action>;
  10272. /**
  10273. * Creates a new Action
  10274. * @param triggerOptions the trigger, with or without parameters, for the action
  10275. * @param condition an optional determinant of action
  10276. */
  10277. constructor(
  10278. /** the trigger, with or without parameters, for the action */
  10279. triggerOptions: any, condition?: Condition);
  10280. /**
  10281. * Internal only
  10282. * @hidden
  10283. */
  10284. _prepare(): void;
  10285. /**
  10286. * Gets the trigger parameters
  10287. * @returns the trigger parameters
  10288. */
  10289. getTriggerParameter(): any;
  10290. /**
  10291. * Internal only - executes current action event
  10292. * @hidden
  10293. */
  10294. _executeCurrent(evt?: ActionEvent): void;
  10295. /**
  10296. * Execute placeholder for child classes
  10297. * @param evt optional action event
  10298. */
  10299. execute(evt?: ActionEvent): void;
  10300. /**
  10301. * Skips to next active action
  10302. */
  10303. skipToNextActiveAction(): void;
  10304. /**
  10305. * Adds action to chain of actions, may be a DoNothingAction
  10306. * @param action defines the next action to execute
  10307. * @returns The action passed in
  10308. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10309. */
  10310. then(action: Action): Action;
  10311. /**
  10312. * Internal only
  10313. * @hidden
  10314. */
  10315. _getProperty(propertyPath: string): string;
  10316. /**
  10317. * Internal only
  10318. * @hidden
  10319. */
  10320. _getEffectiveTarget(target: any, propertyPath: string): any;
  10321. /**
  10322. * Serialize placeholder for child classes
  10323. * @param parent of child
  10324. * @returns the serialized object
  10325. */
  10326. serialize(parent: any): any;
  10327. /**
  10328. * Internal only called by serialize
  10329. * @hidden
  10330. */
  10331. protected _serialize(serializedAction: any, parent?: any): any;
  10332. /**
  10333. * Internal only
  10334. * @hidden
  10335. */
  10336. static _SerializeValueAsString: (value: any) => string;
  10337. /**
  10338. * Internal only
  10339. * @hidden
  10340. */
  10341. static _GetTargetProperty: (target: Node | Scene) => {
  10342. name: string;
  10343. targetType: string;
  10344. value: string;
  10345. };
  10346. }
  10347. }
  10348. declare module BABYLON {
  10349. /**
  10350. * A Condition applied to an Action
  10351. */
  10352. export class Condition {
  10353. /**
  10354. * Internal only - manager for action
  10355. * @hidden
  10356. */
  10357. _actionManager: ActionManager;
  10358. /**
  10359. * Internal only
  10360. * @hidden
  10361. */
  10362. _evaluationId: number;
  10363. /**
  10364. * Internal only
  10365. * @hidden
  10366. */
  10367. _currentResult: boolean;
  10368. /**
  10369. * Creates a new Condition
  10370. * @param actionManager the manager of the action the condition is applied to
  10371. */
  10372. constructor(actionManager: ActionManager);
  10373. /**
  10374. * Check if the current condition is valid
  10375. * @returns a boolean
  10376. */
  10377. isValid(): boolean;
  10378. /**
  10379. * Internal only
  10380. * @hidden
  10381. */
  10382. _getProperty(propertyPath: string): string;
  10383. /**
  10384. * Internal only
  10385. * @hidden
  10386. */
  10387. _getEffectiveTarget(target: any, propertyPath: string): any;
  10388. /**
  10389. * Serialize placeholder for child classes
  10390. * @returns the serialized object
  10391. */
  10392. serialize(): any;
  10393. /**
  10394. * Internal only
  10395. * @hidden
  10396. */
  10397. protected _serialize(serializedCondition: any): any;
  10398. }
  10399. /**
  10400. * Defines specific conditional operators as extensions of Condition
  10401. */
  10402. export class ValueCondition extends Condition {
  10403. /** path to specify the property of the target the conditional operator uses */
  10404. propertyPath: string;
  10405. /** the value compared by the conditional operator against the current value of the property */
  10406. value: any;
  10407. /** the conditional operator, default ValueCondition.IsEqual */
  10408. operator: number;
  10409. /**
  10410. * Internal only
  10411. * @hidden
  10412. */
  10413. private static _IsEqual;
  10414. /**
  10415. * Internal only
  10416. * @hidden
  10417. */
  10418. private static _IsDifferent;
  10419. /**
  10420. * Internal only
  10421. * @hidden
  10422. */
  10423. private static _IsGreater;
  10424. /**
  10425. * Internal only
  10426. * @hidden
  10427. */
  10428. private static _IsLesser;
  10429. /**
  10430. * returns the number for IsEqual
  10431. */
  10432. static readonly IsEqual: number;
  10433. /**
  10434. * Returns the number for IsDifferent
  10435. */
  10436. static readonly IsDifferent: number;
  10437. /**
  10438. * Returns the number for IsGreater
  10439. */
  10440. static readonly IsGreater: number;
  10441. /**
  10442. * Returns the number for IsLesser
  10443. */
  10444. static readonly IsLesser: number;
  10445. /**
  10446. * Internal only The action manager for the condition
  10447. * @hidden
  10448. */
  10449. _actionManager: ActionManager;
  10450. /**
  10451. * Internal only
  10452. * @hidden
  10453. */
  10454. private _target;
  10455. /**
  10456. * Internal only
  10457. * @hidden
  10458. */
  10459. private _effectiveTarget;
  10460. /**
  10461. * Internal only
  10462. * @hidden
  10463. */
  10464. private _property;
  10465. /**
  10466. * Creates a new ValueCondition
  10467. * @param actionManager manager for the action the condition applies to
  10468. * @param target for the action
  10469. * @param propertyPath path to specify the property of the target the conditional operator uses
  10470. * @param value the value compared by the conditional operator against the current value of the property
  10471. * @param operator the conditional operator, default ValueCondition.IsEqual
  10472. */
  10473. constructor(actionManager: ActionManager, target: any,
  10474. /** path to specify the property of the target the conditional operator uses */
  10475. propertyPath: string,
  10476. /** the value compared by the conditional operator against the current value of the property */
  10477. value: any,
  10478. /** the conditional operator, default ValueCondition.IsEqual */
  10479. operator?: number);
  10480. /**
  10481. * Compares the given value with the property value for the specified conditional operator
  10482. * @returns the result of the comparison
  10483. */
  10484. isValid(): boolean;
  10485. /**
  10486. * Serialize the ValueCondition into a JSON compatible object
  10487. * @returns serialization object
  10488. */
  10489. serialize(): any;
  10490. /**
  10491. * Gets the name of the conditional operator for the ValueCondition
  10492. * @param operator the conditional operator
  10493. * @returns the name
  10494. */
  10495. static GetOperatorName(operator: number): string;
  10496. }
  10497. /**
  10498. * Defines a predicate condition as an extension of Condition
  10499. */
  10500. export class PredicateCondition extends Condition {
  10501. /** defines the predicate function used to validate the condition */
  10502. predicate: () => boolean;
  10503. /**
  10504. * Internal only - manager for action
  10505. * @hidden
  10506. */
  10507. _actionManager: ActionManager;
  10508. /**
  10509. * Creates a new PredicateCondition
  10510. * @param actionManager manager for the action the condition applies to
  10511. * @param predicate defines the predicate function used to validate the condition
  10512. */
  10513. constructor(actionManager: ActionManager,
  10514. /** defines the predicate function used to validate the condition */
  10515. predicate: () => boolean);
  10516. /**
  10517. * @returns the validity of the predicate condition
  10518. */
  10519. isValid(): boolean;
  10520. }
  10521. /**
  10522. * Defines a state condition as an extension of Condition
  10523. */
  10524. export class StateCondition extends Condition {
  10525. /** Value to compare with target state */
  10526. value: string;
  10527. /**
  10528. * Internal only - manager for action
  10529. * @hidden
  10530. */
  10531. _actionManager: ActionManager;
  10532. /**
  10533. * Internal only
  10534. * @hidden
  10535. */
  10536. private _target;
  10537. /**
  10538. * Creates a new StateCondition
  10539. * @param actionManager manager for the action the condition applies to
  10540. * @param target of the condition
  10541. * @param value to compare with target state
  10542. */
  10543. constructor(actionManager: ActionManager, target: any,
  10544. /** Value to compare with target state */
  10545. value: string);
  10546. /**
  10547. * Gets a boolean indicating if the current condition is met
  10548. * @returns the validity of the state
  10549. */
  10550. isValid(): boolean;
  10551. /**
  10552. * Serialize the StateCondition into a JSON compatible object
  10553. * @returns serialization object
  10554. */
  10555. serialize(): any;
  10556. }
  10557. }
  10558. declare module BABYLON {
  10559. /**
  10560. * This defines an action responsible to toggle a boolean once triggered.
  10561. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10562. */
  10563. export class SwitchBooleanAction extends Action {
  10564. /**
  10565. * The path to the boolean property in the target object
  10566. */
  10567. propertyPath: string;
  10568. private _target;
  10569. private _effectiveTarget;
  10570. private _property;
  10571. /**
  10572. * Instantiate the action
  10573. * @param triggerOptions defines the trigger options
  10574. * @param target defines the object containing the boolean
  10575. * @param propertyPath defines the path to the boolean property in the target object
  10576. * @param condition defines the trigger related conditions
  10577. */
  10578. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10579. /** @hidden */
  10580. _prepare(): void;
  10581. /**
  10582. * Execute the action toggle the boolean value.
  10583. */
  10584. execute(): void;
  10585. /**
  10586. * Serializes the actions and its related information.
  10587. * @param parent defines the object to serialize in
  10588. * @returns the serialized object
  10589. */
  10590. serialize(parent: any): any;
  10591. }
  10592. /**
  10593. * This defines an action responsible to set a the state field of the target
  10594. * to a desired value once triggered.
  10595. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10596. */
  10597. export class SetStateAction extends Action {
  10598. /**
  10599. * The value to store in the state field.
  10600. */
  10601. value: string;
  10602. private _target;
  10603. /**
  10604. * Instantiate the action
  10605. * @param triggerOptions defines the trigger options
  10606. * @param target defines the object containing the state property
  10607. * @param value defines the value to store in the state field
  10608. * @param condition defines the trigger related conditions
  10609. */
  10610. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10611. /**
  10612. * Execute the action and store the value on the target state property.
  10613. */
  10614. execute(): void;
  10615. /**
  10616. * Serializes the actions and its related information.
  10617. * @param parent defines the object to serialize in
  10618. * @returns the serialized object
  10619. */
  10620. serialize(parent: any): any;
  10621. }
  10622. /**
  10623. * This defines an action responsible to set a property of the target
  10624. * to a desired value once triggered.
  10625. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10626. */
  10627. export class SetValueAction extends Action {
  10628. /**
  10629. * The path of the property to set in the target.
  10630. */
  10631. propertyPath: string;
  10632. /**
  10633. * The value to set in the property
  10634. */
  10635. value: any;
  10636. private _target;
  10637. private _effectiveTarget;
  10638. private _property;
  10639. /**
  10640. * Instantiate the action
  10641. * @param triggerOptions defines the trigger options
  10642. * @param target defines the object containing the property
  10643. * @param propertyPath defines the path of the property to set in the target
  10644. * @param value defines the value to set in the property
  10645. * @param condition defines the trigger related conditions
  10646. */
  10647. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10648. /** @hidden */
  10649. _prepare(): void;
  10650. /**
  10651. * Execute the action and set the targetted property to the desired value.
  10652. */
  10653. execute(): void;
  10654. /**
  10655. * Serializes the actions and its related information.
  10656. * @param parent defines the object to serialize in
  10657. * @returns the serialized object
  10658. */
  10659. serialize(parent: any): any;
  10660. }
  10661. /**
  10662. * This defines an action responsible to increment the target value
  10663. * to a desired value once triggered.
  10664. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10665. */
  10666. export class IncrementValueAction extends Action {
  10667. /**
  10668. * The path of the property to increment in the target.
  10669. */
  10670. propertyPath: string;
  10671. /**
  10672. * The value we should increment the property by.
  10673. */
  10674. value: any;
  10675. private _target;
  10676. private _effectiveTarget;
  10677. private _property;
  10678. /**
  10679. * Instantiate the action
  10680. * @param triggerOptions defines the trigger options
  10681. * @param target defines the object containing the property
  10682. * @param propertyPath defines the path of the property to increment in the target
  10683. * @param value defines the value value we should increment the property by
  10684. * @param condition defines the trigger related conditions
  10685. */
  10686. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10687. /** @hidden */
  10688. _prepare(): void;
  10689. /**
  10690. * Execute the action and increment the target of the value amount.
  10691. */
  10692. execute(): void;
  10693. /**
  10694. * Serializes the actions and its related information.
  10695. * @param parent defines the object to serialize in
  10696. * @returns the serialized object
  10697. */
  10698. serialize(parent: any): any;
  10699. }
  10700. /**
  10701. * This defines an action responsible to start an animation once triggered.
  10702. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10703. */
  10704. export class PlayAnimationAction extends Action {
  10705. /**
  10706. * Where the animation should start (animation frame)
  10707. */
  10708. from: number;
  10709. /**
  10710. * Where the animation should stop (animation frame)
  10711. */
  10712. to: number;
  10713. /**
  10714. * Define if the animation should loop or stop after the first play.
  10715. */
  10716. loop?: boolean;
  10717. private _target;
  10718. /**
  10719. * Instantiate the action
  10720. * @param triggerOptions defines the trigger options
  10721. * @param target defines the target animation or animation name
  10722. * @param from defines from where the animation should start (animation frame)
  10723. * @param end defines where the animation should stop (animation frame)
  10724. * @param loop defines if the animation should loop or stop after the first play
  10725. * @param condition defines the trigger related conditions
  10726. */
  10727. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10728. /** @hidden */
  10729. _prepare(): void;
  10730. /**
  10731. * Execute the action and play the animation.
  10732. */
  10733. execute(): void;
  10734. /**
  10735. * Serializes the actions and its related information.
  10736. * @param parent defines the object to serialize in
  10737. * @returns the serialized object
  10738. */
  10739. serialize(parent: any): any;
  10740. }
  10741. /**
  10742. * This defines an action responsible to stop an animation once triggered.
  10743. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10744. */
  10745. export class StopAnimationAction extends Action {
  10746. private _target;
  10747. /**
  10748. * Instantiate the action
  10749. * @param triggerOptions defines the trigger options
  10750. * @param target defines the target animation or animation name
  10751. * @param condition defines the trigger related conditions
  10752. */
  10753. constructor(triggerOptions: any, target: any, condition?: Condition);
  10754. /** @hidden */
  10755. _prepare(): void;
  10756. /**
  10757. * Execute the action and stop the animation.
  10758. */
  10759. execute(): void;
  10760. /**
  10761. * Serializes the actions and its related information.
  10762. * @param parent defines the object to serialize in
  10763. * @returns the serialized object
  10764. */
  10765. serialize(parent: any): any;
  10766. }
  10767. /**
  10768. * This defines an action responsible that does nothing once triggered.
  10769. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10770. */
  10771. export class DoNothingAction extends Action {
  10772. /**
  10773. * Instantiate the action
  10774. * @param triggerOptions defines the trigger options
  10775. * @param condition defines the trigger related conditions
  10776. */
  10777. constructor(triggerOptions?: any, condition?: Condition);
  10778. /**
  10779. * Execute the action and do nothing.
  10780. */
  10781. execute(): void;
  10782. /**
  10783. * Serializes the actions and its related information.
  10784. * @param parent defines the object to serialize in
  10785. * @returns the serialized object
  10786. */
  10787. serialize(parent: any): any;
  10788. }
  10789. /**
  10790. * This defines an action responsible to trigger several actions once triggered.
  10791. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10792. */
  10793. export class CombineAction extends Action {
  10794. /**
  10795. * The list of aggregated animations to run.
  10796. */
  10797. children: Action[];
  10798. /**
  10799. * Instantiate the action
  10800. * @param triggerOptions defines the trigger options
  10801. * @param children defines the list of aggregated animations to run
  10802. * @param condition defines the trigger related conditions
  10803. */
  10804. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10805. /** @hidden */
  10806. _prepare(): void;
  10807. /**
  10808. * Execute the action and executes all the aggregated actions.
  10809. */
  10810. execute(evt: ActionEvent): void;
  10811. /**
  10812. * Serializes the actions and its related information.
  10813. * @param parent defines the object to serialize in
  10814. * @returns the serialized object
  10815. */
  10816. serialize(parent: any): any;
  10817. }
  10818. /**
  10819. * This defines an action responsible to run code (external event) once triggered.
  10820. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10821. */
  10822. export class ExecuteCodeAction extends Action {
  10823. /**
  10824. * The callback function to run.
  10825. */
  10826. func: (evt: ActionEvent) => void;
  10827. /**
  10828. * Instantiate the action
  10829. * @param triggerOptions defines the trigger options
  10830. * @param func defines the callback function to run
  10831. * @param condition defines the trigger related conditions
  10832. */
  10833. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10834. /**
  10835. * Execute the action and run the attached code.
  10836. */
  10837. execute(evt: ActionEvent): void;
  10838. }
  10839. /**
  10840. * This defines an action responsible to set the parent property of the target once triggered.
  10841. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10842. */
  10843. export class SetParentAction extends Action {
  10844. private _parent;
  10845. private _target;
  10846. /**
  10847. * Instantiate the action
  10848. * @param triggerOptions defines the trigger options
  10849. * @param target defines the target containing the parent property
  10850. * @param parent defines from where the animation should start (animation frame)
  10851. * @param condition defines the trigger related conditions
  10852. */
  10853. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10854. /** @hidden */
  10855. _prepare(): void;
  10856. /**
  10857. * Execute the action and set the parent property.
  10858. */
  10859. execute(): void;
  10860. /**
  10861. * Serializes the actions and its related information.
  10862. * @param parent defines the object to serialize in
  10863. * @returns the serialized object
  10864. */
  10865. serialize(parent: any): any;
  10866. }
  10867. }
  10868. declare module BABYLON {
  10869. /**
  10870. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10871. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10872. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10873. */
  10874. export class ActionManager extends AbstractActionManager {
  10875. /**
  10876. * Nothing
  10877. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10878. */
  10879. static readonly NothingTrigger: number;
  10880. /**
  10881. * On pick
  10882. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10883. */
  10884. static readonly OnPickTrigger: number;
  10885. /**
  10886. * On left pick
  10887. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10888. */
  10889. static readonly OnLeftPickTrigger: number;
  10890. /**
  10891. * On right pick
  10892. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10893. */
  10894. static readonly OnRightPickTrigger: number;
  10895. /**
  10896. * On center pick
  10897. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10898. */
  10899. static readonly OnCenterPickTrigger: number;
  10900. /**
  10901. * On pick down
  10902. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10903. */
  10904. static readonly OnPickDownTrigger: number;
  10905. /**
  10906. * On double pick
  10907. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10908. */
  10909. static readonly OnDoublePickTrigger: number;
  10910. /**
  10911. * On pick up
  10912. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10913. */
  10914. static readonly OnPickUpTrigger: number;
  10915. /**
  10916. * On pick out.
  10917. * This trigger will only be raised if you also declared a OnPickDown
  10918. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10919. */
  10920. static readonly OnPickOutTrigger: number;
  10921. /**
  10922. * On long press
  10923. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10924. */
  10925. static readonly OnLongPressTrigger: number;
  10926. /**
  10927. * On pointer over
  10928. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10929. */
  10930. static readonly OnPointerOverTrigger: number;
  10931. /**
  10932. * On pointer out
  10933. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10934. */
  10935. static readonly OnPointerOutTrigger: number;
  10936. /**
  10937. * On every frame
  10938. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10939. */
  10940. static readonly OnEveryFrameTrigger: number;
  10941. /**
  10942. * On intersection enter
  10943. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10944. */
  10945. static readonly OnIntersectionEnterTrigger: number;
  10946. /**
  10947. * On intersection exit
  10948. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10949. */
  10950. static readonly OnIntersectionExitTrigger: number;
  10951. /**
  10952. * On key down
  10953. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10954. */
  10955. static readonly OnKeyDownTrigger: number;
  10956. /**
  10957. * On key up
  10958. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10959. */
  10960. static readonly OnKeyUpTrigger: number;
  10961. private _scene;
  10962. /**
  10963. * Creates a new action manager
  10964. * @param scene defines the hosting scene
  10965. */
  10966. constructor(scene: Scene);
  10967. /**
  10968. * Releases all associated resources
  10969. */
  10970. dispose(): void;
  10971. /**
  10972. * Gets hosting scene
  10973. * @returns the hosting scene
  10974. */
  10975. getScene(): Scene;
  10976. /**
  10977. * Does this action manager handles actions of any of the given triggers
  10978. * @param triggers defines the triggers to be tested
  10979. * @return a boolean indicating whether one (or more) of the triggers is handled
  10980. */
  10981. hasSpecificTriggers(triggers: number[]): boolean;
  10982. /**
  10983. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10984. * speed.
  10985. * @param triggerA defines the trigger to be tested
  10986. * @param triggerB defines the trigger to be tested
  10987. * @return a boolean indicating whether one (or more) of the triggers is handled
  10988. */
  10989. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10990. /**
  10991. * Does this action manager handles actions of a given trigger
  10992. * @param trigger defines the trigger to be tested
  10993. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10994. * @return whether the trigger is handled
  10995. */
  10996. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10997. /**
  10998. * Does this action manager has pointer triggers
  10999. */
  11000. readonly hasPointerTriggers: boolean;
  11001. /**
  11002. * Does this action manager has pick triggers
  11003. */
  11004. readonly hasPickTriggers: boolean;
  11005. /**
  11006. * Registers an action to this action manager
  11007. * @param action defines the action to be registered
  11008. * @return the action amended (prepared) after registration
  11009. */
  11010. registerAction(action: IAction): Nullable<IAction>;
  11011. /**
  11012. * Unregisters an action to this action manager
  11013. * @param action defines the action to be unregistered
  11014. * @return a boolean indicating whether the action has been unregistered
  11015. */
  11016. unregisterAction(action: IAction): Boolean;
  11017. /**
  11018. * Process a specific trigger
  11019. * @param trigger defines the trigger to process
  11020. * @param evt defines the event details to be processed
  11021. */
  11022. processTrigger(trigger: number, evt?: IActionEvent): void;
  11023. /** @hidden */
  11024. _getEffectiveTarget(target: any, propertyPath: string): any;
  11025. /** @hidden */
  11026. _getProperty(propertyPath: string): string;
  11027. /**
  11028. * Serialize this manager to a JSON object
  11029. * @param name defines the property name to store this manager
  11030. * @returns a JSON representation of this manager
  11031. */
  11032. serialize(name: string): any;
  11033. /**
  11034. * Creates a new ActionManager from a JSON data
  11035. * @param parsedActions defines the JSON data to read from
  11036. * @param object defines the hosting mesh
  11037. * @param scene defines the hosting scene
  11038. */
  11039. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11040. /**
  11041. * Get a trigger name by index
  11042. * @param trigger defines the trigger index
  11043. * @returns a trigger name
  11044. */
  11045. static GetTriggerName(trigger: number): string;
  11046. }
  11047. }
  11048. declare module BABYLON {
  11049. /**
  11050. * Class representing a ray with position and direction
  11051. */
  11052. export class Ray {
  11053. /** origin point */
  11054. origin: Vector3;
  11055. /** direction */
  11056. direction: Vector3;
  11057. /** length of the ray */
  11058. length: number;
  11059. private static readonly TmpVector3;
  11060. private _tmpRay;
  11061. /**
  11062. * Creates a new ray
  11063. * @param origin origin point
  11064. * @param direction direction
  11065. * @param length length of the ray
  11066. */
  11067. constructor(
  11068. /** origin point */
  11069. origin: Vector3,
  11070. /** direction */
  11071. direction: Vector3,
  11072. /** length of the ray */
  11073. length?: number);
  11074. /**
  11075. * Checks if the ray intersects a box
  11076. * @param minimum bound of the box
  11077. * @param maximum bound of the box
  11078. * @param intersectionTreshold extra extend to be added to the box in all direction
  11079. * @returns if the box was hit
  11080. */
  11081. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11082. /**
  11083. * Checks if the ray intersects a box
  11084. * @param box the bounding box to check
  11085. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11086. * @returns if the box was hit
  11087. */
  11088. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11089. /**
  11090. * If the ray hits a sphere
  11091. * @param sphere the bounding sphere to check
  11092. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11093. * @returns true if it hits the sphere
  11094. */
  11095. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11096. /**
  11097. * If the ray hits a triange
  11098. * @param vertex0 triangle vertex
  11099. * @param vertex1 triangle vertex
  11100. * @param vertex2 triangle vertex
  11101. * @returns intersection information if hit
  11102. */
  11103. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11104. /**
  11105. * Checks if ray intersects a plane
  11106. * @param plane the plane to check
  11107. * @returns the distance away it was hit
  11108. */
  11109. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11110. /**
  11111. * Calculate the intercept of a ray on a given axis
  11112. * @param axis to check 'x' | 'y' | 'z'
  11113. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11114. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11115. */
  11116. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11117. /**
  11118. * Checks if ray intersects a mesh
  11119. * @param mesh the mesh to check
  11120. * @param fastCheck if only the bounding box should checked
  11121. * @returns picking info of the intersecton
  11122. */
  11123. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11124. /**
  11125. * Checks if ray intersects a mesh
  11126. * @param meshes the meshes to check
  11127. * @param fastCheck if only the bounding box should checked
  11128. * @param results array to store result in
  11129. * @returns Array of picking infos
  11130. */
  11131. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11132. private _comparePickingInfo;
  11133. private static smallnum;
  11134. private static rayl;
  11135. /**
  11136. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11137. * @param sega the first point of the segment to test the intersection against
  11138. * @param segb the second point of the segment to test the intersection against
  11139. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11140. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11141. */
  11142. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11143. /**
  11144. * Update the ray from viewport position
  11145. * @param x position
  11146. * @param y y position
  11147. * @param viewportWidth viewport width
  11148. * @param viewportHeight viewport height
  11149. * @param world world matrix
  11150. * @param view view matrix
  11151. * @param projection projection matrix
  11152. * @returns this ray updated
  11153. */
  11154. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11155. /**
  11156. * Creates a ray with origin and direction of 0,0,0
  11157. * @returns the new ray
  11158. */
  11159. static Zero(): Ray;
  11160. /**
  11161. * Creates a new ray from screen space and viewport
  11162. * @param x position
  11163. * @param y y position
  11164. * @param viewportWidth viewport width
  11165. * @param viewportHeight viewport height
  11166. * @param world world matrix
  11167. * @param view view matrix
  11168. * @param projection projection matrix
  11169. * @returns new ray
  11170. */
  11171. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11172. /**
  11173. * 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
  11174. * transformed to the given world matrix.
  11175. * @param origin The origin point
  11176. * @param end The end point
  11177. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11178. * @returns the new ray
  11179. */
  11180. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11181. /**
  11182. * Transforms a ray by a matrix
  11183. * @param ray ray to transform
  11184. * @param matrix matrix to apply
  11185. * @returns the resulting new ray
  11186. */
  11187. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11188. /**
  11189. * Transforms a ray by a matrix
  11190. * @param ray ray to transform
  11191. * @param matrix matrix to apply
  11192. * @param result ray to store result in
  11193. */
  11194. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11195. /**
  11196. * Unproject a ray from screen space to object space
  11197. * @param sourceX defines the screen space x coordinate to use
  11198. * @param sourceY defines the screen space y coordinate to use
  11199. * @param viewportWidth defines the current width of the viewport
  11200. * @param viewportHeight defines the current height of the viewport
  11201. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11202. * @param view defines the view matrix to use
  11203. * @param projection defines the projection matrix to use
  11204. */
  11205. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11206. }
  11207. /**
  11208. * Type used to define predicate used to select faces when a mesh intersection is detected
  11209. */
  11210. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11211. interface Scene {
  11212. /** @hidden */
  11213. _tempPickingRay: Nullable<Ray>;
  11214. /** @hidden */
  11215. _cachedRayForTransform: Ray;
  11216. /** @hidden */
  11217. _pickWithRayInverseMatrix: Matrix;
  11218. /** @hidden */
  11219. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11220. /** @hidden */
  11221. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11222. }
  11223. }
  11224. declare module BABYLON {
  11225. /**
  11226. * Groups all the scene component constants in one place to ease maintenance.
  11227. * @hidden
  11228. */
  11229. export class SceneComponentConstants {
  11230. static readonly NAME_EFFECTLAYER: string;
  11231. static readonly NAME_LAYER: string;
  11232. static readonly NAME_LENSFLARESYSTEM: string;
  11233. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11234. static readonly NAME_PARTICLESYSTEM: string;
  11235. static readonly NAME_GAMEPAD: string;
  11236. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11237. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11238. static readonly NAME_DEPTHRENDERER: string;
  11239. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11240. static readonly NAME_SPRITE: string;
  11241. static readonly NAME_OUTLINERENDERER: string;
  11242. static readonly NAME_PROCEDURALTEXTURE: string;
  11243. static readonly NAME_SHADOWGENERATOR: string;
  11244. static readonly NAME_OCTREE: string;
  11245. static readonly NAME_PHYSICSENGINE: string;
  11246. static readonly NAME_AUDIO: string;
  11247. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11248. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11249. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11250. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11251. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11252. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11253. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11254. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11255. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11256. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11257. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11258. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11259. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11260. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11261. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11262. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11263. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11264. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11265. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11266. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11267. static readonly STEP_AFTERRENDER_AUDIO: number;
  11268. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11269. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11270. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11271. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11272. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11273. static readonly STEP_POINTERMOVE_SPRITE: number;
  11274. static readonly STEP_POINTERDOWN_SPRITE: number;
  11275. static readonly STEP_POINTERUP_SPRITE: number;
  11276. }
  11277. /**
  11278. * This represents a scene component.
  11279. *
  11280. * This is used to decouple the dependency the scene is having on the different workloads like
  11281. * layers, post processes...
  11282. */
  11283. export interface ISceneComponent {
  11284. /**
  11285. * The name of the component. Each component must have a unique name.
  11286. */
  11287. name: string;
  11288. /**
  11289. * The scene the component belongs to.
  11290. */
  11291. scene: Scene;
  11292. /**
  11293. * Register the component to one instance of a scene.
  11294. */
  11295. register(): void;
  11296. /**
  11297. * Rebuilds the elements related to this component in case of
  11298. * context lost for instance.
  11299. */
  11300. rebuild(): void;
  11301. /**
  11302. * Disposes the component and the associated ressources.
  11303. */
  11304. dispose(): void;
  11305. }
  11306. /**
  11307. * This represents a SERIALIZABLE scene component.
  11308. *
  11309. * This extends Scene Component to add Serialization methods on top.
  11310. */
  11311. export interface ISceneSerializableComponent extends ISceneComponent {
  11312. /**
  11313. * Adds all the elements from the container to the scene
  11314. * @param container the container holding the elements
  11315. */
  11316. addFromContainer(container: AbstractScene): void;
  11317. /**
  11318. * Removes all the elements in the container from the scene
  11319. * @param container contains the elements to remove
  11320. * @param dispose if the removed element should be disposed (default: false)
  11321. */
  11322. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11323. /**
  11324. * Serializes the component data to the specified json object
  11325. * @param serializationObject The object to serialize to
  11326. */
  11327. serialize(serializationObject: any): void;
  11328. }
  11329. /**
  11330. * Strong typing of a Mesh related stage step action
  11331. */
  11332. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11333. /**
  11334. * Strong typing of a Evaluate Sub Mesh related stage step action
  11335. */
  11336. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11337. /**
  11338. * Strong typing of a Active Mesh related stage step action
  11339. */
  11340. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11341. /**
  11342. * Strong typing of a Camera related stage step action
  11343. */
  11344. export type CameraStageAction = (camera: Camera) => void;
  11345. /**
  11346. * Strong typing of a Camera Frame buffer related stage step action
  11347. */
  11348. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11349. /**
  11350. * Strong typing of a Render Target related stage step action
  11351. */
  11352. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11353. /**
  11354. * Strong typing of a RenderingGroup related stage step action
  11355. */
  11356. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11357. /**
  11358. * Strong typing of a Mesh Render related stage step action
  11359. */
  11360. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11361. /**
  11362. * Strong typing of a simple stage step action
  11363. */
  11364. export type SimpleStageAction = () => void;
  11365. /**
  11366. * Strong typing of a render target action.
  11367. */
  11368. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11369. /**
  11370. * Strong typing of a pointer move action.
  11371. */
  11372. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11373. /**
  11374. * Strong typing of a pointer up/down action.
  11375. */
  11376. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11377. /**
  11378. * Representation of a stage in the scene (Basically a list of ordered steps)
  11379. * @hidden
  11380. */
  11381. export class Stage<T extends Function> extends Array<{
  11382. index: number;
  11383. component: ISceneComponent;
  11384. action: T;
  11385. }> {
  11386. /**
  11387. * Hide ctor from the rest of the world.
  11388. * @param items The items to add.
  11389. */
  11390. private constructor();
  11391. /**
  11392. * Creates a new Stage.
  11393. * @returns A new instance of a Stage
  11394. */
  11395. static Create<T extends Function>(): Stage<T>;
  11396. /**
  11397. * Registers a step in an ordered way in the targeted stage.
  11398. * @param index Defines the position to register the step in
  11399. * @param component Defines the component attached to the step
  11400. * @param action Defines the action to launch during the step
  11401. */
  11402. registerStep(index: number, component: ISceneComponent, action: T): void;
  11403. /**
  11404. * Clears all the steps from the stage.
  11405. */
  11406. clear(): void;
  11407. }
  11408. }
  11409. declare module BABYLON {
  11410. interface Scene {
  11411. /** @hidden */
  11412. _pointerOverSprite: Nullable<Sprite>;
  11413. /** @hidden */
  11414. _pickedDownSprite: Nullable<Sprite>;
  11415. /** @hidden */
  11416. _tempSpritePickingRay: Nullable<Ray>;
  11417. /**
  11418. * All of the sprite managers added to this scene
  11419. * @see http://doc.babylonjs.com/babylon101/sprites
  11420. */
  11421. spriteManagers: Array<ISpriteManager>;
  11422. /**
  11423. * An event triggered when sprites rendering is about to start
  11424. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11425. */
  11426. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11427. /**
  11428. * An event triggered when sprites rendering is done
  11429. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11430. */
  11431. onAfterSpritesRenderingObservable: Observable<Scene>;
  11432. /** @hidden */
  11433. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11434. /** Launch a ray to try to pick a sprite in the scene
  11435. * @param x position on screen
  11436. * @param y position on screen
  11437. * @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
  11438. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11439. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11440. * @returns a PickingInfo
  11441. */
  11442. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11443. /** Use the given ray to pick a sprite in the scene
  11444. * @param ray The ray (in world space) to use to pick meshes
  11445. * @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
  11446. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11447. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11448. * @returns a PickingInfo
  11449. */
  11450. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11451. /** @hidden */
  11452. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11453. /** Launch a ray to try to pick sprites in the scene
  11454. * @param x position on screen
  11455. * @param y position on screen
  11456. * @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
  11457. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11458. * @returns a PickingInfo array
  11459. */
  11460. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11461. /** Use the given ray to pick sprites in the scene
  11462. * @param ray The ray (in world space) to use to pick meshes
  11463. * @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
  11464. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11465. * @returns a PickingInfo array
  11466. */
  11467. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11468. /**
  11469. * Force the sprite under the pointer
  11470. * @param sprite defines the sprite to use
  11471. */
  11472. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11473. /**
  11474. * Gets the sprite under the pointer
  11475. * @returns a Sprite or null if no sprite is under the pointer
  11476. */
  11477. getPointerOverSprite(): Nullable<Sprite>;
  11478. }
  11479. /**
  11480. * Defines the sprite scene component responsible to manage sprites
  11481. * in a given scene.
  11482. */
  11483. export class SpriteSceneComponent implements ISceneComponent {
  11484. /**
  11485. * The component name helpfull to identify the component in the list of scene components.
  11486. */
  11487. readonly name: string;
  11488. /**
  11489. * The scene the component belongs to.
  11490. */
  11491. scene: Scene;
  11492. /** @hidden */
  11493. private _spritePredicate;
  11494. /**
  11495. * Creates a new instance of the component for the given scene
  11496. * @param scene Defines the scene to register the component in
  11497. */
  11498. constructor(scene: Scene);
  11499. /**
  11500. * Registers the component in a given scene
  11501. */
  11502. register(): void;
  11503. /**
  11504. * Rebuilds the elements related to this component in case of
  11505. * context lost for instance.
  11506. */
  11507. rebuild(): void;
  11508. /**
  11509. * Disposes the component and the associated ressources.
  11510. */
  11511. dispose(): void;
  11512. private _pickSpriteButKeepRay;
  11513. private _pointerMove;
  11514. private _pointerDown;
  11515. private _pointerUp;
  11516. }
  11517. }
  11518. declare module BABYLON {
  11519. /** @hidden */
  11520. export var fogFragmentDeclaration: {
  11521. name: string;
  11522. shader: string;
  11523. };
  11524. }
  11525. declare module BABYLON {
  11526. /** @hidden */
  11527. export var fogFragment: {
  11528. name: string;
  11529. shader: string;
  11530. };
  11531. }
  11532. declare module BABYLON {
  11533. /** @hidden */
  11534. export var spritesPixelShader: {
  11535. name: string;
  11536. shader: string;
  11537. };
  11538. }
  11539. declare module BABYLON {
  11540. /** @hidden */
  11541. export var fogVertexDeclaration: {
  11542. name: string;
  11543. shader: string;
  11544. };
  11545. }
  11546. declare module BABYLON {
  11547. /** @hidden */
  11548. export var spritesVertexShader: {
  11549. name: string;
  11550. shader: string;
  11551. };
  11552. }
  11553. declare module BABYLON {
  11554. /**
  11555. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11556. */
  11557. export interface ISpriteManager extends IDisposable {
  11558. /**
  11559. * Restricts the camera to viewing objects with the same layerMask.
  11560. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11561. */
  11562. layerMask: number;
  11563. /**
  11564. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11565. */
  11566. isPickable: boolean;
  11567. /**
  11568. * Specifies the rendering group id for this mesh (0 by default)
  11569. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11570. */
  11571. renderingGroupId: number;
  11572. /**
  11573. * Defines the list of sprites managed by the manager.
  11574. */
  11575. sprites: Array<Sprite>;
  11576. /**
  11577. * Tests the intersection of a sprite with a specific ray.
  11578. * @param ray The ray we are sending to test the collision
  11579. * @param camera The camera space we are sending rays in
  11580. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11581. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11582. * @returns picking info or null.
  11583. */
  11584. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11585. /**
  11586. * Intersects the sprites with a ray
  11587. * @param ray defines the ray to intersect with
  11588. * @param camera defines the current active camera
  11589. * @param predicate defines a predicate used to select candidate sprites
  11590. * @returns null if no hit or a PickingInfo array
  11591. */
  11592. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11593. /**
  11594. * Renders the list of sprites on screen.
  11595. */
  11596. render(): void;
  11597. }
  11598. /**
  11599. * Class used to manage multiple sprites on the same spritesheet
  11600. * @see http://doc.babylonjs.com/babylon101/sprites
  11601. */
  11602. export class SpriteManager implements ISpriteManager {
  11603. /** defines the manager's name */
  11604. name: string;
  11605. /** Gets the list of sprites */
  11606. sprites: Sprite[];
  11607. /** Gets or sets the rendering group id (0 by default) */
  11608. renderingGroupId: number;
  11609. /** Gets or sets camera layer mask */
  11610. layerMask: number;
  11611. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11612. fogEnabled: boolean;
  11613. /** Gets or sets a boolean indicating if the sprites are pickable */
  11614. isPickable: boolean;
  11615. /** Defines the default width of a cell in the spritesheet */
  11616. cellWidth: number;
  11617. /** Defines the default height of a cell in the spritesheet */
  11618. cellHeight: number;
  11619. /** Associative array from JSON sprite data file */
  11620. private _cellData;
  11621. /** Array of sprite names from JSON sprite data file */
  11622. private _spriteMap;
  11623. /** True when packed cell data from JSON file is ready*/
  11624. private _packedAndReady;
  11625. /**
  11626. * An event triggered when the manager is disposed.
  11627. */
  11628. onDisposeObservable: Observable<SpriteManager>;
  11629. private _onDisposeObserver;
  11630. /**
  11631. * Callback called when the manager is disposed
  11632. */
  11633. onDispose: () => void;
  11634. private _capacity;
  11635. private _fromPacked;
  11636. private _spriteTexture;
  11637. private _epsilon;
  11638. private _scene;
  11639. private _vertexData;
  11640. private _buffer;
  11641. private _vertexBuffers;
  11642. private _indexBuffer;
  11643. private _effectBase;
  11644. private _effectFog;
  11645. /**
  11646. * Gets or sets the spritesheet texture
  11647. */
  11648. texture: Texture;
  11649. /**
  11650. * Creates a new sprite manager
  11651. * @param name defines the manager's name
  11652. * @param imgUrl defines the sprite sheet url
  11653. * @param capacity defines the maximum allowed number of sprites
  11654. * @param cellSize defines the size of a sprite cell
  11655. * @param scene defines the hosting scene
  11656. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11657. * @param samplingMode defines the smapling mode to use with spritesheet
  11658. * @param fromPacked set to false; do not alter
  11659. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11660. */
  11661. constructor(
  11662. /** defines the manager's name */
  11663. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11664. private _makePacked;
  11665. private _appendSpriteVertex;
  11666. /**
  11667. * Intersects the sprites with a ray
  11668. * @param ray defines the ray to intersect with
  11669. * @param camera defines the current active camera
  11670. * @param predicate defines a predicate used to select candidate sprites
  11671. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11672. * @returns null if no hit or a PickingInfo
  11673. */
  11674. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11675. /**
  11676. * Intersects the sprites with a ray
  11677. * @param ray defines the ray to intersect with
  11678. * @param camera defines the current active camera
  11679. * @param predicate defines a predicate used to select candidate sprites
  11680. * @returns null if no hit or a PickingInfo array
  11681. */
  11682. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11683. /**
  11684. * Render all child sprites
  11685. */
  11686. render(): void;
  11687. /**
  11688. * Release associated resources
  11689. */
  11690. dispose(): void;
  11691. }
  11692. }
  11693. declare module BABYLON {
  11694. /**
  11695. * Class used to represent a sprite
  11696. * @see http://doc.babylonjs.com/babylon101/sprites
  11697. */
  11698. export class Sprite {
  11699. /** defines the name */
  11700. name: string;
  11701. /** Gets or sets the current world position */
  11702. position: Vector3;
  11703. /** Gets or sets the main color */
  11704. color: Color4;
  11705. /** Gets or sets the width */
  11706. width: number;
  11707. /** Gets or sets the height */
  11708. height: number;
  11709. /** Gets or sets rotation angle */
  11710. angle: number;
  11711. /** Gets or sets the cell index in the sprite sheet */
  11712. cellIndex: number;
  11713. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11714. cellRef: string;
  11715. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11716. invertU: number;
  11717. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11718. invertV: number;
  11719. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11720. disposeWhenFinishedAnimating: boolean;
  11721. /** Gets the list of attached animations */
  11722. animations: Animation[];
  11723. /** Gets or sets a boolean indicating if the sprite can be picked */
  11724. isPickable: boolean;
  11725. /**
  11726. * Gets or sets the associated action manager
  11727. */
  11728. actionManager: Nullable<ActionManager>;
  11729. private _animationStarted;
  11730. private _loopAnimation;
  11731. private _fromIndex;
  11732. private _toIndex;
  11733. private _delay;
  11734. private _direction;
  11735. private _manager;
  11736. private _time;
  11737. private _onAnimationEnd;
  11738. /**
  11739. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11740. */
  11741. isVisible: boolean;
  11742. /**
  11743. * Gets or sets the sprite size
  11744. */
  11745. size: number;
  11746. /**
  11747. * Creates a new Sprite
  11748. * @param name defines the name
  11749. * @param manager defines the manager
  11750. */
  11751. constructor(
  11752. /** defines the name */
  11753. name: string, manager: ISpriteManager);
  11754. /**
  11755. * Starts an animation
  11756. * @param from defines the initial key
  11757. * @param to defines the end key
  11758. * @param loop defines if the animation must loop
  11759. * @param delay defines the start delay (in ms)
  11760. * @param onAnimationEnd defines a callback to call when animation ends
  11761. */
  11762. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11763. /** Stops current animation (if any) */
  11764. stopAnimation(): void;
  11765. /** @hidden */
  11766. _animate(deltaTime: number): void;
  11767. /** Release associated resources */
  11768. dispose(): void;
  11769. }
  11770. }
  11771. declare module BABYLON {
  11772. /**
  11773. * Information about the result of picking within a scene
  11774. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11775. */
  11776. export class PickingInfo {
  11777. /** @hidden */
  11778. _pickingUnavailable: boolean;
  11779. /**
  11780. * If the pick collided with an object
  11781. */
  11782. hit: boolean;
  11783. /**
  11784. * Distance away where the pick collided
  11785. */
  11786. distance: number;
  11787. /**
  11788. * The location of pick collision
  11789. */
  11790. pickedPoint: Nullable<Vector3>;
  11791. /**
  11792. * The mesh corresponding the the pick collision
  11793. */
  11794. pickedMesh: Nullable<AbstractMesh>;
  11795. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11796. bu: number;
  11797. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11798. bv: number;
  11799. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11800. faceId: number;
  11801. /** Id of the the submesh that was picked */
  11802. subMeshId: number;
  11803. /** If a sprite was picked, this will be the sprite the pick collided with */
  11804. pickedSprite: Nullable<Sprite>;
  11805. /**
  11806. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11807. */
  11808. originMesh: Nullable<AbstractMesh>;
  11809. /**
  11810. * The ray that was used to perform the picking.
  11811. */
  11812. ray: Nullable<Ray>;
  11813. /**
  11814. * Gets the normal correspodning to the face the pick collided with
  11815. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11816. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11817. * @returns The normal correspodning to the face the pick collided with
  11818. */
  11819. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11820. /**
  11821. * Gets the texture coordinates of where the pick occured
  11822. * @returns the vector containing the coordnates of the texture
  11823. */
  11824. getTextureCoordinates(): Nullable<Vector2>;
  11825. }
  11826. }
  11827. declare module BABYLON {
  11828. /**
  11829. * Gather the list of pointer event types as constants.
  11830. */
  11831. export class PointerEventTypes {
  11832. /**
  11833. * 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.
  11834. */
  11835. static readonly POINTERDOWN: number;
  11836. /**
  11837. * The pointerup event is fired when a pointer is no longer active.
  11838. */
  11839. static readonly POINTERUP: number;
  11840. /**
  11841. * The pointermove event is fired when a pointer changes coordinates.
  11842. */
  11843. static readonly POINTERMOVE: number;
  11844. /**
  11845. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11846. */
  11847. static readonly POINTERWHEEL: number;
  11848. /**
  11849. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11850. */
  11851. static readonly POINTERPICK: number;
  11852. /**
  11853. * The pointertap event is fired when a the object has been touched and released without drag.
  11854. */
  11855. static readonly POINTERTAP: number;
  11856. /**
  11857. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11858. */
  11859. static readonly POINTERDOUBLETAP: number;
  11860. }
  11861. /**
  11862. * Base class of pointer info types.
  11863. */
  11864. export class PointerInfoBase {
  11865. /**
  11866. * Defines the type of event (PointerEventTypes)
  11867. */
  11868. type: number;
  11869. /**
  11870. * Defines the related dom event
  11871. */
  11872. event: PointerEvent | MouseWheelEvent;
  11873. /**
  11874. * Instantiates the base class of pointers info.
  11875. * @param type Defines the type of event (PointerEventTypes)
  11876. * @param event Defines the related dom event
  11877. */
  11878. constructor(
  11879. /**
  11880. * Defines the type of event (PointerEventTypes)
  11881. */
  11882. type: number,
  11883. /**
  11884. * Defines the related dom event
  11885. */
  11886. event: PointerEvent | MouseWheelEvent);
  11887. }
  11888. /**
  11889. * This class is used to store pointer related info for the onPrePointerObservable event.
  11890. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11891. */
  11892. export class PointerInfoPre extends PointerInfoBase {
  11893. /**
  11894. * Ray from a pointer if availible (eg. 6dof controller)
  11895. */
  11896. ray: Nullable<Ray>;
  11897. /**
  11898. * Defines the local position of the pointer on the canvas.
  11899. */
  11900. localPosition: Vector2;
  11901. /**
  11902. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11903. */
  11904. skipOnPointerObservable: boolean;
  11905. /**
  11906. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11907. * @param type Defines the type of event (PointerEventTypes)
  11908. * @param event Defines the related dom event
  11909. * @param localX Defines the local x coordinates of the pointer when the event occured
  11910. * @param localY Defines the local y coordinates of the pointer when the event occured
  11911. */
  11912. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11913. }
  11914. /**
  11915. * This type contains all the data related to a pointer event in Babylon.js.
  11916. * 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.
  11917. */
  11918. export class PointerInfo extends PointerInfoBase {
  11919. /**
  11920. * Defines the picking info associated to the info (if any)\
  11921. */
  11922. pickInfo: Nullable<PickingInfo>;
  11923. /**
  11924. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11925. * @param type Defines the type of event (PointerEventTypes)
  11926. * @param event Defines the related dom event
  11927. * @param pickInfo Defines the picking info associated to the info (if any)\
  11928. */
  11929. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11930. /**
  11931. * Defines the picking info associated to the info (if any)\
  11932. */
  11933. pickInfo: Nullable<PickingInfo>);
  11934. }
  11935. /**
  11936. * Data relating to a touch event on the screen.
  11937. */
  11938. export interface PointerTouch {
  11939. /**
  11940. * X coordinate of touch.
  11941. */
  11942. x: number;
  11943. /**
  11944. * Y coordinate of touch.
  11945. */
  11946. y: number;
  11947. /**
  11948. * Id of touch. Unique for each finger.
  11949. */
  11950. pointerId: number;
  11951. /**
  11952. * Event type passed from DOM.
  11953. */
  11954. type: any;
  11955. }
  11956. }
  11957. declare module BABYLON {
  11958. /**
  11959. * Manage the mouse inputs to control the movement of a free camera.
  11960. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11961. */
  11962. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11963. /**
  11964. * Define if touch is enabled in the mouse input
  11965. */
  11966. touchEnabled: boolean;
  11967. /**
  11968. * Defines the camera the input is attached to.
  11969. */
  11970. camera: FreeCamera;
  11971. /**
  11972. * Defines the buttons associated with the input to handle camera move.
  11973. */
  11974. buttons: number[];
  11975. /**
  11976. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11977. */
  11978. angularSensibility: number;
  11979. private _pointerInput;
  11980. private _onMouseMove;
  11981. private _observer;
  11982. private previousPosition;
  11983. /**
  11984. * Observable for when a pointer move event occurs containing the move offset
  11985. */
  11986. onPointerMovedObservable: Observable<{
  11987. offsetX: number;
  11988. offsetY: number;
  11989. }>;
  11990. /**
  11991. * @hidden
  11992. * If the camera should be rotated automatically based on pointer movement
  11993. */
  11994. _allowCameraRotation: boolean;
  11995. /**
  11996. * Manage the mouse inputs to control the movement of a free camera.
  11997. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11998. * @param touchEnabled Defines if touch is enabled or not
  11999. */
  12000. constructor(
  12001. /**
  12002. * Define if touch is enabled in the mouse input
  12003. */
  12004. touchEnabled?: boolean);
  12005. /**
  12006. * Attach the input controls to a specific dom element to get the input from.
  12007. * @param element Defines the element the controls should be listened from
  12008. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12009. */
  12010. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12011. /**
  12012. * Called on JS contextmenu event.
  12013. * Override this method to provide functionality.
  12014. */
  12015. protected onContextMenu(evt: PointerEvent): void;
  12016. /**
  12017. * Detach the current controls from the specified dom element.
  12018. * @param element Defines the element to stop listening the inputs from
  12019. */
  12020. detachControl(element: Nullable<HTMLElement>): void;
  12021. /**
  12022. * Gets the class name of the current intput.
  12023. * @returns the class name
  12024. */
  12025. getClassName(): string;
  12026. /**
  12027. * Get the friendly name associated with the input class.
  12028. * @returns the input friendly name
  12029. */
  12030. getSimpleName(): string;
  12031. }
  12032. }
  12033. declare module BABYLON {
  12034. /**
  12035. * Manage the touch inputs to control the movement of a free camera.
  12036. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12037. */
  12038. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12039. /**
  12040. * Defines the camera the input is attached to.
  12041. */
  12042. camera: FreeCamera;
  12043. /**
  12044. * Defines the touch sensibility for rotation.
  12045. * The higher the faster.
  12046. */
  12047. touchAngularSensibility: number;
  12048. /**
  12049. * Defines the touch sensibility for move.
  12050. * The higher the faster.
  12051. */
  12052. touchMoveSensibility: number;
  12053. private _offsetX;
  12054. private _offsetY;
  12055. private _pointerPressed;
  12056. private _pointerInput;
  12057. private _observer;
  12058. private _onLostFocus;
  12059. /**
  12060. * Attach the input controls to a specific dom element to get the input from.
  12061. * @param element Defines the element the controls should be listened from
  12062. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12063. */
  12064. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12065. /**
  12066. * Detach the current controls from the specified dom element.
  12067. * @param element Defines the element to stop listening the inputs from
  12068. */
  12069. detachControl(element: Nullable<HTMLElement>): void;
  12070. /**
  12071. * Update the current camera state depending on the inputs that have been used this frame.
  12072. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12073. */
  12074. checkInputs(): void;
  12075. /**
  12076. * Gets the class name of the current intput.
  12077. * @returns the class name
  12078. */
  12079. getClassName(): string;
  12080. /**
  12081. * Get the friendly name associated with the input class.
  12082. * @returns the input friendly name
  12083. */
  12084. getSimpleName(): string;
  12085. }
  12086. }
  12087. declare module BABYLON {
  12088. /**
  12089. * Default Inputs manager for the FreeCamera.
  12090. * It groups all the default supported inputs for ease of use.
  12091. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12092. */
  12093. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12094. /**
  12095. * @hidden
  12096. */
  12097. _mouseInput: Nullable<FreeCameraMouseInput>;
  12098. /**
  12099. * Instantiates a new FreeCameraInputsManager.
  12100. * @param camera Defines the camera the inputs belong to
  12101. */
  12102. constructor(camera: FreeCamera);
  12103. /**
  12104. * Add keyboard input support to the input manager.
  12105. * @returns the current input manager
  12106. */
  12107. addKeyboard(): FreeCameraInputsManager;
  12108. /**
  12109. * Add mouse input support to the input manager.
  12110. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12111. * @returns the current input manager
  12112. */
  12113. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12114. /**
  12115. * Removes the mouse input support from the manager
  12116. * @returns the current input manager
  12117. */
  12118. removeMouse(): FreeCameraInputsManager;
  12119. /**
  12120. * Add touch input support to the input manager.
  12121. * @returns the current input manager
  12122. */
  12123. addTouch(): FreeCameraInputsManager;
  12124. /**
  12125. * Remove all attached input methods from a camera
  12126. */
  12127. clear(): void;
  12128. }
  12129. }
  12130. declare module BABYLON {
  12131. /**
  12132. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12133. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12134. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12135. */
  12136. export class FreeCamera extends TargetCamera {
  12137. /**
  12138. * Define the collision ellipsoid of the camera.
  12139. * This is helpful to simulate a camera body like the player body around the camera
  12140. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12141. */
  12142. ellipsoid: Vector3;
  12143. /**
  12144. * Define an offset for the position of the ellipsoid around the camera.
  12145. * This can be helpful to determine the center of the body near the gravity center of the body
  12146. * instead of its head.
  12147. */
  12148. ellipsoidOffset: Vector3;
  12149. /**
  12150. * Enable or disable collisions of the camera with the rest of the scene objects.
  12151. */
  12152. checkCollisions: boolean;
  12153. /**
  12154. * Enable or disable gravity on the camera.
  12155. */
  12156. applyGravity: boolean;
  12157. /**
  12158. * Define the input manager associated to the camera.
  12159. */
  12160. inputs: FreeCameraInputsManager;
  12161. /**
  12162. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12163. * Higher values reduce sensitivity.
  12164. */
  12165. /**
  12166. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12167. * Higher values reduce sensitivity.
  12168. */
  12169. angularSensibility: number;
  12170. /**
  12171. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12172. */
  12173. keysUp: number[];
  12174. /**
  12175. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12176. */
  12177. keysDown: number[];
  12178. /**
  12179. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12180. */
  12181. keysLeft: number[];
  12182. /**
  12183. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12184. */
  12185. keysRight: number[];
  12186. /**
  12187. * Event raised when the camera collide with a mesh in the scene.
  12188. */
  12189. onCollide: (collidedMesh: AbstractMesh) => void;
  12190. private _collider;
  12191. private _needMoveForGravity;
  12192. private _oldPosition;
  12193. private _diffPosition;
  12194. private _newPosition;
  12195. /** @hidden */
  12196. _localDirection: Vector3;
  12197. /** @hidden */
  12198. _transformedDirection: Vector3;
  12199. /**
  12200. * Instantiates a Free Camera.
  12201. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12202. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12203. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12204. * @param name Define the name of the camera in the scene
  12205. * @param position Define the start position of the camera in the scene
  12206. * @param scene Define the scene the camera belongs to
  12207. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12208. */
  12209. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12210. /**
  12211. * Attached controls to the current camera.
  12212. * @param element Defines the element the controls should be listened from
  12213. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12214. */
  12215. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12216. /**
  12217. * Detach the current controls from the camera.
  12218. * The camera will stop reacting to inputs.
  12219. * @param element Defines the element to stop listening the inputs from
  12220. */
  12221. detachControl(element: HTMLElement): void;
  12222. private _collisionMask;
  12223. /**
  12224. * Define a collision mask to limit the list of object the camera can collide with
  12225. */
  12226. collisionMask: number;
  12227. /** @hidden */
  12228. _collideWithWorld(displacement: Vector3): void;
  12229. private _onCollisionPositionChange;
  12230. /** @hidden */
  12231. _checkInputs(): void;
  12232. /** @hidden */
  12233. _decideIfNeedsToMove(): boolean;
  12234. /** @hidden */
  12235. _updatePosition(): void;
  12236. /**
  12237. * Destroy the camera and release the current resources hold by it.
  12238. */
  12239. dispose(): void;
  12240. /**
  12241. * Gets the current object class name.
  12242. * @return the class name
  12243. */
  12244. getClassName(): string;
  12245. }
  12246. }
  12247. declare module BABYLON {
  12248. /**
  12249. * Represents a gamepad control stick position
  12250. */
  12251. export class StickValues {
  12252. /**
  12253. * The x component of the control stick
  12254. */
  12255. x: number;
  12256. /**
  12257. * The y component of the control stick
  12258. */
  12259. y: number;
  12260. /**
  12261. * Initializes the gamepad x and y control stick values
  12262. * @param x The x component of the gamepad control stick value
  12263. * @param y The y component of the gamepad control stick value
  12264. */
  12265. constructor(
  12266. /**
  12267. * The x component of the control stick
  12268. */
  12269. x: number,
  12270. /**
  12271. * The y component of the control stick
  12272. */
  12273. y: number);
  12274. }
  12275. /**
  12276. * An interface which manages callbacks for gamepad button changes
  12277. */
  12278. export interface GamepadButtonChanges {
  12279. /**
  12280. * Called when a gamepad has been changed
  12281. */
  12282. changed: boolean;
  12283. /**
  12284. * Called when a gamepad press event has been triggered
  12285. */
  12286. pressChanged: boolean;
  12287. /**
  12288. * Called when a touch event has been triggered
  12289. */
  12290. touchChanged: boolean;
  12291. /**
  12292. * Called when a value has changed
  12293. */
  12294. valueChanged: boolean;
  12295. }
  12296. /**
  12297. * Represents a gamepad
  12298. */
  12299. export class Gamepad {
  12300. /**
  12301. * The id of the gamepad
  12302. */
  12303. id: string;
  12304. /**
  12305. * The index of the gamepad
  12306. */
  12307. index: number;
  12308. /**
  12309. * The browser gamepad
  12310. */
  12311. browserGamepad: any;
  12312. /**
  12313. * Specifies what type of gamepad this represents
  12314. */
  12315. type: number;
  12316. private _leftStick;
  12317. private _rightStick;
  12318. /** @hidden */
  12319. _isConnected: boolean;
  12320. private _leftStickAxisX;
  12321. private _leftStickAxisY;
  12322. private _rightStickAxisX;
  12323. private _rightStickAxisY;
  12324. /**
  12325. * Triggered when the left control stick has been changed
  12326. */
  12327. private _onleftstickchanged;
  12328. /**
  12329. * Triggered when the right control stick has been changed
  12330. */
  12331. private _onrightstickchanged;
  12332. /**
  12333. * Represents a gamepad controller
  12334. */
  12335. static GAMEPAD: number;
  12336. /**
  12337. * Represents a generic controller
  12338. */
  12339. static GENERIC: number;
  12340. /**
  12341. * Represents an XBox controller
  12342. */
  12343. static XBOX: number;
  12344. /**
  12345. * Represents a pose-enabled controller
  12346. */
  12347. static POSE_ENABLED: number;
  12348. /**
  12349. * Represents an Dual Shock controller
  12350. */
  12351. static DUALSHOCK: number;
  12352. /**
  12353. * Specifies whether the left control stick should be Y-inverted
  12354. */
  12355. protected _invertLeftStickY: boolean;
  12356. /**
  12357. * Specifies if the gamepad has been connected
  12358. */
  12359. readonly isConnected: boolean;
  12360. /**
  12361. * Initializes the gamepad
  12362. * @param id The id of the gamepad
  12363. * @param index The index of the gamepad
  12364. * @param browserGamepad The browser gamepad
  12365. * @param leftStickX The x component of the left joystick
  12366. * @param leftStickY The y component of the left joystick
  12367. * @param rightStickX The x component of the right joystick
  12368. * @param rightStickY The y component of the right joystick
  12369. */
  12370. constructor(
  12371. /**
  12372. * The id of the gamepad
  12373. */
  12374. id: string,
  12375. /**
  12376. * The index of the gamepad
  12377. */
  12378. index: number,
  12379. /**
  12380. * The browser gamepad
  12381. */
  12382. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12383. /**
  12384. * Callback triggered when the left joystick has changed
  12385. * @param callback
  12386. */
  12387. onleftstickchanged(callback: (values: StickValues) => void): void;
  12388. /**
  12389. * Callback triggered when the right joystick has changed
  12390. * @param callback
  12391. */
  12392. onrightstickchanged(callback: (values: StickValues) => void): void;
  12393. /**
  12394. * Gets the left joystick
  12395. */
  12396. /**
  12397. * Sets the left joystick values
  12398. */
  12399. leftStick: StickValues;
  12400. /**
  12401. * Gets the right joystick
  12402. */
  12403. /**
  12404. * Sets the right joystick value
  12405. */
  12406. rightStick: StickValues;
  12407. /**
  12408. * Updates the gamepad joystick positions
  12409. */
  12410. update(): void;
  12411. /**
  12412. * Disposes the gamepad
  12413. */
  12414. dispose(): void;
  12415. }
  12416. /**
  12417. * Represents a generic gamepad
  12418. */
  12419. export class GenericPad extends Gamepad {
  12420. private _buttons;
  12421. private _onbuttondown;
  12422. private _onbuttonup;
  12423. /**
  12424. * Observable triggered when a button has been pressed
  12425. */
  12426. onButtonDownObservable: Observable<number>;
  12427. /**
  12428. * Observable triggered when a button has been released
  12429. */
  12430. onButtonUpObservable: Observable<number>;
  12431. /**
  12432. * Callback triggered when a button has been pressed
  12433. * @param callback Called when a button has been pressed
  12434. */
  12435. onbuttondown(callback: (buttonPressed: number) => void): void;
  12436. /**
  12437. * Callback triggered when a button has been released
  12438. * @param callback Called when a button has been released
  12439. */
  12440. onbuttonup(callback: (buttonReleased: number) => void): void;
  12441. /**
  12442. * Initializes the generic gamepad
  12443. * @param id The id of the generic gamepad
  12444. * @param index The index of the generic gamepad
  12445. * @param browserGamepad The browser gamepad
  12446. */
  12447. constructor(id: string, index: number, browserGamepad: any);
  12448. private _setButtonValue;
  12449. /**
  12450. * Updates the generic gamepad
  12451. */
  12452. update(): void;
  12453. /**
  12454. * Disposes the generic gamepad
  12455. */
  12456. dispose(): void;
  12457. }
  12458. }
  12459. declare module BABYLON {
  12460. interface Engine {
  12461. /**
  12462. * Creates a raw texture
  12463. * @param data defines the data to store in the texture
  12464. * @param width defines the width of the texture
  12465. * @param height defines the height of the texture
  12466. * @param format defines the format of the data
  12467. * @param generateMipMaps defines if the engine should generate the mip levels
  12468. * @param invertY defines if data must be stored with Y axis inverted
  12469. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12470. * @param compression defines the compression used (null by default)
  12471. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12472. * @returns the raw texture inside an InternalTexture
  12473. */
  12474. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12475. /**
  12476. * Update a raw texture
  12477. * @param texture defines the texture to update
  12478. * @param data defines the data to store in the texture
  12479. * @param format defines the format of the data
  12480. * @param invertY defines if data must be stored with Y axis inverted
  12481. */
  12482. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12483. /**
  12484. * Update a raw texture
  12485. * @param texture defines the texture to update
  12486. * @param data defines the data to store in the texture
  12487. * @param format defines the format of the data
  12488. * @param invertY defines if data must be stored with Y axis inverted
  12489. * @param compression defines the compression used (null by default)
  12490. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12491. */
  12492. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12493. /**
  12494. * Creates a new raw cube texture
  12495. * @param data defines the array of data to use to create each face
  12496. * @param size defines the size of the textures
  12497. * @param format defines the format of the data
  12498. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12499. * @param generateMipMaps defines if the engine should generate the mip levels
  12500. * @param invertY defines if data must be stored with Y axis inverted
  12501. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12502. * @param compression defines the compression used (null by default)
  12503. * @returns the cube texture as an InternalTexture
  12504. */
  12505. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12506. /**
  12507. * Update a raw cube texture
  12508. * @param texture defines the texture to udpdate
  12509. * @param data defines the data to store
  12510. * @param format defines the data format
  12511. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12512. * @param invertY defines if data must be stored with Y axis inverted
  12513. */
  12514. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12515. /**
  12516. * Update a raw cube texture
  12517. * @param texture defines the texture to udpdate
  12518. * @param data defines the data to store
  12519. * @param format defines the data format
  12520. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12521. * @param invertY defines if data must be stored with Y axis inverted
  12522. * @param compression defines the compression used (null by default)
  12523. */
  12524. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12525. /**
  12526. * Update a raw cube texture
  12527. * @param texture defines the texture to udpdate
  12528. * @param data defines the data to store
  12529. * @param format defines the data format
  12530. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12531. * @param invertY defines if data must be stored with Y axis inverted
  12532. * @param compression defines the compression used (null by default)
  12533. * @param level defines which level of the texture to update
  12534. */
  12535. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12536. /**
  12537. * Creates a new raw cube texture from a specified url
  12538. * @param url defines the url where the data is located
  12539. * @param scene defines the current scene
  12540. * @param size defines the size of the textures
  12541. * @param format defines the format of the data
  12542. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12543. * @param noMipmap defines if the engine should avoid generating the mip levels
  12544. * @param callback defines a callback used to extract texture data from loaded data
  12545. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12546. * @param onLoad defines a callback called when texture is loaded
  12547. * @param onError defines a callback called if there is an error
  12548. * @returns the cube texture as an InternalTexture
  12549. */
  12550. 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;
  12551. /**
  12552. * Creates a new raw cube texture from a specified url
  12553. * @param url defines the url where the data is located
  12554. * @param scene defines the current scene
  12555. * @param size defines the size of the textures
  12556. * @param format defines the format of the data
  12557. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12558. * @param noMipmap defines if the engine should avoid generating the mip levels
  12559. * @param callback defines a callback used to extract texture data from loaded data
  12560. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12561. * @param onLoad defines a callback called when texture is loaded
  12562. * @param onError defines a callback called if there is an error
  12563. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12564. * @param invertY defines if data must be stored with Y axis inverted
  12565. * @returns the cube texture as an InternalTexture
  12566. */
  12567. 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;
  12568. /**
  12569. * Creates a new raw 3D texture
  12570. * @param data defines the data used to create the texture
  12571. * @param width defines the width of the texture
  12572. * @param height defines the height of the texture
  12573. * @param depth defines the depth of the texture
  12574. * @param format defines the format of the texture
  12575. * @param generateMipMaps defines if the engine must generate mip levels
  12576. * @param invertY defines if data must be stored with Y axis inverted
  12577. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12578. * @param compression defines the compressed used (can be null)
  12579. * @param textureType defines the compressed used (can be null)
  12580. * @returns a new raw 3D texture (stored in an InternalTexture)
  12581. */
  12582. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12583. /**
  12584. * Update a raw 3D texture
  12585. * @param texture defines the texture to update
  12586. * @param data defines the data to store
  12587. * @param format defines the data format
  12588. * @param invertY defines if data must be stored with Y axis inverted
  12589. */
  12590. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12591. /**
  12592. * Update a raw 3D texture
  12593. * @param texture defines the texture to update
  12594. * @param data defines the data to store
  12595. * @param format defines the data format
  12596. * @param invertY defines if data must be stored with Y axis inverted
  12597. * @param compression defines the used compression (can be null)
  12598. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12599. */
  12600. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12601. /**
  12602. * Creates a new raw 2D array texture
  12603. * @param data defines the data used to create the texture
  12604. * @param width defines the width of the texture
  12605. * @param height defines the height of the texture
  12606. * @param depth defines the number of layers of the texture
  12607. * @param format defines the format of the texture
  12608. * @param generateMipMaps defines if the engine must generate mip levels
  12609. * @param invertY defines if data must be stored with Y axis inverted
  12610. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12611. * @param compression defines the compressed used (can be null)
  12612. * @param textureType defines the compressed used (can be null)
  12613. * @returns a new raw 2D array texture (stored in an InternalTexture)
  12614. */
  12615. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12616. /**
  12617. * Update a raw 2D array texture
  12618. * @param texture defines the texture to update
  12619. * @param data defines the data to store
  12620. * @param format defines the data format
  12621. * @param invertY defines if data must be stored with Y axis inverted
  12622. */
  12623. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12624. /**
  12625. * Update a raw 2D array texture
  12626. * @param texture defines the texture to update
  12627. * @param data defines the data to store
  12628. * @param format defines the data format
  12629. * @param invertY defines if data must be stored with Y axis inverted
  12630. * @param compression defines the used compression (can be null)
  12631. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12632. */
  12633. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12634. }
  12635. }
  12636. declare module BABYLON {
  12637. /**
  12638. * Raw texture can help creating a texture directly from an array of data.
  12639. * This can be super useful if you either get the data from an uncompressed source or
  12640. * if you wish to create your texture pixel by pixel.
  12641. */
  12642. export class RawTexture extends Texture {
  12643. /**
  12644. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12645. */
  12646. format: number;
  12647. private _engine;
  12648. /**
  12649. * Instantiates a new RawTexture.
  12650. * Raw texture can help creating a texture directly from an array of data.
  12651. * This can be super useful if you either get the data from an uncompressed source or
  12652. * if you wish to create your texture pixel by pixel.
  12653. * @param data define the array of data to use to create the texture
  12654. * @param width define the width of the texture
  12655. * @param height define the height of the texture
  12656. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12657. * @param scene define the scene the texture belongs to
  12658. * @param generateMipMaps define whether mip maps should be generated or not
  12659. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12660. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12661. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12662. */
  12663. constructor(data: ArrayBufferView, width: number, height: number,
  12664. /**
  12665. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12666. */
  12667. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12668. /**
  12669. * Updates the texture underlying data.
  12670. * @param data Define the new data of the texture
  12671. */
  12672. update(data: ArrayBufferView): void;
  12673. /**
  12674. * Creates a luminance texture from some data.
  12675. * @param data Define the texture data
  12676. * @param width Define the width of the texture
  12677. * @param height Define the height of the texture
  12678. * @param scene Define the scene the texture belongs to
  12679. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12680. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12681. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12682. * @returns the luminance texture
  12683. */
  12684. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12685. /**
  12686. * Creates a luminance alpha texture from some data.
  12687. * @param data Define the texture data
  12688. * @param width Define the width of the texture
  12689. * @param height Define the height of the texture
  12690. * @param scene Define the scene the texture belongs to
  12691. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12692. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12693. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12694. * @returns the luminance alpha texture
  12695. */
  12696. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12697. /**
  12698. * Creates an alpha texture from some data.
  12699. * @param data Define the texture data
  12700. * @param width Define the width of the texture
  12701. * @param height Define the height of the texture
  12702. * @param scene Define the scene the texture belongs to
  12703. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12704. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12705. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12706. * @returns the alpha texture
  12707. */
  12708. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12709. /**
  12710. * Creates a RGB texture from some data.
  12711. * @param data Define the texture data
  12712. * @param width Define the width of the texture
  12713. * @param height Define the height of the texture
  12714. * @param scene Define the scene the texture belongs to
  12715. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12716. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12717. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12718. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12719. * @returns the RGB alpha texture
  12720. */
  12721. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12722. /**
  12723. * Creates a RGBA texture from some data.
  12724. * @param data Define the texture data
  12725. * @param width Define the width of the texture
  12726. * @param height Define the height of the texture
  12727. * @param scene Define the scene the texture belongs to
  12728. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12729. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12730. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12731. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12732. * @returns the RGBA texture
  12733. */
  12734. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12735. /**
  12736. * Creates a R texture from some data.
  12737. * @param data Define the texture data
  12738. * @param width Define the width of the texture
  12739. * @param height Define the height of the texture
  12740. * @param scene Define the scene the texture belongs to
  12741. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12742. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12743. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12744. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12745. * @returns the R texture
  12746. */
  12747. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12748. }
  12749. }
  12750. declare module BABYLON {
  12751. /**
  12752. * Interface for the size containing width and height
  12753. */
  12754. export interface ISize {
  12755. /**
  12756. * Width
  12757. */
  12758. width: number;
  12759. /**
  12760. * Heighht
  12761. */
  12762. height: number;
  12763. }
  12764. /**
  12765. * Size containing widht and height
  12766. */
  12767. export class Size implements ISize {
  12768. /**
  12769. * Width
  12770. */
  12771. width: number;
  12772. /**
  12773. * Height
  12774. */
  12775. height: number;
  12776. /**
  12777. * Creates a Size object from the given width and height (floats).
  12778. * @param width width of the new size
  12779. * @param height height of the new size
  12780. */
  12781. constructor(width: number, height: number);
  12782. /**
  12783. * Returns a string with the Size width and height
  12784. * @returns a string with the Size width and height
  12785. */
  12786. toString(): string;
  12787. /**
  12788. * "Size"
  12789. * @returns the string "Size"
  12790. */
  12791. getClassName(): string;
  12792. /**
  12793. * Returns the Size hash code.
  12794. * @returns a hash code for a unique width and height
  12795. */
  12796. getHashCode(): number;
  12797. /**
  12798. * Updates the current size from the given one.
  12799. * @param src the given size
  12800. */
  12801. copyFrom(src: Size): void;
  12802. /**
  12803. * Updates in place the current Size from the given floats.
  12804. * @param width width of the new size
  12805. * @param height height of the new size
  12806. * @returns the updated Size.
  12807. */
  12808. copyFromFloats(width: number, height: number): Size;
  12809. /**
  12810. * Updates in place the current Size from the given floats.
  12811. * @param width width to set
  12812. * @param height height to set
  12813. * @returns the updated Size.
  12814. */
  12815. set(width: number, height: number): Size;
  12816. /**
  12817. * Multiplies the width and height by numbers
  12818. * @param w factor to multiple the width by
  12819. * @param h factor to multiple the height by
  12820. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12821. */
  12822. multiplyByFloats(w: number, h: number): Size;
  12823. /**
  12824. * Clones the size
  12825. * @returns a new Size copied from the given one.
  12826. */
  12827. clone(): Size;
  12828. /**
  12829. * True if the current Size and the given one width and height are strictly equal.
  12830. * @param other the other size to compare against
  12831. * @returns True if the current Size and the given one width and height are strictly equal.
  12832. */
  12833. equals(other: Size): boolean;
  12834. /**
  12835. * The surface of the Size : width * height (float).
  12836. */
  12837. readonly surface: number;
  12838. /**
  12839. * Create a new size of zero
  12840. * @returns a new Size set to (0.0, 0.0)
  12841. */
  12842. static Zero(): Size;
  12843. /**
  12844. * Sums the width and height of two sizes
  12845. * @param otherSize size to add to this size
  12846. * @returns a new Size set as the addition result of the current Size and the given one.
  12847. */
  12848. add(otherSize: Size): Size;
  12849. /**
  12850. * Subtracts the width and height of two
  12851. * @param otherSize size to subtract to this size
  12852. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12853. */
  12854. subtract(otherSize: Size): Size;
  12855. /**
  12856. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12857. * @param start starting size to lerp between
  12858. * @param end end size to lerp between
  12859. * @param amount amount to lerp between the start and end values
  12860. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12861. */
  12862. static Lerp(start: Size, end: Size, amount: number): Size;
  12863. }
  12864. }
  12865. declare module BABYLON {
  12866. /**
  12867. * Defines a runtime animation
  12868. */
  12869. export class RuntimeAnimation {
  12870. private _events;
  12871. /**
  12872. * The current frame of the runtime animation
  12873. */
  12874. private _currentFrame;
  12875. /**
  12876. * The animation used by the runtime animation
  12877. */
  12878. private _animation;
  12879. /**
  12880. * The target of the runtime animation
  12881. */
  12882. private _target;
  12883. /**
  12884. * The initiating animatable
  12885. */
  12886. private _host;
  12887. /**
  12888. * The original value of the runtime animation
  12889. */
  12890. private _originalValue;
  12891. /**
  12892. * The original blend value of the runtime animation
  12893. */
  12894. private _originalBlendValue;
  12895. /**
  12896. * The offsets cache of the runtime animation
  12897. */
  12898. private _offsetsCache;
  12899. /**
  12900. * The high limits cache of the runtime animation
  12901. */
  12902. private _highLimitsCache;
  12903. /**
  12904. * Specifies if the runtime animation has been stopped
  12905. */
  12906. private _stopped;
  12907. /**
  12908. * The blending factor of the runtime animation
  12909. */
  12910. private _blendingFactor;
  12911. /**
  12912. * The BabylonJS scene
  12913. */
  12914. private _scene;
  12915. /**
  12916. * The current value of the runtime animation
  12917. */
  12918. private _currentValue;
  12919. /** @hidden */
  12920. _animationState: _IAnimationState;
  12921. /**
  12922. * The active target of the runtime animation
  12923. */
  12924. private _activeTargets;
  12925. private _currentActiveTarget;
  12926. private _directTarget;
  12927. /**
  12928. * The target path of the runtime animation
  12929. */
  12930. private _targetPath;
  12931. /**
  12932. * The weight of the runtime animation
  12933. */
  12934. private _weight;
  12935. /**
  12936. * The ratio offset of the runtime animation
  12937. */
  12938. private _ratioOffset;
  12939. /**
  12940. * The previous delay of the runtime animation
  12941. */
  12942. private _previousDelay;
  12943. /**
  12944. * The previous ratio of the runtime animation
  12945. */
  12946. private _previousRatio;
  12947. private _enableBlending;
  12948. private _keys;
  12949. private _minFrame;
  12950. private _maxFrame;
  12951. private _minValue;
  12952. private _maxValue;
  12953. private _targetIsArray;
  12954. /**
  12955. * Gets the current frame of the runtime animation
  12956. */
  12957. readonly currentFrame: number;
  12958. /**
  12959. * Gets the weight of the runtime animation
  12960. */
  12961. readonly weight: number;
  12962. /**
  12963. * Gets the current value of the runtime animation
  12964. */
  12965. readonly currentValue: any;
  12966. /**
  12967. * Gets the target path of the runtime animation
  12968. */
  12969. readonly targetPath: string;
  12970. /**
  12971. * Gets the actual target of the runtime animation
  12972. */
  12973. readonly target: any;
  12974. /** @hidden */
  12975. _onLoop: () => void;
  12976. /**
  12977. * Create a new RuntimeAnimation object
  12978. * @param target defines the target of the animation
  12979. * @param animation defines the source animation object
  12980. * @param scene defines the hosting scene
  12981. * @param host defines the initiating Animatable
  12982. */
  12983. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  12984. private _preparePath;
  12985. /**
  12986. * Gets the animation from the runtime animation
  12987. */
  12988. readonly animation: Animation;
  12989. /**
  12990. * Resets the runtime animation to the beginning
  12991. * @param restoreOriginal defines whether to restore the target property to the original value
  12992. */
  12993. reset(restoreOriginal?: boolean): void;
  12994. /**
  12995. * Specifies if the runtime animation is stopped
  12996. * @returns Boolean specifying if the runtime animation is stopped
  12997. */
  12998. isStopped(): boolean;
  12999. /**
  13000. * Disposes of the runtime animation
  13001. */
  13002. dispose(): void;
  13003. /**
  13004. * Apply the interpolated value to the target
  13005. * @param currentValue defines the value computed by the animation
  13006. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  13007. */
  13008. setValue(currentValue: any, weight: number): void;
  13009. private _getOriginalValues;
  13010. private _setValue;
  13011. /**
  13012. * Gets the loop pmode of the runtime animation
  13013. * @returns Loop Mode
  13014. */
  13015. private _getCorrectLoopMode;
  13016. /**
  13017. * Move the current animation to a given frame
  13018. * @param frame defines the frame to move to
  13019. */
  13020. goToFrame(frame: number): void;
  13021. /**
  13022. * @hidden Internal use only
  13023. */
  13024. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13025. /**
  13026. * Execute the current animation
  13027. * @param delay defines the delay to add to the current frame
  13028. * @param from defines the lower bound of the animation range
  13029. * @param to defines the upper bound of the animation range
  13030. * @param loop defines if the current animation must loop
  13031. * @param speedRatio defines the current speed ratio
  13032. * @param weight defines the weight of the animation (default is -1 so no weight)
  13033. * @param onLoop optional callback called when animation loops
  13034. * @returns a boolean indicating if the animation is running
  13035. */
  13036. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13037. }
  13038. }
  13039. declare module BABYLON {
  13040. /**
  13041. * Class used to store an actual running animation
  13042. */
  13043. export class Animatable {
  13044. /** defines the target object */
  13045. target: any;
  13046. /** defines the starting frame number (default is 0) */
  13047. fromFrame: number;
  13048. /** defines the ending frame number (default is 100) */
  13049. toFrame: number;
  13050. /** defines if the animation must loop (default is false) */
  13051. loopAnimation: boolean;
  13052. /** defines a callback to call when animation ends if it is not looping */
  13053. onAnimationEnd?: (() => void) | null | undefined;
  13054. /** defines a callback to call when animation loops */
  13055. onAnimationLoop?: (() => void) | null | undefined;
  13056. private _localDelayOffset;
  13057. private _pausedDelay;
  13058. private _runtimeAnimations;
  13059. private _paused;
  13060. private _scene;
  13061. private _speedRatio;
  13062. private _weight;
  13063. private _syncRoot;
  13064. /**
  13065. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13066. * This will only apply for non looping animation (default is true)
  13067. */
  13068. disposeOnEnd: boolean;
  13069. /**
  13070. * Gets a boolean indicating if the animation has started
  13071. */
  13072. animationStarted: boolean;
  13073. /**
  13074. * Observer raised when the animation ends
  13075. */
  13076. onAnimationEndObservable: Observable<Animatable>;
  13077. /**
  13078. * Observer raised when the animation loops
  13079. */
  13080. onAnimationLoopObservable: Observable<Animatable>;
  13081. /**
  13082. * Gets the root Animatable used to synchronize and normalize animations
  13083. */
  13084. readonly syncRoot: Nullable<Animatable>;
  13085. /**
  13086. * Gets the current frame of the first RuntimeAnimation
  13087. * Used to synchronize Animatables
  13088. */
  13089. readonly masterFrame: number;
  13090. /**
  13091. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13092. */
  13093. weight: number;
  13094. /**
  13095. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13096. */
  13097. speedRatio: number;
  13098. /**
  13099. * Creates a new Animatable
  13100. * @param scene defines the hosting scene
  13101. * @param target defines the target object
  13102. * @param fromFrame defines the starting frame number (default is 0)
  13103. * @param toFrame defines the ending frame number (default is 100)
  13104. * @param loopAnimation defines if the animation must loop (default is false)
  13105. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13106. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13107. * @param animations defines a group of animation to add to the new Animatable
  13108. * @param onAnimationLoop defines a callback to call when animation loops
  13109. */
  13110. constructor(scene: Scene,
  13111. /** defines the target object */
  13112. target: any,
  13113. /** defines the starting frame number (default is 0) */
  13114. fromFrame?: number,
  13115. /** defines the ending frame number (default is 100) */
  13116. toFrame?: number,
  13117. /** defines if the animation must loop (default is false) */
  13118. loopAnimation?: boolean, speedRatio?: number,
  13119. /** defines a callback to call when animation ends if it is not looping */
  13120. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13121. /** defines a callback to call when animation loops */
  13122. onAnimationLoop?: (() => void) | null | undefined);
  13123. /**
  13124. * Synchronize and normalize current Animatable with a source Animatable
  13125. * This is useful when using animation weights and when animations are not of the same length
  13126. * @param root defines the root Animatable to synchronize with
  13127. * @returns the current Animatable
  13128. */
  13129. syncWith(root: Animatable): Animatable;
  13130. /**
  13131. * Gets the list of runtime animations
  13132. * @returns an array of RuntimeAnimation
  13133. */
  13134. getAnimations(): RuntimeAnimation[];
  13135. /**
  13136. * Adds more animations to the current animatable
  13137. * @param target defines the target of the animations
  13138. * @param animations defines the new animations to add
  13139. */
  13140. appendAnimations(target: any, animations: Animation[]): void;
  13141. /**
  13142. * Gets the source animation for a specific property
  13143. * @param property defines the propertyu to look for
  13144. * @returns null or the source animation for the given property
  13145. */
  13146. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13147. /**
  13148. * Gets the runtime animation for a specific property
  13149. * @param property defines the propertyu to look for
  13150. * @returns null or the runtime animation for the given property
  13151. */
  13152. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13153. /**
  13154. * Resets the animatable to its original state
  13155. */
  13156. reset(): void;
  13157. /**
  13158. * Allows the animatable to blend with current running animations
  13159. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13160. * @param blendingSpeed defines the blending speed to use
  13161. */
  13162. enableBlending(blendingSpeed: number): void;
  13163. /**
  13164. * Disable animation blending
  13165. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13166. */
  13167. disableBlending(): void;
  13168. /**
  13169. * Jump directly to a given frame
  13170. * @param frame defines the frame to jump to
  13171. */
  13172. goToFrame(frame: number): void;
  13173. /**
  13174. * Pause the animation
  13175. */
  13176. pause(): void;
  13177. /**
  13178. * Restart the animation
  13179. */
  13180. restart(): void;
  13181. private _raiseOnAnimationEnd;
  13182. /**
  13183. * Stop and delete the current animation
  13184. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13185. * @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)
  13186. */
  13187. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13188. /**
  13189. * Wait asynchronously for the animation to end
  13190. * @returns a promise which will be fullfilled when the animation ends
  13191. */
  13192. waitAsync(): Promise<Animatable>;
  13193. /** @hidden */
  13194. _animate(delay: number): boolean;
  13195. }
  13196. interface Scene {
  13197. /** @hidden */
  13198. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13199. /** @hidden */
  13200. _processLateAnimationBindingsForMatrices(holder: {
  13201. totalWeight: number;
  13202. animations: RuntimeAnimation[];
  13203. originalValue: Matrix;
  13204. }): any;
  13205. /** @hidden */
  13206. _processLateAnimationBindingsForQuaternions(holder: {
  13207. totalWeight: number;
  13208. animations: RuntimeAnimation[];
  13209. originalValue: Quaternion;
  13210. }, refQuaternion: Quaternion): Quaternion;
  13211. /** @hidden */
  13212. _processLateAnimationBindings(): void;
  13213. /**
  13214. * Will start the animation sequence of a given target
  13215. * @param target defines the target
  13216. * @param from defines from which frame should animation start
  13217. * @param to defines until which frame should animation run.
  13218. * @param weight defines the weight to apply to the animation (1.0 by default)
  13219. * @param loop defines if the animation loops
  13220. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13221. * @param onAnimationEnd defines the function to be executed when the animation ends
  13222. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13223. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13224. * @param onAnimationLoop defines the callback to call when an animation loops
  13225. * @returns the animatable object created for this animation
  13226. */
  13227. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13228. /**
  13229. * Will start the animation sequence of a given target
  13230. * @param target defines the target
  13231. * @param from defines from which frame should animation start
  13232. * @param to defines until which frame should animation run.
  13233. * @param loop defines if the animation loops
  13234. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13235. * @param onAnimationEnd defines the function to be executed when the animation ends
  13236. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13237. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13238. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13239. * @param onAnimationLoop defines the callback to call when an animation loops
  13240. * @returns the animatable object created for this animation
  13241. */
  13242. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13243. /**
  13244. * Will start the animation sequence of a given target and its hierarchy
  13245. * @param target defines the target
  13246. * @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.
  13247. * @param from defines from which frame should animation start
  13248. * @param to defines until which frame should animation run.
  13249. * @param loop defines if the animation loops
  13250. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13251. * @param onAnimationEnd defines the function to be executed when the animation ends
  13252. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13253. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13254. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13255. * @param onAnimationLoop defines the callback to call when an animation loops
  13256. * @returns the list of created animatables
  13257. */
  13258. 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[];
  13259. /**
  13260. * Begin a new animation on a given node
  13261. * @param target defines the target where the animation will take place
  13262. * @param animations defines the list of animations to start
  13263. * @param from defines the initial value
  13264. * @param to defines the final value
  13265. * @param loop defines if you want animation to loop (off by default)
  13266. * @param speedRatio defines the speed ratio to apply to all animations
  13267. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13268. * @param onAnimationLoop defines the callback to call when an animation loops
  13269. * @returns the list of created animatables
  13270. */
  13271. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13272. /**
  13273. * Begin a new animation on a given node and its hierarchy
  13274. * @param target defines the root node where the animation will take place
  13275. * @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.
  13276. * @param animations defines the list of animations to start
  13277. * @param from defines the initial value
  13278. * @param to defines the final value
  13279. * @param loop defines if you want animation to loop (off by default)
  13280. * @param speedRatio defines the speed ratio to apply to all animations
  13281. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13282. * @param onAnimationLoop defines the callback to call when an animation loops
  13283. * @returns the list of animatables created for all nodes
  13284. */
  13285. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13286. /**
  13287. * Gets the animatable associated with a specific target
  13288. * @param target defines the target of the animatable
  13289. * @returns the required animatable if found
  13290. */
  13291. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13292. /**
  13293. * Gets all animatables associated with a given target
  13294. * @param target defines the target to look animatables for
  13295. * @returns an array of Animatables
  13296. */
  13297. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13298. /**
  13299. * Stops and removes all animations that have been applied to the scene
  13300. */
  13301. stopAllAnimations(): void;
  13302. /**
  13303. * Gets the current delta time used by animation engine
  13304. */
  13305. deltaTime: number;
  13306. }
  13307. interface Bone {
  13308. /**
  13309. * Copy an animation range from another bone
  13310. * @param source defines the source bone
  13311. * @param rangeName defines the range name to copy
  13312. * @param frameOffset defines the frame offset
  13313. * @param rescaleAsRequired defines if rescaling must be applied if required
  13314. * @param skelDimensionsRatio defines the scaling ratio
  13315. * @returns true if operation was successful
  13316. */
  13317. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13318. }
  13319. }
  13320. declare module BABYLON {
  13321. /**
  13322. * Class used to override all child animations of a given target
  13323. */
  13324. export class AnimationPropertiesOverride {
  13325. /**
  13326. * Gets or sets a value indicating if animation blending must be used
  13327. */
  13328. enableBlending: boolean;
  13329. /**
  13330. * Gets or sets the blending speed to use when enableBlending is true
  13331. */
  13332. blendingSpeed: number;
  13333. /**
  13334. * Gets or sets the default loop mode to use
  13335. */
  13336. loopMode: number;
  13337. }
  13338. }
  13339. declare module BABYLON {
  13340. /**
  13341. * Class used to handle skinning animations
  13342. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13343. */
  13344. export class Skeleton implements IAnimatable {
  13345. /** defines the skeleton name */
  13346. name: string;
  13347. /** defines the skeleton Id */
  13348. id: string;
  13349. /**
  13350. * Defines the list of child bones
  13351. */
  13352. bones: Bone[];
  13353. /**
  13354. * Defines an estimate of the dimension of the skeleton at rest
  13355. */
  13356. dimensionsAtRest: Vector3;
  13357. /**
  13358. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13359. */
  13360. needInitialSkinMatrix: boolean;
  13361. /**
  13362. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13363. */
  13364. overrideMesh: Nullable<AbstractMesh>;
  13365. /**
  13366. * Gets the list of animations attached to this skeleton
  13367. */
  13368. animations: Array<Animation>;
  13369. private _scene;
  13370. private _isDirty;
  13371. private _transformMatrices;
  13372. private _transformMatrixTexture;
  13373. private _meshesWithPoseMatrix;
  13374. private _animatables;
  13375. private _identity;
  13376. private _synchronizedWithMesh;
  13377. private _ranges;
  13378. private _lastAbsoluteTransformsUpdateId;
  13379. private _canUseTextureForBones;
  13380. private _uniqueId;
  13381. /** @hidden */
  13382. _numBonesWithLinkedTransformNode: number;
  13383. /** @hidden */
  13384. _hasWaitingData: Nullable<boolean>;
  13385. /**
  13386. * Specifies if the skeleton should be serialized
  13387. */
  13388. doNotSerialize: boolean;
  13389. private _useTextureToStoreBoneMatrices;
  13390. /**
  13391. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13392. * Please note that this option is not available if the hardware does not support it
  13393. */
  13394. useTextureToStoreBoneMatrices: boolean;
  13395. private _animationPropertiesOverride;
  13396. /**
  13397. * Gets or sets the animation properties override
  13398. */
  13399. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13400. /**
  13401. * List of inspectable custom properties (used by the Inspector)
  13402. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13403. */
  13404. inspectableCustomProperties: IInspectable[];
  13405. /**
  13406. * An observable triggered before computing the skeleton's matrices
  13407. */
  13408. onBeforeComputeObservable: Observable<Skeleton>;
  13409. /**
  13410. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13411. */
  13412. readonly isUsingTextureForMatrices: boolean;
  13413. /**
  13414. * Gets the unique ID of this skeleton
  13415. */
  13416. readonly uniqueId: number;
  13417. /**
  13418. * Creates a new skeleton
  13419. * @param name defines the skeleton name
  13420. * @param id defines the skeleton Id
  13421. * @param scene defines the hosting scene
  13422. */
  13423. constructor(
  13424. /** defines the skeleton name */
  13425. name: string,
  13426. /** defines the skeleton Id */
  13427. id: string, scene: Scene);
  13428. /**
  13429. * Gets the current object class name.
  13430. * @return the class name
  13431. */
  13432. getClassName(): string;
  13433. /**
  13434. * Returns an array containing the root bones
  13435. * @returns an array containing the root bones
  13436. */
  13437. getChildren(): Array<Bone>;
  13438. /**
  13439. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13440. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13441. * @returns a Float32Array containing matrices data
  13442. */
  13443. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13444. /**
  13445. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13446. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13447. * @returns a raw texture containing the data
  13448. */
  13449. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13450. /**
  13451. * Gets the current hosting scene
  13452. * @returns a scene object
  13453. */
  13454. getScene(): Scene;
  13455. /**
  13456. * Gets a string representing the current skeleton data
  13457. * @param fullDetails defines a boolean indicating if we want a verbose version
  13458. * @returns a string representing the current skeleton data
  13459. */
  13460. toString(fullDetails?: boolean): string;
  13461. /**
  13462. * Get bone's index searching by name
  13463. * @param name defines bone's name to search for
  13464. * @return the indice of the bone. Returns -1 if not found
  13465. */
  13466. getBoneIndexByName(name: string): number;
  13467. /**
  13468. * Creater a new animation range
  13469. * @param name defines the name of the range
  13470. * @param from defines the start key
  13471. * @param to defines the end key
  13472. */
  13473. createAnimationRange(name: string, from: number, to: number): void;
  13474. /**
  13475. * Delete a specific animation range
  13476. * @param name defines the name of the range
  13477. * @param deleteFrames defines if frames must be removed as well
  13478. */
  13479. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13480. /**
  13481. * Gets a specific animation range
  13482. * @param name defines the name of the range to look for
  13483. * @returns the requested animation range or null if not found
  13484. */
  13485. getAnimationRange(name: string): Nullable<AnimationRange>;
  13486. /**
  13487. * Gets the list of all animation ranges defined on this skeleton
  13488. * @returns an array
  13489. */
  13490. getAnimationRanges(): Nullable<AnimationRange>[];
  13491. /**
  13492. * Copy animation range from a source skeleton.
  13493. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13494. * @param source defines the source skeleton
  13495. * @param name defines the name of the range to copy
  13496. * @param rescaleAsRequired defines if rescaling must be applied if required
  13497. * @returns true if operation was successful
  13498. */
  13499. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13500. /**
  13501. * Forces the skeleton to go to rest pose
  13502. */
  13503. returnToRest(): void;
  13504. private _getHighestAnimationFrame;
  13505. /**
  13506. * Begin a specific animation range
  13507. * @param name defines the name of the range to start
  13508. * @param loop defines if looping must be turned on (false by default)
  13509. * @param speedRatio defines the speed ratio to apply (1 by default)
  13510. * @param onAnimationEnd defines a callback which will be called when animation will end
  13511. * @returns a new animatable
  13512. */
  13513. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13514. /** @hidden */
  13515. _markAsDirty(): void;
  13516. /** @hidden */
  13517. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13518. /** @hidden */
  13519. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13520. private _computeTransformMatrices;
  13521. /**
  13522. * Build all resources required to render a skeleton
  13523. */
  13524. prepare(): void;
  13525. /**
  13526. * Gets the list of animatables currently running for this skeleton
  13527. * @returns an array of animatables
  13528. */
  13529. getAnimatables(): IAnimatable[];
  13530. /**
  13531. * Clone the current skeleton
  13532. * @param name defines the name of the new skeleton
  13533. * @param id defines the id of the new skeleton
  13534. * @returns the new skeleton
  13535. */
  13536. clone(name: string, id?: string): Skeleton;
  13537. /**
  13538. * Enable animation blending for this skeleton
  13539. * @param blendingSpeed defines the blending speed to apply
  13540. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13541. */
  13542. enableBlending(blendingSpeed?: number): void;
  13543. /**
  13544. * Releases all resources associated with the current skeleton
  13545. */
  13546. dispose(): void;
  13547. /**
  13548. * Serialize the skeleton in a JSON object
  13549. * @returns a JSON object
  13550. */
  13551. serialize(): any;
  13552. /**
  13553. * Creates a new skeleton from serialized data
  13554. * @param parsedSkeleton defines the serialized data
  13555. * @param scene defines the hosting scene
  13556. * @returns a new skeleton
  13557. */
  13558. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13559. /**
  13560. * Compute all node absolute transforms
  13561. * @param forceUpdate defines if computation must be done even if cache is up to date
  13562. */
  13563. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13564. /**
  13565. * Gets the root pose matrix
  13566. * @returns a matrix
  13567. */
  13568. getPoseMatrix(): Nullable<Matrix>;
  13569. /**
  13570. * Sorts bones per internal index
  13571. */
  13572. sortBones(): void;
  13573. private _sortBones;
  13574. }
  13575. }
  13576. declare module BABYLON {
  13577. /**
  13578. * Class used to store bone information
  13579. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13580. */
  13581. export class Bone extends Node {
  13582. /**
  13583. * defines the bone name
  13584. */
  13585. name: string;
  13586. private static _tmpVecs;
  13587. private static _tmpQuat;
  13588. private static _tmpMats;
  13589. /**
  13590. * Gets the list of child bones
  13591. */
  13592. children: Bone[];
  13593. /** Gets the animations associated with this bone */
  13594. animations: Animation[];
  13595. /**
  13596. * Gets or sets bone length
  13597. */
  13598. length: number;
  13599. /**
  13600. * @hidden Internal only
  13601. * Set this value to map this bone to a different index in the transform matrices
  13602. * Set this value to -1 to exclude the bone from the transform matrices
  13603. */
  13604. _index: Nullable<number>;
  13605. private _skeleton;
  13606. private _localMatrix;
  13607. private _restPose;
  13608. private _baseMatrix;
  13609. private _absoluteTransform;
  13610. private _invertedAbsoluteTransform;
  13611. private _parent;
  13612. private _scalingDeterminant;
  13613. private _worldTransform;
  13614. private _localScaling;
  13615. private _localRotation;
  13616. private _localPosition;
  13617. private _needToDecompose;
  13618. private _needToCompose;
  13619. /** @hidden */
  13620. _linkedTransformNode: Nullable<TransformNode>;
  13621. /** @hidden */
  13622. _waitingTransformNodeId: Nullable<string>;
  13623. /** @hidden */
  13624. /** @hidden */
  13625. _matrix: Matrix;
  13626. /**
  13627. * Create a new bone
  13628. * @param name defines the bone name
  13629. * @param skeleton defines the parent skeleton
  13630. * @param parentBone defines the parent (can be null if the bone is the root)
  13631. * @param localMatrix defines the local matrix
  13632. * @param restPose defines the rest pose matrix
  13633. * @param baseMatrix defines the base matrix
  13634. * @param index defines index of the bone in the hiearchy
  13635. */
  13636. constructor(
  13637. /**
  13638. * defines the bone name
  13639. */
  13640. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13641. /**
  13642. * Gets the current object class name.
  13643. * @return the class name
  13644. */
  13645. getClassName(): string;
  13646. /**
  13647. * Gets the parent skeleton
  13648. * @returns a skeleton
  13649. */
  13650. getSkeleton(): Skeleton;
  13651. /**
  13652. * Gets parent bone
  13653. * @returns a bone or null if the bone is the root of the bone hierarchy
  13654. */
  13655. getParent(): Nullable<Bone>;
  13656. /**
  13657. * Returns an array containing the root bones
  13658. * @returns an array containing the root bones
  13659. */
  13660. getChildren(): Array<Bone>;
  13661. /**
  13662. * Gets the node index in matrix array generated for rendering
  13663. * @returns the node index
  13664. */
  13665. getIndex(): number;
  13666. /**
  13667. * Sets the parent bone
  13668. * @param parent defines the parent (can be null if the bone is the root)
  13669. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13670. */
  13671. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13672. /**
  13673. * Gets the local matrix
  13674. * @returns a matrix
  13675. */
  13676. getLocalMatrix(): Matrix;
  13677. /**
  13678. * Gets the base matrix (initial matrix which remains unchanged)
  13679. * @returns a matrix
  13680. */
  13681. getBaseMatrix(): Matrix;
  13682. /**
  13683. * Gets the rest pose matrix
  13684. * @returns a matrix
  13685. */
  13686. getRestPose(): Matrix;
  13687. /**
  13688. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13689. */
  13690. getWorldMatrix(): Matrix;
  13691. /**
  13692. * Sets the local matrix to rest pose matrix
  13693. */
  13694. returnToRest(): void;
  13695. /**
  13696. * Gets the inverse of the absolute transform matrix.
  13697. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13698. * @returns a matrix
  13699. */
  13700. getInvertedAbsoluteTransform(): Matrix;
  13701. /**
  13702. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13703. * @returns a matrix
  13704. */
  13705. getAbsoluteTransform(): Matrix;
  13706. /**
  13707. * Links with the given transform node.
  13708. * The local matrix of this bone is copied from the transform node every frame.
  13709. * @param transformNode defines the transform node to link to
  13710. */
  13711. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13712. /**
  13713. * Gets the node used to drive the bone's transformation
  13714. * @returns a transform node or null
  13715. */
  13716. getTransformNode(): Nullable<TransformNode>;
  13717. /** Gets or sets current position (in local space) */
  13718. position: Vector3;
  13719. /** Gets or sets current rotation (in local space) */
  13720. rotation: Vector3;
  13721. /** Gets or sets current rotation quaternion (in local space) */
  13722. rotationQuaternion: Quaternion;
  13723. /** Gets or sets current scaling (in local space) */
  13724. scaling: Vector3;
  13725. /**
  13726. * Gets the animation properties override
  13727. */
  13728. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13729. private _decompose;
  13730. private _compose;
  13731. /**
  13732. * Update the base and local matrices
  13733. * @param matrix defines the new base or local matrix
  13734. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13735. * @param updateLocalMatrix defines if the local matrix should be updated
  13736. */
  13737. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13738. /** @hidden */
  13739. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13740. /**
  13741. * Flag the bone as dirty (Forcing it to update everything)
  13742. */
  13743. markAsDirty(): void;
  13744. /** @hidden */
  13745. _markAsDirtyAndCompose(): void;
  13746. private _markAsDirtyAndDecompose;
  13747. /**
  13748. * Translate the bone in local or world space
  13749. * @param vec The amount to translate the bone
  13750. * @param space The space that the translation is in
  13751. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13752. */
  13753. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13754. /**
  13755. * Set the postion of the bone in local or world space
  13756. * @param position The position to set the bone
  13757. * @param space The space that the position is in
  13758. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13759. */
  13760. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13761. /**
  13762. * Set the absolute position of the bone (world space)
  13763. * @param position The position to set the bone
  13764. * @param mesh The mesh that this bone is attached to
  13765. */
  13766. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13767. /**
  13768. * Scale the bone on the x, y and z axes (in local space)
  13769. * @param x The amount to scale the bone on the x axis
  13770. * @param y The amount to scale the bone on the y axis
  13771. * @param z The amount to scale the bone on the z axis
  13772. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13773. */
  13774. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13775. /**
  13776. * Set the bone scaling in local space
  13777. * @param scale defines the scaling vector
  13778. */
  13779. setScale(scale: Vector3): void;
  13780. /**
  13781. * Gets the current scaling in local space
  13782. * @returns the current scaling vector
  13783. */
  13784. getScale(): Vector3;
  13785. /**
  13786. * Gets the current scaling in local space and stores it in a target vector
  13787. * @param result defines the target vector
  13788. */
  13789. getScaleToRef(result: Vector3): void;
  13790. /**
  13791. * Set the yaw, pitch, and roll of the bone in local or world space
  13792. * @param yaw The rotation of the bone on the y axis
  13793. * @param pitch The rotation of the bone on the x axis
  13794. * @param roll The rotation of the bone on the z axis
  13795. * @param space The space that the axes of rotation are in
  13796. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13797. */
  13798. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13799. /**
  13800. * Add a rotation to the bone on an axis in local or world space
  13801. * @param axis The axis to rotate the bone on
  13802. * @param amount The amount to rotate the bone
  13803. * @param space The space that the axis is in
  13804. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13805. */
  13806. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13807. /**
  13808. * Set the rotation of the bone to a particular axis angle in local or world space
  13809. * @param axis The axis to rotate the bone on
  13810. * @param angle The angle that the bone should be rotated to
  13811. * @param space The space that the axis is in
  13812. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13813. */
  13814. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13815. /**
  13816. * Set the euler rotation of the bone in local of world space
  13817. * @param rotation The euler rotation that the bone should be set to
  13818. * @param space The space that the rotation is in
  13819. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13820. */
  13821. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13822. /**
  13823. * Set the quaternion rotation of the bone in local of world space
  13824. * @param quat The quaternion rotation that the bone should be set to
  13825. * @param space The space that the rotation is in
  13826. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13827. */
  13828. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13829. /**
  13830. * Set the rotation matrix of the bone in local of world space
  13831. * @param rotMat The rotation matrix that the bone should be set to
  13832. * @param space The space that the rotation is in
  13833. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13834. */
  13835. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13836. private _rotateWithMatrix;
  13837. private _getNegativeRotationToRef;
  13838. /**
  13839. * Get the position of the bone in local or world space
  13840. * @param space The space that the returned position is in
  13841. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13842. * @returns The position of the bone
  13843. */
  13844. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13845. /**
  13846. * Copy the position of the bone to a vector3 in local or world space
  13847. * @param space The space that the returned position is in
  13848. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13849. * @param result The vector3 to copy the position to
  13850. */
  13851. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13852. /**
  13853. * Get the absolute position of the bone (world space)
  13854. * @param mesh The mesh that this bone is attached to
  13855. * @returns The absolute position of the bone
  13856. */
  13857. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13858. /**
  13859. * Copy the absolute position of the bone (world space) to the result param
  13860. * @param mesh The mesh that this bone is attached to
  13861. * @param result The vector3 to copy the absolute position to
  13862. */
  13863. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13864. /**
  13865. * Compute the absolute transforms of this bone and its children
  13866. */
  13867. computeAbsoluteTransforms(): void;
  13868. /**
  13869. * Get the world direction from an axis that is in the local space of the bone
  13870. * @param localAxis The local direction that is used to compute the world direction
  13871. * @param mesh The mesh that this bone is attached to
  13872. * @returns The world direction
  13873. */
  13874. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13875. /**
  13876. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13877. * @param localAxis The local direction that is used to compute the world direction
  13878. * @param mesh The mesh that this bone is attached to
  13879. * @param result The vector3 that the world direction will be copied to
  13880. */
  13881. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13882. /**
  13883. * Get the euler rotation of the bone in local or world space
  13884. * @param space The space that the rotation should be in
  13885. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13886. * @returns The euler rotation
  13887. */
  13888. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13889. /**
  13890. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13891. * @param space The space that the rotation should be in
  13892. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13893. * @param result The vector3 that the rotation should be copied to
  13894. */
  13895. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13896. /**
  13897. * Get the quaternion rotation of the bone in either local or world space
  13898. * @param space The space that the rotation should be in
  13899. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13900. * @returns The quaternion rotation
  13901. */
  13902. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13903. /**
  13904. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13905. * @param space The space that the rotation should be in
  13906. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13907. * @param result The quaternion that the rotation should be copied to
  13908. */
  13909. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13910. /**
  13911. * Get the rotation matrix of the bone in local or world space
  13912. * @param space The space that the rotation should be in
  13913. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13914. * @returns The rotation matrix
  13915. */
  13916. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13917. /**
  13918. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13919. * @param space The space that the rotation should be in
  13920. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13921. * @param result The quaternion that the rotation should be copied to
  13922. */
  13923. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13924. /**
  13925. * Get the world position of a point that is in the local space of the bone
  13926. * @param position The local position
  13927. * @param mesh The mesh that this bone is attached to
  13928. * @returns The world position
  13929. */
  13930. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13931. /**
  13932. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13933. * @param position The local position
  13934. * @param mesh The mesh that this bone is attached to
  13935. * @param result The vector3 that the world position should be copied to
  13936. */
  13937. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13938. /**
  13939. * Get the local position of a point that is in world space
  13940. * @param position The world position
  13941. * @param mesh The mesh that this bone is attached to
  13942. * @returns The local position
  13943. */
  13944. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13945. /**
  13946. * Get the local position of a point that is in world space and copy it to the result param
  13947. * @param position The world position
  13948. * @param mesh The mesh that this bone is attached to
  13949. * @param result The vector3 that the local position should be copied to
  13950. */
  13951. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13952. }
  13953. }
  13954. declare module BABYLON {
  13955. /**
  13956. * 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.
  13957. * @see https://doc.babylonjs.com/how_to/transformnode
  13958. */
  13959. export class TransformNode extends Node {
  13960. /**
  13961. * Object will not rotate to face the camera
  13962. */
  13963. static BILLBOARDMODE_NONE: number;
  13964. /**
  13965. * Object will rotate to face the camera but only on the x axis
  13966. */
  13967. static BILLBOARDMODE_X: number;
  13968. /**
  13969. * Object will rotate to face the camera but only on the y axis
  13970. */
  13971. static BILLBOARDMODE_Y: number;
  13972. /**
  13973. * Object will rotate to face the camera but only on the z axis
  13974. */
  13975. static BILLBOARDMODE_Z: number;
  13976. /**
  13977. * Object will rotate to face the camera
  13978. */
  13979. static BILLBOARDMODE_ALL: number;
  13980. /**
  13981. * Object will rotate to face the camera's position instead of orientation
  13982. */
  13983. static BILLBOARDMODE_USE_POSITION: number;
  13984. private _forward;
  13985. private _forwardInverted;
  13986. private _up;
  13987. private _right;
  13988. private _rightInverted;
  13989. private _position;
  13990. private _rotation;
  13991. private _rotationQuaternion;
  13992. protected _scaling: Vector3;
  13993. protected _isDirty: boolean;
  13994. private _transformToBoneReferal;
  13995. private _isAbsoluteSynced;
  13996. private _billboardMode;
  13997. /**
  13998. * Gets or sets the billboard mode. Default is 0.
  13999. *
  14000. * | Value | Type | Description |
  14001. * | --- | --- | --- |
  14002. * | 0 | BILLBOARDMODE_NONE | |
  14003. * | 1 | BILLBOARDMODE_X | |
  14004. * | 2 | BILLBOARDMODE_Y | |
  14005. * | 4 | BILLBOARDMODE_Z | |
  14006. * | 7 | BILLBOARDMODE_ALL | |
  14007. *
  14008. */
  14009. billboardMode: number;
  14010. private _preserveParentRotationForBillboard;
  14011. /**
  14012. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14013. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14014. */
  14015. preserveParentRotationForBillboard: boolean;
  14016. /**
  14017. * 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
  14018. */
  14019. scalingDeterminant: number;
  14020. private _infiniteDistance;
  14021. /**
  14022. * Gets or sets the distance of the object to max, often used by skybox
  14023. */
  14024. infiniteDistance: boolean;
  14025. /**
  14026. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14027. * By default the system will update normals to compensate
  14028. */
  14029. ignoreNonUniformScaling: boolean;
  14030. /**
  14031. * 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
  14032. */
  14033. reIntegrateRotationIntoRotationQuaternion: boolean;
  14034. /** @hidden */
  14035. _poseMatrix: Nullable<Matrix>;
  14036. /** @hidden */
  14037. _localMatrix: Matrix;
  14038. private _usePivotMatrix;
  14039. private _absolutePosition;
  14040. private _absoluteScaling;
  14041. private _absoluteRotationQuaternion;
  14042. private _pivotMatrix;
  14043. private _pivotMatrixInverse;
  14044. protected _postMultiplyPivotMatrix: boolean;
  14045. protected _isWorldMatrixFrozen: boolean;
  14046. /** @hidden */
  14047. _indexInSceneTransformNodesArray: number;
  14048. /**
  14049. * An event triggered after the world matrix is updated
  14050. */
  14051. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14052. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14053. /**
  14054. * Gets a string identifying the name of the class
  14055. * @returns "TransformNode" string
  14056. */
  14057. getClassName(): string;
  14058. /**
  14059. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14060. */
  14061. position: Vector3;
  14062. /**
  14063. * 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)).
  14064. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14065. */
  14066. rotation: Vector3;
  14067. /**
  14068. * 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)).
  14069. */
  14070. scaling: Vector3;
  14071. /**
  14072. * 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).
  14073. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14074. */
  14075. rotationQuaternion: Nullable<Quaternion>;
  14076. /**
  14077. * The forward direction of that transform in world space.
  14078. */
  14079. readonly forward: Vector3;
  14080. /**
  14081. * The up direction of that transform in world space.
  14082. */
  14083. readonly up: Vector3;
  14084. /**
  14085. * The right direction of that transform in world space.
  14086. */
  14087. readonly right: Vector3;
  14088. /**
  14089. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14090. * @param matrix the matrix to copy the pose from
  14091. * @returns this TransformNode.
  14092. */
  14093. updatePoseMatrix(matrix: Matrix): TransformNode;
  14094. /**
  14095. * Returns the mesh Pose matrix.
  14096. * @returns the pose matrix
  14097. */
  14098. getPoseMatrix(): Matrix;
  14099. /** @hidden */
  14100. _isSynchronized(): boolean;
  14101. /** @hidden */
  14102. _initCache(): void;
  14103. /**
  14104. * Flag the transform node as dirty (Forcing it to update everything)
  14105. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14106. * @returns this transform node
  14107. */
  14108. markAsDirty(property: string): TransformNode;
  14109. /**
  14110. * Returns the current mesh absolute position.
  14111. * Returns a Vector3.
  14112. */
  14113. readonly absolutePosition: Vector3;
  14114. /**
  14115. * Returns the current mesh absolute scaling.
  14116. * Returns a Vector3.
  14117. */
  14118. readonly absoluteScaling: Vector3;
  14119. /**
  14120. * Returns the current mesh absolute rotation.
  14121. * Returns a Quaternion.
  14122. */
  14123. readonly absoluteRotationQuaternion: Quaternion;
  14124. /**
  14125. * Sets a new matrix to apply before all other transformation
  14126. * @param matrix defines the transform matrix
  14127. * @returns the current TransformNode
  14128. */
  14129. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14130. /**
  14131. * Sets a new pivot matrix to the current node
  14132. * @param matrix defines the new pivot matrix to use
  14133. * @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
  14134. * @returns the current TransformNode
  14135. */
  14136. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14137. /**
  14138. * Returns the mesh pivot matrix.
  14139. * Default : Identity.
  14140. * @returns the matrix
  14141. */
  14142. getPivotMatrix(): Matrix;
  14143. /**
  14144. * Instantiate (when possible) or clone that node with its hierarchy
  14145. * @param newParent defines the new parent to use for the instance (or clone)
  14146. * @param options defines options to configure how copy is done
  14147. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14148. * @returns an instance (or a clone) of the current node with its hiearchy
  14149. */
  14150. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14151. doNotInstantiate: boolean;
  14152. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14153. /**
  14154. * Prevents the World matrix to be computed any longer
  14155. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14156. * @returns the TransformNode.
  14157. */
  14158. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14159. /**
  14160. * Allows back the World matrix computation.
  14161. * @returns the TransformNode.
  14162. */
  14163. unfreezeWorldMatrix(): this;
  14164. /**
  14165. * True if the World matrix has been frozen.
  14166. */
  14167. readonly isWorldMatrixFrozen: boolean;
  14168. /**
  14169. * Retuns the mesh absolute position in the World.
  14170. * @returns a Vector3.
  14171. */
  14172. getAbsolutePosition(): Vector3;
  14173. /**
  14174. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14175. * @param absolutePosition the absolute position to set
  14176. * @returns the TransformNode.
  14177. */
  14178. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14179. /**
  14180. * Sets the mesh position in its local space.
  14181. * @param vector3 the position to set in localspace
  14182. * @returns the TransformNode.
  14183. */
  14184. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14185. /**
  14186. * Returns the mesh position in the local space from the current World matrix values.
  14187. * @returns a new Vector3.
  14188. */
  14189. getPositionExpressedInLocalSpace(): Vector3;
  14190. /**
  14191. * Translates the mesh along the passed Vector3 in its local space.
  14192. * @param vector3 the distance to translate in localspace
  14193. * @returns the TransformNode.
  14194. */
  14195. locallyTranslate(vector3: Vector3): TransformNode;
  14196. private static _lookAtVectorCache;
  14197. /**
  14198. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14199. * @param targetPoint the position (must be in same space as current mesh) to look at
  14200. * @param yawCor optional yaw (y-axis) correction in radians
  14201. * @param pitchCor optional pitch (x-axis) correction in radians
  14202. * @param rollCor optional roll (z-axis) correction in radians
  14203. * @param space the choosen space of the target
  14204. * @returns the TransformNode.
  14205. */
  14206. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14207. /**
  14208. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14209. * This Vector3 is expressed in the World space.
  14210. * @param localAxis axis to rotate
  14211. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14212. */
  14213. getDirection(localAxis: Vector3): Vector3;
  14214. /**
  14215. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14216. * localAxis is expressed in the mesh local space.
  14217. * result is computed in the Wordl space from the mesh World matrix.
  14218. * @param localAxis axis to rotate
  14219. * @param result the resulting transformnode
  14220. * @returns this TransformNode.
  14221. */
  14222. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14223. /**
  14224. * Sets this transform node rotation to the given local axis.
  14225. * @param localAxis the axis in local space
  14226. * @param yawCor optional yaw (y-axis) correction in radians
  14227. * @param pitchCor optional pitch (x-axis) correction in radians
  14228. * @param rollCor optional roll (z-axis) correction in radians
  14229. * @returns this TransformNode
  14230. */
  14231. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14232. /**
  14233. * Sets a new pivot point to the current node
  14234. * @param point defines the new pivot point to use
  14235. * @param space defines if the point is in world or local space (local by default)
  14236. * @returns the current TransformNode
  14237. */
  14238. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14239. /**
  14240. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14241. * @returns the pivot point
  14242. */
  14243. getPivotPoint(): Vector3;
  14244. /**
  14245. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14246. * @param result the vector3 to store the result
  14247. * @returns this TransformNode.
  14248. */
  14249. getPivotPointToRef(result: Vector3): TransformNode;
  14250. /**
  14251. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14252. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14253. */
  14254. getAbsolutePivotPoint(): Vector3;
  14255. /**
  14256. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14257. * @param result vector3 to store the result
  14258. * @returns this TransformNode.
  14259. */
  14260. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14261. /**
  14262. * Defines the passed node as the parent of the current node.
  14263. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14264. * @see https://doc.babylonjs.com/how_to/parenting
  14265. * @param node the node ot set as the parent
  14266. * @returns this TransformNode.
  14267. */
  14268. setParent(node: Nullable<Node>): TransformNode;
  14269. private _nonUniformScaling;
  14270. /**
  14271. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14272. */
  14273. readonly nonUniformScaling: boolean;
  14274. /** @hidden */
  14275. _updateNonUniformScalingState(value: boolean): boolean;
  14276. /**
  14277. * Attach the current TransformNode to another TransformNode associated with a bone
  14278. * @param bone Bone affecting the TransformNode
  14279. * @param affectedTransformNode TransformNode associated with the bone
  14280. * @returns this object
  14281. */
  14282. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14283. /**
  14284. * Detach the transform node if its associated with a bone
  14285. * @returns this object
  14286. */
  14287. detachFromBone(): TransformNode;
  14288. private static _rotationAxisCache;
  14289. /**
  14290. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14291. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14292. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14293. * The passed axis is also normalized.
  14294. * @param axis the axis to rotate around
  14295. * @param amount the amount to rotate in radians
  14296. * @param space Space to rotate in (Default: local)
  14297. * @returns the TransformNode.
  14298. */
  14299. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14300. /**
  14301. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14302. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14303. * The passed axis is also normalized. .
  14304. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14305. * @param point the point to rotate around
  14306. * @param axis the axis to rotate around
  14307. * @param amount the amount to rotate in radians
  14308. * @returns the TransformNode
  14309. */
  14310. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14311. /**
  14312. * Translates the mesh along the axis vector for the passed distance in the given space.
  14313. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14314. * @param axis the axis to translate in
  14315. * @param distance the distance to translate
  14316. * @param space Space to rotate in (Default: local)
  14317. * @returns the TransformNode.
  14318. */
  14319. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14320. /**
  14321. * Adds a rotation step to the mesh current rotation.
  14322. * x, y, z are Euler angles expressed in radians.
  14323. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14324. * This means this rotation is made in the mesh local space only.
  14325. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14326. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14327. * ```javascript
  14328. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14329. * ```
  14330. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14331. * 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.
  14332. * @param x Rotation to add
  14333. * @param y Rotation to add
  14334. * @param z Rotation to add
  14335. * @returns the TransformNode.
  14336. */
  14337. addRotation(x: number, y: number, z: number): TransformNode;
  14338. /**
  14339. * @hidden
  14340. */
  14341. protected _getEffectiveParent(): Nullable<Node>;
  14342. /**
  14343. * Computes the world matrix of the node
  14344. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14345. * @returns the world matrix
  14346. */
  14347. computeWorldMatrix(force?: boolean): Matrix;
  14348. protected _afterComputeWorldMatrix(): void;
  14349. /**
  14350. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14351. * @param func callback function to add
  14352. *
  14353. * @returns the TransformNode.
  14354. */
  14355. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14356. /**
  14357. * Removes a registered callback function.
  14358. * @param func callback function to remove
  14359. * @returns the TransformNode.
  14360. */
  14361. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14362. /**
  14363. * Gets the position of the current mesh in camera space
  14364. * @param camera defines the camera to use
  14365. * @returns a position
  14366. */
  14367. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14368. /**
  14369. * Returns the distance from the mesh to the active camera
  14370. * @param camera defines the camera to use
  14371. * @returns the distance
  14372. */
  14373. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14374. /**
  14375. * Clone the current transform node
  14376. * @param name Name of the new clone
  14377. * @param newParent New parent for the clone
  14378. * @param doNotCloneChildren Do not clone children hierarchy
  14379. * @returns the new transform node
  14380. */
  14381. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14382. /**
  14383. * Serializes the objects information.
  14384. * @param currentSerializationObject defines the object to serialize in
  14385. * @returns the serialized object
  14386. */
  14387. serialize(currentSerializationObject?: any): any;
  14388. /**
  14389. * Returns a new TransformNode object parsed from the source provided.
  14390. * @param parsedTransformNode is the source.
  14391. * @param scene the scne the object belongs to
  14392. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14393. * @returns a new TransformNode object parsed from the source provided.
  14394. */
  14395. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14396. /**
  14397. * Get all child-transformNodes of this node
  14398. * @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
  14399. * @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
  14400. * @returns an array of TransformNode
  14401. */
  14402. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14403. /**
  14404. * Releases resources associated with this transform node.
  14405. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14406. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14407. */
  14408. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14409. /**
  14410. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14411. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14412. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14413. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14414. * @returns the current mesh
  14415. */
  14416. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14417. private _syncAbsoluteScalingAndRotation;
  14418. }
  14419. }
  14420. declare module BABYLON {
  14421. /**
  14422. * Defines the types of pose enabled controllers that are supported
  14423. */
  14424. export enum PoseEnabledControllerType {
  14425. /**
  14426. * HTC Vive
  14427. */
  14428. VIVE = 0,
  14429. /**
  14430. * Oculus Rift
  14431. */
  14432. OCULUS = 1,
  14433. /**
  14434. * Windows mixed reality
  14435. */
  14436. WINDOWS = 2,
  14437. /**
  14438. * Samsung gear VR
  14439. */
  14440. GEAR_VR = 3,
  14441. /**
  14442. * Google Daydream
  14443. */
  14444. DAYDREAM = 4,
  14445. /**
  14446. * Generic
  14447. */
  14448. GENERIC = 5
  14449. }
  14450. /**
  14451. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14452. */
  14453. export interface MutableGamepadButton {
  14454. /**
  14455. * Value of the button/trigger
  14456. */
  14457. value: number;
  14458. /**
  14459. * If the button/trigger is currently touched
  14460. */
  14461. touched: boolean;
  14462. /**
  14463. * If the button/trigger is currently pressed
  14464. */
  14465. pressed: boolean;
  14466. }
  14467. /**
  14468. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14469. * @hidden
  14470. */
  14471. export interface ExtendedGamepadButton extends GamepadButton {
  14472. /**
  14473. * If the button/trigger is currently pressed
  14474. */
  14475. readonly pressed: boolean;
  14476. /**
  14477. * If the button/trigger is currently touched
  14478. */
  14479. readonly touched: boolean;
  14480. /**
  14481. * Value of the button/trigger
  14482. */
  14483. readonly value: number;
  14484. }
  14485. /** @hidden */
  14486. export interface _GamePadFactory {
  14487. /**
  14488. * Returns wether or not the current gamepad can be created for this type of controller.
  14489. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14490. * @returns true if it can be created, otherwise false
  14491. */
  14492. canCreate(gamepadInfo: any): boolean;
  14493. /**
  14494. * Creates a new instance of the Gamepad.
  14495. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14496. * @returns the new gamepad instance
  14497. */
  14498. create(gamepadInfo: any): Gamepad;
  14499. }
  14500. /**
  14501. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14502. */
  14503. export class PoseEnabledControllerHelper {
  14504. /** @hidden */
  14505. static _ControllerFactories: _GamePadFactory[];
  14506. /** @hidden */
  14507. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14508. /**
  14509. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14510. * @param vrGamepad the gamepad to initialized
  14511. * @returns a vr controller of the type the gamepad identified as
  14512. */
  14513. static InitiateController(vrGamepad: any): Gamepad;
  14514. }
  14515. /**
  14516. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14517. */
  14518. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14519. /**
  14520. * If the controller is used in a webXR session
  14521. */
  14522. isXR: boolean;
  14523. private _deviceRoomPosition;
  14524. private _deviceRoomRotationQuaternion;
  14525. /**
  14526. * The device position in babylon space
  14527. */
  14528. devicePosition: Vector3;
  14529. /**
  14530. * The device rotation in babylon space
  14531. */
  14532. deviceRotationQuaternion: Quaternion;
  14533. /**
  14534. * The scale factor of the device in babylon space
  14535. */
  14536. deviceScaleFactor: number;
  14537. /**
  14538. * (Likely devicePosition should be used instead) The device position in its room space
  14539. */
  14540. position: Vector3;
  14541. /**
  14542. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14543. */
  14544. rotationQuaternion: Quaternion;
  14545. /**
  14546. * The type of controller (Eg. Windows mixed reality)
  14547. */
  14548. controllerType: PoseEnabledControllerType;
  14549. protected _calculatedPosition: Vector3;
  14550. private _calculatedRotation;
  14551. /**
  14552. * The raw pose from the device
  14553. */
  14554. rawPose: DevicePose;
  14555. private _trackPosition;
  14556. private _maxRotationDistFromHeadset;
  14557. private _draggedRoomRotation;
  14558. /**
  14559. * @hidden
  14560. */
  14561. _disableTrackPosition(fixedPosition: Vector3): void;
  14562. /**
  14563. * Internal, the mesh attached to the controller
  14564. * @hidden
  14565. */
  14566. _mesh: Nullable<AbstractMesh>;
  14567. private _poseControlledCamera;
  14568. private _leftHandSystemQuaternion;
  14569. /**
  14570. * Internal, matrix used to convert room space to babylon space
  14571. * @hidden
  14572. */
  14573. _deviceToWorld: Matrix;
  14574. /**
  14575. * Node to be used when casting a ray from the controller
  14576. * @hidden
  14577. */
  14578. _pointingPoseNode: Nullable<TransformNode>;
  14579. /**
  14580. * Name of the child mesh that can be used to cast a ray from the controller
  14581. */
  14582. static readonly POINTING_POSE: string;
  14583. /**
  14584. * Creates a new PoseEnabledController from a gamepad
  14585. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14586. */
  14587. constructor(browserGamepad: any);
  14588. private _workingMatrix;
  14589. /**
  14590. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14591. */
  14592. update(): void;
  14593. /**
  14594. * Updates only the pose device and mesh without doing any button event checking
  14595. */
  14596. protected _updatePoseAndMesh(): void;
  14597. /**
  14598. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14599. * @param poseData raw pose fromthe device
  14600. */
  14601. updateFromDevice(poseData: DevicePose): void;
  14602. /**
  14603. * @hidden
  14604. */
  14605. _meshAttachedObservable: Observable<AbstractMesh>;
  14606. /**
  14607. * Attaches a mesh to the controller
  14608. * @param mesh the mesh to be attached
  14609. */
  14610. attachToMesh(mesh: AbstractMesh): void;
  14611. /**
  14612. * Attaches the controllers mesh to a camera
  14613. * @param camera the camera the mesh should be attached to
  14614. */
  14615. attachToPoseControlledCamera(camera: TargetCamera): void;
  14616. /**
  14617. * Disposes of the controller
  14618. */
  14619. dispose(): void;
  14620. /**
  14621. * The mesh that is attached to the controller
  14622. */
  14623. readonly mesh: Nullable<AbstractMesh>;
  14624. /**
  14625. * Gets the ray of the controller in the direction the controller is pointing
  14626. * @param length the length the resulting ray should be
  14627. * @returns a ray in the direction the controller is pointing
  14628. */
  14629. getForwardRay(length?: number): Ray;
  14630. }
  14631. }
  14632. declare module BABYLON {
  14633. /**
  14634. * Defines the WebVRController object that represents controllers tracked in 3D space
  14635. */
  14636. export abstract class WebVRController extends PoseEnabledController {
  14637. /**
  14638. * Internal, the default controller model for the controller
  14639. */
  14640. protected _defaultModel: Nullable<AbstractMesh>;
  14641. /**
  14642. * Fired when the trigger state has changed
  14643. */
  14644. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14645. /**
  14646. * Fired when the main button state has changed
  14647. */
  14648. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14649. /**
  14650. * Fired when the secondary button state has changed
  14651. */
  14652. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14653. /**
  14654. * Fired when the pad state has changed
  14655. */
  14656. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14657. /**
  14658. * Fired when controllers stick values have changed
  14659. */
  14660. onPadValuesChangedObservable: Observable<StickValues>;
  14661. /**
  14662. * Array of button availible on the controller
  14663. */
  14664. protected _buttons: Array<MutableGamepadButton>;
  14665. private _onButtonStateChange;
  14666. /**
  14667. * Fired when a controller button's state has changed
  14668. * @param callback the callback containing the button that was modified
  14669. */
  14670. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14671. /**
  14672. * X and Y axis corresponding to the controllers joystick
  14673. */
  14674. pad: StickValues;
  14675. /**
  14676. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14677. */
  14678. hand: string;
  14679. /**
  14680. * The default controller model for the controller
  14681. */
  14682. readonly defaultModel: Nullable<AbstractMesh>;
  14683. /**
  14684. * Creates a new WebVRController from a gamepad
  14685. * @param vrGamepad the gamepad that the WebVRController should be created from
  14686. */
  14687. constructor(vrGamepad: any);
  14688. /**
  14689. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14690. */
  14691. update(): void;
  14692. /**
  14693. * Function to be called when a button is modified
  14694. */
  14695. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14696. /**
  14697. * Loads a mesh and attaches it to the controller
  14698. * @param scene the scene the mesh should be added to
  14699. * @param meshLoaded callback for when the mesh has been loaded
  14700. */
  14701. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14702. private _setButtonValue;
  14703. private _changes;
  14704. private _checkChanges;
  14705. /**
  14706. * Disposes of th webVRCOntroller
  14707. */
  14708. dispose(): void;
  14709. }
  14710. }
  14711. declare module BABYLON {
  14712. /**
  14713. * The HemisphericLight simulates the ambient environment light,
  14714. * so the passed direction is the light reflection direction, not the incoming direction.
  14715. */
  14716. export class HemisphericLight extends Light {
  14717. /**
  14718. * The groundColor is the light in the opposite direction to the one specified during creation.
  14719. * 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.
  14720. */
  14721. groundColor: Color3;
  14722. /**
  14723. * The light reflection direction, not the incoming direction.
  14724. */
  14725. direction: Vector3;
  14726. /**
  14727. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14728. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14729. * The HemisphericLight can't cast shadows.
  14730. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14731. * @param name The friendly name of the light
  14732. * @param direction The direction of the light reflection
  14733. * @param scene The scene the light belongs to
  14734. */
  14735. constructor(name: string, direction: Vector3, scene: Scene);
  14736. protected _buildUniformLayout(): void;
  14737. /**
  14738. * Returns the string "HemisphericLight".
  14739. * @return The class name
  14740. */
  14741. getClassName(): string;
  14742. /**
  14743. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14744. * Returns the updated direction.
  14745. * @param target The target the direction should point to
  14746. * @return The computed direction
  14747. */
  14748. setDirectionToTarget(target: Vector3): Vector3;
  14749. /**
  14750. * Returns the shadow generator associated to the light.
  14751. * @returns Always null for hemispheric lights because it does not support shadows.
  14752. */
  14753. getShadowGenerator(): Nullable<IShadowGenerator>;
  14754. /**
  14755. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14756. * @param effect The effect to update
  14757. * @param lightIndex The index of the light in the effect to update
  14758. * @returns The hemispheric light
  14759. */
  14760. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14761. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14762. /**
  14763. * Computes the world matrix of the node
  14764. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14765. * @param useWasUpdatedFlag defines a reserved property
  14766. * @returns the world matrix
  14767. */
  14768. computeWorldMatrix(): Matrix;
  14769. /**
  14770. * Returns the integer 3.
  14771. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14772. */
  14773. getTypeID(): number;
  14774. /**
  14775. * Prepares the list of defines specific to the light type.
  14776. * @param defines the list of defines
  14777. * @param lightIndex defines the index of the light for the effect
  14778. */
  14779. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14780. }
  14781. }
  14782. declare module BABYLON {
  14783. /** @hidden */
  14784. export var vrMultiviewToSingleviewPixelShader: {
  14785. name: string;
  14786. shader: string;
  14787. };
  14788. }
  14789. declare module BABYLON {
  14790. /**
  14791. * Renders to multiple views with a single draw call
  14792. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14793. */
  14794. export class MultiviewRenderTarget extends RenderTargetTexture {
  14795. /**
  14796. * Creates a multiview render target
  14797. * @param scene scene used with the render target
  14798. * @param size the size of the render target (used for each view)
  14799. */
  14800. constructor(scene: Scene, size?: number | {
  14801. width: number;
  14802. height: number;
  14803. } | {
  14804. ratio: number;
  14805. });
  14806. /**
  14807. * @hidden
  14808. * @param faceIndex the face index, if its a cube texture
  14809. */
  14810. _bindFrameBuffer(faceIndex?: number): void;
  14811. /**
  14812. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14813. * @returns the view count
  14814. */
  14815. getViewCount(): number;
  14816. }
  14817. }
  14818. declare module BABYLON {
  14819. /**
  14820. * Represents a camera frustum
  14821. */
  14822. export class Frustum {
  14823. /**
  14824. * Gets the planes representing the frustum
  14825. * @param transform matrix to be applied to the returned planes
  14826. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14827. */
  14828. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14829. /**
  14830. * Gets the near frustum plane transformed by the transform matrix
  14831. * @param transform transformation matrix to be applied to the resulting frustum plane
  14832. * @param frustumPlane the resuling frustum plane
  14833. */
  14834. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14835. /**
  14836. * Gets the far frustum plane transformed by the transform matrix
  14837. * @param transform transformation matrix to be applied to the resulting frustum plane
  14838. * @param frustumPlane the resuling frustum plane
  14839. */
  14840. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14841. /**
  14842. * Gets the left frustum plane transformed by the transform matrix
  14843. * @param transform transformation matrix to be applied to the resulting frustum plane
  14844. * @param frustumPlane the resuling frustum plane
  14845. */
  14846. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14847. /**
  14848. * Gets the right frustum plane transformed by the transform matrix
  14849. * @param transform transformation matrix to be applied to the resulting frustum plane
  14850. * @param frustumPlane the resuling frustum plane
  14851. */
  14852. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14853. /**
  14854. * Gets the top frustum plane transformed by the transform matrix
  14855. * @param transform transformation matrix to be applied to the resulting frustum plane
  14856. * @param frustumPlane the resuling frustum plane
  14857. */
  14858. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14859. /**
  14860. * Gets the bottom frustum plane transformed by the transform matrix
  14861. * @param transform transformation matrix to be applied to the resulting frustum plane
  14862. * @param frustumPlane the resuling frustum plane
  14863. */
  14864. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14865. /**
  14866. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14867. * @param transform transformation matrix to be applied to the resulting frustum planes
  14868. * @param frustumPlanes the resuling frustum planes
  14869. */
  14870. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14871. }
  14872. }
  14873. declare module BABYLON {
  14874. interface Engine {
  14875. /**
  14876. * Creates a new multiview render target
  14877. * @param width defines the width of the texture
  14878. * @param height defines the height of the texture
  14879. * @returns the created multiview texture
  14880. */
  14881. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14882. /**
  14883. * Binds a multiview framebuffer to be drawn to
  14884. * @param multiviewTexture texture to bind
  14885. */
  14886. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14887. }
  14888. interface Camera {
  14889. /**
  14890. * @hidden
  14891. * 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)
  14892. */
  14893. _useMultiviewToSingleView: boolean;
  14894. /**
  14895. * @hidden
  14896. * 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)
  14897. */
  14898. _multiviewTexture: Nullable<RenderTargetTexture>;
  14899. /**
  14900. * @hidden
  14901. * ensures the multiview texture of the camera exists and has the specified width/height
  14902. * @param width height to set on the multiview texture
  14903. * @param height width to set on the multiview texture
  14904. */
  14905. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  14906. }
  14907. interface Scene {
  14908. /** @hidden */
  14909. _transformMatrixR: Matrix;
  14910. /** @hidden */
  14911. _multiviewSceneUbo: Nullable<UniformBuffer>;
  14912. /** @hidden */
  14913. _createMultiviewUbo(): void;
  14914. /** @hidden */
  14915. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  14916. /** @hidden */
  14917. _renderMultiviewToSingleView(camera: Camera): void;
  14918. }
  14919. }
  14920. declare module BABYLON {
  14921. /**
  14922. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  14923. * This will not be used for webXR as it supports displaying texture arrays directly
  14924. */
  14925. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  14926. /**
  14927. * Initializes a VRMultiviewToSingleview
  14928. * @param name name of the post process
  14929. * @param camera camera to be applied to
  14930. * @param scaleFactor scaling factor to the size of the output texture
  14931. */
  14932. constructor(name: string, camera: Camera, scaleFactor: number);
  14933. }
  14934. }
  14935. declare module BABYLON {
  14936. /**
  14937. * Interface used to define additional presentation attributes
  14938. */
  14939. export interface IVRPresentationAttributes {
  14940. /**
  14941. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  14942. */
  14943. highRefreshRate: boolean;
  14944. /**
  14945. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  14946. */
  14947. foveationLevel: number;
  14948. }
  14949. interface Engine {
  14950. /** @hidden */
  14951. _vrDisplay: any;
  14952. /** @hidden */
  14953. _vrSupported: boolean;
  14954. /** @hidden */
  14955. _oldSize: Size;
  14956. /** @hidden */
  14957. _oldHardwareScaleFactor: number;
  14958. /** @hidden */
  14959. _vrExclusivePointerMode: boolean;
  14960. /** @hidden */
  14961. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  14962. /** @hidden */
  14963. _onVRDisplayPointerRestricted: () => void;
  14964. /** @hidden */
  14965. _onVRDisplayPointerUnrestricted: () => void;
  14966. /** @hidden */
  14967. _onVrDisplayConnect: Nullable<(display: any) => void>;
  14968. /** @hidden */
  14969. _onVrDisplayDisconnect: Nullable<() => void>;
  14970. /** @hidden */
  14971. _onVrDisplayPresentChange: Nullable<() => void>;
  14972. /**
  14973. * Observable signaled when VR display mode changes
  14974. */
  14975. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  14976. /**
  14977. * Observable signaled when VR request present is complete
  14978. */
  14979. onVRRequestPresentComplete: Observable<boolean>;
  14980. /**
  14981. * Observable signaled when VR request present starts
  14982. */
  14983. onVRRequestPresentStart: Observable<Engine>;
  14984. /**
  14985. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  14986. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  14987. */
  14988. isInVRExclusivePointerMode: boolean;
  14989. /**
  14990. * Gets a boolean indicating if a webVR device was detected
  14991. * @returns true if a webVR device was detected
  14992. */
  14993. isVRDevicePresent(): boolean;
  14994. /**
  14995. * Gets the current webVR device
  14996. * @returns the current webVR device (or null)
  14997. */
  14998. getVRDevice(): any;
  14999. /**
  15000. * Initializes a webVR display and starts listening to display change events
  15001. * The onVRDisplayChangedObservable will be notified upon these changes
  15002. * @returns A promise containing a VRDisplay and if vr is supported
  15003. */
  15004. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15005. /** @hidden */
  15006. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15007. /**
  15008. * Gets or sets the presentation attributes used to configure VR rendering
  15009. */
  15010. vrPresentationAttributes?: IVRPresentationAttributes;
  15011. /**
  15012. * Call this function to switch to webVR mode
  15013. * Will do nothing if webVR is not supported or if there is no webVR device
  15014. * @param options the webvr options provided to the camera. mainly used for multiview
  15015. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15016. */
  15017. enableVR(options: WebVROptions): void;
  15018. /** @hidden */
  15019. _onVRFullScreenTriggered(): void;
  15020. }
  15021. }
  15022. declare module BABYLON {
  15023. /**
  15024. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15025. * IMPORTANT!! The data is right-hand data.
  15026. * @export
  15027. * @interface DevicePose
  15028. */
  15029. export interface DevicePose {
  15030. /**
  15031. * The position of the device, values in array are [x,y,z].
  15032. */
  15033. readonly position: Nullable<Float32Array>;
  15034. /**
  15035. * The linearVelocity of the device, values in array are [x,y,z].
  15036. */
  15037. readonly linearVelocity: Nullable<Float32Array>;
  15038. /**
  15039. * The linearAcceleration of the device, values in array are [x,y,z].
  15040. */
  15041. readonly linearAcceleration: Nullable<Float32Array>;
  15042. /**
  15043. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15044. */
  15045. readonly orientation: Nullable<Float32Array>;
  15046. /**
  15047. * The angularVelocity of the device, values in array are [x,y,z].
  15048. */
  15049. readonly angularVelocity: Nullable<Float32Array>;
  15050. /**
  15051. * The angularAcceleration of the device, values in array are [x,y,z].
  15052. */
  15053. readonly angularAcceleration: Nullable<Float32Array>;
  15054. }
  15055. /**
  15056. * Interface representing a pose controlled object in Babylon.
  15057. * A pose controlled object has both regular pose values as well as pose values
  15058. * from an external device such as a VR head mounted display
  15059. */
  15060. export interface PoseControlled {
  15061. /**
  15062. * The position of the object in babylon space.
  15063. */
  15064. position: Vector3;
  15065. /**
  15066. * The rotation quaternion of the object in babylon space.
  15067. */
  15068. rotationQuaternion: Quaternion;
  15069. /**
  15070. * The position of the device in babylon space.
  15071. */
  15072. devicePosition?: Vector3;
  15073. /**
  15074. * The rotation quaternion of the device in babylon space.
  15075. */
  15076. deviceRotationQuaternion: Quaternion;
  15077. /**
  15078. * The raw pose coming from the device.
  15079. */
  15080. rawPose: Nullable<DevicePose>;
  15081. /**
  15082. * The scale of the device to be used when translating from device space to babylon space.
  15083. */
  15084. deviceScaleFactor: number;
  15085. /**
  15086. * Updates the poseControlled values based on the input device pose.
  15087. * @param poseData the pose data to update the object with
  15088. */
  15089. updateFromDevice(poseData: DevicePose): void;
  15090. }
  15091. /**
  15092. * Set of options to customize the webVRCamera
  15093. */
  15094. export interface WebVROptions {
  15095. /**
  15096. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15097. */
  15098. trackPosition?: boolean;
  15099. /**
  15100. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15101. */
  15102. positionScale?: number;
  15103. /**
  15104. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15105. */
  15106. displayName?: string;
  15107. /**
  15108. * Should the native controller meshes be initialized. (default: true)
  15109. */
  15110. controllerMeshes?: boolean;
  15111. /**
  15112. * Creating a default HemiLight only on controllers. (default: true)
  15113. */
  15114. defaultLightingOnControllers?: boolean;
  15115. /**
  15116. * If you don't want to use the default VR button of the helper. (default: false)
  15117. */
  15118. useCustomVRButton?: boolean;
  15119. /**
  15120. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15121. */
  15122. customVRButton?: HTMLButtonElement;
  15123. /**
  15124. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15125. */
  15126. rayLength?: number;
  15127. /**
  15128. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15129. */
  15130. defaultHeight?: number;
  15131. /**
  15132. * If multiview should be used if availible (default: false)
  15133. */
  15134. useMultiview?: boolean;
  15135. }
  15136. /**
  15137. * This represents a WebVR camera.
  15138. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15139. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15140. */
  15141. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15142. private webVROptions;
  15143. /**
  15144. * @hidden
  15145. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15146. */
  15147. _vrDevice: any;
  15148. /**
  15149. * The rawPose of the vrDevice.
  15150. */
  15151. rawPose: Nullable<DevicePose>;
  15152. private _onVREnabled;
  15153. private _specsVersion;
  15154. private _attached;
  15155. private _frameData;
  15156. protected _descendants: Array<Node>;
  15157. private _deviceRoomPosition;
  15158. /** @hidden */
  15159. _deviceRoomRotationQuaternion: Quaternion;
  15160. private _standingMatrix;
  15161. /**
  15162. * Represents device position in babylon space.
  15163. */
  15164. devicePosition: Vector3;
  15165. /**
  15166. * Represents device rotation in babylon space.
  15167. */
  15168. deviceRotationQuaternion: Quaternion;
  15169. /**
  15170. * The scale of the device to be used when translating from device space to babylon space.
  15171. */
  15172. deviceScaleFactor: number;
  15173. private _deviceToWorld;
  15174. private _worldToDevice;
  15175. /**
  15176. * References to the webVR controllers for the vrDevice.
  15177. */
  15178. controllers: Array<WebVRController>;
  15179. /**
  15180. * Emits an event when a controller is attached.
  15181. */
  15182. onControllersAttachedObservable: Observable<WebVRController[]>;
  15183. /**
  15184. * Emits an event when a controller's mesh has been loaded;
  15185. */
  15186. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15187. /**
  15188. * Emits an event when the HMD's pose has been updated.
  15189. */
  15190. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15191. private _poseSet;
  15192. /**
  15193. * If the rig cameras be used as parent instead of this camera.
  15194. */
  15195. rigParenting: boolean;
  15196. private _lightOnControllers;
  15197. private _defaultHeight?;
  15198. /**
  15199. * Instantiates a WebVRFreeCamera.
  15200. * @param name The name of the WebVRFreeCamera
  15201. * @param position The starting anchor position for the camera
  15202. * @param scene The scene the camera belongs to
  15203. * @param webVROptions a set of customizable options for the webVRCamera
  15204. */
  15205. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15206. /**
  15207. * Gets the device distance from the ground in meters.
  15208. * @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.
  15209. */
  15210. deviceDistanceToRoomGround(): number;
  15211. /**
  15212. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15213. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15214. */
  15215. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15216. /**
  15217. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15218. * @returns A promise with a boolean set to if the standing matrix is supported.
  15219. */
  15220. useStandingMatrixAsync(): Promise<boolean>;
  15221. /**
  15222. * Disposes the camera
  15223. */
  15224. dispose(): void;
  15225. /**
  15226. * Gets a vrController by name.
  15227. * @param name The name of the controller to retreive
  15228. * @returns the controller matching the name specified or null if not found
  15229. */
  15230. getControllerByName(name: string): Nullable<WebVRController>;
  15231. private _leftController;
  15232. /**
  15233. * The controller corresponding to the users left hand.
  15234. */
  15235. readonly leftController: Nullable<WebVRController>;
  15236. private _rightController;
  15237. /**
  15238. * The controller corresponding to the users right hand.
  15239. */
  15240. readonly rightController: Nullable<WebVRController>;
  15241. /**
  15242. * Casts a ray forward from the vrCamera's gaze.
  15243. * @param length Length of the ray (default: 100)
  15244. * @returns the ray corresponding to the gaze
  15245. */
  15246. getForwardRay(length?: number): Ray;
  15247. /**
  15248. * @hidden
  15249. * Updates the camera based on device's frame data
  15250. */
  15251. _checkInputs(): void;
  15252. /**
  15253. * Updates the poseControlled values based on the input device pose.
  15254. * @param poseData Pose coming from the device
  15255. */
  15256. updateFromDevice(poseData: DevicePose): void;
  15257. private _htmlElementAttached;
  15258. private _detachIfAttached;
  15259. /**
  15260. * WebVR's attach control will start broadcasting frames to the device.
  15261. * Note that in certain browsers (chrome for example) this function must be called
  15262. * within a user-interaction callback. Example:
  15263. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15264. *
  15265. * @param element html element to attach the vrDevice to
  15266. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15267. */
  15268. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15269. /**
  15270. * Detaches the camera from the html element and disables VR
  15271. *
  15272. * @param element html element to detach from
  15273. */
  15274. detachControl(element: HTMLElement): void;
  15275. /**
  15276. * @returns the name of this class
  15277. */
  15278. getClassName(): string;
  15279. /**
  15280. * Calls resetPose on the vrDisplay
  15281. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15282. */
  15283. resetToCurrentRotation(): void;
  15284. /**
  15285. * @hidden
  15286. * Updates the rig cameras (left and right eye)
  15287. */
  15288. _updateRigCameras(): void;
  15289. private _workingVector;
  15290. private _oneVector;
  15291. private _workingMatrix;
  15292. private updateCacheCalled;
  15293. private _correctPositionIfNotTrackPosition;
  15294. /**
  15295. * @hidden
  15296. * Updates the cached values of the camera
  15297. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15298. */
  15299. _updateCache(ignoreParentClass?: boolean): void;
  15300. /**
  15301. * @hidden
  15302. * Get current device position in babylon world
  15303. */
  15304. _computeDevicePosition(): void;
  15305. /**
  15306. * Updates the current device position and rotation in the babylon world
  15307. */
  15308. update(): void;
  15309. /**
  15310. * @hidden
  15311. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15312. * @returns an identity matrix
  15313. */
  15314. _getViewMatrix(): Matrix;
  15315. private _tmpMatrix;
  15316. /**
  15317. * This function is called by the two RIG cameras.
  15318. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15319. * @hidden
  15320. */
  15321. _getWebVRViewMatrix(): Matrix;
  15322. /** @hidden */
  15323. _getWebVRProjectionMatrix(): Matrix;
  15324. private _onGamepadConnectedObserver;
  15325. private _onGamepadDisconnectedObserver;
  15326. private _updateCacheWhenTrackingDisabledObserver;
  15327. /**
  15328. * Initializes the controllers and their meshes
  15329. */
  15330. initControllers(): void;
  15331. }
  15332. }
  15333. declare module BABYLON {
  15334. /**
  15335. * Size options for a post process
  15336. */
  15337. export type PostProcessOptions = {
  15338. width: number;
  15339. height: number;
  15340. };
  15341. /**
  15342. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15343. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15344. */
  15345. export class PostProcess {
  15346. /** Name of the PostProcess. */
  15347. name: string;
  15348. /**
  15349. * Gets or sets the unique id of the post process
  15350. */
  15351. uniqueId: number;
  15352. /**
  15353. * Width of the texture to apply the post process on
  15354. */
  15355. width: number;
  15356. /**
  15357. * Height of the texture to apply the post process on
  15358. */
  15359. height: number;
  15360. /**
  15361. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15362. * @hidden
  15363. */
  15364. _outputTexture: Nullable<InternalTexture>;
  15365. /**
  15366. * Sampling mode used by the shader
  15367. * See https://doc.babylonjs.com/classes/3.1/texture
  15368. */
  15369. renderTargetSamplingMode: number;
  15370. /**
  15371. * Clear color to use when screen clearing
  15372. */
  15373. clearColor: Color4;
  15374. /**
  15375. * If the buffer needs to be cleared before applying the post process. (default: true)
  15376. * Should be set to false if shader will overwrite all previous pixels.
  15377. */
  15378. autoClear: boolean;
  15379. /**
  15380. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15381. */
  15382. alphaMode: number;
  15383. /**
  15384. * Sets the setAlphaBlendConstants of the babylon engine
  15385. */
  15386. alphaConstants: Color4;
  15387. /**
  15388. * Animations to be used for the post processing
  15389. */
  15390. animations: Animation[];
  15391. /**
  15392. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15393. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15394. */
  15395. enablePixelPerfectMode: boolean;
  15396. /**
  15397. * Force the postprocess to be applied without taking in account viewport
  15398. */
  15399. forceFullscreenViewport: boolean;
  15400. /**
  15401. * List of inspectable custom properties (used by the Inspector)
  15402. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15403. */
  15404. inspectableCustomProperties: IInspectable[];
  15405. /**
  15406. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15407. *
  15408. * | Value | Type | Description |
  15409. * | ----- | ----------------------------------- | ----------- |
  15410. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15411. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15412. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15413. *
  15414. */
  15415. scaleMode: number;
  15416. /**
  15417. * Force textures to be a power of two (default: false)
  15418. */
  15419. alwaysForcePOT: boolean;
  15420. private _samples;
  15421. /**
  15422. * Number of sample textures (default: 1)
  15423. */
  15424. samples: number;
  15425. /**
  15426. * Modify the scale of the post process to be the same as the viewport (default: false)
  15427. */
  15428. adaptScaleToCurrentViewport: boolean;
  15429. private _camera;
  15430. private _scene;
  15431. private _engine;
  15432. private _options;
  15433. private _reusable;
  15434. private _textureType;
  15435. /**
  15436. * Smart array of input and output textures for the post process.
  15437. * @hidden
  15438. */
  15439. _textures: SmartArray<InternalTexture>;
  15440. /**
  15441. * The index in _textures that corresponds to the output texture.
  15442. * @hidden
  15443. */
  15444. _currentRenderTextureInd: number;
  15445. private _effect;
  15446. private _samplers;
  15447. private _fragmentUrl;
  15448. private _vertexUrl;
  15449. private _parameters;
  15450. private _scaleRatio;
  15451. protected _indexParameters: any;
  15452. private _shareOutputWithPostProcess;
  15453. private _texelSize;
  15454. private _forcedOutputTexture;
  15455. /**
  15456. * Returns the fragment url or shader name used in the post process.
  15457. * @returns the fragment url or name in the shader store.
  15458. */
  15459. getEffectName(): string;
  15460. /**
  15461. * An event triggered when the postprocess is activated.
  15462. */
  15463. onActivateObservable: Observable<Camera>;
  15464. private _onActivateObserver;
  15465. /**
  15466. * A function that is added to the onActivateObservable
  15467. */
  15468. onActivate: Nullable<(camera: Camera) => void>;
  15469. /**
  15470. * An event triggered when the postprocess changes its size.
  15471. */
  15472. onSizeChangedObservable: Observable<PostProcess>;
  15473. private _onSizeChangedObserver;
  15474. /**
  15475. * A function that is added to the onSizeChangedObservable
  15476. */
  15477. onSizeChanged: (postProcess: PostProcess) => void;
  15478. /**
  15479. * An event triggered when the postprocess applies its effect.
  15480. */
  15481. onApplyObservable: Observable<Effect>;
  15482. private _onApplyObserver;
  15483. /**
  15484. * A function that is added to the onApplyObservable
  15485. */
  15486. onApply: (effect: Effect) => void;
  15487. /**
  15488. * An event triggered before rendering the postprocess
  15489. */
  15490. onBeforeRenderObservable: Observable<Effect>;
  15491. private _onBeforeRenderObserver;
  15492. /**
  15493. * A function that is added to the onBeforeRenderObservable
  15494. */
  15495. onBeforeRender: (effect: Effect) => void;
  15496. /**
  15497. * An event triggered after rendering the postprocess
  15498. */
  15499. onAfterRenderObservable: Observable<Effect>;
  15500. private _onAfterRenderObserver;
  15501. /**
  15502. * A function that is added to the onAfterRenderObservable
  15503. */
  15504. onAfterRender: (efect: Effect) => void;
  15505. /**
  15506. * 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
  15507. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15508. */
  15509. inputTexture: InternalTexture;
  15510. /**
  15511. * Gets the camera which post process is applied to.
  15512. * @returns The camera the post process is applied to.
  15513. */
  15514. getCamera(): Camera;
  15515. /**
  15516. * Gets the texel size of the postprocess.
  15517. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15518. */
  15519. readonly texelSize: Vector2;
  15520. /**
  15521. * Creates a new instance PostProcess
  15522. * @param name The name of the PostProcess.
  15523. * @param fragmentUrl The url of the fragment shader to be used.
  15524. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15525. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15526. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15527. * @param camera The camera to apply the render pass to.
  15528. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15529. * @param engine The engine which the post process will be applied. (default: current engine)
  15530. * @param reusable If the post process can be reused on the same frame. (default: false)
  15531. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15532. * @param textureType Type of textures used when performing the post process. (default: 0)
  15533. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15534. * @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
  15535. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15536. */
  15537. constructor(
  15538. /** Name of the PostProcess. */
  15539. 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);
  15540. /**
  15541. * Gets a string idenfifying the name of the class
  15542. * @returns "PostProcess" string
  15543. */
  15544. getClassName(): string;
  15545. /**
  15546. * Gets the engine which this post process belongs to.
  15547. * @returns The engine the post process was enabled with.
  15548. */
  15549. getEngine(): Engine;
  15550. /**
  15551. * The effect that is created when initializing the post process.
  15552. * @returns The created effect corresponding the the postprocess.
  15553. */
  15554. getEffect(): Effect;
  15555. /**
  15556. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15557. * @param postProcess The post process to share the output with.
  15558. * @returns This post process.
  15559. */
  15560. shareOutputWith(postProcess: PostProcess): PostProcess;
  15561. /**
  15562. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15563. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15564. */
  15565. useOwnOutput(): void;
  15566. /**
  15567. * Updates the effect with the current post process compile time values and recompiles the shader.
  15568. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15569. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15570. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15571. * @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
  15572. * @param onCompiled Called when the shader has been compiled.
  15573. * @param onError Called if there is an error when compiling a shader.
  15574. */
  15575. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15576. /**
  15577. * The post process is reusable if it can be used multiple times within one frame.
  15578. * @returns If the post process is reusable
  15579. */
  15580. isReusable(): boolean;
  15581. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15582. markTextureDirty(): void;
  15583. /**
  15584. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15585. * 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.
  15586. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15587. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15588. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15589. * @returns The target texture that was bound to be written to.
  15590. */
  15591. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15592. /**
  15593. * If the post process is supported.
  15594. */
  15595. readonly isSupported: boolean;
  15596. /**
  15597. * The aspect ratio of the output texture.
  15598. */
  15599. readonly aspectRatio: number;
  15600. /**
  15601. * Get a value indicating if the post-process is ready to be used
  15602. * @returns true if the post-process is ready (shader is compiled)
  15603. */
  15604. isReady(): boolean;
  15605. /**
  15606. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15607. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15608. */
  15609. apply(): Nullable<Effect>;
  15610. private _disposeTextures;
  15611. /**
  15612. * Disposes the post process.
  15613. * @param camera The camera to dispose the post process on.
  15614. */
  15615. dispose(camera?: Camera): void;
  15616. }
  15617. }
  15618. declare module BABYLON {
  15619. /** @hidden */
  15620. export var kernelBlurVaryingDeclaration: {
  15621. name: string;
  15622. shader: string;
  15623. };
  15624. }
  15625. declare module BABYLON {
  15626. /** @hidden */
  15627. export var kernelBlurFragment: {
  15628. name: string;
  15629. shader: string;
  15630. };
  15631. }
  15632. declare module BABYLON {
  15633. /** @hidden */
  15634. export var kernelBlurFragment2: {
  15635. name: string;
  15636. shader: string;
  15637. };
  15638. }
  15639. declare module BABYLON {
  15640. /** @hidden */
  15641. export var kernelBlurPixelShader: {
  15642. name: string;
  15643. shader: string;
  15644. };
  15645. }
  15646. declare module BABYLON {
  15647. /** @hidden */
  15648. export var kernelBlurVertex: {
  15649. name: string;
  15650. shader: string;
  15651. };
  15652. }
  15653. declare module BABYLON {
  15654. /** @hidden */
  15655. export var kernelBlurVertexShader: {
  15656. name: string;
  15657. shader: string;
  15658. };
  15659. }
  15660. declare module BABYLON {
  15661. /**
  15662. * The Blur Post Process which blurs an image based on a kernel and direction.
  15663. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15664. */
  15665. export class BlurPostProcess extends PostProcess {
  15666. /** The direction in which to blur the image. */
  15667. direction: Vector2;
  15668. private blockCompilation;
  15669. protected _kernel: number;
  15670. protected _idealKernel: number;
  15671. protected _packedFloat: boolean;
  15672. private _staticDefines;
  15673. /**
  15674. * Sets the length in pixels of the blur sample region
  15675. */
  15676. /**
  15677. * Gets the length in pixels of the blur sample region
  15678. */
  15679. kernel: number;
  15680. /**
  15681. * Sets wether or not the blur needs to unpack/repack floats
  15682. */
  15683. /**
  15684. * Gets wether or not the blur is unpacking/repacking floats
  15685. */
  15686. packedFloat: boolean;
  15687. /**
  15688. * Creates a new instance BlurPostProcess
  15689. * @param name The name of the effect.
  15690. * @param direction The direction in which to blur the image.
  15691. * @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.
  15692. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15693. * @param camera The camera to apply the render pass to.
  15694. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15695. * @param engine The engine which the post process will be applied. (default: current engine)
  15696. * @param reusable If the post process can be reused on the same frame. (default: false)
  15697. * @param textureType Type of textures used when performing the post process. (default: 0)
  15698. * @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)
  15699. */
  15700. constructor(name: string,
  15701. /** The direction in which to blur the image. */
  15702. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15703. /**
  15704. * Updates the effect with the current post process compile time values and recompiles the shader.
  15705. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15706. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15707. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15708. * @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
  15709. * @param onCompiled Called when the shader has been compiled.
  15710. * @param onError Called if there is an error when compiling a shader.
  15711. */
  15712. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15713. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15714. /**
  15715. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15716. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15717. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15718. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15719. * The gaps between physical kernels are compensated for in the weighting of the samples
  15720. * @param idealKernel Ideal blur kernel.
  15721. * @return Nearest best kernel.
  15722. */
  15723. protected _nearestBestKernel(idealKernel: number): number;
  15724. /**
  15725. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15726. * @param x The point on the Gaussian distribution to sample.
  15727. * @return the value of the Gaussian function at x.
  15728. */
  15729. protected _gaussianWeight(x: number): number;
  15730. /**
  15731. * Generates a string that can be used as a floating point number in GLSL.
  15732. * @param x Value to print.
  15733. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15734. * @return GLSL float string.
  15735. */
  15736. protected _glslFloat(x: number, decimalFigures?: number): string;
  15737. }
  15738. }
  15739. declare module BABYLON {
  15740. /**
  15741. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15742. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15743. * You can then easily use it as a reflectionTexture on a flat surface.
  15744. * In case the surface is not a plane, please consider relying on reflection probes.
  15745. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15746. */
  15747. export class MirrorTexture extends RenderTargetTexture {
  15748. private scene;
  15749. /**
  15750. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15751. * 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.
  15752. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15753. */
  15754. mirrorPlane: Plane;
  15755. /**
  15756. * Define the blur ratio used to blur the reflection if needed.
  15757. */
  15758. blurRatio: number;
  15759. /**
  15760. * Define the adaptive blur kernel used to blur the reflection if needed.
  15761. * This will autocompute the closest best match for the `blurKernel`
  15762. */
  15763. adaptiveBlurKernel: number;
  15764. /**
  15765. * Define the blur kernel used to blur the reflection if needed.
  15766. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15767. */
  15768. blurKernel: number;
  15769. /**
  15770. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15771. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15772. */
  15773. blurKernelX: number;
  15774. /**
  15775. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15776. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15777. */
  15778. blurKernelY: number;
  15779. private _autoComputeBlurKernel;
  15780. protected _onRatioRescale(): void;
  15781. private _updateGammaSpace;
  15782. private _imageProcessingConfigChangeObserver;
  15783. private _transformMatrix;
  15784. private _mirrorMatrix;
  15785. private _savedViewMatrix;
  15786. private _blurX;
  15787. private _blurY;
  15788. private _adaptiveBlurKernel;
  15789. private _blurKernelX;
  15790. private _blurKernelY;
  15791. private _blurRatio;
  15792. /**
  15793. * Instantiates a Mirror Texture.
  15794. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15795. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15796. * You can then easily use it as a reflectionTexture on a flat surface.
  15797. * In case the surface is not a plane, please consider relying on reflection probes.
  15798. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15799. * @param name
  15800. * @param size
  15801. * @param scene
  15802. * @param generateMipMaps
  15803. * @param type
  15804. * @param samplingMode
  15805. * @param generateDepthBuffer
  15806. */
  15807. constructor(name: string, size: number | {
  15808. width: number;
  15809. height: number;
  15810. } | {
  15811. ratio: number;
  15812. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15813. private _preparePostProcesses;
  15814. /**
  15815. * Clone the mirror texture.
  15816. * @returns the cloned texture
  15817. */
  15818. clone(): MirrorTexture;
  15819. /**
  15820. * Serialize the texture to a JSON representation you could use in Parse later on
  15821. * @returns the serialized JSON representation
  15822. */
  15823. serialize(): any;
  15824. /**
  15825. * Dispose the texture and release its associated resources.
  15826. */
  15827. dispose(): void;
  15828. }
  15829. }
  15830. declare module BABYLON {
  15831. /**
  15832. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15833. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15834. */
  15835. export class Texture extends BaseTexture {
  15836. /**
  15837. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  15838. */
  15839. static SerializeBuffers: boolean;
  15840. /** @hidden */
  15841. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  15842. /** @hidden */
  15843. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  15844. /** @hidden */
  15845. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  15846. /** nearest is mag = nearest and min = nearest and mip = linear */
  15847. static readonly NEAREST_SAMPLINGMODE: number;
  15848. /** nearest is mag = nearest and min = nearest and mip = linear */
  15849. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15850. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15851. static readonly BILINEAR_SAMPLINGMODE: number;
  15852. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15853. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15854. /** Trilinear is mag = linear and min = linear and mip = linear */
  15855. static readonly TRILINEAR_SAMPLINGMODE: number;
  15856. /** Trilinear is mag = linear and min = linear and mip = linear */
  15857. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15858. /** mag = nearest and min = nearest and mip = nearest */
  15859. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15860. /** mag = nearest and min = linear and mip = nearest */
  15861. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15862. /** mag = nearest and min = linear and mip = linear */
  15863. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15864. /** mag = nearest and min = linear and mip = none */
  15865. static readonly NEAREST_LINEAR: number;
  15866. /** mag = nearest and min = nearest and mip = none */
  15867. static readonly NEAREST_NEAREST: number;
  15868. /** mag = linear and min = nearest and mip = nearest */
  15869. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  15870. /** mag = linear and min = nearest and mip = linear */
  15871. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  15872. /** mag = linear and min = linear and mip = none */
  15873. static readonly LINEAR_LINEAR: number;
  15874. /** mag = linear and min = nearest and mip = none */
  15875. static readonly LINEAR_NEAREST: number;
  15876. /** Explicit coordinates mode */
  15877. static readonly EXPLICIT_MODE: number;
  15878. /** Spherical coordinates mode */
  15879. static readonly SPHERICAL_MODE: number;
  15880. /** Planar coordinates mode */
  15881. static readonly PLANAR_MODE: number;
  15882. /** Cubic coordinates mode */
  15883. static readonly CUBIC_MODE: number;
  15884. /** Projection coordinates mode */
  15885. static readonly PROJECTION_MODE: number;
  15886. /** Inverse Cubic coordinates mode */
  15887. static readonly SKYBOX_MODE: number;
  15888. /** Inverse Cubic coordinates mode */
  15889. static readonly INVCUBIC_MODE: number;
  15890. /** Equirectangular coordinates mode */
  15891. static readonly EQUIRECTANGULAR_MODE: number;
  15892. /** Equirectangular Fixed coordinates mode */
  15893. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  15894. /** Equirectangular Fixed Mirrored coordinates mode */
  15895. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  15896. /** Texture is not repeating outside of 0..1 UVs */
  15897. static readonly CLAMP_ADDRESSMODE: number;
  15898. /** Texture is repeating outside of 0..1 UVs */
  15899. static readonly WRAP_ADDRESSMODE: number;
  15900. /** Texture is repeating and mirrored */
  15901. static readonly MIRROR_ADDRESSMODE: number;
  15902. /**
  15903. * 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
  15904. */
  15905. static UseSerializedUrlIfAny: boolean;
  15906. /**
  15907. * Define the url of the texture.
  15908. */
  15909. url: Nullable<string>;
  15910. /**
  15911. * Define an offset on the texture to offset the u coordinates of the UVs
  15912. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15913. */
  15914. uOffset: number;
  15915. /**
  15916. * Define an offset on the texture to offset the v coordinates of the UVs
  15917. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15918. */
  15919. vOffset: number;
  15920. /**
  15921. * Define an offset on the texture to scale the u coordinates of the UVs
  15922. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15923. */
  15924. uScale: number;
  15925. /**
  15926. * Define an offset on the texture to scale the v coordinates of the UVs
  15927. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15928. */
  15929. vScale: number;
  15930. /**
  15931. * Define an offset on the texture to rotate around the u coordinates of the UVs
  15932. * @see http://doc.babylonjs.com/how_to/more_materials
  15933. */
  15934. uAng: number;
  15935. /**
  15936. * Define an offset on the texture to rotate around the v coordinates of the UVs
  15937. * @see http://doc.babylonjs.com/how_to/more_materials
  15938. */
  15939. vAng: number;
  15940. /**
  15941. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  15942. * @see http://doc.babylonjs.com/how_to/more_materials
  15943. */
  15944. wAng: number;
  15945. /**
  15946. * Defines the center of rotation (U)
  15947. */
  15948. uRotationCenter: number;
  15949. /**
  15950. * Defines the center of rotation (V)
  15951. */
  15952. vRotationCenter: number;
  15953. /**
  15954. * Defines the center of rotation (W)
  15955. */
  15956. wRotationCenter: number;
  15957. /**
  15958. * Are mip maps generated for this texture or not.
  15959. */
  15960. readonly noMipmap: boolean;
  15961. /**
  15962. * List of inspectable custom properties (used by the Inspector)
  15963. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15964. */
  15965. inspectableCustomProperties: Nullable<IInspectable[]>;
  15966. private _noMipmap;
  15967. /** @hidden */
  15968. _invertY: boolean;
  15969. private _rowGenerationMatrix;
  15970. private _cachedTextureMatrix;
  15971. private _projectionModeMatrix;
  15972. private _t0;
  15973. private _t1;
  15974. private _t2;
  15975. private _cachedUOffset;
  15976. private _cachedVOffset;
  15977. private _cachedUScale;
  15978. private _cachedVScale;
  15979. private _cachedUAng;
  15980. private _cachedVAng;
  15981. private _cachedWAng;
  15982. private _cachedProjectionMatrixId;
  15983. private _cachedCoordinatesMode;
  15984. /** @hidden */
  15985. protected _initialSamplingMode: number;
  15986. /** @hidden */
  15987. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  15988. private _deleteBuffer;
  15989. protected _format: Nullable<number>;
  15990. private _delayedOnLoad;
  15991. private _delayedOnError;
  15992. private _mimeType?;
  15993. /**
  15994. * Observable triggered once the texture has been loaded.
  15995. */
  15996. onLoadObservable: Observable<Texture>;
  15997. protected _isBlocking: boolean;
  15998. /**
  15999. * Is the texture preventing material to render while loading.
  16000. * If false, a default texture will be used instead of the loading one during the preparation step.
  16001. */
  16002. isBlocking: boolean;
  16003. /**
  16004. * Get the current sampling mode associated with the texture.
  16005. */
  16006. readonly samplingMode: number;
  16007. /**
  16008. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16009. */
  16010. readonly invertY: boolean;
  16011. /**
  16012. * Instantiates a new texture.
  16013. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16014. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16015. * @param url defines the url of the picture to load as a texture
  16016. * @param scene defines the scene or engine the texture will belong to
  16017. * @param noMipmap defines if the texture will require mip maps or not
  16018. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  16019. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16020. * @param onLoad defines a callback triggered when the texture has been loaded
  16021. * @param onError defines a callback triggered when an error occurred during the loading session
  16022. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  16023. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  16024. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16025. * @param mimeType defines an optional mime type information
  16026. */
  16027. 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 | ImageBitmap>, deleteBuffer?: boolean, format?: number, mimeType?: string);
  16028. /**
  16029. * Update the url (and optional buffer) of this texture if url was null during construction.
  16030. * @param url the url of the texture
  16031. * @param buffer the buffer of the texture (defaults to null)
  16032. * @param onLoad callback called when the texture is loaded (defaults to null)
  16033. */
  16034. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16035. /**
  16036. * Finish the loading sequence of a texture flagged as delayed load.
  16037. * @hidden
  16038. */
  16039. delayLoad(): void;
  16040. private _prepareRowForTextureGeneration;
  16041. /**
  16042. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16043. * @returns the transform matrix of the texture.
  16044. */
  16045. getTextureMatrix(uBase?: number): Matrix;
  16046. /**
  16047. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16048. * @returns The reflection texture transform
  16049. */
  16050. getReflectionTextureMatrix(): Matrix;
  16051. /**
  16052. * Clones the texture.
  16053. * @returns the cloned texture
  16054. */
  16055. clone(): Texture;
  16056. /**
  16057. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16058. * @returns The JSON representation of the texture
  16059. */
  16060. serialize(): any;
  16061. /**
  16062. * Get the current class name of the texture useful for serialization or dynamic coding.
  16063. * @returns "Texture"
  16064. */
  16065. getClassName(): string;
  16066. /**
  16067. * Dispose the texture and release its associated resources.
  16068. */
  16069. dispose(): void;
  16070. /**
  16071. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16072. * @param parsedTexture Define the JSON representation of the texture
  16073. * @param scene Define the scene the parsed texture should be instantiated in
  16074. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16075. * @returns The parsed texture if successful
  16076. */
  16077. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16078. /**
  16079. * Creates a texture from its base 64 representation.
  16080. * @param data Define the base64 payload without the data: prefix
  16081. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16082. * @param scene Define the scene the texture should belong to
  16083. * @param noMipmap Forces the texture to not create mip map information if true
  16084. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16085. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16086. * @param onLoad define a callback triggered when the texture has been loaded
  16087. * @param onError define a callback triggered when an error occurred during the loading session
  16088. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16089. * @returns the created texture
  16090. */
  16091. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16092. /**
  16093. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16094. * @param data Define the base64 payload without the data: prefix
  16095. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16096. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16097. * @param scene Define the scene the texture should belong to
  16098. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16099. * @param noMipmap Forces the texture to not create mip map information if true
  16100. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16101. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16102. * @param onLoad define a callback triggered when the texture has been loaded
  16103. * @param onError define a callback triggered when an error occurred during the loading session
  16104. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16105. * @returns the created texture
  16106. */
  16107. 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;
  16108. }
  16109. }
  16110. declare module BABYLON {
  16111. /**
  16112. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16113. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16114. */
  16115. export class PostProcessManager {
  16116. private _scene;
  16117. private _indexBuffer;
  16118. private _vertexBuffers;
  16119. /**
  16120. * Creates a new instance PostProcess
  16121. * @param scene The scene that the post process is associated with.
  16122. */
  16123. constructor(scene: Scene);
  16124. private _prepareBuffers;
  16125. private _buildIndexBuffer;
  16126. /**
  16127. * Rebuilds the vertex buffers of the manager.
  16128. * @hidden
  16129. */
  16130. _rebuild(): void;
  16131. /**
  16132. * Prepares a frame to be run through a post process.
  16133. * @param sourceTexture The input texture to the post procesess. (default: null)
  16134. * @param postProcesses An array of post processes to be run. (default: null)
  16135. * @returns True if the post processes were able to be run.
  16136. * @hidden
  16137. */
  16138. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16139. /**
  16140. * Manually render a set of post processes to a texture.
  16141. * @param postProcesses An array of post processes to be run.
  16142. * @param targetTexture The target texture to render to.
  16143. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16144. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16145. * @param lodLevel defines which lod of the texture to render to
  16146. */
  16147. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16148. /**
  16149. * Finalize the result of the output of the postprocesses.
  16150. * @param doNotPresent If true the result will not be displayed to the screen.
  16151. * @param targetTexture The target texture to render to.
  16152. * @param faceIndex The index of the face to bind the target texture to.
  16153. * @param postProcesses The array of post processes to render.
  16154. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16155. * @hidden
  16156. */
  16157. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16158. /**
  16159. * Disposes of the post process manager.
  16160. */
  16161. dispose(): void;
  16162. }
  16163. }
  16164. declare module BABYLON {
  16165. /** Interface used by value gradients (color, factor, ...) */
  16166. export interface IValueGradient {
  16167. /**
  16168. * Gets or sets the gradient value (between 0 and 1)
  16169. */
  16170. gradient: number;
  16171. }
  16172. /** Class used to store color4 gradient */
  16173. export class ColorGradient implements IValueGradient {
  16174. /**
  16175. * Gets or sets the gradient value (between 0 and 1)
  16176. */
  16177. gradient: number;
  16178. /**
  16179. * Gets or sets first associated color
  16180. */
  16181. color1: Color4;
  16182. /**
  16183. * Gets or sets second associated color
  16184. */
  16185. color2?: Color4;
  16186. /**
  16187. * Will get a color picked randomly between color1 and color2.
  16188. * If color2 is undefined then color1 will be used
  16189. * @param result defines the target Color4 to store the result in
  16190. */
  16191. getColorToRef(result: Color4): void;
  16192. }
  16193. /** Class used to store color 3 gradient */
  16194. export class Color3Gradient implements IValueGradient {
  16195. /**
  16196. * Gets or sets the gradient value (between 0 and 1)
  16197. */
  16198. gradient: number;
  16199. /**
  16200. * Gets or sets the associated color
  16201. */
  16202. color: Color3;
  16203. }
  16204. /** Class used to store factor gradient */
  16205. export class FactorGradient implements IValueGradient {
  16206. /**
  16207. * Gets or sets the gradient value (between 0 and 1)
  16208. */
  16209. gradient: number;
  16210. /**
  16211. * Gets or sets first associated factor
  16212. */
  16213. factor1: number;
  16214. /**
  16215. * Gets or sets second associated factor
  16216. */
  16217. factor2?: number;
  16218. /**
  16219. * Will get a number picked randomly between factor1 and factor2.
  16220. * If factor2 is undefined then factor1 will be used
  16221. * @returns the picked number
  16222. */
  16223. getFactor(): number;
  16224. }
  16225. /**
  16226. * Helper used to simplify some generic gradient tasks
  16227. */
  16228. export class GradientHelper {
  16229. /**
  16230. * Gets the current gradient from an array of IValueGradient
  16231. * @param ratio defines the current ratio to get
  16232. * @param gradients defines the array of IValueGradient
  16233. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16234. */
  16235. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16236. }
  16237. }
  16238. declare module BABYLON {
  16239. interface ThinEngine {
  16240. /**
  16241. * Creates a dynamic texture
  16242. * @param width defines the width of the texture
  16243. * @param height defines the height of the texture
  16244. * @param generateMipMaps defines if the engine should generate the mip levels
  16245. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  16246. * @returns the dynamic texture inside an InternalTexture
  16247. */
  16248. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  16249. /**
  16250. * Update the content of a dynamic texture
  16251. * @param texture defines the texture to update
  16252. * @param canvas defines the canvas containing the source
  16253. * @param invertY defines if data must be stored with Y axis inverted
  16254. * @param premulAlpha defines if alpha is stored as premultiplied
  16255. * @param format defines the format of the data
  16256. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  16257. */
  16258. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  16259. }
  16260. }
  16261. declare module BABYLON {
  16262. /**
  16263. * Helper class used to generate a canvas to manipulate images
  16264. */
  16265. export class CanvasGenerator {
  16266. /**
  16267. * Create a new canvas (or offscreen canvas depending on the context)
  16268. * @param width defines the expected width
  16269. * @param height defines the expected height
  16270. * @return a new canvas or offscreen canvas
  16271. */
  16272. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  16273. }
  16274. }
  16275. declare module BABYLON {
  16276. /**
  16277. * A class extending Texture allowing drawing on a texture
  16278. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16279. */
  16280. export class DynamicTexture extends Texture {
  16281. private _generateMipMaps;
  16282. private _canvas;
  16283. private _context;
  16284. private _engine;
  16285. /**
  16286. * Creates a DynamicTexture
  16287. * @param name defines the name of the texture
  16288. * @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
  16289. * @param scene defines the scene where you want the texture
  16290. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16291. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16292. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16293. */
  16294. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16295. /**
  16296. * Get the current class name of the texture useful for serialization or dynamic coding.
  16297. * @returns "DynamicTexture"
  16298. */
  16299. getClassName(): string;
  16300. /**
  16301. * Gets the current state of canRescale
  16302. */
  16303. readonly canRescale: boolean;
  16304. private _recreate;
  16305. /**
  16306. * Scales the texture
  16307. * @param ratio the scale factor to apply to both width and height
  16308. */
  16309. scale(ratio: number): void;
  16310. /**
  16311. * Resizes the texture
  16312. * @param width the new width
  16313. * @param height the new height
  16314. */
  16315. scaleTo(width: number, height: number): void;
  16316. /**
  16317. * Gets the context of the canvas used by the texture
  16318. * @returns the canvas context of the dynamic texture
  16319. */
  16320. getContext(): CanvasRenderingContext2D;
  16321. /**
  16322. * Clears the texture
  16323. */
  16324. clear(): void;
  16325. /**
  16326. * Updates the texture
  16327. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16328. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16329. */
  16330. update(invertY?: boolean, premulAlpha?: boolean): void;
  16331. /**
  16332. * Draws text onto the texture
  16333. * @param text defines the text to be drawn
  16334. * @param x defines the placement of the text from the left
  16335. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16336. * @param font defines the font to be used with font-style, font-size, font-name
  16337. * @param color defines the color used for the text
  16338. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16339. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16340. * @param update defines whether texture is immediately update (default is true)
  16341. */
  16342. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16343. /**
  16344. * Clones the texture
  16345. * @returns the clone of the texture.
  16346. */
  16347. clone(): DynamicTexture;
  16348. /**
  16349. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16350. * @returns a serialized dynamic texture object
  16351. */
  16352. serialize(): any;
  16353. /** @hidden */
  16354. _rebuild(): void;
  16355. }
  16356. }
  16357. declare module BABYLON {
  16358. interface AbstractScene {
  16359. /**
  16360. * The list of procedural textures added to the scene
  16361. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16362. */
  16363. proceduralTextures: Array<ProceduralTexture>;
  16364. }
  16365. /**
  16366. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16367. * in a given scene.
  16368. */
  16369. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16370. /**
  16371. * The component name helpfull to identify the component in the list of scene components.
  16372. */
  16373. readonly name: string;
  16374. /**
  16375. * The scene the component belongs to.
  16376. */
  16377. scene: Scene;
  16378. /**
  16379. * Creates a new instance of the component for the given scene
  16380. * @param scene Defines the scene to register the component in
  16381. */
  16382. constructor(scene: Scene);
  16383. /**
  16384. * Registers the component in a given scene
  16385. */
  16386. register(): void;
  16387. /**
  16388. * Rebuilds the elements related to this component in case of
  16389. * context lost for instance.
  16390. */
  16391. rebuild(): void;
  16392. /**
  16393. * Disposes the component and the associated ressources.
  16394. */
  16395. dispose(): void;
  16396. private _beforeClear;
  16397. }
  16398. }
  16399. declare module BABYLON {
  16400. interface ThinEngine {
  16401. /**
  16402. * Creates a new render target cube texture
  16403. * @param size defines the size of the texture
  16404. * @param options defines the options used to create the texture
  16405. * @returns a new render target cube texture stored in an InternalTexture
  16406. */
  16407. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16408. }
  16409. }
  16410. declare module BABYLON {
  16411. /** @hidden */
  16412. export var proceduralVertexShader: {
  16413. name: string;
  16414. shader: string;
  16415. };
  16416. }
  16417. declare module BABYLON {
  16418. /**
  16419. * 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.
  16420. * This is the base class of any Procedural texture and contains most of the shareable code.
  16421. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16422. */
  16423. export class ProceduralTexture extends Texture {
  16424. isCube: boolean;
  16425. /**
  16426. * Define if the texture is enabled or not (disabled texture will not render)
  16427. */
  16428. isEnabled: boolean;
  16429. /**
  16430. * Define if the texture must be cleared before rendering (default is true)
  16431. */
  16432. autoClear: boolean;
  16433. /**
  16434. * Callback called when the texture is generated
  16435. */
  16436. onGenerated: () => void;
  16437. /**
  16438. * Event raised when the texture is generated
  16439. */
  16440. onGeneratedObservable: Observable<ProceduralTexture>;
  16441. /** @hidden */
  16442. _generateMipMaps: boolean;
  16443. /** @hidden **/
  16444. _effect: Effect;
  16445. /** @hidden */
  16446. _textures: {
  16447. [key: string]: Texture;
  16448. };
  16449. private _size;
  16450. private _currentRefreshId;
  16451. private _refreshRate;
  16452. private _vertexBuffers;
  16453. private _indexBuffer;
  16454. private _uniforms;
  16455. private _samplers;
  16456. private _fragment;
  16457. private _floats;
  16458. private _ints;
  16459. private _floatsArrays;
  16460. private _colors3;
  16461. private _colors4;
  16462. private _vectors2;
  16463. private _vectors3;
  16464. private _matrices;
  16465. private _fallbackTexture;
  16466. private _fallbackTextureUsed;
  16467. private _engine;
  16468. private _cachedDefines;
  16469. private _contentUpdateId;
  16470. private _contentData;
  16471. /**
  16472. * Instantiates a new procedural texture.
  16473. * 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.
  16474. * This is the base class of any Procedural texture and contains most of the shareable code.
  16475. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16476. * @param name Define the name of the texture
  16477. * @param size Define the size of the texture to create
  16478. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16479. * @param scene Define the scene the texture belongs to
  16480. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16481. * @param generateMipMaps Define if the texture should creates mip maps or not
  16482. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16483. */
  16484. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16485. /**
  16486. * The effect that is created when initializing the post process.
  16487. * @returns The created effect corresponding the the postprocess.
  16488. */
  16489. getEffect(): Effect;
  16490. /**
  16491. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16492. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16493. */
  16494. getContent(): Nullable<ArrayBufferView>;
  16495. private _createIndexBuffer;
  16496. /** @hidden */
  16497. _rebuild(): void;
  16498. /**
  16499. * Resets the texture in order to recreate its associated resources.
  16500. * This can be called in case of context loss
  16501. */
  16502. reset(): void;
  16503. protected _getDefines(): string;
  16504. /**
  16505. * Is the texture ready to be used ? (rendered at least once)
  16506. * @returns true if ready, otherwise, false.
  16507. */
  16508. isReady(): boolean;
  16509. /**
  16510. * Resets the refresh counter of the texture and start bak from scratch.
  16511. * Could be useful to regenerate the texture if it is setup to render only once.
  16512. */
  16513. resetRefreshCounter(): void;
  16514. /**
  16515. * Set the fragment shader to use in order to render the texture.
  16516. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16517. */
  16518. setFragment(fragment: any): void;
  16519. /**
  16520. * Define the refresh rate of the texture or the rendering frequency.
  16521. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16522. */
  16523. refreshRate: number;
  16524. /** @hidden */
  16525. _shouldRender(): boolean;
  16526. /**
  16527. * Get the size the texture is rendering at.
  16528. * @returns the size (texture is always squared)
  16529. */
  16530. getRenderSize(): number;
  16531. /**
  16532. * Resize the texture to new value.
  16533. * @param size Define the new size the texture should have
  16534. * @param generateMipMaps Define whether the new texture should create mip maps
  16535. */
  16536. resize(size: number, generateMipMaps: boolean): void;
  16537. private _checkUniform;
  16538. /**
  16539. * Set a texture in the shader program used to render.
  16540. * @param name Define the name of the uniform samplers as defined in the shader
  16541. * @param texture Define the texture to bind to this sampler
  16542. * @return the texture itself allowing "fluent" like uniform updates
  16543. */
  16544. setTexture(name: string, texture: Texture): ProceduralTexture;
  16545. /**
  16546. * Set a float in the shader.
  16547. * @param name Define the name of the uniform as defined in the shader
  16548. * @param value Define the value to give to the uniform
  16549. * @return the texture itself allowing "fluent" like uniform updates
  16550. */
  16551. setFloat(name: string, value: number): ProceduralTexture;
  16552. /**
  16553. * Set a int in the shader.
  16554. * @param name Define the name of the uniform as defined in the shader
  16555. * @param value Define the value to give to the uniform
  16556. * @return the texture itself allowing "fluent" like uniform updates
  16557. */
  16558. setInt(name: string, value: number): ProceduralTexture;
  16559. /**
  16560. * Set an array of floats in the shader.
  16561. * @param name Define the name of the uniform as defined in the shader
  16562. * @param value Define the value to give to the uniform
  16563. * @return the texture itself allowing "fluent" like uniform updates
  16564. */
  16565. setFloats(name: string, value: number[]): ProceduralTexture;
  16566. /**
  16567. * Set a vec3 in the shader from a Color3.
  16568. * @param name Define the name of the uniform as defined in the shader
  16569. * @param value Define the value to give to the uniform
  16570. * @return the texture itself allowing "fluent" like uniform updates
  16571. */
  16572. setColor3(name: string, value: Color3): ProceduralTexture;
  16573. /**
  16574. * Set a vec4 in the shader from a Color4.
  16575. * @param name Define the name of the uniform as defined in the shader
  16576. * @param value Define the value to give to the uniform
  16577. * @return the texture itself allowing "fluent" like uniform updates
  16578. */
  16579. setColor4(name: string, value: Color4): ProceduralTexture;
  16580. /**
  16581. * Set a vec2 in the shader from a Vector2.
  16582. * @param name Define the name of the uniform as defined in the shader
  16583. * @param value Define the value to give to the uniform
  16584. * @return the texture itself allowing "fluent" like uniform updates
  16585. */
  16586. setVector2(name: string, value: Vector2): ProceduralTexture;
  16587. /**
  16588. * Set a vec3 in the shader from a Vector3.
  16589. * @param name Define the name of the uniform as defined in the shader
  16590. * @param value Define the value to give to the uniform
  16591. * @return the texture itself allowing "fluent" like uniform updates
  16592. */
  16593. setVector3(name: string, value: Vector3): ProceduralTexture;
  16594. /**
  16595. * Set a mat4 in the shader from a MAtrix.
  16596. * @param name Define the name of the uniform as defined in the shader
  16597. * @param value Define the value to give to the uniform
  16598. * @return the texture itself allowing "fluent" like uniform updates
  16599. */
  16600. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16601. /**
  16602. * Render the texture to its associated render target.
  16603. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16604. */
  16605. render(useCameraPostProcess?: boolean): void;
  16606. /**
  16607. * Clone the texture.
  16608. * @returns the cloned texture
  16609. */
  16610. clone(): ProceduralTexture;
  16611. /**
  16612. * Dispose the texture and release its asoociated resources.
  16613. */
  16614. dispose(): void;
  16615. }
  16616. }
  16617. declare module BABYLON {
  16618. /**
  16619. * This represents the base class for particle system in Babylon.
  16620. * 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.
  16621. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16622. * @example https://doc.babylonjs.com/babylon101/particles
  16623. */
  16624. export class BaseParticleSystem {
  16625. /**
  16626. * Source color is added to the destination color without alpha affecting the result
  16627. */
  16628. static BLENDMODE_ONEONE: number;
  16629. /**
  16630. * Blend current color and particle color using particle’s alpha
  16631. */
  16632. static BLENDMODE_STANDARD: number;
  16633. /**
  16634. * Add current color and particle color multiplied by particle’s alpha
  16635. */
  16636. static BLENDMODE_ADD: number;
  16637. /**
  16638. * Multiply current color with particle color
  16639. */
  16640. static BLENDMODE_MULTIPLY: number;
  16641. /**
  16642. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16643. */
  16644. static BLENDMODE_MULTIPLYADD: number;
  16645. /**
  16646. * List of animations used by the particle system.
  16647. */
  16648. animations: Animation[];
  16649. /**
  16650. * The id of the Particle system.
  16651. */
  16652. id: string;
  16653. /**
  16654. * The friendly name of the Particle system.
  16655. */
  16656. name: string;
  16657. /**
  16658. * The rendering group used by the Particle system to chose when to render.
  16659. */
  16660. renderingGroupId: number;
  16661. /**
  16662. * The emitter represents the Mesh or position we are attaching the particle system to.
  16663. */
  16664. emitter: Nullable<AbstractMesh | Vector3>;
  16665. /**
  16666. * The maximum number of particles to emit per frame
  16667. */
  16668. emitRate: number;
  16669. /**
  16670. * If you want to launch only a few particles at once, that can be done, as well.
  16671. */
  16672. manualEmitCount: number;
  16673. /**
  16674. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16675. */
  16676. updateSpeed: number;
  16677. /**
  16678. * The amount of time the particle system is running (depends of the overall update speed).
  16679. */
  16680. targetStopDuration: number;
  16681. /**
  16682. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16683. */
  16684. disposeOnStop: boolean;
  16685. /**
  16686. * Minimum power of emitting particles.
  16687. */
  16688. minEmitPower: number;
  16689. /**
  16690. * Maximum power of emitting particles.
  16691. */
  16692. maxEmitPower: number;
  16693. /**
  16694. * Minimum life time of emitting particles.
  16695. */
  16696. minLifeTime: number;
  16697. /**
  16698. * Maximum life time of emitting particles.
  16699. */
  16700. maxLifeTime: number;
  16701. /**
  16702. * Minimum Size of emitting particles.
  16703. */
  16704. minSize: number;
  16705. /**
  16706. * Maximum Size of emitting particles.
  16707. */
  16708. maxSize: number;
  16709. /**
  16710. * Minimum scale of emitting particles on X axis.
  16711. */
  16712. minScaleX: number;
  16713. /**
  16714. * Maximum scale of emitting particles on X axis.
  16715. */
  16716. maxScaleX: number;
  16717. /**
  16718. * Minimum scale of emitting particles on Y axis.
  16719. */
  16720. minScaleY: number;
  16721. /**
  16722. * Maximum scale of emitting particles on Y axis.
  16723. */
  16724. maxScaleY: number;
  16725. /**
  16726. * Gets or sets the minimal initial rotation in radians.
  16727. */
  16728. minInitialRotation: number;
  16729. /**
  16730. * Gets or sets the maximal initial rotation in radians.
  16731. */
  16732. maxInitialRotation: number;
  16733. /**
  16734. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16735. */
  16736. minAngularSpeed: number;
  16737. /**
  16738. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16739. */
  16740. maxAngularSpeed: number;
  16741. /**
  16742. * The texture used to render each particle. (this can be a spritesheet)
  16743. */
  16744. particleTexture: Nullable<Texture>;
  16745. /**
  16746. * The layer mask we are rendering the particles through.
  16747. */
  16748. layerMask: number;
  16749. /**
  16750. * This can help using your own shader to render the particle system.
  16751. * The according effect will be created
  16752. */
  16753. customShader: any;
  16754. /**
  16755. * By default particle system starts as soon as they are created. This prevents the
  16756. * automatic start to happen and let you decide when to start emitting particles.
  16757. */
  16758. preventAutoStart: boolean;
  16759. private _noiseTexture;
  16760. /**
  16761. * Gets or sets a texture used to add random noise to particle positions
  16762. */
  16763. noiseTexture: Nullable<ProceduralTexture>;
  16764. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16765. noiseStrength: Vector3;
  16766. /**
  16767. * Callback triggered when the particle animation is ending.
  16768. */
  16769. onAnimationEnd: Nullable<() => void>;
  16770. /**
  16771. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16772. */
  16773. blendMode: number;
  16774. /**
  16775. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16776. * to override the particles.
  16777. */
  16778. forceDepthWrite: boolean;
  16779. /** 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 */
  16780. preWarmCycles: number;
  16781. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16782. preWarmStepOffset: number;
  16783. /**
  16784. * 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)
  16785. */
  16786. spriteCellChangeSpeed: number;
  16787. /**
  16788. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16789. */
  16790. startSpriteCellID: number;
  16791. /**
  16792. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16793. */
  16794. endSpriteCellID: number;
  16795. /**
  16796. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16797. */
  16798. spriteCellWidth: number;
  16799. /**
  16800. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16801. */
  16802. spriteCellHeight: number;
  16803. /**
  16804. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16805. */
  16806. spriteRandomStartCell: boolean;
  16807. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16808. translationPivot: Vector2;
  16809. /** @hidden */
  16810. protected _isAnimationSheetEnabled: boolean;
  16811. /**
  16812. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16813. */
  16814. beginAnimationOnStart: boolean;
  16815. /**
  16816. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16817. */
  16818. beginAnimationFrom: number;
  16819. /**
  16820. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16821. */
  16822. beginAnimationTo: number;
  16823. /**
  16824. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16825. */
  16826. beginAnimationLoop: boolean;
  16827. /**
  16828. * Gets or sets a world offset applied to all particles
  16829. */
  16830. worldOffset: Vector3;
  16831. /**
  16832. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16833. */
  16834. isAnimationSheetEnabled: boolean;
  16835. /**
  16836. * Get hosting scene
  16837. * @returns the scene
  16838. */
  16839. getScene(): Scene;
  16840. /**
  16841. * You can use gravity if you want to give an orientation to your particles.
  16842. */
  16843. gravity: Vector3;
  16844. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16845. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16846. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16847. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16848. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16849. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16850. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16851. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16852. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16853. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16854. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16855. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16856. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16857. /**
  16858. * Defines the delay in milliseconds before starting the system (0 by default)
  16859. */
  16860. startDelay: number;
  16861. /**
  16862. * Gets the current list of drag gradients.
  16863. * You must use addDragGradient and removeDragGradient to udpate this list
  16864. * @returns the list of drag gradients
  16865. */
  16866. getDragGradients(): Nullable<Array<FactorGradient>>;
  16867. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16868. limitVelocityDamping: number;
  16869. /**
  16870. * Gets the current list of limit velocity gradients.
  16871. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16872. * @returns the list of limit velocity gradients
  16873. */
  16874. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16875. /**
  16876. * Gets the current list of color gradients.
  16877. * You must use addColorGradient and removeColorGradient to udpate this list
  16878. * @returns the list of color gradients
  16879. */
  16880. getColorGradients(): Nullable<Array<ColorGradient>>;
  16881. /**
  16882. * Gets the current list of size gradients.
  16883. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16884. * @returns the list of size gradients
  16885. */
  16886. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16887. /**
  16888. * Gets the current list of color remap gradients.
  16889. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16890. * @returns the list of color remap gradients
  16891. */
  16892. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16893. /**
  16894. * Gets the current list of alpha remap gradients.
  16895. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16896. * @returns the list of alpha remap gradients
  16897. */
  16898. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16899. /**
  16900. * Gets the current list of life time gradients.
  16901. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16902. * @returns the list of life time gradients
  16903. */
  16904. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16905. /**
  16906. * Gets the current list of angular speed gradients.
  16907. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16908. * @returns the list of angular speed gradients
  16909. */
  16910. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16911. /**
  16912. * Gets the current list of velocity gradients.
  16913. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16914. * @returns the list of velocity gradients
  16915. */
  16916. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16917. /**
  16918. * Gets the current list of start size gradients.
  16919. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16920. * @returns the list of start size gradients
  16921. */
  16922. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16923. /**
  16924. * Gets the current list of emit rate gradients.
  16925. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16926. * @returns the list of emit rate gradients
  16927. */
  16928. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16929. /**
  16930. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16931. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16932. */
  16933. direction1: Vector3;
  16934. /**
  16935. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16936. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16937. */
  16938. direction2: Vector3;
  16939. /**
  16940. * 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.
  16941. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16942. */
  16943. minEmitBox: Vector3;
  16944. /**
  16945. * 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.
  16946. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16947. */
  16948. maxEmitBox: Vector3;
  16949. /**
  16950. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16951. */
  16952. color1: Color4;
  16953. /**
  16954. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16955. */
  16956. color2: Color4;
  16957. /**
  16958. * Color the particle will have at the end of its lifetime
  16959. */
  16960. colorDead: Color4;
  16961. /**
  16962. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  16963. */
  16964. textureMask: Color4;
  16965. /**
  16966. * The particle emitter type defines the emitter used by the particle system.
  16967. * It can be for example box, sphere, or cone...
  16968. */
  16969. particleEmitterType: IParticleEmitterType;
  16970. /** @hidden */
  16971. _isSubEmitter: boolean;
  16972. /**
  16973. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16974. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16975. */
  16976. billboardMode: number;
  16977. protected _isBillboardBased: boolean;
  16978. /**
  16979. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16980. */
  16981. isBillboardBased: boolean;
  16982. /**
  16983. * The scene the particle system belongs to.
  16984. */
  16985. protected _scene: Scene;
  16986. /**
  16987. * Local cache of defines for image processing.
  16988. */
  16989. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  16990. /**
  16991. * Default configuration related to image processing available in the standard Material.
  16992. */
  16993. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  16994. /**
  16995. * Gets the image processing configuration used either in this material.
  16996. */
  16997. /**
  16998. * Sets the Default image processing configuration used either in the this material.
  16999. *
  17000. * If sets to null, the scene one is in use.
  17001. */
  17002. imageProcessingConfiguration: ImageProcessingConfiguration;
  17003. /**
  17004. * Attaches a new image processing configuration to the Standard Material.
  17005. * @param configuration
  17006. */
  17007. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17008. /** @hidden */
  17009. protected _reset(): void;
  17010. /** @hidden */
  17011. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17012. /**
  17013. * Instantiates a particle system.
  17014. * 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.
  17015. * @param name The name of the particle system
  17016. */
  17017. constructor(name: string);
  17018. /**
  17019. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17020. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17021. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17022. * @returns the emitter
  17023. */
  17024. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17025. /**
  17026. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17027. * @param radius The radius of the hemisphere to emit from
  17028. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17029. * @returns the emitter
  17030. */
  17031. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17032. /**
  17033. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17034. * @param radius The radius of the sphere to emit from
  17035. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17036. * @returns the emitter
  17037. */
  17038. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17039. /**
  17040. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17041. * @param radius The radius of the sphere to emit from
  17042. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17043. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17044. * @returns the emitter
  17045. */
  17046. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17047. /**
  17048. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17049. * @param radius The radius of the emission cylinder
  17050. * @param height The height of the emission cylinder
  17051. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17052. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17053. * @returns the emitter
  17054. */
  17055. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17056. /**
  17057. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17058. * @param radius The radius of the cylinder to emit from
  17059. * @param height The height of the emission cylinder
  17060. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17061. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17062. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17063. * @returns the emitter
  17064. */
  17065. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17066. /**
  17067. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17068. * @param radius The radius of the cone to emit from
  17069. * @param angle The base angle of the cone
  17070. * @returns the emitter
  17071. */
  17072. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17073. /**
  17074. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17075. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17076. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17077. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17078. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17079. * @returns the emitter
  17080. */
  17081. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17082. }
  17083. }
  17084. declare module BABYLON {
  17085. /**
  17086. * Type of sub emitter
  17087. */
  17088. export enum SubEmitterType {
  17089. /**
  17090. * Attached to the particle over it's lifetime
  17091. */
  17092. ATTACHED = 0,
  17093. /**
  17094. * Created when the particle dies
  17095. */
  17096. END = 1
  17097. }
  17098. /**
  17099. * Sub emitter class used to emit particles from an existing particle
  17100. */
  17101. export class SubEmitter {
  17102. /**
  17103. * the particle system to be used by the sub emitter
  17104. */
  17105. particleSystem: ParticleSystem;
  17106. /**
  17107. * Type of the submitter (Default: END)
  17108. */
  17109. type: SubEmitterType;
  17110. /**
  17111. * 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)
  17112. * Note: This only is supported when using an emitter of type Mesh
  17113. */
  17114. inheritDirection: boolean;
  17115. /**
  17116. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17117. */
  17118. inheritedVelocityAmount: number;
  17119. /**
  17120. * Creates a sub emitter
  17121. * @param particleSystem the particle system to be used by the sub emitter
  17122. */
  17123. constructor(
  17124. /**
  17125. * the particle system to be used by the sub emitter
  17126. */
  17127. particleSystem: ParticleSystem);
  17128. /**
  17129. * Clones the sub emitter
  17130. * @returns the cloned sub emitter
  17131. */
  17132. clone(): SubEmitter;
  17133. /**
  17134. * Serialize current object to a JSON object
  17135. * @returns the serialized object
  17136. */
  17137. serialize(): any;
  17138. /** @hidden */
  17139. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17140. /**
  17141. * Creates a new SubEmitter from a serialized JSON version
  17142. * @param serializationObject defines the JSON object to read from
  17143. * @param scene defines the hosting scene
  17144. * @param rootUrl defines the rootUrl for data loading
  17145. * @returns a new SubEmitter
  17146. */
  17147. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17148. /** Release associated resources */
  17149. dispose(): void;
  17150. }
  17151. }
  17152. declare module BABYLON {
  17153. /** @hidden */
  17154. export var clipPlaneFragmentDeclaration: {
  17155. name: string;
  17156. shader: string;
  17157. };
  17158. }
  17159. declare module BABYLON {
  17160. /** @hidden */
  17161. export var imageProcessingDeclaration: {
  17162. name: string;
  17163. shader: string;
  17164. };
  17165. }
  17166. declare module BABYLON {
  17167. /** @hidden */
  17168. export var imageProcessingFunctions: {
  17169. name: string;
  17170. shader: string;
  17171. };
  17172. }
  17173. declare module BABYLON {
  17174. /** @hidden */
  17175. export var clipPlaneFragment: {
  17176. name: string;
  17177. shader: string;
  17178. };
  17179. }
  17180. declare module BABYLON {
  17181. /** @hidden */
  17182. export var particlesPixelShader: {
  17183. name: string;
  17184. shader: string;
  17185. };
  17186. }
  17187. declare module BABYLON {
  17188. /** @hidden */
  17189. export var clipPlaneVertexDeclaration: {
  17190. name: string;
  17191. shader: string;
  17192. };
  17193. }
  17194. declare module BABYLON {
  17195. /** @hidden */
  17196. export var clipPlaneVertex: {
  17197. name: string;
  17198. shader: string;
  17199. };
  17200. }
  17201. declare module BABYLON {
  17202. /** @hidden */
  17203. export var particlesVertexShader: {
  17204. name: string;
  17205. shader: string;
  17206. };
  17207. }
  17208. declare module BABYLON {
  17209. /**
  17210. * This represents a particle system in Babylon.
  17211. * 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.
  17212. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17213. * @example https://doc.babylonjs.com/babylon101/particles
  17214. */
  17215. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17216. /**
  17217. * Billboard mode will only apply to Y axis
  17218. */
  17219. static readonly BILLBOARDMODE_Y: number;
  17220. /**
  17221. * Billboard mode will apply to all axes
  17222. */
  17223. static readonly BILLBOARDMODE_ALL: number;
  17224. /**
  17225. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17226. */
  17227. static readonly BILLBOARDMODE_STRETCHED: number;
  17228. /**
  17229. * This function can be defined to provide custom update for active particles.
  17230. * This function will be called instead of regular update (age, position, color, etc.).
  17231. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17232. */
  17233. updateFunction: (particles: Particle[]) => void;
  17234. private _emitterWorldMatrix;
  17235. /**
  17236. * This function can be defined to specify initial direction for every new particle.
  17237. * It by default use the emitterType defined function
  17238. */
  17239. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17240. /**
  17241. * This function can be defined to specify initial position for every new particle.
  17242. * It by default use the emitterType defined function
  17243. */
  17244. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17245. /**
  17246. * @hidden
  17247. */
  17248. _inheritedVelocityOffset: Vector3;
  17249. /**
  17250. * An event triggered when the system is disposed
  17251. */
  17252. onDisposeObservable: Observable<ParticleSystem>;
  17253. private _onDisposeObserver;
  17254. /**
  17255. * Sets a callback that will be triggered when the system is disposed
  17256. */
  17257. onDispose: () => void;
  17258. private _particles;
  17259. private _epsilon;
  17260. private _capacity;
  17261. private _stockParticles;
  17262. private _newPartsExcess;
  17263. private _vertexData;
  17264. private _vertexBuffer;
  17265. private _vertexBuffers;
  17266. private _spriteBuffer;
  17267. private _indexBuffer;
  17268. private _effect;
  17269. private _customEffect;
  17270. private _cachedDefines;
  17271. private _scaledColorStep;
  17272. private _colorDiff;
  17273. private _scaledDirection;
  17274. private _scaledGravity;
  17275. private _currentRenderId;
  17276. private _alive;
  17277. private _useInstancing;
  17278. private _started;
  17279. private _stopped;
  17280. private _actualFrame;
  17281. private _scaledUpdateSpeed;
  17282. private _vertexBufferSize;
  17283. /** @hidden */
  17284. _currentEmitRateGradient: Nullable<FactorGradient>;
  17285. /** @hidden */
  17286. _currentEmitRate1: number;
  17287. /** @hidden */
  17288. _currentEmitRate2: number;
  17289. /** @hidden */
  17290. _currentStartSizeGradient: Nullable<FactorGradient>;
  17291. /** @hidden */
  17292. _currentStartSize1: number;
  17293. /** @hidden */
  17294. _currentStartSize2: number;
  17295. private readonly _rawTextureWidth;
  17296. private _rampGradientsTexture;
  17297. private _useRampGradients;
  17298. /** Gets or sets a boolean indicating that ramp gradients must be used
  17299. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17300. */
  17301. useRampGradients: boolean;
  17302. /**
  17303. * 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.
  17304. * 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: [])
  17305. */
  17306. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17307. private _subEmitters;
  17308. /**
  17309. * @hidden
  17310. * If the particle systems emitter should be disposed when the particle system is disposed
  17311. */
  17312. _disposeEmitterOnDispose: boolean;
  17313. /**
  17314. * The current active Sub-systems, this property is used by the root particle system only.
  17315. */
  17316. activeSubSystems: Array<ParticleSystem>;
  17317. private _rootParticleSystem;
  17318. /**
  17319. * Gets the current list of active particles
  17320. */
  17321. readonly particles: Particle[];
  17322. /**
  17323. * Returns the string "ParticleSystem"
  17324. * @returns a string containing the class name
  17325. */
  17326. getClassName(): string;
  17327. /**
  17328. * Instantiates a particle system.
  17329. * 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.
  17330. * @param name The name of the particle system
  17331. * @param capacity The max number of particles alive at the same time
  17332. * @param scene The scene the particle system belongs to
  17333. * @param customEffect a custom effect used to change the way particles are rendered by default
  17334. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17335. * @param epsilon Offset used to render the particles
  17336. */
  17337. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17338. private _addFactorGradient;
  17339. private _removeFactorGradient;
  17340. /**
  17341. * Adds a new life time gradient
  17342. * @param gradient defines the gradient to use (between 0 and 1)
  17343. * @param factor defines the life time factor to affect to the specified gradient
  17344. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17345. * @returns the current particle system
  17346. */
  17347. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17348. /**
  17349. * Remove a specific life time gradient
  17350. * @param gradient defines the gradient to remove
  17351. * @returns the current particle system
  17352. */
  17353. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17354. /**
  17355. * Adds a new size gradient
  17356. * @param gradient defines the gradient to use (between 0 and 1)
  17357. * @param factor defines the size factor to affect to the specified gradient
  17358. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17359. * @returns the current particle system
  17360. */
  17361. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17362. /**
  17363. * Remove a specific size gradient
  17364. * @param gradient defines the gradient to remove
  17365. * @returns the current particle system
  17366. */
  17367. removeSizeGradient(gradient: number): IParticleSystem;
  17368. /**
  17369. * Adds a new color remap gradient
  17370. * @param gradient defines the gradient to use (between 0 and 1)
  17371. * @param min defines the color remap minimal range
  17372. * @param max defines the color remap maximal range
  17373. * @returns the current particle system
  17374. */
  17375. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17376. /**
  17377. * Remove a specific color remap gradient
  17378. * @param gradient defines the gradient to remove
  17379. * @returns the current particle system
  17380. */
  17381. removeColorRemapGradient(gradient: number): IParticleSystem;
  17382. /**
  17383. * Adds a new alpha remap gradient
  17384. * @param gradient defines the gradient to use (between 0 and 1)
  17385. * @param min defines the alpha remap minimal range
  17386. * @param max defines the alpha remap maximal range
  17387. * @returns the current particle system
  17388. */
  17389. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17390. /**
  17391. * Remove a specific alpha remap gradient
  17392. * @param gradient defines the gradient to remove
  17393. * @returns the current particle system
  17394. */
  17395. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17396. /**
  17397. * Adds a new angular speed gradient
  17398. * @param gradient defines the gradient to use (between 0 and 1)
  17399. * @param factor defines the angular speed to affect to the specified gradient
  17400. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17401. * @returns the current particle system
  17402. */
  17403. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17404. /**
  17405. * Remove a specific angular speed gradient
  17406. * @param gradient defines the gradient to remove
  17407. * @returns the current particle system
  17408. */
  17409. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17410. /**
  17411. * Adds a new velocity gradient
  17412. * @param gradient defines the gradient to use (between 0 and 1)
  17413. * @param factor defines the velocity to affect to the specified gradient
  17414. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17415. * @returns the current particle system
  17416. */
  17417. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17418. /**
  17419. * Remove a specific velocity gradient
  17420. * @param gradient defines the gradient to remove
  17421. * @returns the current particle system
  17422. */
  17423. removeVelocityGradient(gradient: number): IParticleSystem;
  17424. /**
  17425. * Adds a new limit velocity gradient
  17426. * @param gradient defines the gradient to use (between 0 and 1)
  17427. * @param factor defines the limit velocity value to affect to the specified gradient
  17428. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17429. * @returns the current particle system
  17430. */
  17431. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17432. /**
  17433. * Remove a specific limit velocity gradient
  17434. * @param gradient defines the gradient to remove
  17435. * @returns the current particle system
  17436. */
  17437. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17438. /**
  17439. * Adds a new drag gradient
  17440. * @param gradient defines the gradient to use (between 0 and 1)
  17441. * @param factor defines the drag value to affect to the specified gradient
  17442. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17443. * @returns the current particle system
  17444. */
  17445. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17446. /**
  17447. * Remove a specific drag gradient
  17448. * @param gradient defines the gradient to remove
  17449. * @returns the current particle system
  17450. */
  17451. removeDragGradient(gradient: number): IParticleSystem;
  17452. /**
  17453. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17454. * @param gradient defines the gradient to use (between 0 and 1)
  17455. * @param factor defines the emit rate value to affect to the specified gradient
  17456. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17457. * @returns the current particle system
  17458. */
  17459. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17460. /**
  17461. * Remove a specific emit rate gradient
  17462. * @param gradient defines the gradient to remove
  17463. * @returns the current particle system
  17464. */
  17465. removeEmitRateGradient(gradient: number): IParticleSystem;
  17466. /**
  17467. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17468. * @param gradient defines the gradient to use (between 0 and 1)
  17469. * @param factor defines the start size value to affect to the specified gradient
  17470. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17471. * @returns the current particle system
  17472. */
  17473. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17474. /**
  17475. * Remove a specific start size gradient
  17476. * @param gradient defines the gradient to remove
  17477. * @returns the current particle system
  17478. */
  17479. removeStartSizeGradient(gradient: number): IParticleSystem;
  17480. private _createRampGradientTexture;
  17481. /**
  17482. * Gets the current list of ramp gradients.
  17483. * You must use addRampGradient and removeRampGradient to udpate this list
  17484. * @returns the list of ramp gradients
  17485. */
  17486. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17487. /**
  17488. * Adds a new ramp gradient used to remap particle colors
  17489. * @param gradient defines the gradient to use (between 0 and 1)
  17490. * @param color defines the color to affect to the specified gradient
  17491. * @returns the current particle system
  17492. */
  17493. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17494. /**
  17495. * Remove a specific ramp gradient
  17496. * @param gradient defines the gradient to remove
  17497. * @returns the current particle system
  17498. */
  17499. removeRampGradient(gradient: number): ParticleSystem;
  17500. /**
  17501. * Adds a new color gradient
  17502. * @param gradient defines the gradient to use (between 0 and 1)
  17503. * @param color1 defines the color to affect to the specified gradient
  17504. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17505. * @returns this particle system
  17506. */
  17507. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17508. /**
  17509. * Remove a specific color gradient
  17510. * @param gradient defines the gradient to remove
  17511. * @returns this particle system
  17512. */
  17513. removeColorGradient(gradient: number): IParticleSystem;
  17514. private _fetchR;
  17515. protected _reset(): void;
  17516. private _resetEffect;
  17517. private _createVertexBuffers;
  17518. private _createIndexBuffer;
  17519. /**
  17520. * Gets the maximum number of particles active at the same time.
  17521. * @returns The max number of active particles.
  17522. */
  17523. getCapacity(): number;
  17524. /**
  17525. * Gets whether there are still active particles in the system.
  17526. * @returns True if it is alive, otherwise false.
  17527. */
  17528. isAlive(): boolean;
  17529. /**
  17530. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17531. * @returns True if it has been started, otherwise false.
  17532. */
  17533. isStarted(): boolean;
  17534. private _prepareSubEmitterInternalArray;
  17535. /**
  17536. * Starts the particle system and begins to emit
  17537. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17538. */
  17539. start(delay?: number): void;
  17540. /**
  17541. * Stops the particle system.
  17542. * @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.
  17543. */
  17544. stop(stopSubEmitters?: boolean): void;
  17545. /**
  17546. * Remove all active particles
  17547. */
  17548. reset(): void;
  17549. /**
  17550. * @hidden (for internal use only)
  17551. */
  17552. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17553. /**
  17554. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17555. * Its lifetime will start back at 0.
  17556. */
  17557. recycleParticle: (particle: Particle) => void;
  17558. private _stopSubEmitters;
  17559. private _createParticle;
  17560. private _removeFromRoot;
  17561. private _emitFromParticle;
  17562. private _update;
  17563. /** @hidden */
  17564. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17565. /** @hidden */
  17566. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17567. /** @hidden */
  17568. private _getEffect;
  17569. /**
  17570. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17571. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17572. */
  17573. animate(preWarmOnly?: boolean): void;
  17574. private _appendParticleVertices;
  17575. /**
  17576. * Rebuilds the particle system.
  17577. */
  17578. rebuild(): void;
  17579. /**
  17580. * Is this system ready to be used/rendered
  17581. * @return true if the system is ready
  17582. */
  17583. isReady(): boolean;
  17584. private _render;
  17585. /**
  17586. * Renders the particle system in its current state.
  17587. * @returns the current number of particles
  17588. */
  17589. render(): number;
  17590. /**
  17591. * Disposes the particle system and free the associated resources
  17592. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17593. */
  17594. dispose(disposeTexture?: boolean): void;
  17595. /**
  17596. * Clones the particle system.
  17597. * @param name The name of the cloned object
  17598. * @param newEmitter The new emitter to use
  17599. * @returns the cloned particle system
  17600. */
  17601. clone(name: string, newEmitter: any): ParticleSystem;
  17602. /**
  17603. * Serializes the particle system to a JSON object.
  17604. * @returns the JSON object
  17605. */
  17606. serialize(): any;
  17607. /** @hidden */
  17608. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17609. /** @hidden */
  17610. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17611. /**
  17612. * Parses a JSON object to create a particle system.
  17613. * @param parsedParticleSystem The JSON object to parse
  17614. * @param scene The scene to create the particle system in
  17615. * @param rootUrl The root url to use to load external dependencies like texture
  17616. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17617. * @returns the Parsed particle system
  17618. */
  17619. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17620. }
  17621. }
  17622. declare module BABYLON {
  17623. /**
  17624. * A particle represents one of the element emitted by a particle system.
  17625. * This is mainly define by its coordinates, direction, velocity and age.
  17626. */
  17627. export class Particle {
  17628. /**
  17629. * The particle system the particle belongs to.
  17630. */
  17631. particleSystem: ParticleSystem;
  17632. private static _Count;
  17633. /**
  17634. * Unique ID of the particle
  17635. */
  17636. id: number;
  17637. /**
  17638. * The world position of the particle in the scene.
  17639. */
  17640. position: Vector3;
  17641. /**
  17642. * The world direction of the particle in the scene.
  17643. */
  17644. direction: Vector3;
  17645. /**
  17646. * The color of the particle.
  17647. */
  17648. color: Color4;
  17649. /**
  17650. * The color change of the particle per step.
  17651. */
  17652. colorStep: Color4;
  17653. /**
  17654. * Defines how long will the life of the particle be.
  17655. */
  17656. lifeTime: number;
  17657. /**
  17658. * The current age of the particle.
  17659. */
  17660. age: number;
  17661. /**
  17662. * The current size of the particle.
  17663. */
  17664. size: number;
  17665. /**
  17666. * The current scale of the particle.
  17667. */
  17668. scale: Vector2;
  17669. /**
  17670. * The current angle of the particle.
  17671. */
  17672. angle: number;
  17673. /**
  17674. * Defines how fast is the angle changing.
  17675. */
  17676. angularSpeed: number;
  17677. /**
  17678. * Defines the cell index used by the particle to be rendered from a sprite.
  17679. */
  17680. cellIndex: number;
  17681. /**
  17682. * The information required to support color remapping
  17683. */
  17684. remapData: Vector4;
  17685. /** @hidden */
  17686. _randomCellOffset?: number;
  17687. /** @hidden */
  17688. _initialDirection: Nullable<Vector3>;
  17689. /** @hidden */
  17690. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17691. /** @hidden */
  17692. _initialStartSpriteCellID: number;
  17693. /** @hidden */
  17694. _initialEndSpriteCellID: number;
  17695. /** @hidden */
  17696. _currentColorGradient: Nullable<ColorGradient>;
  17697. /** @hidden */
  17698. _currentColor1: Color4;
  17699. /** @hidden */
  17700. _currentColor2: Color4;
  17701. /** @hidden */
  17702. _currentSizeGradient: Nullable<FactorGradient>;
  17703. /** @hidden */
  17704. _currentSize1: number;
  17705. /** @hidden */
  17706. _currentSize2: number;
  17707. /** @hidden */
  17708. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17709. /** @hidden */
  17710. _currentAngularSpeed1: number;
  17711. /** @hidden */
  17712. _currentAngularSpeed2: number;
  17713. /** @hidden */
  17714. _currentVelocityGradient: Nullable<FactorGradient>;
  17715. /** @hidden */
  17716. _currentVelocity1: number;
  17717. /** @hidden */
  17718. _currentVelocity2: number;
  17719. /** @hidden */
  17720. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17721. /** @hidden */
  17722. _currentLimitVelocity1: number;
  17723. /** @hidden */
  17724. _currentLimitVelocity2: number;
  17725. /** @hidden */
  17726. _currentDragGradient: Nullable<FactorGradient>;
  17727. /** @hidden */
  17728. _currentDrag1: number;
  17729. /** @hidden */
  17730. _currentDrag2: number;
  17731. /** @hidden */
  17732. _randomNoiseCoordinates1: Vector3;
  17733. /** @hidden */
  17734. _randomNoiseCoordinates2: Vector3;
  17735. /**
  17736. * Creates a new instance Particle
  17737. * @param particleSystem the particle system the particle belongs to
  17738. */
  17739. constructor(
  17740. /**
  17741. * The particle system the particle belongs to.
  17742. */
  17743. particleSystem: ParticleSystem);
  17744. private updateCellInfoFromSystem;
  17745. /**
  17746. * Defines how the sprite cell index is updated for the particle
  17747. */
  17748. updateCellIndex(): void;
  17749. /** @hidden */
  17750. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17751. /** @hidden */
  17752. _inheritParticleInfoToSubEmitters(): void;
  17753. /** @hidden */
  17754. _reset(): void;
  17755. /**
  17756. * Copy the properties of particle to another one.
  17757. * @param other the particle to copy the information to.
  17758. */
  17759. copyTo(other: Particle): void;
  17760. }
  17761. }
  17762. declare module BABYLON {
  17763. /**
  17764. * Particle emitter represents a volume emitting particles.
  17765. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17766. */
  17767. export interface IParticleEmitterType {
  17768. /**
  17769. * Called by the particle System when the direction is computed for the created particle.
  17770. * @param worldMatrix is the world matrix of the particle system
  17771. * @param directionToUpdate is the direction vector to update with the result
  17772. * @param particle is the particle we are computed the direction for
  17773. */
  17774. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17775. /**
  17776. * Called by the particle System when the position is computed for the created particle.
  17777. * @param worldMatrix is the world matrix of the particle system
  17778. * @param positionToUpdate is the position vector to update with the result
  17779. * @param particle is the particle we are computed the position for
  17780. */
  17781. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17782. /**
  17783. * Clones the current emitter and returns a copy of it
  17784. * @returns the new emitter
  17785. */
  17786. clone(): IParticleEmitterType;
  17787. /**
  17788. * Called by the GPUParticleSystem to setup the update shader
  17789. * @param effect defines the update shader
  17790. */
  17791. applyToShader(effect: Effect): void;
  17792. /**
  17793. * Returns a string to use to update the GPU particles update shader
  17794. * @returns the effect defines string
  17795. */
  17796. getEffectDefines(): string;
  17797. /**
  17798. * Returns a string representing the class name
  17799. * @returns a string containing the class name
  17800. */
  17801. getClassName(): string;
  17802. /**
  17803. * Serializes the particle system to a JSON object.
  17804. * @returns the JSON object
  17805. */
  17806. serialize(): any;
  17807. /**
  17808. * Parse properties from a JSON object
  17809. * @param serializationObject defines the JSON object
  17810. */
  17811. parse(serializationObject: any): void;
  17812. }
  17813. }
  17814. declare module BABYLON {
  17815. /**
  17816. * Particle emitter emitting particles from the inside of a box.
  17817. * It emits the particles randomly between 2 given directions.
  17818. */
  17819. export class BoxParticleEmitter implements IParticleEmitterType {
  17820. /**
  17821. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17822. */
  17823. direction1: Vector3;
  17824. /**
  17825. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17826. */
  17827. direction2: Vector3;
  17828. /**
  17829. * 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.
  17830. */
  17831. minEmitBox: Vector3;
  17832. /**
  17833. * 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.
  17834. */
  17835. maxEmitBox: Vector3;
  17836. /**
  17837. * Creates a new instance BoxParticleEmitter
  17838. */
  17839. constructor();
  17840. /**
  17841. * Called by the particle System when the direction is computed for the created particle.
  17842. * @param worldMatrix is the world matrix of the particle system
  17843. * @param directionToUpdate is the direction vector to update with the result
  17844. * @param particle is the particle we are computed the direction for
  17845. */
  17846. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17847. /**
  17848. * Called by the particle System when the position is computed for the created particle.
  17849. * @param worldMatrix is the world matrix of the particle system
  17850. * @param positionToUpdate is the position vector to update with the result
  17851. * @param particle is the particle we are computed the position for
  17852. */
  17853. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17854. /**
  17855. * Clones the current emitter and returns a copy of it
  17856. * @returns the new emitter
  17857. */
  17858. clone(): BoxParticleEmitter;
  17859. /**
  17860. * Called by the GPUParticleSystem to setup the update shader
  17861. * @param effect defines the update shader
  17862. */
  17863. applyToShader(effect: Effect): void;
  17864. /**
  17865. * Returns a string to use to update the GPU particles update shader
  17866. * @returns a string containng the defines string
  17867. */
  17868. getEffectDefines(): string;
  17869. /**
  17870. * Returns the string "BoxParticleEmitter"
  17871. * @returns a string containing the class name
  17872. */
  17873. getClassName(): string;
  17874. /**
  17875. * Serializes the particle system to a JSON object.
  17876. * @returns the JSON object
  17877. */
  17878. serialize(): any;
  17879. /**
  17880. * Parse properties from a JSON object
  17881. * @param serializationObject defines the JSON object
  17882. */
  17883. parse(serializationObject: any): void;
  17884. }
  17885. }
  17886. declare module BABYLON {
  17887. /**
  17888. * Particle emitter emitting particles from the inside of a cone.
  17889. * It emits the particles alongside the cone volume from the base to the particle.
  17890. * The emission direction might be randomized.
  17891. */
  17892. export class ConeParticleEmitter implements IParticleEmitterType {
  17893. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17894. directionRandomizer: number;
  17895. private _radius;
  17896. private _angle;
  17897. private _height;
  17898. /**
  17899. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  17900. */
  17901. radiusRange: number;
  17902. /**
  17903. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  17904. */
  17905. heightRange: number;
  17906. /**
  17907. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  17908. */
  17909. emitFromSpawnPointOnly: boolean;
  17910. /**
  17911. * Gets or sets the radius of the emission cone
  17912. */
  17913. radius: number;
  17914. /**
  17915. * Gets or sets the angle of the emission cone
  17916. */
  17917. angle: number;
  17918. private _buildHeight;
  17919. /**
  17920. * Creates a new instance ConeParticleEmitter
  17921. * @param radius the radius of the emission cone (1 by default)
  17922. * @param angle the cone base angle (PI by default)
  17923. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  17924. */
  17925. constructor(radius?: number, angle?: number,
  17926. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17927. directionRandomizer?: number);
  17928. /**
  17929. * Called by the particle System when the direction is computed for the created particle.
  17930. * @param worldMatrix is the world matrix of the particle system
  17931. * @param directionToUpdate is the direction vector to update with the result
  17932. * @param particle is the particle we are computed the direction for
  17933. */
  17934. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17935. /**
  17936. * Called by the particle System when the position is computed for the created particle.
  17937. * @param worldMatrix is the world matrix of the particle system
  17938. * @param positionToUpdate is the position vector to update with the result
  17939. * @param particle is the particle we are computed the position for
  17940. */
  17941. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17942. /**
  17943. * Clones the current emitter and returns a copy of it
  17944. * @returns the new emitter
  17945. */
  17946. clone(): ConeParticleEmitter;
  17947. /**
  17948. * Called by the GPUParticleSystem to setup the update shader
  17949. * @param effect defines the update shader
  17950. */
  17951. applyToShader(effect: Effect): void;
  17952. /**
  17953. * Returns a string to use to update the GPU particles update shader
  17954. * @returns a string containng the defines string
  17955. */
  17956. getEffectDefines(): string;
  17957. /**
  17958. * Returns the string "ConeParticleEmitter"
  17959. * @returns a string containing the class name
  17960. */
  17961. getClassName(): string;
  17962. /**
  17963. * Serializes the particle system to a JSON object.
  17964. * @returns the JSON object
  17965. */
  17966. serialize(): any;
  17967. /**
  17968. * Parse properties from a JSON object
  17969. * @param serializationObject defines the JSON object
  17970. */
  17971. parse(serializationObject: any): void;
  17972. }
  17973. }
  17974. declare module BABYLON {
  17975. /**
  17976. * Particle emitter emitting particles from the inside of a cylinder.
  17977. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  17978. */
  17979. export class CylinderParticleEmitter implements IParticleEmitterType {
  17980. /**
  17981. * The radius of the emission cylinder.
  17982. */
  17983. radius: number;
  17984. /**
  17985. * The height of the emission cylinder.
  17986. */
  17987. height: number;
  17988. /**
  17989. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17990. */
  17991. radiusRange: number;
  17992. /**
  17993. * How much to randomize the particle direction [0-1].
  17994. */
  17995. directionRandomizer: number;
  17996. /**
  17997. * Creates a new instance CylinderParticleEmitter
  17998. * @param radius the radius of the emission cylinder (1 by default)
  17999. * @param height the height of the emission cylinder (1 by default)
  18000. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18001. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18002. */
  18003. constructor(
  18004. /**
  18005. * The radius of the emission cylinder.
  18006. */
  18007. radius?: number,
  18008. /**
  18009. * The height of the emission cylinder.
  18010. */
  18011. height?: number,
  18012. /**
  18013. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18014. */
  18015. radiusRange?: number,
  18016. /**
  18017. * How much to randomize the particle direction [0-1].
  18018. */
  18019. directionRandomizer?: number);
  18020. /**
  18021. * Called by the particle System when the direction is computed for the created particle.
  18022. * @param worldMatrix is the world matrix of the particle system
  18023. * @param directionToUpdate is the direction vector to update with the result
  18024. * @param particle is the particle we are computed the direction for
  18025. */
  18026. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18027. /**
  18028. * Called by the particle System when the position is computed for the created particle.
  18029. * @param worldMatrix is the world matrix of the particle system
  18030. * @param positionToUpdate is the position vector to update with the result
  18031. * @param particle is the particle we are computed the position for
  18032. */
  18033. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18034. /**
  18035. * Clones the current emitter and returns a copy of it
  18036. * @returns the new emitter
  18037. */
  18038. clone(): CylinderParticleEmitter;
  18039. /**
  18040. * Called by the GPUParticleSystem to setup the update shader
  18041. * @param effect defines the update shader
  18042. */
  18043. applyToShader(effect: Effect): void;
  18044. /**
  18045. * Returns a string to use to update the GPU particles update shader
  18046. * @returns a string containng the defines string
  18047. */
  18048. getEffectDefines(): string;
  18049. /**
  18050. * Returns the string "CylinderParticleEmitter"
  18051. * @returns a string containing the class name
  18052. */
  18053. getClassName(): string;
  18054. /**
  18055. * Serializes the particle system to a JSON object.
  18056. * @returns the JSON object
  18057. */
  18058. serialize(): any;
  18059. /**
  18060. * Parse properties from a JSON object
  18061. * @param serializationObject defines the JSON object
  18062. */
  18063. parse(serializationObject: any): void;
  18064. }
  18065. /**
  18066. * Particle emitter emitting particles from the inside of a cylinder.
  18067. * It emits the particles randomly between two vectors.
  18068. */
  18069. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18070. /**
  18071. * The min limit of the emission direction.
  18072. */
  18073. direction1: Vector3;
  18074. /**
  18075. * The max limit of the emission direction.
  18076. */
  18077. direction2: Vector3;
  18078. /**
  18079. * Creates a new instance CylinderDirectedParticleEmitter
  18080. * @param radius the radius of the emission cylinder (1 by default)
  18081. * @param height the height of the emission cylinder (1 by default)
  18082. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18083. * @param direction1 the min limit of the emission direction (up vector by default)
  18084. * @param direction2 the max limit of the emission direction (up vector by default)
  18085. */
  18086. constructor(radius?: number, height?: number, radiusRange?: number,
  18087. /**
  18088. * The min limit of the emission direction.
  18089. */
  18090. direction1?: Vector3,
  18091. /**
  18092. * The max limit of the emission direction.
  18093. */
  18094. direction2?: Vector3);
  18095. /**
  18096. * Called by the particle System when the direction is computed for the created particle.
  18097. * @param worldMatrix is the world matrix of the particle system
  18098. * @param directionToUpdate is the direction vector to update with the result
  18099. * @param particle is the particle we are computed the direction for
  18100. */
  18101. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18102. /**
  18103. * Clones the current emitter and returns a copy of it
  18104. * @returns the new emitter
  18105. */
  18106. clone(): CylinderDirectedParticleEmitter;
  18107. /**
  18108. * Called by the GPUParticleSystem to setup the update shader
  18109. * @param effect defines the update shader
  18110. */
  18111. applyToShader(effect: Effect): void;
  18112. /**
  18113. * Returns a string to use to update the GPU particles update shader
  18114. * @returns a string containng the defines string
  18115. */
  18116. getEffectDefines(): string;
  18117. /**
  18118. * Returns the string "CylinderDirectedParticleEmitter"
  18119. * @returns a string containing the class name
  18120. */
  18121. getClassName(): string;
  18122. /**
  18123. * Serializes the particle system to a JSON object.
  18124. * @returns the JSON object
  18125. */
  18126. serialize(): any;
  18127. /**
  18128. * Parse properties from a JSON object
  18129. * @param serializationObject defines the JSON object
  18130. */
  18131. parse(serializationObject: any): void;
  18132. }
  18133. }
  18134. declare module BABYLON {
  18135. /**
  18136. * Particle emitter emitting particles from the inside of a hemisphere.
  18137. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18138. */
  18139. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18140. /**
  18141. * The radius of the emission hemisphere.
  18142. */
  18143. radius: number;
  18144. /**
  18145. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18146. */
  18147. radiusRange: number;
  18148. /**
  18149. * How much to randomize the particle direction [0-1].
  18150. */
  18151. directionRandomizer: number;
  18152. /**
  18153. * Creates a new instance HemisphericParticleEmitter
  18154. * @param radius the radius of the emission hemisphere (1 by default)
  18155. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18156. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18157. */
  18158. constructor(
  18159. /**
  18160. * The radius of the emission hemisphere.
  18161. */
  18162. radius?: number,
  18163. /**
  18164. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18165. */
  18166. radiusRange?: number,
  18167. /**
  18168. * How much to randomize the particle direction [0-1].
  18169. */
  18170. directionRandomizer?: number);
  18171. /**
  18172. * Called by the particle System when the direction is computed for the created particle.
  18173. * @param worldMatrix is the world matrix of the particle system
  18174. * @param directionToUpdate is the direction vector to update with the result
  18175. * @param particle is the particle we are computed the direction for
  18176. */
  18177. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18178. /**
  18179. * Called by the particle System when the position is computed for the created particle.
  18180. * @param worldMatrix is the world matrix of the particle system
  18181. * @param positionToUpdate is the position vector to update with the result
  18182. * @param particle is the particle we are computed the position for
  18183. */
  18184. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18185. /**
  18186. * Clones the current emitter and returns a copy of it
  18187. * @returns the new emitter
  18188. */
  18189. clone(): HemisphericParticleEmitter;
  18190. /**
  18191. * Called by the GPUParticleSystem to setup the update shader
  18192. * @param effect defines the update shader
  18193. */
  18194. applyToShader(effect: Effect): void;
  18195. /**
  18196. * Returns a string to use to update the GPU particles update shader
  18197. * @returns a string containng the defines string
  18198. */
  18199. getEffectDefines(): string;
  18200. /**
  18201. * Returns the string "HemisphericParticleEmitter"
  18202. * @returns a string containing the class name
  18203. */
  18204. getClassName(): string;
  18205. /**
  18206. * Serializes the particle system to a JSON object.
  18207. * @returns the JSON object
  18208. */
  18209. serialize(): any;
  18210. /**
  18211. * Parse properties from a JSON object
  18212. * @param serializationObject defines the JSON object
  18213. */
  18214. parse(serializationObject: any): void;
  18215. }
  18216. }
  18217. declare module BABYLON {
  18218. /**
  18219. * Particle emitter emitting particles from a point.
  18220. * It emits the particles randomly between 2 given directions.
  18221. */
  18222. export class PointParticleEmitter implements IParticleEmitterType {
  18223. /**
  18224. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18225. */
  18226. direction1: Vector3;
  18227. /**
  18228. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18229. */
  18230. direction2: Vector3;
  18231. /**
  18232. * Creates a new instance PointParticleEmitter
  18233. */
  18234. constructor();
  18235. /**
  18236. * Called by the particle System when the direction is computed for the created particle.
  18237. * @param worldMatrix is the world matrix of the particle system
  18238. * @param directionToUpdate is the direction vector to update with the result
  18239. * @param particle is the particle we are computed the direction for
  18240. */
  18241. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18242. /**
  18243. * Called by the particle System when the position is computed for the created particle.
  18244. * @param worldMatrix is the world matrix of the particle system
  18245. * @param positionToUpdate is the position vector to update with the result
  18246. * @param particle is the particle we are computed the position for
  18247. */
  18248. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18249. /**
  18250. * Clones the current emitter and returns a copy of it
  18251. * @returns the new emitter
  18252. */
  18253. clone(): PointParticleEmitter;
  18254. /**
  18255. * Called by the GPUParticleSystem to setup the update shader
  18256. * @param effect defines the update shader
  18257. */
  18258. applyToShader(effect: Effect): void;
  18259. /**
  18260. * Returns a string to use to update the GPU particles update shader
  18261. * @returns a string containng the defines string
  18262. */
  18263. getEffectDefines(): string;
  18264. /**
  18265. * Returns the string "PointParticleEmitter"
  18266. * @returns a string containing the class name
  18267. */
  18268. getClassName(): string;
  18269. /**
  18270. * Serializes the particle system to a JSON object.
  18271. * @returns the JSON object
  18272. */
  18273. serialize(): any;
  18274. /**
  18275. * Parse properties from a JSON object
  18276. * @param serializationObject defines the JSON object
  18277. */
  18278. parse(serializationObject: any): void;
  18279. }
  18280. }
  18281. declare module BABYLON {
  18282. /**
  18283. * Particle emitter emitting particles from the inside of a sphere.
  18284. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18285. */
  18286. export class SphereParticleEmitter implements IParticleEmitterType {
  18287. /**
  18288. * The radius of the emission sphere.
  18289. */
  18290. radius: number;
  18291. /**
  18292. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18293. */
  18294. radiusRange: number;
  18295. /**
  18296. * How much to randomize the particle direction [0-1].
  18297. */
  18298. directionRandomizer: number;
  18299. /**
  18300. * Creates a new instance SphereParticleEmitter
  18301. * @param radius the radius of the emission sphere (1 by default)
  18302. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18303. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18304. */
  18305. constructor(
  18306. /**
  18307. * The radius of the emission sphere.
  18308. */
  18309. radius?: number,
  18310. /**
  18311. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18312. */
  18313. radiusRange?: number,
  18314. /**
  18315. * How much to randomize the particle direction [0-1].
  18316. */
  18317. directionRandomizer?: number);
  18318. /**
  18319. * Called by the particle System when the direction is computed for the created particle.
  18320. * @param worldMatrix is the world matrix of the particle system
  18321. * @param directionToUpdate is the direction vector to update with the result
  18322. * @param particle is the particle we are computed the direction for
  18323. */
  18324. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18325. /**
  18326. * Called by the particle System when the position is computed for the created particle.
  18327. * @param worldMatrix is the world matrix of the particle system
  18328. * @param positionToUpdate is the position vector to update with the result
  18329. * @param particle is the particle we are computed the position for
  18330. */
  18331. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18332. /**
  18333. * Clones the current emitter and returns a copy of it
  18334. * @returns the new emitter
  18335. */
  18336. clone(): SphereParticleEmitter;
  18337. /**
  18338. * Called by the GPUParticleSystem to setup the update shader
  18339. * @param effect defines the update shader
  18340. */
  18341. applyToShader(effect: Effect): void;
  18342. /**
  18343. * Returns a string to use to update the GPU particles update shader
  18344. * @returns a string containng the defines string
  18345. */
  18346. getEffectDefines(): string;
  18347. /**
  18348. * Returns the string "SphereParticleEmitter"
  18349. * @returns a string containing the class name
  18350. */
  18351. getClassName(): string;
  18352. /**
  18353. * Serializes the particle system to a JSON object.
  18354. * @returns the JSON object
  18355. */
  18356. serialize(): any;
  18357. /**
  18358. * Parse properties from a JSON object
  18359. * @param serializationObject defines the JSON object
  18360. */
  18361. parse(serializationObject: any): void;
  18362. }
  18363. /**
  18364. * Particle emitter emitting particles from the inside of a sphere.
  18365. * It emits the particles randomly between two vectors.
  18366. */
  18367. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18368. /**
  18369. * The min limit of the emission direction.
  18370. */
  18371. direction1: Vector3;
  18372. /**
  18373. * The max limit of the emission direction.
  18374. */
  18375. direction2: Vector3;
  18376. /**
  18377. * Creates a new instance SphereDirectedParticleEmitter
  18378. * @param radius the radius of the emission sphere (1 by default)
  18379. * @param direction1 the min limit of the emission direction (up vector by default)
  18380. * @param direction2 the max limit of the emission direction (up vector by default)
  18381. */
  18382. constructor(radius?: number,
  18383. /**
  18384. * The min limit of the emission direction.
  18385. */
  18386. direction1?: Vector3,
  18387. /**
  18388. * The max limit of the emission direction.
  18389. */
  18390. direction2?: Vector3);
  18391. /**
  18392. * Called by the particle System when the direction is computed for the created particle.
  18393. * @param worldMatrix is the world matrix of the particle system
  18394. * @param directionToUpdate is the direction vector to update with the result
  18395. * @param particle is the particle we are computed the direction for
  18396. */
  18397. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18398. /**
  18399. * Clones the current emitter and returns a copy of it
  18400. * @returns the new emitter
  18401. */
  18402. clone(): SphereDirectedParticleEmitter;
  18403. /**
  18404. * Called by the GPUParticleSystem to setup the update shader
  18405. * @param effect defines the update shader
  18406. */
  18407. applyToShader(effect: Effect): void;
  18408. /**
  18409. * Returns a string to use to update the GPU particles update shader
  18410. * @returns a string containng the defines string
  18411. */
  18412. getEffectDefines(): string;
  18413. /**
  18414. * Returns the string "SphereDirectedParticleEmitter"
  18415. * @returns a string containing the class name
  18416. */
  18417. getClassName(): string;
  18418. /**
  18419. * Serializes the particle system to a JSON object.
  18420. * @returns the JSON object
  18421. */
  18422. serialize(): any;
  18423. /**
  18424. * Parse properties from a JSON object
  18425. * @param serializationObject defines the JSON object
  18426. */
  18427. parse(serializationObject: any): void;
  18428. }
  18429. }
  18430. declare module BABYLON {
  18431. /**
  18432. * Interface representing a particle system in Babylon.js.
  18433. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18434. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18435. */
  18436. export interface IParticleSystem {
  18437. /**
  18438. * List of animations used by the particle system.
  18439. */
  18440. animations: Animation[];
  18441. /**
  18442. * The id of the Particle system.
  18443. */
  18444. id: string;
  18445. /**
  18446. * The name of the Particle system.
  18447. */
  18448. name: string;
  18449. /**
  18450. * The emitter represents the Mesh or position we are attaching the particle system to.
  18451. */
  18452. emitter: Nullable<AbstractMesh | Vector3>;
  18453. /**
  18454. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18455. */
  18456. isBillboardBased: boolean;
  18457. /**
  18458. * The rendering group used by the Particle system to chose when to render.
  18459. */
  18460. renderingGroupId: number;
  18461. /**
  18462. * The layer mask we are rendering the particles through.
  18463. */
  18464. layerMask: number;
  18465. /**
  18466. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18467. */
  18468. updateSpeed: number;
  18469. /**
  18470. * The amount of time the particle system is running (depends of the overall update speed).
  18471. */
  18472. targetStopDuration: number;
  18473. /**
  18474. * The texture used to render each particle. (this can be a spritesheet)
  18475. */
  18476. particleTexture: Nullable<Texture>;
  18477. /**
  18478. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18479. */
  18480. blendMode: number;
  18481. /**
  18482. * Minimum life time of emitting particles.
  18483. */
  18484. minLifeTime: number;
  18485. /**
  18486. * Maximum life time of emitting particles.
  18487. */
  18488. maxLifeTime: number;
  18489. /**
  18490. * Minimum Size of emitting particles.
  18491. */
  18492. minSize: number;
  18493. /**
  18494. * Maximum Size of emitting particles.
  18495. */
  18496. maxSize: number;
  18497. /**
  18498. * Minimum scale of emitting particles on X axis.
  18499. */
  18500. minScaleX: number;
  18501. /**
  18502. * Maximum scale of emitting particles on X axis.
  18503. */
  18504. maxScaleX: number;
  18505. /**
  18506. * Minimum scale of emitting particles on Y axis.
  18507. */
  18508. minScaleY: number;
  18509. /**
  18510. * Maximum scale of emitting particles on Y axis.
  18511. */
  18512. maxScaleY: number;
  18513. /**
  18514. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18515. */
  18516. color1: Color4;
  18517. /**
  18518. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18519. */
  18520. color2: Color4;
  18521. /**
  18522. * Color the particle will have at the end of its lifetime.
  18523. */
  18524. colorDead: Color4;
  18525. /**
  18526. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18527. */
  18528. emitRate: number;
  18529. /**
  18530. * You can use gravity if you want to give an orientation to your particles.
  18531. */
  18532. gravity: Vector3;
  18533. /**
  18534. * Minimum power of emitting particles.
  18535. */
  18536. minEmitPower: number;
  18537. /**
  18538. * Maximum power of emitting particles.
  18539. */
  18540. maxEmitPower: number;
  18541. /**
  18542. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18543. */
  18544. minAngularSpeed: number;
  18545. /**
  18546. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18547. */
  18548. maxAngularSpeed: number;
  18549. /**
  18550. * Gets or sets the minimal initial rotation in radians.
  18551. */
  18552. minInitialRotation: number;
  18553. /**
  18554. * Gets or sets the maximal initial rotation in radians.
  18555. */
  18556. maxInitialRotation: number;
  18557. /**
  18558. * The particle emitter type defines the emitter used by the particle system.
  18559. * It can be for example box, sphere, or cone...
  18560. */
  18561. particleEmitterType: Nullable<IParticleEmitterType>;
  18562. /**
  18563. * Defines the delay in milliseconds before starting the system (0 by default)
  18564. */
  18565. startDelay: number;
  18566. /**
  18567. * 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
  18568. */
  18569. preWarmCycles: number;
  18570. /**
  18571. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18572. */
  18573. preWarmStepOffset: number;
  18574. /**
  18575. * 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)
  18576. */
  18577. spriteCellChangeSpeed: number;
  18578. /**
  18579. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18580. */
  18581. startSpriteCellID: number;
  18582. /**
  18583. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18584. */
  18585. endSpriteCellID: number;
  18586. /**
  18587. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18588. */
  18589. spriteCellWidth: number;
  18590. /**
  18591. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18592. */
  18593. spriteCellHeight: number;
  18594. /**
  18595. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18596. */
  18597. spriteRandomStartCell: boolean;
  18598. /**
  18599. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18600. */
  18601. isAnimationSheetEnabled: boolean;
  18602. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18603. translationPivot: Vector2;
  18604. /**
  18605. * Gets or sets a texture used to add random noise to particle positions
  18606. */
  18607. noiseTexture: Nullable<BaseTexture>;
  18608. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18609. noiseStrength: Vector3;
  18610. /**
  18611. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18612. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18613. */
  18614. billboardMode: number;
  18615. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18616. limitVelocityDamping: number;
  18617. /**
  18618. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18619. */
  18620. beginAnimationOnStart: boolean;
  18621. /**
  18622. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18623. */
  18624. beginAnimationFrom: number;
  18625. /**
  18626. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18627. */
  18628. beginAnimationTo: number;
  18629. /**
  18630. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18631. */
  18632. beginAnimationLoop: boolean;
  18633. /**
  18634. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18635. */
  18636. disposeOnStop: boolean;
  18637. /**
  18638. * Gets the maximum number of particles active at the same time.
  18639. * @returns The max number of active particles.
  18640. */
  18641. getCapacity(): number;
  18642. /**
  18643. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18644. * @returns True if it has been started, otherwise false.
  18645. */
  18646. isStarted(): boolean;
  18647. /**
  18648. * Animates the particle system for this frame.
  18649. */
  18650. animate(): void;
  18651. /**
  18652. * Renders the particle system in its current state.
  18653. * @returns the current number of particles
  18654. */
  18655. render(): number;
  18656. /**
  18657. * Dispose the particle system and frees its associated resources.
  18658. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18659. */
  18660. dispose(disposeTexture?: boolean): void;
  18661. /**
  18662. * Clones the particle system.
  18663. * @param name The name of the cloned object
  18664. * @param newEmitter The new emitter to use
  18665. * @returns the cloned particle system
  18666. */
  18667. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18668. /**
  18669. * Serializes the particle system to a JSON object.
  18670. * @returns the JSON object
  18671. */
  18672. serialize(): any;
  18673. /**
  18674. * Rebuild the particle system
  18675. */
  18676. rebuild(): void;
  18677. /**
  18678. * Starts the particle system and begins to emit
  18679. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18680. */
  18681. start(delay?: number): void;
  18682. /**
  18683. * Stops the particle system.
  18684. */
  18685. stop(): void;
  18686. /**
  18687. * Remove all active particles
  18688. */
  18689. reset(): void;
  18690. /**
  18691. * Is this system ready to be used/rendered
  18692. * @return true if the system is ready
  18693. */
  18694. isReady(): boolean;
  18695. /**
  18696. * Adds a new color gradient
  18697. * @param gradient defines the gradient to use (between 0 and 1)
  18698. * @param color1 defines the color to affect to the specified gradient
  18699. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18700. * @returns the current particle system
  18701. */
  18702. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18703. /**
  18704. * Remove a specific color gradient
  18705. * @param gradient defines the gradient to remove
  18706. * @returns the current particle system
  18707. */
  18708. removeColorGradient(gradient: number): IParticleSystem;
  18709. /**
  18710. * Adds a new size gradient
  18711. * @param gradient defines the gradient to use (between 0 and 1)
  18712. * @param factor defines the size factor to affect to the specified gradient
  18713. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18714. * @returns the current particle system
  18715. */
  18716. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18717. /**
  18718. * Remove a specific size gradient
  18719. * @param gradient defines the gradient to remove
  18720. * @returns the current particle system
  18721. */
  18722. removeSizeGradient(gradient: number): IParticleSystem;
  18723. /**
  18724. * Gets the current list of color gradients.
  18725. * You must use addColorGradient and removeColorGradient to udpate this list
  18726. * @returns the list of color gradients
  18727. */
  18728. getColorGradients(): Nullable<Array<ColorGradient>>;
  18729. /**
  18730. * Gets the current list of size gradients.
  18731. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18732. * @returns the list of size gradients
  18733. */
  18734. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18735. /**
  18736. * Gets the current list of angular speed gradients.
  18737. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18738. * @returns the list of angular speed gradients
  18739. */
  18740. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18741. /**
  18742. * Adds a new angular speed gradient
  18743. * @param gradient defines the gradient to use (between 0 and 1)
  18744. * @param factor defines the angular speed to affect to the specified gradient
  18745. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18746. * @returns the current particle system
  18747. */
  18748. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18749. /**
  18750. * Remove a specific angular speed gradient
  18751. * @param gradient defines the gradient to remove
  18752. * @returns the current particle system
  18753. */
  18754. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18755. /**
  18756. * Gets the current list of velocity gradients.
  18757. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18758. * @returns the list of velocity gradients
  18759. */
  18760. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18761. /**
  18762. * Adds a new velocity gradient
  18763. * @param gradient defines the gradient to use (between 0 and 1)
  18764. * @param factor defines the velocity to affect to the specified gradient
  18765. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18766. * @returns the current particle system
  18767. */
  18768. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18769. /**
  18770. * Remove a specific velocity gradient
  18771. * @param gradient defines the gradient to remove
  18772. * @returns the current particle system
  18773. */
  18774. removeVelocityGradient(gradient: number): IParticleSystem;
  18775. /**
  18776. * Gets the current list of limit velocity gradients.
  18777. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18778. * @returns the list of limit velocity gradients
  18779. */
  18780. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18781. /**
  18782. * Adds a new limit velocity gradient
  18783. * @param gradient defines the gradient to use (between 0 and 1)
  18784. * @param factor defines the limit velocity to affect to the specified gradient
  18785. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18786. * @returns the current particle system
  18787. */
  18788. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18789. /**
  18790. * Remove a specific limit velocity gradient
  18791. * @param gradient defines the gradient to remove
  18792. * @returns the current particle system
  18793. */
  18794. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18795. /**
  18796. * Adds a new drag gradient
  18797. * @param gradient defines the gradient to use (between 0 and 1)
  18798. * @param factor defines the drag to affect to the specified gradient
  18799. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18800. * @returns the current particle system
  18801. */
  18802. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18803. /**
  18804. * Remove a specific drag gradient
  18805. * @param gradient defines the gradient to remove
  18806. * @returns the current particle system
  18807. */
  18808. removeDragGradient(gradient: number): IParticleSystem;
  18809. /**
  18810. * Gets the current list of drag gradients.
  18811. * You must use addDragGradient and removeDragGradient to udpate this list
  18812. * @returns the list of drag gradients
  18813. */
  18814. getDragGradients(): Nullable<Array<FactorGradient>>;
  18815. /**
  18816. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18817. * @param gradient defines the gradient to use (between 0 and 1)
  18818. * @param factor defines the emit rate to affect to the specified gradient
  18819. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18820. * @returns the current particle system
  18821. */
  18822. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18823. /**
  18824. * Remove a specific emit rate gradient
  18825. * @param gradient defines the gradient to remove
  18826. * @returns the current particle system
  18827. */
  18828. removeEmitRateGradient(gradient: number): IParticleSystem;
  18829. /**
  18830. * Gets the current list of emit rate gradients.
  18831. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  18832. * @returns the list of emit rate gradients
  18833. */
  18834. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  18835. /**
  18836. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18837. * @param gradient defines the gradient to use (between 0 and 1)
  18838. * @param factor defines the start size to affect to the specified gradient
  18839. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18840. * @returns the current particle system
  18841. */
  18842. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18843. /**
  18844. * Remove a specific start size gradient
  18845. * @param gradient defines the gradient to remove
  18846. * @returns the current particle system
  18847. */
  18848. removeStartSizeGradient(gradient: number): IParticleSystem;
  18849. /**
  18850. * Gets the current list of start size gradients.
  18851. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  18852. * @returns the list of start size gradients
  18853. */
  18854. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  18855. /**
  18856. * Adds a new life time gradient
  18857. * @param gradient defines the gradient to use (between 0 and 1)
  18858. * @param factor defines the life time factor to affect to the specified gradient
  18859. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18860. * @returns the current particle system
  18861. */
  18862. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18863. /**
  18864. * Remove a specific life time gradient
  18865. * @param gradient defines the gradient to remove
  18866. * @returns the current particle system
  18867. */
  18868. removeLifeTimeGradient(gradient: number): IParticleSystem;
  18869. /**
  18870. * Gets the current list of life time gradients.
  18871. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  18872. * @returns the list of life time gradients
  18873. */
  18874. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  18875. /**
  18876. * Gets the current list of color gradients.
  18877. * You must use addColorGradient and removeColorGradient to udpate this list
  18878. * @returns the list of color gradients
  18879. */
  18880. getColorGradients(): Nullable<Array<ColorGradient>>;
  18881. /**
  18882. * Adds a new ramp gradient used to remap particle colors
  18883. * @param gradient defines the gradient to use (between 0 and 1)
  18884. * @param color defines the color to affect to the specified gradient
  18885. * @returns the current particle system
  18886. */
  18887. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  18888. /**
  18889. * Gets the current list of ramp gradients.
  18890. * You must use addRampGradient and removeRampGradient to udpate this list
  18891. * @returns the list of ramp gradients
  18892. */
  18893. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18894. /** Gets or sets a boolean indicating that ramp gradients must be used
  18895. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  18896. */
  18897. useRampGradients: boolean;
  18898. /**
  18899. * Adds a new color remap gradient
  18900. * @param gradient defines the gradient to use (between 0 and 1)
  18901. * @param min defines the color remap minimal range
  18902. * @param max defines the color remap maximal range
  18903. * @returns the current particle system
  18904. */
  18905. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18906. /**
  18907. * Gets the current list of color remap gradients.
  18908. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  18909. * @returns the list of color remap gradients
  18910. */
  18911. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  18912. /**
  18913. * Adds a new alpha remap gradient
  18914. * @param gradient defines the gradient to use (between 0 and 1)
  18915. * @param min defines the alpha remap minimal range
  18916. * @param max defines the alpha remap maximal range
  18917. * @returns the current particle system
  18918. */
  18919. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18920. /**
  18921. * Gets the current list of alpha remap gradients.
  18922. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  18923. * @returns the list of alpha remap gradients
  18924. */
  18925. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  18926. /**
  18927. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  18928. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18929. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18930. * @returns the emitter
  18931. */
  18932. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  18933. /**
  18934. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  18935. * @param radius The radius of the hemisphere to emit from
  18936. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18937. * @returns the emitter
  18938. */
  18939. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  18940. /**
  18941. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  18942. * @param radius The radius of the sphere to emit from
  18943. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18944. * @returns the emitter
  18945. */
  18946. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  18947. /**
  18948. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  18949. * @param radius The radius of the sphere to emit from
  18950. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  18951. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  18952. * @returns the emitter
  18953. */
  18954. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18955. /**
  18956. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  18957. * @param radius The radius of the emission cylinder
  18958. * @param height The height of the emission cylinder
  18959. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  18960. * @param directionRandomizer How much to randomize the particle direction [0-1]
  18961. * @returns the emitter
  18962. */
  18963. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  18964. /**
  18965. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  18966. * @param radius The radius of the cylinder to emit from
  18967. * @param height The height of the emission cylinder
  18968. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18969. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  18970. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  18971. * @returns the emitter
  18972. */
  18973. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18974. /**
  18975. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  18976. * @param radius The radius of the cone to emit from
  18977. * @param angle The base angle of the cone
  18978. * @returns the emitter
  18979. */
  18980. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  18981. /**
  18982. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  18983. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18984. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18985. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18986. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18987. * @returns the emitter
  18988. */
  18989. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  18990. /**
  18991. * Get hosting scene
  18992. * @returns the scene
  18993. */
  18994. getScene(): Scene;
  18995. }
  18996. }
  18997. declare module BABYLON {
  18998. /**
  18999. * Creates an instance based on a source mesh.
  19000. */
  19001. export class InstancedMesh extends AbstractMesh {
  19002. private _sourceMesh;
  19003. private _currentLOD;
  19004. /** @hidden */
  19005. _indexInSourceMeshInstanceArray: number;
  19006. constructor(name: string, source: Mesh);
  19007. /**
  19008. * Returns the string "InstancedMesh".
  19009. */
  19010. getClassName(): string;
  19011. /** Gets the list of lights affecting that mesh */
  19012. readonly lightSources: Light[];
  19013. _resyncLightSources(): void;
  19014. _resyncLightSource(light: Light): void;
  19015. _removeLightSource(light: Light, dispose: boolean): void;
  19016. /**
  19017. * If the source mesh receives shadows
  19018. */
  19019. readonly receiveShadows: boolean;
  19020. /**
  19021. * The material of the source mesh
  19022. */
  19023. readonly material: Nullable<Material>;
  19024. /**
  19025. * Visibility of the source mesh
  19026. */
  19027. readonly visibility: number;
  19028. /**
  19029. * Skeleton of the source mesh
  19030. */
  19031. readonly skeleton: Nullable<Skeleton>;
  19032. /**
  19033. * Rendering ground id of the source mesh
  19034. */
  19035. renderingGroupId: number;
  19036. /**
  19037. * Returns the total number of vertices (integer).
  19038. */
  19039. getTotalVertices(): number;
  19040. /**
  19041. * Returns a positive integer : the total number of indices in this mesh geometry.
  19042. * @returns the numner of indices or zero if the mesh has no geometry.
  19043. */
  19044. getTotalIndices(): number;
  19045. /**
  19046. * The source mesh of the instance
  19047. */
  19048. readonly sourceMesh: Mesh;
  19049. /**
  19050. * Is this node ready to be used/rendered
  19051. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19052. * @return {boolean} is it ready
  19053. */
  19054. isReady(completeCheck?: boolean): boolean;
  19055. /**
  19056. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19057. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19058. * @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.
  19059. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19060. */
  19061. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19062. /**
  19063. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19064. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19065. * The `data` are either a numeric array either a Float32Array.
  19066. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19067. * 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).
  19068. * Note that a new underlying VertexBuffer object is created each call.
  19069. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19070. *
  19071. * Possible `kind` values :
  19072. * - VertexBuffer.PositionKind
  19073. * - VertexBuffer.UVKind
  19074. * - VertexBuffer.UV2Kind
  19075. * - VertexBuffer.UV3Kind
  19076. * - VertexBuffer.UV4Kind
  19077. * - VertexBuffer.UV5Kind
  19078. * - VertexBuffer.UV6Kind
  19079. * - VertexBuffer.ColorKind
  19080. * - VertexBuffer.MatricesIndicesKind
  19081. * - VertexBuffer.MatricesIndicesExtraKind
  19082. * - VertexBuffer.MatricesWeightsKind
  19083. * - VertexBuffer.MatricesWeightsExtraKind
  19084. *
  19085. * Returns the Mesh.
  19086. */
  19087. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19088. /**
  19089. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19090. * If the mesh has no geometry, it is simply returned as it is.
  19091. * The `data` are either a numeric array either a Float32Array.
  19092. * No new underlying VertexBuffer object is created.
  19093. * 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.
  19094. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19095. *
  19096. * Possible `kind` values :
  19097. * - VertexBuffer.PositionKind
  19098. * - VertexBuffer.UVKind
  19099. * - VertexBuffer.UV2Kind
  19100. * - VertexBuffer.UV3Kind
  19101. * - VertexBuffer.UV4Kind
  19102. * - VertexBuffer.UV5Kind
  19103. * - VertexBuffer.UV6Kind
  19104. * - VertexBuffer.ColorKind
  19105. * - VertexBuffer.MatricesIndicesKind
  19106. * - VertexBuffer.MatricesIndicesExtraKind
  19107. * - VertexBuffer.MatricesWeightsKind
  19108. * - VertexBuffer.MatricesWeightsExtraKind
  19109. *
  19110. * Returns the Mesh.
  19111. */
  19112. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19113. /**
  19114. * Sets the mesh indices.
  19115. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19116. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19117. * This method creates a new index buffer each call.
  19118. * Returns the Mesh.
  19119. */
  19120. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19121. /**
  19122. * Boolean : True if the mesh owns the requested kind of data.
  19123. */
  19124. isVerticesDataPresent(kind: string): boolean;
  19125. /**
  19126. * Returns an array of indices (IndicesArray).
  19127. */
  19128. getIndices(): Nullable<IndicesArray>;
  19129. readonly _positions: Nullable<Vector3[]>;
  19130. /**
  19131. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19132. * This means the mesh underlying bounding box and sphere are recomputed.
  19133. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19134. * @returns the current mesh
  19135. */
  19136. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19137. /** @hidden */
  19138. _preActivate(): InstancedMesh;
  19139. /** @hidden */
  19140. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19141. /** @hidden */
  19142. _postActivate(): void;
  19143. getWorldMatrix(): Matrix;
  19144. readonly isAnInstance: boolean;
  19145. /**
  19146. * Returns the current associated LOD AbstractMesh.
  19147. */
  19148. getLOD(camera: Camera): AbstractMesh;
  19149. /** @hidden */
  19150. _syncSubMeshes(): InstancedMesh;
  19151. /** @hidden */
  19152. _generatePointsArray(): boolean;
  19153. /**
  19154. * Creates a new InstancedMesh from the current mesh.
  19155. * - name (string) : the cloned mesh name
  19156. * - newParent (optional Node) : the optional Node to parent the clone to.
  19157. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19158. *
  19159. * Returns the clone.
  19160. */
  19161. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19162. /**
  19163. * Disposes the InstancedMesh.
  19164. * Returns nothing.
  19165. */
  19166. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19167. }
  19168. interface Mesh {
  19169. /**
  19170. * Register a custom buffer that will be instanced
  19171. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19172. * @param kind defines the buffer kind
  19173. * @param stride defines the stride in floats
  19174. */
  19175. registerInstancedBuffer(kind: string, stride: number): void;
  19176. /** @hidden */
  19177. _userInstancedBuffersStorage: {
  19178. data: {
  19179. [key: string]: Float32Array;
  19180. };
  19181. sizes: {
  19182. [key: string]: number;
  19183. };
  19184. vertexBuffers: {
  19185. [key: string]: Nullable<VertexBuffer>;
  19186. };
  19187. strides: {
  19188. [key: string]: number;
  19189. };
  19190. };
  19191. }
  19192. interface AbstractMesh {
  19193. /**
  19194. * Object used to store instanced buffers defined by user
  19195. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19196. */
  19197. instancedBuffers: {
  19198. [key: string]: any;
  19199. };
  19200. }
  19201. }
  19202. declare module BABYLON {
  19203. /**
  19204. * Defines the options associated with the creation of a shader material.
  19205. */
  19206. export interface IShaderMaterialOptions {
  19207. /**
  19208. * Does the material work in alpha blend mode
  19209. */
  19210. needAlphaBlending: boolean;
  19211. /**
  19212. * Does the material work in alpha test mode
  19213. */
  19214. needAlphaTesting: boolean;
  19215. /**
  19216. * The list of attribute names used in the shader
  19217. */
  19218. attributes: string[];
  19219. /**
  19220. * The list of unifrom names used in the shader
  19221. */
  19222. uniforms: string[];
  19223. /**
  19224. * The list of UBO names used in the shader
  19225. */
  19226. uniformBuffers: string[];
  19227. /**
  19228. * The list of sampler names used in the shader
  19229. */
  19230. samplers: string[];
  19231. /**
  19232. * The list of defines used in the shader
  19233. */
  19234. defines: string[];
  19235. }
  19236. /**
  19237. * 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.
  19238. *
  19239. * This returned material effects how the mesh will look based on the code in the shaders.
  19240. *
  19241. * @see http://doc.babylonjs.com/how_to/shader_material
  19242. */
  19243. export class ShaderMaterial extends Material {
  19244. private _shaderPath;
  19245. private _options;
  19246. private _textures;
  19247. private _textureArrays;
  19248. private _floats;
  19249. private _ints;
  19250. private _floatsArrays;
  19251. private _colors3;
  19252. private _colors3Arrays;
  19253. private _colors4;
  19254. private _colors4Arrays;
  19255. private _vectors2;
  19256. private _vectors3;
  19257. private _vectors4;
  19258. private _matrices;
  19259. private _matrixArrays;
  19260. private _matrices3x3;
  19261. private _matrices2x2;
  19262. private _vectors2Arrays;
  19263. private _vectors3Arrays;
  19264. private _vectors4Arrays;
  19265. private _cachedWorldViewMatrix;
  19266. private _cachedWorldViewProjectionMatrix;
  19267. private _renderId;
  19268. private _multiview;
  19269. /**
  19270. * Instantiate a new shader material.
  19271. * 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.
  19272. * This returned material effects how the mesh will look based on the code in the shaders.
  19273. * @see http://doc.babylonjs.com/how_to/shader_material
  19274. * @param name Define the name of the material in the scene
  19275. * @param scene Define the scene the material belongs to
  19276. * @param shaderPath Defines the route to the shader code in one of three ways:
  19277. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19278. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19279. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19280. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19281. * @param options Define the options used to create the shader
  19282. */
  19283. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19284. /**
  19285. * Gets the shader path used to define the shader code
  19286. * It can be modified to trigger a new compilation
  19287. */
  19288. /**
  19289. * Sets the shader path used to define the shader code
  19290. * It can be modified to trigger a new compilation
  19291. */
  19292. shaderPath: any;
  19293. /**
  19294. * Gets the options used to compile the shader.
  19295. * They can be modified to trigger a new compilation
  19296. */
  19297. readonly options: IShaderMaterialOptions;
  19298. /**
  19299. * Gets the current class name of the material e.g. "ShaderMaterial"
  19300. * Mainly use in serialization.
  19301. * @returns the class name
  19302. */
  19303. getClassName(): string;
  19304. /**
  19305. * Specifies if the material will require alpha blending
  19306. * @returns a boolean specifying if alpha blending is needed
  19307. */
  19308. needAlphaBlending(): boolean;
  19309. /**
  19310. * Specifies if this material should be rendered in alpha test mode
  19311. * @returns a boolean specifying if an alpha test is needed.
  19312. */
  19313. needAlphaTesting(): boolean;
  19314. private _checkUniform;
  19315. /**
  19316. * Set a texture in the shader.
  19317. * @param name Define the name of the uniform samplers as defined in the shader
  19318. * @param texture Define the texture to bind to this sampler
  19319. * @return the material itself allowing "fluent" like uniform updates
  19320. */
  19321. setTexture(name: string, texture: Texture): ShaderMaterial;
  19322. /**
  19323. * Set a texture array in the shader.
  19324. * @param name Define the name of the uniform sampler array as defined in the shader
  19325. * @param textures Define the list of textures to bind to this sampler
  19326. * @return the material itself allowing "fluent" like uniform updates
  19327. */
  19328. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19329. /**
  19330. * Set a float in the shader.
  19331. * @param name Define the name of the uniform as defined in the shader
  19332. * @param value Define the value to give to the uniform
  19333. * @return the material itself allowing "fluent" like uniform updates
  19334. */
  19335. setFloat(name: string, value: number): ShaderMaterial;
  19336. /**
  19337. * Set a int in the shader.
  19338. * @param name Define the name of the uniform as defined in the shader
  19339. * @param value Define the value to give to the uniform
  19340. * @return the material itself allowing "fluent" like uniform updates
  19341. */
  19342. setInt(name: string, value: number): ShaderMaterial;
  19343. /**
  19344. * Set an array of floats in the shader.
  19345. * @param name Define the name of the uniform as defined in the shader
  19346. * @param value Define the value to give to the uniform
  19347. * @return the material itself allowing "fluent" like uniform updates
  19348. */
  19349. setFloats(name: string, value: number[]): ShaderMaterial;
  19350. /**
  19351. * Set a vec3 in the shader from a Color3.
  19352. * @param name Define the name of the uniform as defined in the shader
  19353. * @param value Define the value to give to the uniform
  19354. * @return the material itself allowing "fluent" like uniform updates
  19355. */
  19356. setColor3(name: string, value: Color3): ShaderMaterial;
  19357. /**
  19358. * Set a vec3 array in the shader from a Color3 array.
  19359. * @param name Define the name of the uniform as defined in the shader
  19360. * @param value Define the value to give to the uniform
  19361. * @return the material itself allowing "fluent" like uniform updates
  19362. */
  19363. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19364. /**
  19365. * Set a vec4 in the shader from a Color4.
  19366. * @param name Define the name of the uniform as defined in the shader
  19367. * @param value Define the value to give to the uniform
  19368. * @return the material itself allowing "fluent" like uniform updates
  19369. */
  19370. setColor4(name: string, value: Color4): ShaderMaterial;
  19371. /**
  19372. * Set a vec4 array in the shader from a Color4 array.
  19373. * @param name Define the name of the uniform as defined in the shader
  19374. * @param value Define the value to give to the uniform
  19375. * @return the material itself allowing "fluent" like uniform updates
  19376. */
  19377. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19378. /**
  19379. * Set a vec2 in the shader from a Vector2.
  19380. * @param name Define the name of the uniform as defined in the shader
  19381. * @param value Define the value to give to the uniform
  19382. * @return the material itself allowing "fluent" like uniform updates
  19383. */
  19384. setVector2(name: string, value: Vector2): ShaderMaterial;
  19385. /**
  19386. * Set a vec3 in the shader from a Vector3.
  19387. * @param name Define the name of the uniform as defined in the shader
  19388. * @param value Define the value to give to the uniform
  19389. * @return the material itself allowing "fluent" like uniform updates
  19390. */
  19391. setVector3(name: string, value: Vector3): ShaderMaterial;
  19392. /**
  19393. * Set a vec4 in the shader from a Vector4.
  19394. * @param name Define the name of the uniform as defined in the shader
  19395. * @param value Define the value to give to the uniform
  19396. * @return the material itself allowing "fluent" like uniform updates
  19397. */
  19398. setVector4(name: string, value: Vector4): ShaderMaterial;
  19399. /**
  19400. * Set a mat4 in the shader from a Matrix.
  19401. * @param name Define the name of the uniform as defined in the shader
  19402. * @param value Define the value to give to the uniform
  19403. * @return the material itself allowing "fluent" like uniform updates
  19404. */
  19405. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19406. /**
  19407. * Set a float32Array in the shader from a matrix array.
  19408. * @param name Define the name of the uniform as defined in the shader
  19409. * @param value Define the value to give to the uniform
  19410. * @return the material itself allowing "fluent" like uniform updates
  19411. */
  19412. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  19413. /**
  19414. * Set a mat3 in the shader from a Float32Array.
  19415. * @param name Define the name of the uniform as defined in the shader
  19416. * @param value Define the value to give to the uniform
  19417. * @return the material itself allowing "fluent" like uniform updates
  19418. */
  19419. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19420. /**
  19421. * Set a mat2 in the shader from a Float32Array.
  19422. * @param name Define the name of the uniform as defined in the shader
  19423. * @param value Define the value to give to the uniform
  19424. * @return the material itself allowing "fluent" like uniform updates
  19425. */
  19426. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19427. /**
  19428. * Set a vec2 array in the shader from a number array.
  19429. * @param name Define the name of the uniform as defined in the shader
  19430. * @param value Define the value to give to the uniform
  19431. * @return the material itself allowing "fluent" like uniform updates
  19432. */
  19433. setArray2(name: string, value: number[]): ShaderMaterial;
  19434. /**
  19435. * Set a vec3 array in the shader from a number array.
  19436. * @param name Define the name of the uniform as defined in the shader
  19437. * @param value Define the value to give to the uniform
  19438. * @return the material itself allowing "fluent" like uniform updates
  19439. */
  19440. setArray3(name: string, value: number[]): ShaderMaterial;
  19441. /**
  19442. * Set a vec4 array in the shader from a number array.
  19443. * @param name Define the name of the uniform as defined in the shader
  19444. * @param value Define the value to give to the uniform
  19445. * @return the material itself allowing "fluent" like uniform updates
  19446. */
  19447. setArray4(name: string, value: number[]): ShaderMaterial;
  19448. private _checkCache;
  19449. /**
  19450. * Specifies that the submesh is ready to be used
  19451. * @param mesh defines the mesh to check
  19452. * @param subMesh defines which submesh to check
  19453. * @param useInstances specifies that instances should be used
  19454. * @returns a boolean indicating that the submesh is ready or not
  19455. */
  19456. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19457. /**
  19458. * Checks if the material is ready to render the requested mesh
  19459. * @param mesh Define the mesh to render
  19460. * @param useInstances Define whether or not the material is used with instances
  19461. * @returns true if ready, otherwise false
  19462. */
  19463. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19464. /**
  19465. * Binds the world matrix to the material
  19466. * @param world defines the world transformation matrix
  19467. */
  19468. bindOnlyWorldMatrix(world: Matrix): void;
  19469. /**
  19470. * Binds the material to the mesh
  19471. * @param world defines the world transformation matrix
  19472. * @param mesh defines the mesh to bind the material to
  19473. */
  19474. bind(world: Matrix, mesh?: Mesh): void;
  19475. /**
  19476. * Gets the active textures from the material
  19477. * @returns an array of textures
  19478. */
  19479. getActiveTextures(): BaseTexture[];
  19480. /**
  19481. * Specifies if the material uses a texture
  19482. * @param texture defines the texture to check against the material
  19483. * @returns a boolean specifying if the material uses the texture
  19484. */
  19485. hasTexture(texture: BaseTexture): boolean;
  19486. /**
  19487. * Makes a duplicate of the material, and gives it a new name
  19488. * @param name defines the new name for the duplicated material
  19489. * @returns the cloned material
  19490. */
  19491. clone(name: string): ShaderMaterial;
  19492. /**
  19493. * Disposes the material
  19494. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19495. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19496. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19497. */
  19498. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19499. /**
  19500. * Serializes this material in a JSON representation
  19501. * @returns the serialized material object
  19502. */
  19503. serialize(): any;
  19504. /**
  19505. * Creates a shader material from parsed shader material data
  19506. * @param source defines the JSON represnetation of the material
  19507. * @param scene defines the hosting scene
  19508. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19509. * @returns a new material
  19510. */
  19511. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19512. }
  19513. }
  19514. declare module BABYLON {
  19515. /** @hidden */
  19516. export var colorPixelShader: {
  19517. name: string;
  19518. shader: string;
  19519. };
  19520. }
  19521. declare module BABYLON {
  19522. /** @hidden */
  19523. export var colorVertexShader: {
  19524. name: string;
  19525. shader: string;
  19526. };
  19527. }
  19528. declare module BABYLON {
  19529. /**
  19530. * Line mesh
  19531. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19532. */
  19533. export class LinesMesh extends Mesh {
  19534. /**
  19535. * If vertex color should be applied to the mesh
  19536. */
  19537. readonly useVertexColor?: boolean | undefined;
  19538. /**
  19539. * If vertex alpha should be applied to the mesh
  19540. */
  19541. readonly useVertexAlpha?: boolean | undefined;
  19542. /**
  19543. * Color of the line (Default: White)
  19544. */
  19545. color: Color3;
  19546. /**
  19547. * Alpha of the line (Default: 1)
  19548. */
  19549. alpha: number;
  19550. /**
  19551. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19552. * This margin is expressed in world space coordinates, so its value may vary.
  19553. * Default value is 0.1
  19554. */
  19555. intersectionThreshold: number;
  19556. private _colorShader;
  19557. private color4;
  19558. /**
  19559. * Creates a new LinesMesh
  19560. * @param name defines the name
  19561. * @param scene defines the hosting scene
  19562. * @param parent defines the parent mesh if any
  19563. * @param source defines the optional source LinesMesh used to clone data from
  19564. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19565. * When false, achieved by calling a clone(), also passing False.
  19566. * This will make creation of children, recursive.
  19567. * @param useVertexColor defines if this LinesMesh supports vertex color
  19568. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19569. */
  19570. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19571. /**
  19572. * If vertex color should be applied to the mesh
  19573. */
  19574. useVertexColor?: boolean | undefined,
  19575. /**
  19576. * If vertex alpha should be applied to the mesh
  19577. */
  19578. useVertexAlpha?: boolean | undefined);
  19579. private _addClipPlaneDefine;
  19580. private _removeClipPlaneDefine;
  19581. isReady(): boolean;
  19582. /**
  19583. * Returns the string "LineMesh"
  19584. */
  19585. getClassName(): string;
  19586. /**
  19587. * @hidden
  19588. */
  19589. /**
  19590. * @hidden
  19591. */
  19592. material: Material;
  19593. /**
  19594. * @hidden
  19595. */
  19596. readonly checkCollisions: boolean;
  19597. /** @hidden */
  19598. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19599. /** @hidden */
  19600. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19601. /**
  19602. * Disposes of the line mesh
  19603. * @param doNotRecurse If children should be disposed
  19604. */
  19605. dispose(doNotRecurse?: boolean): void;
  19606. /**
  19607. * Returns a new LineMesh object cloned from the current one.
  19608. */
  19609. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19610. /**
  19611. * Creates a new InstancedLinesMesh object from the mesh model.
  19612. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19613. * @param name defines the name of the new instance
  19614. * @returns a new InstancedLinesMesh
  19615. */
  19616. createInstance(name: string): InstancedLinesMesh;
  19617. }
  19618. /**
  19619. * Creates an instance based on a source LinesMesh
  19620. */
  19621. export class InstancedLinesMesh extends InstancedMesh {
  19622. /**
  19623. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19624. * This margin is expressed in world space coordinates, so its value may vary.
  19625. * Initilized with the intersectionThreshold value of the source LinesMesh
  19626. */
  19627. intersectionThreshold: number;
  19628. constructor(name: string, source: LinesMesh);
  19629. /**
  19630. * Returns the string "InstancedLinesMesh".
  19631. */
  19632. getClassName(): string;
  19633. }
  19634. }
  19635. declare module BABYLON {
  19636. /** @hidden */
  19637. export var linePixelShader: {
  19638. name: string;
  19639. shader: string;
  19640. };
  19641. }
  19642. declare module BABYLON {
  19643. /** @hidden */
  19644. export var lineVertexShader: {
  19645. name: string;
  19646. shader: string;
  19647. };
  19648. }
  19649. declare module BABYLON {
  19650. interface AbstractMesh {
  19651. /**
  19652. * Gets the edgesRenderer associated with the mesh
  19653. */
  19654. edgesRenderer: Nullable<EdgesRenderer>;
  19655. }
  19656. interface LinesMesh {
  19657. /**
  19658. * Enables the edge rendering mode on the mesh.
  19659. * This mode makes the mesh edges visible
  19660. * @param epsilon defines the maximal distance between two angles to detect a face
  19661. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19662. * @returns the currentAbstractMesh
  19663. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19664. */
  19665. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19666. }
  19667. interface InstancedLinesMesh {
  19668. /**
  19669. * Enables the edge rendering mode on the mesh.
  19670. * This mode makes the mesh edges visible
  19671. * @param epsilon defines the maximal distance between two angles to detect a face
  19672. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19673. * @returns the current InstancedLinesMesh
  19674. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19675. */
  19676. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19677. }
  19678. /**
  19679. * Defines the minimum contract an Edges renderer should follow.
  19680. */
  19681. export interface IEdgesRenderer extends IDisposable {
  19682. /**
  19683. * Gets or sets a boolean indicating if the edgesRenderer is active
  19684. */
  19685. isEnabled: boolean;
  19686. /**
  19687. * Renders the edges of the attached mesh,
  19688. */
  19689. render(): void;
  19690. /**
  19691. * Checks wether or not the edges renderer is ready to render.
  19692. * @return true if ready, otherwise false.
  19693. */
  19694. isReady(): boolean;
  19695. }
  19696. /**
  19697. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19698. */
  19699. export class EdgesRenderer implements IEdgesRenderer {
  19700. /**
  19701. * Define the size of the edges with an orthographic camera
  19702. */
  19703. edgesWidthScalerForOrthographic: number;
  19704. /**
  19705. * Define the size of the edges with a perspective camera
  19706. */
  19707. edgesWidthScalerForPerspective: number;
  19708. protected _source: AbstractMesh;
  19709. protected _linesPositions: number[];
  19710. protected _linesNormals: number[];
  19711. protected _linesIndices: number[];
  19712. protected _epsilon: number;
  19713. protected _indicesCount: number;
  19714. protected _lineShader: ShaderMaterial;
  19715. protected _ib: DataBuffer;
  19716. protected _buffers: {
  19717. [key: string]: Nullable<VertexBuffer>;
  19718. };
  19719. protected _checkVerticesInsteadOfIndices: boolean;
  19720. private _meshRebuildObserver;
  19721. private _meshDisposeObserver;
  19722. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19723. isEnabled: boolean;
  19724. /**
  19725. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19726. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19727. * @param source Mesh used to create edges
  19728. * @param epsilon sum of angles in adjacency to check for edge
  19729. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19730. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19731. */
  19732. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19733. protected _prepareRessources(): void;
  19734. /** @hidden */
  19735. _rebuild(): void;
  19736. /**
  19737. * Releases the required resources for the edges renderer
  19738. */
  19739. dispose(): void;
  19740. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19741. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19742. /**
  19743. * Checks if the pair of p0 and p1 is en edge
  19744. * @param faceIndex
  19745. * @param edge
  19746. * @param faceNormals
  19747. * @param p0
  19748. * @param p1
  19749. * @private
  19750. */
  19751. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19752. /**
  19753. * push line into the position, normal and index buffer
  19754. * @protected
  19755. */
  19756. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19757. /**
  19758. * Generates lines edges from adjacencjes
  19759. * @private
  19760. */
  19761. _generateEdgesLines(): void;
  19762. /**
  19763. * Checks wether or not the edges renderer is ready to render.
  19764. * @return true if ready, otherwise false.
  19765. */
  19766. isReady(): boolean;
  19767. /**
  19768. * Renders the edges of the attached mesh,
  19769. */
  19770. render(): void;
  19771. }
  19772. /**
  19773. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19774. */
  19775. export class LineEdgesRenderer extends EdgesRenderer {
  19776. /**
  19777. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19778. * @param source LineMesh used to generate edges
  19779. * @param epsilon not important (specified angle for edge detection)
  19780. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19781. */
  19782. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19783. /**
  19784. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19785. */
  19786. _generateEdgesLines(): void;
  19787. }
  19788. }
  19789. declare module BABYLON {
  19790. /**
  19791. * This represents the object necessary to create a rendering group.
  19792. * This is exclusively used and created by the rendering manager.
  19793. * To modify the behavior, you use the available helpers in your scene or meshes.
  19794. * @hidden
  19795. */
  19796. export class RenderingGroup {
  19797. index: number;
  19798. private static _zeroVector;
  19799. private _scene;
  19800. private _opaqueSubMeshes;
  19801. private _transparentSubMeshes;
  19802. private _alphaTestSubMeshes;
  19803. private _depthOnlySubMeshes;
  19804. private _particleSystems;
  19805. private _spriteManagers;
  19806. private _opaqueSortCompareFn;
  19807. private _alphaTestSortCompareFn;
  19808. private _transparentSortCompareFn;
  19809. private _renderOpaque;
  19810. private _renderAlphaTest;
  19811. private _renderTransparent;
  19812. /** @hidden */
  19813. _edgesRenderers: SmartArray<IEdgesRenderer>;
  19814. onBeforeTransparentRendering: () => void;
  19815. /**
  19816. * Set the opaque sort comparison function.
  19817. * If null the sub meshes will be render in the order they were created
  19818. */
  19819. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19820. /**
  19821. * Set the alpha test sort comparison function.
  19822. * If null the sub meshes will be render in the order they were created
  19823. */
  19824. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19825. /**
  19826. * Set the transparent sort comparison function.
  19827. * If null the sub meshes will be render in the order they were created
  19828. */
  19829. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19830. /**
  19831. * Creates a new rendering group.
  19832. * @param index The rendering group index
  19833. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  19834. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  19835. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  19836. */
  19837. 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>);
  19838. /**
  19839. * Render all the sub meshes contained in the group.
  19840. * @param customRenderFunction Used to override the default render behaviour of the group.
  19841. * @returns true if rendered some submeshes.
  19842. */
  19843. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  19844. /**
  19845. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  19846. * @param subMeshes The submeshes to render
  19847. */
  19848. private renderOpaqueSorted;
  19849. /**
  19850. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  19851. * @param subMeshes The submeshes to render
  19852. */
  19853. private renderAlphaTestSorted;
  19854. /**
  19855. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  19856. * @param subMeshes The submeshes to render
  19857. */
  19858. private renderTransparentSorted;
  19859. /**
  19860. * Renders the submeshes in a specified order.
  19861. * @param subMeshes The submeshes to sort before render
  19862. * @param sortCompareFn The comparison function use to sort
  19863. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  19864. * @param transparent Specifies to activate blending if true
  19865. */
  19866. private static renderSorted;
  19867. /**
  19868. * Renders the submeshes in the order they were dispatched (no sort applied).
  19869. * @param subMeshes The submeshes to render
  19870. */
  19871. private static renderUnsorted;
  19872. /**
  19873. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19874. * are rendered back to front if in the same alpha index.
  19875. *
  19876. * @param a The first submesh
  19877. * @param b The second submesh
  19878. * @returns The result of the comparison
  19879. */
  19880. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  19881. /**
  19882. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19883. * are rendered back to front.
  19884. *
  19885. * @param a The first submesh
  19886. * @param b The second submesh
  19887. * @returns The result of the comparison
  19888. */
  19889. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  19890. /**
  19891. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19892. * are rendered front to back (prevent overdraw).
  19893. *
  19894. * @param a The first submesh
  19895. * @param b The second submesh
  19896. * @returns The result of the comparison
  19897. */
  19898. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  19899. /**
  19900. * Resets the different lists of submeshes to prepare a new frame.
  19901. */
  19902. prepare(): void;
  19903. dispose(): void;
  19904. /**
  19905. * Inserts the submesh in its correct queue depending on its material.
  19906. * @param subMesh The submesh to dispatch
  19907. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19908. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19909. */
  19910. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19911. dispatchSprites(spriteManager: ISpriteManager): void;
  19912. dispatchParticles(particleSystem: IParticleSystem): void;
  19913. private _renderParticles;
  19914. private _renderSprites;
  19915. }
  19916. }
  19917. declare module BABYLON {
  19918. /**
  19919. * Interface describing the different options available in the rendering manager
  19920. * regarding Auto Clear between groups.
  19921. */
  19922. export interface IRenderingManagerAutoClearSetup {
  19923. /**
  19924. * Defines whether or not autoclear is enable.
  19925. */
  19926. autoClear: boolean;
  19927. /**
  19928. * Defines whether or not to autoclear the depth buffer.
  19929. */
  19930. depth: boolean;
  19931. /**
  19932. * Defines whether or not to autoclear the stencil buffer.
  19933. */
  19934. stencil: boolean;
  19935. }
  19936. /**
  19937. * This class is used by the onRenderingGroupObservable
  19938. */
  19939. export class RenderingGroupInfo {
  19940. /**
  19941. * The Scene that being rendered
  19942. */
  19943. scene: Scene;
  19944. /**
  19945. * The camera currently used for the rendering pass
  19946. */
  19947. camera: Nullable<Camera>;
  19948. /**
  19949. * The ID of the renderingGroup being processed
  19950. */
  19951. renderingGroupId: number;
  19952. }
  19953. /**
  19954. * This is the manager responsible of all the rendering for meshes sprites and particles.
  19955. * It is enable to manage the different groups as well as the different necessary sort functions.
  19956. * This should not be used directly aside of the few static configurations
  19957. */
  19958. export class RenderingManager {
  19959. /**
  19960. * The max id used for rendering groups (not included)
  19961. */
  19962. static MAX_RENDERINGGROUPS: number;
  19963. /**
  19964. * The min id used for rendering groups (included)
  19965. */
  19966. static MIN_RENDERINGGROUPS: number;
  19967. /**
  19968. * Used to globally prevent autoclearing scenes.
  19969. */
  19970. static AUTOCLEAR: boolean;
  19971. /**
  19972. * @hidden
  19973. */
  19974. _useSceneAutoClearSetup: boolean;
  19975. private _scene;
  19976. private _renderingGroups;
  19977. private _depthStencilBufferAlreadyCleaned;
  19978. private _autoClearDepthStencil;
  19979. private _customOpaqueSortCompareFn;
  19980. private _customAlphaTestSortCompareFn;
  19981. private _customTransparentSortCompareFn;
  19982. private _renderingGroupInfo;
  19983. /**
  19984. * Instantiates a new rendering group for a particular scene
  19985. * @param scene Defines the scene the groups belongs to
  19986. */
  19987. constructor(scene: Scene);
  19988. private _clearDepthStencilBuffer;
  19989. /**
  19990. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  19991. * @hidden
  19992. */
  19993. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  19994. /**
  19995. * Resets the different information of the group to prepare a new frame
  19996. * @hidden
  19997. */
  19998. reset(): void;
  19999. /**
  20000. * Dispose and release the group and its associated resources.
  20001. * @hidden
  20002. */
  20003. dispose(): void;
  20004. /**
  20005. * Clear the info related to rendering groups preventing retention points during dispose.
  20006. */
  20007. freeRenderingGroups(): void;
  20008. private _prepareRenderingGroup;
  20009. /**
  20010. * Add a sprite manager to the rendering manager in order to render it this frame.
  20011. * @param spriteManager Define the sprite manager to render
  20012. */
  20013. dispatchSprites(spriteManager: ISpriteManager): void;
  20014. /**
  20015. * Add a particle system to the rendering manager in order to render it this frame.
  20016. * @param particleSystem Define the particle system to render
  20017. */
  20018. dispatchParticles(particleSystem: IParticleSystem): void;
  20019. /**
  20020. * Add a submesh to the manager in order to render it this frame
  20021. * @param subMesh The submesh to dispatch
  20022. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20023. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20024. */
  20025. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20026. /**
  20027. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20028. * This allowed control for front to back rendering or reversly depending of the special needs.
  20029. *
  20030. * @param renderingGroupId The rendering group id corresponding to its index
  20031. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20032. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20033. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20034. */
  20035. 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;
  20036. /**
  20037. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20038. *
  20039. * @param renderingGroupId The rendering group id corresponding to its index
  20040. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20041. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20042. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20043. */
  20044. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20045. /**
  20046. * Gets the current auto clear configuration for one rendering group of the rendering
  20047. * manager.
  20048. * @param index the rendering group index to get the information for
  20049. * @returns The auto clear setup for the requested rendering group
  20050. */
  20051. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20052. }
  20053. }
  20054. declare module BABYLON {
  20055. /**
  20056. * This Helps creating a texture that will be created from a camera in your scene.
  20057. * It is basically a dynamic texture that could be used to create special effects for instance.
  20058. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20059. */
  20060. export class RenderTargetTexture extends Texture {
  20061. isCube: boolean;
  20062. /**
  20063. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20064. */
  20065. static readonly REFRESHRATE_RENDER_ONCE: number;
  20066. /**
  20067. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20068. */
  20069. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20070. /**
  20071. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20072. * the central point of your effect and can save a lot of performances.
  20073. */
  20074. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20075. /**
  20076. * Use this predicate to dynamically define the list of mesh you want to render.
  20077. * If set, the renderList property will be overwritten.
  20078. */
  20079. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20080. private _renderList;
  20081. /**
  20082. * Use this list to define the list of mesh you want to render.
  20083. */
  20084. renderList: Nullable<Array<AbstractMesh>>;
  20085. private _hookArray;
  20086. /**
  20087. * Define if particles should be rendered in your texture.
  20088. */
  20089. renderParticles: boolean;
  20090. /**
  20091. * Define if sprites should be rendered in your texture.
  20092. */
  20093. renderSprites: boolean;
  20094. /**
  20095. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20096. */
  20097. coordinatesMode: number;
  20098. /**
  20099. * Define the camera used to render the texture.
  20100. */
  20101. activeCamera: Nullable<Camera>;
  20102. /**
  20103. * Override the render function of the texture with your own one.
  20104. */
  20105. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20106. /**
  20107. * Define if camera post processes should be use while rendering the texture.
  20108. */
  20109. useCameraPostProcesses: boolean;
  20110. /**
  20111. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20112. */
  20113. ignoreCameraViewport: boolean;
  20114. private _postProcessManager;
  20115. private _postProcesses;
  20116. private _resizeObserver;
  20117. /**
  20118. * An event triggered when the texture is unbind.
  20119. */
  20120. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20121. /**
  20122. * An event triggered when the texture is unbind.
  20123. */
  20124. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20125. private _onAfterUnbindObserver;
  20126. /**
  20127. * Set a after unbind callback in the texture.
  20128. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20129. */
  20130. onAfterUnbind: () => void;
  20131. /**
  20132. * An event triggered before rendering the texture
  20133. */
  20134. onBeforeRenderObservable: Observable<number>;
  20135. private _onBeforeRenderObserver;
  20136. /**
  20137. * Set a before render callback in the texture.
  20138. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20139. */
  20140. onBeforeRender: (faceIndex: number) => void;
  20141. /**
  20142. * An event triggered after rendering the texture
  20143. */
  20144. onAfterRenderObservable: Observable<number>;
  20145. private _onAfterRenderObserver;
  20146. /**
  20147. * Set a after render callback in the texture.
  20148. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20149. */
  20150. onAfterRender: (faceIndex: number) => void;
  20151. /**
  20152. * An event triggered after the texture clear
  20153. */
  20154. onClearObservable: Observable<Engine>;
  20155. private _onClearObserver;
  20156. /**
  20157. * Set a clear callback in the texture.
  20158. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20159. */
  20160. onClear: (Engine: Engine) => void;
  20161. /**
  20162. * An event triggered when the texture is resized.
  20163. */
  20164. onResizeObservable: Observable<RenderTargetTexture>;
  20165. /**
  20166. * Define the clear color of the Render Target if it should be different from the scene.
  20167. */
  20168. clearColor: Color4;
  20169. protected _size: number | {
  20170. width: number;
  20171. height: number;
  20172. };
  20173. protected _initialSizeParameter: number | {
  20174. width: number;
  20175. height: number;
  20176. } | {
  20177. ratio: number;
  20178. };
  20179. protected _sizeRatio: Nullable<number>;
  20180. /** @hidden */
  20181. _generateMipMaps: boolean;
  20182. protected _renderingManager: RenderingManager;
  20183. /** @hidden */
  20184. _waitingRenderList: string[];
  20185. protected _doNotChangeAspectRatio: boolean;
  20186. protected _currentRefreshId: number;
  20187. protected _refreshRate: number;
  20188. protected _textureMatrix: Matrix;
  20189. protected _samples: number;
  20190. protected _renderTargetOptions: RenderTargetCreationOptions;
  20191. /**
  20192. * Gets render target creation options that were used.
  20193. */
  20194. readonly renderTargetOptions: RenderTargetCreationOptions;
  20195. protected _engine: Engine;
  20196. protected _onRatioRescale(): void;
  20197. /**
  20198. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20199. * It must define where the camera used to render the texture is set
  20200. */
  20201. boundingBoxPosition: Vector3;
  20202. private _boundingBoxSize;
  20203. /**
  20204. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20205. * When defined, the cubemap will switch to local mode
  20206. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20207. * @example https://www.babylonjs-playground.com/#RNASML
  20208. */
  20209. boundingBoxSize: Vector3;
  20210. /**
  20211. * In case the RTT has been created with a depth texture, get the associated
  20212. * depth texture.
  20213. * Otherwise, return null.
  20214. */
  20215. depthStencilTexture: Nullable<InternalTexture>;
  20216. /**
  20217. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20218. * or used a shadow, depth texture...
  20219. * @param name The friendly name of the texture
  20220. * @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)
  20221. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20222. * @param generateMipMaps True if mip maps need to be generated after render.
  20223. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20224. * @param type The type of the buffer in the RTT (int, half float, float...)
  20225. * @param isCube True if a cube texture needs to be created
  20226. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20227. * @param generateDepthBuffer True to generate a depth buffer
  20228. * @param generateStencilBuffer True to generate a stencil buffer
  20229. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20230. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20231. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20232. */
  20233. constructor(name: string, size: number | {
  20234. width: number;
  20235. height: number;
  20236. } | {
  20237. ratio: number;
  20238. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20239. /**
  20240. * Creates a depth stencil texture.
  20241. * This is only available in WebGL 2 or with the depth texture extension available.
  20242. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20243. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20244. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20245. */
  20246. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20247. private _processSizeParameter;
  20248. /**
  20249. * Define the number of samples to use in case of MSAA.
  20250. * It defaults to one meaning no MSAA has been enabled.
  20251. */
  20252. samples: number;
  20253. /**
  20254. * Resets the refresh counter of the texture and start bak from scratch.
  20255. * Could be useful to regenerate the texture if it is setup to render only once.
  20256. */
  20257. resetRefreshCounter(): void;
  20258. /**
  20259. * Define the refresh rate of the texture or the rendering frequency.
  20260. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20261. */
  20262. refreshRate: number;
  20263. /**
  20264. * Adds a post process to the render target rendering passes.
  20265. * @param postProcess define the post process to add
  20266. */
  20267. addPostProcess(postProcess: PostProcess): void;
  20268. /**
  20269. * Clear all the post processes attached to the render target
  20270. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20271. */
  20272. clearPostProcesses(dispose?: boolean): void;
  20273. /**
  20274. * Remove one of the post process from the list of attached post processes to the texture
  20275. * @param postProcess define the post process to remove from the list
  20276. */
  20277. removePostProcess(postProcess: PostProcess): void;
  20278. /** @hidden */
  20279. _shouldRender(): boolean;
  20280. /**
  20281. * Gets the actual render size of the texture.
  20282. * @returns the width of the render size
  20283. */
  20284. getRenderSize(): number;
  20285. /**
  20286. * Gets the actual render width of the texture.
  20287. * @returns the width of the render size
  20288. */
  20289. getRenderWidth(): number;
  20290. /**
  20291. * Gets the actual render height of the texture.
  20292. * @returns the height of the render size
  20293. */
  20294. getRenderHeight(): number;
  20295. /**
  20296. * Get if the texture can be rescaled or not.
  20297. */
  20298. readonly canRescale: boolean;
  20299. /**
  20300. * Resize the texture using a ratio.
  20301. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20302. */
  20303. scale(ratio: number): void;
  20304. /**
  20305. * Get the texture reflection matrix used to rotate/transform the reflection.
  20306. * @returns the reflection matrix
  20307. */
  20308. getReflectionTextureMatrix(): Matrix;
  20309. /**
  20310. * Resize the texture to a new desired size.
  20311. * Be carrefull as it will recreate all the data in the new texture.
  20312. * @param size Define the new size. It can be:
  20313. * - a number for squared texture,
  20314. * - an object containing { width: number, height: number }
  20315. * - or an object containing a ratio { ratio: number }
  20316. */
  20317. resize(size: number | {
  20318. width: number;
  20319. height: number;
  20320. } | {
  20321. ratio: number;
  20322. }): void;
  20323. /**
  20324. * Renders all the objects from the render list into the texture.
  20325. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20326. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20327. */
  20328. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20329. private _bestReflectionRenderTargetDimension;
  20330. /**
  20331. * @hidden
  20332. * @param faceIndex face index to bind to if this is a cubetexture
  20333. */
  20334. _bindFrameBuffer(faceIndex?: number): void;
  20335. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20336. private renderToTarget;
  20337. /**
  20338. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20339. * This allowed control for front to back rendering or reversly depending of the special needs.
  20340. *
  20341. * @param renderingGroupId The rendering group id corresponding to its index
  20342. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20343. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20344. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20345. */
  20346. 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;
  20347. /**
  20348. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20349. *
  20350. * @param renderingGroupId The rendering group id corresponding to its index
  20351. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20352. */
  20353. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20354. /**
  20355. * Clones the texture.
  20356. * @returns the cloned texture
  20357. */
  20358. clone(): RenderTargetTexture;
  20359. /**
  20360. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20361. * @returns The JSON representation of the texture
  20362. */
  20363. serialize(): any;
  20364. /**
  20365. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20366. */
  20367. disposeFramebufferObjects(): void;
  20368. /**
  20369. * Dispose the texture and release its associated resources.
  20370. */
  20371. dispose(): void;
  20372. /** @hidden */
  20373. _rebuild(): void;
  20374. /**
  20375. * Clear the info related to rendering groups preventing retention point in material dispose.
  20376. */
  20377. freeRenderingGroups(): void;
  20378. /**
  20379. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20380. * @returns the view count
  20381. */
  20382. getViewCount(): number;
  20383. }
  20384. }
  20385. declare module BABYLON {
  20386. /**
  20387. * Options for compiling materials.
  20388. */
  20389. export interface IMaterialCompilationOptions {
  20390. /**
  20391. * Defines whether clip planes are enabled.
  20392. */
  20393. clipPlane: boolean;
  20394. /**
  20395. * Defines whether instances are enabled.
  20396. */
  20397. useInstances: boolean;
  20398. }
  20399. /**
  20400. * Base class for the main features of a material in Babylon.js
  20401. */
  20402. export class Material implements IAnimatable {
  20403. /**
  20404. * Returns the triangle fill mode
  20405. */
  20406. static readonly TriangleFillMode: number;
  20407. /**
  20408. * Returns the wireframe mode
  20409. */
  20410. static readonly WireFrameFillMode: number;
  20411. /**
  20412. * Returns the point fill mode
  20413. */
  20414. static readonly PointFillMode: number;
  20415. /**
  20416. * Returns the point list draw mode
  20417. */
  20418. static readonly PointListDrawMode: number;
  20419. /**
  20420. * Returns the line list draw mode
  20421. */
  20422. static readonly LineListDrawMode: number;
  20423. /**
  20424. * Returns the line loop draw mode
  20425. */
  20426. static readonly LineLoopDrawMode: number;
  20427. /**
  20428. * Returns the line strip draw mode
  20429. */
  20430. static readonly LineStripDrawMode: number;
  20431. /**
  20432. * Returns the triangle strip draw mode
  20433. */
  20434. static readonly TriangleStripDrawMode: number;
  20435. /**
  20436. * Returns the triangle fan draw mode
  20437. */
  20438. static readonly TriangleFanDrawMode: number;
  20439. /**
  20440. * Stores the clock-wise side orientation
  20441. */
  20442. static readonly ClockWiseSideOrientation: number;
  20443. /**
  20444. * Stores the counter clock-wise side orientation
  20445. */
  20446. static readonly CounterClockWiseSideOrientation: number;
  20447. /**
  20448. * The dirty texture flag value
  20449. */
  20450. static readonly TextureDirtyFlag: number;
  20451. /**
  20452. * The dirty light flag value
  20453. */
  20454. static readonly LightDirtyFlag: number;
  20455. /**
  20456. * The dirty fresnel flag value
  20457. */
  20458. static readonly FresnelDirtyFlag: number;
  20459. /**
  20460. * The dirty attribute flag value
  20461. */
  20462. static readonly AttributesDirtyFlag: number;
  20463. /**
  20464. * The dirty misc flag value
  20465. */
  20466. static readonly MiscDirtyFlag: number;
  20467. /**
  20468. * The all dirty flag value
  20469. */
  20470. static readonly AllDirtyFlag: number;
  20471. /**
  20472. * The ID of the material
  20473. */
  20474. id: string;
  20475. /**
  20476. * Gets or sets the unique id of the material
  20477. */
  20478. uniqueId: number;
  20479. /**
  20480. * The name of the material
  20481. */
  20482. name: string;
  20483. /**
  20484. * Gets or sets user defined metadata
  20485. */
  20486. metadata: any;
  20487. /**
  20488. * For internal use only. Please do not use.
  20489. */
  20490. reservedDataStore: any;
  20491. /**
  20492. * Specifies if the ready state should be checked on each call
  20493. */
  20494. checkReadyOnEveryCall: boolean;
  20495. /**
  20496. * Specifies if the ready state should be checked once
  20497. */
  20498. checkReadyOnlyOnce: boolean;
  20499. /**
  20500. * The state of the material
  20501. */
  20502. state: string;
  20503. /**
  20504. * The alpha value of the material
  20505. */
  20506. protected _alpha: number;
  20507. /**
  20508. * List of inspectable custom properties (used by the Inspector)
  20509. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20510. */
  20511. inspectableCustomProperties: IInspectable[];
  20512. /**
  20513. * Sets the alpha value of the material
  20514. */
  20515. /**
  20516. * Gets the alpha value of the material
  20517. */
  20518. alpha: number;
  20519. /**
  20520. * Specifies if back face culling is enabled
  20521. */
  20522. protected _backFaceCulling: boolean;
  20523. /**
  20524. * Sets the back-face culling state
  20525. */
  20526. /**
  20527. * Gets the back-face culling state
  20528. */
  20529. backFaceCulling: boolean;
  20530. /**
  20531. * Stores the value for side orientation
  20532. */
  20533. sideOrientation: number;
  20534. /**
  20535. * Callback triggered when the material is compiled
  20536. */
  20537. onCompiled: Nullable<(effect: Effect) => void>;
  20538. /**
  20539. * Callback triggered when an error occurs
  20540. */
  20541. onError: Nullable<(effect: Effect, errors: string) => void>;
  20542. /**
  20543. * Callback triggered to get the render target textures
  20544. */
  20545. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20546. /**
  20547. * Gets a boolean indicating that current material needs to register RTT
  20548. */
  20549. readonly hasRenderTargetTextures: boolean;
  20550. /**
  20551. * Specifies if the material should be serialized
  20552. */
  20553. doNotSerialize: boolean;
  20554. /**
  20555. * @hidden
  20556. */
  20557. _storeEffectOnSubMeshes: boolean;
  20558. /**
  20559. * Stores the animations for the material
  20560. */
  20561. animations: Nullable<Array<Animation>>;
  20562. /**
  20563. * An event triggered when the material is disposed
  20564. */
  20565. onDisposeObservable: Observable<Material>;
  20566. /**
  20567. * An observer which watches for dispose events
  20568. */
  20569. private _onDisposeObserver;
  20570. private _onUnBindObservable;
  20571. /**
  20572. * Called during a dispose event
  20573. */
  20574. onDispose: () => void;
  20575. private _onBindObservable;
  20576. /**
  20577. * An event triggered when the material is bound
  20578. */
  20579. readonly onBindObservable: Observable<AbstractMesh>;
  20580. /**
  20581. * An observer which watches for bind events
  20582. */
  20583. private _onBindObserver;
  20584. /**
  20585. * Called during a bind event
  20586. */
  20587. onBind: (Mesh: AbstractMesh) => void;
  20588. /**
  20589. * An event triggered when the material is unbound
  20590. */
  20591. readonly onUnBindObservable: Observable<Material>;
  20592. /**
  20593. * Stores the value of the alpha mode
  20594. */
  20595. private _alphaMode;
  20596. /**
  20597. * Sets the value of the alpha mode.
  20598. *
  20599. * | Value | Type | Description |
  20600. * | --- | --- | --- |
  20601. * | 0 | ALPHA_DISABLE | |
  20602. * | 1 | ALPHA_ADD | |
  20603. * | 2 | ALPHA_COMBINE | |
  20604. * | 3 | ALPHA_SUBTRACT | |
  20605. * | 4 | ALPHA_MULTIPLY | |
  20606. * | 5 | ALPHA_MAXIMIZED | |
  20607. * | 6 | ALPHA_ONEONE | |
  20608. * | 7 | ALPHA_PREMULTIPLIED | |
  20609. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20610. * | 9 | ALPHA_INTERPOLATE | |
  20611. * | 10 | ALPHA_SCREENMODE | |
  20612. *
  20613. */
  20614. /**
  20615. * Gets the value of the alpha mode
  20616. */
  20617. alphaMode: number;
  20618. /**
  20619. * Stores the state of the need depth pre-pass value
  20620. */
  20621. private _needDepthPrePass;
  20622. /**
  20623. * Sets the need depth pre-pass value
  20624. */
  20625. /**
  20626. * Gets the depth pre-pass value
  20627. */
  20628. needDepthPrePass: boolean;
  20629. /**
  20630. * Specifies if depth writing should be disabled
  20631. */
  20632. disableDepthWrite: boolean;
  20633. /**
  20634. * Specifies if depth writing should be forced
  20635. */
  20636. forceDepthWrite: boolean;
  20637. /**
  20638. * Specifies the depth function that should be used. 0 means the default engine function
  20639. */
  20640. depthFunction: number;
  20641. /**
  20642. * Specifies if there should be a separate pass for culling
  20643. */
  20644. separateCullingPass: boolean;
  20645. /**
  20646. * Stores the state specifing if fog should be enabled
  20647. */
  20648. private _fogEnabled;
  20649. /**
  20650. * Sets the state for enabling fog
  20651. */
  20652. /**
  20653. * Gets the value of the fog enabled state
  20654. */
  20655. fogEnabled: boolean;
  20656. /**
  20657. * Stores the size of points
  20658. */
  20659. pointSize: number;
  20660. /**
  20661. * Stores the z offset value
  20662. */
  20663. zOffset: number;
  20664. /**
  20665. * Gets a value specifying if wireframe mode is enabled
  20666. */
  20667. /**
  20668. * Sets the state of wireframe mode
  20669. */
  20670. wireframe: boolean;
  20671. /**
  20672. * Gets the value specifying if point clouds are enabled
  20673. */
  20674. /**
  20675. * Sets the state of point cloud mode
  20676. */
  20677. pointsCloud: boolean;
  20678. /**
  20679. * Gets the material fill mode
  20680. */
  20681. /**
  20682. * Sets the material fill mode
  20683. */
  20684. fillMode: number;
  20685. /**
  20686. * @hidden
  20687. * Stores the effects for the material
  20688. */
  20689. _effect: Nullable<Effect>;
  20690. /**
  20691. * @hidden
  20692. * Specifies if the material was previously ready
  20693. */
  20694. _wasPreviouslyReady: boolean;
  20695. /**
  20696. * Specifies if uniform buffers should be used
  20697. */
  20698. private _useUBO;
  20699. /**
  20700. * Stores a reference to the scene
  20701. */
  20702. private _scene;
  20703. /**
  20704. * Stores the fill mode state
  20705. */
  20706. private _fillMode;
  20707. /**
  20708. * Specifies if the depth write state should be cached
  20709. */
  20710. private _cachedDepthWriteState;
  20711. /**
  20712. * Specifies if the depth function state should be cached
  20713. */
  20714. private _cachedDepthFunctionState;
  20715. /**
  20716. * Stores the uniform buffer
  20717. */
  20718. protected _uniformBuffer: UniformBuffer;
  20719. /** @hidden */
  20720. _indexInSceneMaterialArray: number;
  20721. /** @hidden */
  20722. meshMap: Nullable<{
  20723. [id: string]: AbstractMesh | undefined;
  20724. }>;
  20725. /**
  20726. * Creates a material instance
  20727. * @param name defines the name of the material
  20728. * @param scene defines the scene to reference
  20729. * @param doNotAdd specifies if the material should be added to the scene
  20730. */
  20731. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20732. /**
  20733. * Returns a string representation of the current material
  20734. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20735. * @returns a string with material information
  20736. */
  20737. toString(fullDetails?: boolean): string;
  20738. /**
  20739. * Gets the class name of the material
  20740. * @returns a string with the class name of the material
  20741. */
  20742. getClassName(): string;
  20743. /**
  20744. * Specifies if updates for the material been locked
  20745. */
  20746. readonly isFrozen: boolean;
  20747. /**
  20748. * Locks updates for the material
  20749. */
  20750. freeze(): void;
  20751. /**
  20752. * Unlocks updates for the material
  20753. */
  20754. unfreeze(): void;
  20755. /**
  20756. * Specifies if the material is ready to be used
  20757. * @param mesh defines the mesh to check
  20758. * @param useInstances specifies if instances should be used
  20759. * @returns a boolean indicating if the material is ready to be used
  20760. */
  20761. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20762. /**
  20763. * Specifies that the submesh is ready to be used
  20764. * @param mesh defines the mesh to check
  20765. * @param subMesh defines which submesh to check
  20766. * @param useInstances specifies that instances should be used
  20767. * @returns a boolean indicating that the submesh is ready or not
  20768. */
  20769. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20770. /**
  20771. * Returns the material effect
  20772. * @returns the effect associated with the material
  20773. */
  20774. getEffect(): Nullable<Effect>;
  20775. /**
  20776. * Returns the current scene
  20777. * @returns a Scene
  20778. */
  20779. getScene(): Scene;
  20780. /**
  20781. * Specifies if the material will require alpha blending
  20782. * @returns a boolean specifying if alpha blending is needed
  20783. */
  20784. needAlphaBlending(): boolean;
  20785. /**
  20786. * Specifies if the mesh will require alpha blending
  20787. * @param mesh defines the mesh to check
  20788. * @returns a boolean specifying if alpha blending is needed for the mesh
  20789. */
  20790. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20791. /**
  20792. * Specifies if this material should be rendered in alpha test mode
  20793. * @returns a boolean specifying if an alpha test is needed.
  20794. */
  20795. needAlphaTesting(): boolean;
  20796. /**
  20797. * Gets the texture used for the alpha test
  20798. * @returns the texture to use for alpha testing
  20799. */
  20800. getAlphaTestTexture(): Nullable<BaseTexture>;
  20801. /**
  20802. * Marks the material to indicate that it needs to be re-calculated
  20803. */
  20804. markDirty(): void;
  20805. /** @hidden */
  20806. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  20807. /**
  20808. * Binds the material to the mesh
  20809. * @param world defines the world transformation matrix
  20810. * @param mesh defines the mesh to bind the material to
  20811. */
  20812. bind(world: Matrix, mesh?: Mesh): void;
  20813. /**
  20814. * Binds the submesh to the material
  20815. * @param world defines the world transformation matrix
  20816. * @param mesh defines the mesh containing the submesh
  20817. * @param subMesh defines the submesh to bind the material to
  20818. */
  20819. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20820. /**
  20821. * Binds the world matrix to the material
  20822. * @param world defines the world transformation matrix
  20823. */
  20824. bindOnlyWorldMatrix(world: Matrix): void;
  20825. /**
  20826. * Binds the scene's uniform buffer to the effect.
  20827. * @param effect defines the effect to bind to the scene uniform buffer
  20828. * @param sceneUbo defines the uniform buffer storing scene data
  20829. */
  20830. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  20831. /**
  20832. * Binds the view matrix to the effect
  20833. * @param effect defines the effect to bind the view matrix to
  20834. */
  20835. bindView(effect: Effect): void;
  20836. /**
  20837. * Binds the view projection matrix to the effect
  20838. * @param effect defines the effect to bind the view projection matrix to
  20839. */
  20840. bindViewProjection(effect: Effect): void;
  20841. /**
  20842. * Specifies if material alpha testing should be turned on for the mesh
  20843. * @param mesh defines the mesh to check
  20844. */
  20845. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  20846. /**
  20847. * Processes to execute after binding the material to a mesh
  20848. * @param mesh defines the rendered mesh
  20849. */
  20850. protected _afterBind(mesh?: Mesh): void;
  20851. /**
  20852. * Unbinds the material from the mesh
  20853. */
  20854. unbind(): void;
  20855. /**
  20856. * Gets the active textures from the material
  20857. * @returns an array of textures
  20858. */
  20859. getActiveTextures(): BaseTexture[];
  20860. /**
  20861. * Specifies if the material uses a texture
  20862. * @param texture defines the texture to check against the material
  20863. * @returns a boolean specifying if the material uses the texture
  20864. */
  20865. hasTexture(texture: BaseTexture): boolean;
  20866. /**
  20867. * Makes a duplicate of the material, and gives it a new name
  20868. * @param name defines the new name for the duplicated material
  20869. * @returns the cloned material
  20870. */
  20871. clone(name: string): Nullable<Material>;
  20872. /**
  20873. * Gets the meshes bound to the material
  20874. * @returns an array of meshes bound to the material
  20875. */
  20876. getBindedMeshes(): AbstractMesh[];
  20877. /**
  20878. * Force shader compilation
  20879. * @param mesh defines the mesh associated with this material
  20880. * @param onCompiled defines a function to execute once the material is compiled
  20881. * @param options defines the options to configure the compilation
  20882. * @param onError defines a function to execute if the material fails compiling
  20883. */
  20884. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  20885. /**
  20886. * Force shader compilation
  20887. * @param mesh defines the mesh that will use this material
  20888. * @param options defines additional options for compiling the shaders
  20889. * @returns a promise that resolves when the compilation completes
  20890. */
  20891. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  20892. private static readonly _AllDirtyCallBack;
  20893. private static readonly _ImageProcessingDirtyCallBack;
  20894. private static readonly _TextureDirtyCallBack;
  20895. private static readonly _FresnelDirtyCallBack;
  20896. private static readonly _MiscDirtyCallBack;
  20897. private static readonly _LightsDirtyCallBack;
  20898. private static readonly _AttributeDirtyCallBack;
  20899. private static _FresnelAndMiscDirtyCallBack;
  20900. private static _TextureAndMiscDirtyCallBack;
  20901. private static readonly _DirtyCallbackArray;
  20902. private static readonly _RunDirtyCallBacks;
  20903. /**
  20904. * Marks a define in the material to indicate that it needs to be re-computed
  20905. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  20906. */
  20907. markAsDirty(flag: number): void;
  20908. /**
  20909. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  20910. * @param func defines a function which checks material defines against the submeshes
  20911. */
  20912. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  20913. /**
  20914. * Indicates that we need to re-calculated for all submeshes
  20915. */
  20916. protected _markAllSubMeshesAsAllDirty(): void;
  20917. /**
  20918. * Indicates that image processing needs to be re-calculated for all submeshes
  20919. */
  20920. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  20921. /**
  20922. * Indicates that textures need to be re-calculated for all submeshes
  20923. */
  20924. protected _markAllSubMeshesAsTexturesDirty(): void;
  20925. /**
  20926. * Indicates that fresnel needs to be re-calculated for all submeshes
  20927. */
  20928. protected _markAllSubMeshesAsFresnelDirty(): void;
  20929. /**
  20930. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  20931. */
  20932. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  20933. /**
  20934. * Indicates that lights need to be re-calculated for all submeshes
  20935. */
  20936. protected _markAllSubMeshesAsLightsDirty(): void;
  20937. /**
  20938. * Indicates that attributes need to be re-calculated for all submeshes
  20939. */
  20940. protected _markAllSubMeshesAsAttributesDirty(): void;
  20941. /**
  20942. * Indicates that misc needs to be re-calculated for all submeshes
  20943. */
  20944. protected _markAllSubMeshesAsMiscDirty(): void;
  20945. /**
  20946. * Indicates that textures and misc need to be re-calculated for all submeshes
  20947. */
  20948. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  20949. /**
  20950. * Disposes the material
  20951. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20952. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20953. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20954. */
  20955. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20956. /** @hidden */
  20957. private releaseVertexArrayObject;
  20958. /**
  20959. * Serializes this material
  20960. * @returns the serialized material object
  20961. */
  20962. serialize(): any;
  20963. /**
  20964. * Creates a material from parsed material data
  20965. * @param parsedMaterial defines parsed material data
  20966. * @param scene defines the hosting scene
  20967. * @param rootUrl defines the root URL to use to load textures
  20968. * @returns a new material
  20969. */
  20970. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  20971. }
  20972. }
  20973. declare module BABYLON {
  20974. /**
  20975. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20976. * separate meshes. This can be use to improve performances.
  20977. * @see http://doc.babylonjs.com/how_to/multi_materials
  20978. */
  20979. export class MultiMaterial extends Material {
  20980. private _subMaterials;
  20981. /**
  20982. * Gets or Sets the list of Materials used within the multi material.
  20983. * They need to be ordered according to the submeshes order in the associated mesh
  20984. */
  20985. subMaterials: Nullable<Material>[];
  20986. /**
  20987. * Function used to align with Node.getChildren()
  20988. * @returns the list of Materials used within the multi material
  20989. */
  20990. getChildren(): Nullable<Material>[];
  20991. /**
  20992. * Instantiates a new Multi Material
  20993. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20994. * separate meshes. This can be use to improve performances.
  20995. * @see http://doc.babylonjs.com/how_to/multi_materials
  20996. * @param name Define the name in the scene
  20997. * @param scene Define the scene the material belongs to
  20998. */
  20999. constructor(name: string, scene: Scene);
  21000. private _hookArray;
  21001. /**
  21002. * Get one of the submaterial by its index in the submaterials array
  21003. * @param index The index to look the sub material at
  21004. * @returns The Material if the index has been defined
  21005. */
  21006. getSubMaterial(index: number): Nullable<Material>;
  21007. /**
  21008. * Get the list of active textures for the whole sub materials list.
  21009. * @returns All the textures that will be used during the rendering
  21010. */
  21011. getActiveTextures(): BaseTexture[];
  21012. /**
  21013. * Gets the current class name of the material e.g. "MultiMaterial"
  21014. * Mainly use in serialization.
  21015. * @returns the class name
  21016. */
  21017. getClassName(): string;
  21018. /**
  21019. * Checks if the material is ready to render the requested sub mesh
  21020. * @param mesh Define the mesh the submesh belongs to
  21021. * @param subMesh Define the sub mesh to look readyness for
  21022. * @param useInstances Define whether or not the material is used with instances
  21023. * @returns true if ready, otherwise false
  21024. */
  21025. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21026. /**
  21027. * Clones the current material and its related sub materials
  21028. * @param name Define the name of the newly cloned material
  21029. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21030. * @returns the cloned material
  21031. */
  21032. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21033. /**
  21034. * Serializes the materials into a JSON representation.
  21035. * @returns the JSON representation
  21036. */
  21037. serialize(): any;
  21038. /**
  21039. * Dispose the material and release its associated resources
  21040. * @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)
  21041. * @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)
  21042. * @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)
  21043. */
  21044. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21045. /**
  21046. * Creates a MultiMaterial from parsed MultiMaterial data.
  21047. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21048. * @param scene defines the hosting scene
  21049. * @returns a new MultiMaterial
  21050. */
  21051. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21052. }
  21053. }
  21054. declare module BABYLON {
  21055. /**
  21056. * Base class for submeshes
  21057. */
  21058. export class BaseSubMesh {
  21059. /** @hidden */
  21060. _materialDefines: Nullable<MaterialDefines>;
  21061. /** @hidden */
  21062. _materialEffect: Nullable<Effect>;
  21063. /**
  21064. * Gets material defines used by the effect associated to the sub mesh
  21065. */
  21066. /**
  21067. * Sets material defines used by the effect associated to the sub mesh
  21068. */
  21069. materialDefines: Nullable<MaterialDefines>;
  21070. /**
  21071. * Gets associated effect
  21072. */
  21073. readonly effect: Nullable<Effect>;
  21074. /**
  21075. * Sets associated effect (effect used to render this submesh)
  21076. * @param effect defines the effect to associate with
  21077. * @param defines defines the set of defines used to compile this effect
  21078. */
  21079. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21080. }
  21081. /**
  21082. * Defines a subdivision inside a mesh
  21083. */
  21084. export class SubMesh extends BaseSubMesh implements ICullable {
  21085. /** the material index to use */
  21086. materialIndex: number;
  21087. /** vertex index start */
  21088. verticesStart: number;
  21089. /** vertices count */
  21090. verticesCount: number;
  21091. /** index start */
  21092. indexStart: number;
  21093. /** indices count */
  21094. indexCount: number;
  21095. /** @hidden */
  21096. _linesIndexCount: number;
  21097. private _mesh;
  21098. private _renderingMesh;
  21099. private _boundingInfo;
  21100. private _linesIndexBuffer;
  21101. /** @hidden */
  21102. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21103. /** @hidden */
  21104. _trianglePlanes: Plane[];
  21105. /** @hidden */
  21106. _lastColliderTransformMatrix: Nullable<Matrix>;
  21107. /** @hidden */
  21108. _renderId: number;
  21109. /** @hidden */
  21110. _alphaIndex: number;
  21111. /** @hidden */
  21112. _distanceToCamera: number;
  21113. /** @hidden */
  21114. _id: number;
  21115. private _currentMaterial;
  21116. /**
  21117. * Add a new submesh to a mesh
  21118. * @param materialIndex defines the material index to use
  21119. * @param verticesStart defines vertex index start
  21120. * @param verticesCount defines vertices count
  21121. * @param indexStart defines index start
  21122. * @param indexCount defines indices count
  21123. * @param mesh defines the parent mesh
  21124. * @param renderingMesh defines an optional rendering mesh
  21125. * @param createBoundingBox defines if bounding box should be created for this submesh
  21126. * @returns the new submesh
  21127. */
  21128. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21129. /**
  21130. * Creates a new submesh
  21131. * @param materialIndex defines the material index to use
  21132. * @param verticesStart defines vertex index start
  21133. * @param verticesCount defines vertices count
  21134. * @param indexStart defines index start
  21135. * @param indexCount defines indices count
  21136. * @param mesh defines the parent mesh
  21137. * @param renderingMesh defines an optional rendering mesh
  21138. * @param createBoundingBox defines if bounding box should be created for this submesh
  21139. */
  21140. constructor(
  21141. /** the material index to use */
  21142. materialIndex: number,
  21143. /** vertex index start */
  21144. verticesStart: number,
  21145. /** vertices count */
  21146. verticesCount: number,
  21147. /** index start */
  21148. indexStart: number,
  21149. /** indices count */
  21150. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21151. /**
  21152. * Returns true if this submesh covers the entire parent mesh
  21153. * @ignorenaming
  21154. */
  21155. readonly IsGlobal: boolean;
  21156. /**
  21157. * Returns the submesh BoudingInfo object
  21158. * @returns current bounding info (or mesh's one if the submesh is global)
  21159. */
  21160. getBoundingInfo(): BoundingInfo;
  21161. /**
  21162. * Sets the submesh BoundingInfo
  21163. * @param boundingInfo defines the new bounding info to use
  21164. * @returns the SubMesh
  21165. */
  21166. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21167. /**
  21168. * Returns the mesh of the current submesh
  21169. * @return the parent mesh
  21170. */
  21171. getMesh(): AbstractMesh;
  21172. /**
  21173. * Returns the rendering mesh of the submesh
  21174. * @returns the rendering mesh (could be different from parent mesh)
  21175. */
  21176. getRenderingMesh(): Mesh;
  21177. /**
  21178. * Returns the submesh material
  21179. * @returns null or the current material
  21180. */
  21181. getMaterial(): Nullable<Material>;
  21182. /**
  21183. * Sets a new updated BoundingInfo object to the submesh
  21184. * @param data defines an optional position array to use to determine the bounding info
  21185. * @returns the SubMesh
  21186. */
  21187. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21188. /** @hidden */
  21189. _checkCollision(collider: Collider): boolean;
  21190. /**
  21191. * Updates the submesh BoundingInfo
  21192. * @param world defines the world matrix to use to update the bounding info
  21193. * @returns the submesh
  21194. */
  21195. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21196. /**
  21197. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21198. * @param frustumPlanes defines the frustum planes
  21199. * @returns true if the submesh is intersecting with the frustum
  21200. */
  21201. isInFrustum(frustumPlanes: Plane[]): boolean;
  21202. /**
  21203. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21204. * @param frustumPlanes defines the frustum planes
  21205. * @returns true if the submesh is inside the frustum
  21206. */
  21207. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21208. /**
  21209. * Renders the submesh
  21210. * @param enableAlphaMode defines if alpha needs to be used
  21211. * @returns the submesh
  21212. */
  21213. render(enableAlphaMode: boolean): SubMesh;
  21214. /**
  21215. * @hidden
  21216. */
  21217. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21218. /**
  21219. * Checks if the submesh intersects with a ray
  21220. * @param ray defines the ray to test
  21221. * @returns true is the passed ray intersects the submesh bounding box
  21222. */
  21223. canIntersects(ray: Ray): boolean;
  21224. /**
  21225. * Intersects current submesh with a ray
  21226. * @param ray defines the ray to test
  21227. * @param positions defines mesh's positions array
  21228. * @param indices defines mesh's indices array
  21229. * @param fastCheck defines if only bounding info should be used
  21230. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21231. * @returns intersection info or null if no intersection
  21232. */
  21233. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21234. /** @hidden */
  21235. private _intersectLines;
  21236. /** @hidden */
  21237. private _intersectUnIndexedLines;
  21238. /** @hidden */
  21239. private _intersectTriangles;
  21240. /** @hidden */
  21241. private _intersectUnIndexedTriangles;
  21242. /** @hidden */
  21243. _rebuild(): void;
  21244. /**
  21245. * Creates a new submesh from the passed mesh
  21246. * @param newMesh defines the new hosting mesh
  21247. * @param newRenderingMesh defines an optional rendering mesh
  21248. * @returns the new submesh
  21249. */
  21250. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21251. /**
  21252. * Release associated resources
  21253. */
  21254. dispose(): void;
  21255. /**
  21256. * Gets the class name
  21257. * @returns the string "SubMesh".
  21258. */
  21259. getClassName(): string;
  21260. /**
  21261. * Creates a new submesh from indices data
  21262. * @param materialIndex the index of the main mesh material
  21263. * @param startIndex the index where to start the copy in the mesh indices array
  21264. * @param indexCount the number of indices to copy then from the startIndex
  21265. * @param mesh the main mesh to create the submesh from
  21266. * @param renderingMesh the optional rendering mesh
  21267. * @returns a new submesh
  21268. */
  21269. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21270. }
  21271. }
  21272. declare module BABYLON {
  21273. /**
  21274. * Class used to represent data loading progression
  21275. */
  21276. export class SceneLoaderFlags {
  21277. private static _ForceFullSceneLoadingForIncremental;
  21278. private static _ShowLoadingScreen;
  21279. private static _CleanBoneMatrixWeights;
  21280. private static _loggingLevel;
  21281. /**
  21282. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21283. */
  21284. static ForceFullSceneLoadingForIncremental: boolean;
  21285. /**
  21286. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21287. */
  21288. static ShowLoadingScreen: boolean;
  21289. /**
  21290. * Defines the current logging level (while loading the scene)
  21291. * @ignorenaming
  21292. */
  21293. static loggingLevel: number;
  21294. /**
  21295. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21296. */
  21297. static CleanBoneMatrixWeights: boolean;
  21298. }
  21299. }
  21300. declare module BABYLON {
  21301. /**
  21302. * Class used to store geometry data (vertex buffers + index buffer)
  21303. */
  21304. export class Geometry implements IGetSetVerticesData {
  21305. /**
  21306. * Gets or sets the ID of the geometry
  21307. */
  21308. id: string;
  21309. /**
  21310. * Gets or sets the unique ID of the geometry
  21311. */
  21312. uniqueId: number;
  21313. /**
  21314. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21315. */
  21316. delayLoadState: number;
  21317. /**
  21318. * Gets the file containing the data to load when running in delay load state
  21319. */
  21320. delayLoadingFile: Nullable<string>;
  21321. /**
  21322. * Callback called when the geometry is updated
  21323. */
  21324. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21325. private _scene;
  21326. private _engine;
  21327. private _meshes;
  21328. private _totalVertices;
  21329. /** @hidden */
  21330. _indices: IndicesArray;
  21331. /** @hidden */
  21332. _vertexBuffers: {
  21333. [key: string]: VertexBuffer;
  21334. };
  21335. private _isDisposed;
  21336. private _extend;
  21337. private _boundingBias;
  21338. /** @hidden */
  21339. _delayInfo: Array<string>;
  21340. private _indexBuffer;
  21341. private _indexBufferIsUpdatable;
  21342. /** @hidden */
  21343. _boundingInfo: Nullable<BoundingInfo>;
  21344. /** @hidden */
  21345. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21346. /** @hidden */
  21347. _softwareSkinningFrameId: number;
  21348. private _vertexArrayObjects;
  21349. private _updatable;
  21350. /** @hidden */
  21351. _positions: Nullable<Vector3[]>;
  21352. /**
  21353. * 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
  21354. */
  21355. /**
  21356. * 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
  21357. */
  21358. boundingBias: Vector2;
  21359. /**
  21360. * Static function used to attach a new empty geometry to a mesh
  21361. * @param mesh defines the mesh to attach the geometry to
  21362. * @returns the new Geometry
  21363. */
  21364. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21365. /**
  21366. * Creates a new geometry
  21367. * @param id defines the unique ID
  21368. * @param scene defines the hosting scene
  21369. * @param vertexData defines the VertexData used to get geometry data
  21370. * @param updatable defines if geometry must be updatable (false by default)
  21371. * @param mesh defines the mesh that will be associated with the geometry
  21372. */
  21373. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21374. /**
  21375. * Gets the current extend of the geometry
  21376. */
  21377. readonly extend: {
  21378. minimum: Vector3;
  21379. maximum: Vector3;
  21380. };
  21381. /**
  21382. * Gets the hosting scene
  21383. * @returns the hosting Scene
  21384. */
  21385. getScene(): Scene;
  21386. /**
  21387. * Gets the hosting engine
  21388. * @returns the hosting Engine
  21389. */
  21390. getEngine(): Engine;
  21391. /**
  21392. * Defines if the geometry is ready to use
  21393. * @returns true if the geometry is ready to be used
  21394. */
  21395. isReady(): boolean;
  21396. /**
  21397. * Gets a value indicating that the geometry should not be serialized
  21398. */
  21399. readonly doNotSerialize: boolean;
  21400. /** @hidden */
  21401. _rebuild(): void;
  21402. /**
  21403. * Affects all geometry data in one call
  21404. * @param vertexData defines the geometry data
  21405. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21406. */
  21407. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21408. /**
  21409. * Set specific vertex data
  21410. * @param kind defines the data kind (Position, normal, etc...)
  21411. * @param data defines the vertex data to use
  21412. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21413. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21414. */
  21415. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21416. /**
  21417. * Removes a specific vertex data
  21418. * @param kind defines the data kind (Position, normal, etc...)
  21419. */
  21420. removeVerticesData(kind: string): void;
  21421. /**
  21422. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21423. * @param buffer defines the vertex buffer to use
  21424. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21425. */
  21426. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21427. /**
  21428. * Update a specific vertex buffer
  21429. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21430. * It will do nothing if the buffer is not updatable
  21431. * @param kind defines the data kind (Position, normal, etc...)
  21432. * @param data defines the data to use
  21433. * @param offset defines the offset in the target buffer where to store the data
  21434. * @param useBytes set to true if the offset is in bytes
  21435. */
  21436. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21437. /**
  21438. * Update a specific vertex buffer
  21439. * This function will create a new buffer if the current one is not updatable
  21440. * @param kind defines the data kind (Position, normal, etc...)
  21441. * @param data defines the data to use
  21442. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21443. */
  21444. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21445. private _updateBoundingInfo;
  21446. /** @hidden */
  21447. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21448. /**
  21449. * Gets total number of vertices
  21450. * @returns the total number of vertices
  21451. */
  21452. getTotalVertices(): number;
  21453. /**
  21454. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21455. * @param kind defines the data kind (Position, normal, etc...)
  21456. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21457. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21458. * @returns a float array containing vertex data
  21459. */
  21460. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21461. /**
  21462. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21463. * @param kind defines the data kind (Position, normal, etc...)
  21464. * @returns true if the vertex buffer with the specified kind is updatable
  21465. */
  21466. isVertexBufferUpdatable(kind: string): boolean;
  21467. /**
  21468. * Gets a specific vertex buffer
  21469. * @param kind defines the data kind (Position, normal, etc...)
  21470. * @returns a VertexBuffer
  21471. */
  21472. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21473. /**
  21474. * Returns all vertex buffers
  21475. * @return an object holding all vertex buffers indexed by kind
  21476. */
  21477. getVertexBuffers(): Nullable<{
  21478. [key: string]: VertexBuffer;
  21479. }>;
  21480. /**
  21481. * Gets a boolean indicating if specific vertex buffer is present
  21482. * @param kind defines the data kind (Position, normal, etc...)
  21483. * @returns true if data is present
  21484. */
  21485. isVerticesDataPresent(kind: string): boolean;
  21486. /**
  21487. * Gets a list of all attached data kinds (Position, normal, etc...)
  21488. * @returns a list of string containing all kinds
  21489. */
  21490. getVerticesDataKinds(): string[];
  21491. /**
  21492. * Update index buffer
  21493. * @param indices defines the indices to store in the index buffer
  21494. * @param offset defines the offset in the target buffer where to store the data
  21495. * @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)
  21496. */
  21497. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21498. /**
  21499. * Creates a new index buffer
  21500. * @param indices defines the indices to store in the index buffer
  21501. * @param totalVertices defines the total number of vertices (could be null)
  21502. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21503. */
  21504. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21505. /**
  21506. * Return the total number of indices
  21507. * @returns the total number of indices
  21508. */
  21509. getTotalIndices(): number;
  21510. /**
  21511. * Gets the index buffer array
  21512. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21513. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21514. * @returns the index buffer array
  21515. */
  21516. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21517. /**
  21518. * Gets the index buffer
  21519. * @return the index buffer
  21520. */
  21521. getIndexBuffer(): Nullable<DataBuffer>;
  21522. /** @hidden */
  21523. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21524. /**
  21525. * Release the associated resources for a specific mesh
  21526. * @param mesh defines the source mesh
  21527. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21528. */
  21529. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21530. /**
  21531. * Apply current geometry to a given mesh
  21532. * @param mesh defines the mesh to apply geometry to
  21533. */
  21534. applyToMesh(mesh: Mesh): void;
  21535. private _updateExtend;
  21536. private _applyToMesh;
  21537. private notifyUpdate;
  21538. /**
  21539. * Load the geometry if it was flagged as delay loaded
  21540. * @param scene defines the hosting scene
  21541. * @param onLoaded defines a callback called when the geometry is loaded
  21542. */
  21543. load(scene: Scene, onLoaded?: () => void): void;
  21544. private _queueLoad;
  21545. /**
  21546. * Invert the geometry to move from a right handed system to a left handed one.
  21547. */
  21548. toLeftHanded(): void;
  21549. /** @hidden */
  21550. _resetPointsArrayCache(): void;
  21551. /** @hidden */
  21552. _generatePointsArray(): boolean;
  21553. /**
  21554. * Gets a value indicating if the geometry is disposed
  21555. * @returns true if the geometry was disposed
  21556. */
  21557. isDisposed(): boolean;
  21558. private _disposeVertexArrayObjects;
  21559. /**
  21560. * Free all associated resources
  21561. */
  21562. dispose(): void;
  21563. /**
  21564. * Clone the current geometry into a new geometry
  21565. * @param id defines the unique ID of the new geometry
  21566. * @returns a new geometry object
  21567. */
  21568. copy(id: string): Geometry;
  21569. /**
  21570. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21571. * @return a JSON representation of the current geometry data (without the vertices data)
  21572. */
  21573. serialize(): any;
  21574. private toNumberArray;
  21575. /**
  21576. * Serialize all vertices data into a JSON oject
  21577. * @returns a JSON representation of the current geometry data
  21578. */
  21579. serializeVerticeData(): any;
  21580. /**
  21581. * Extracts a clone of a mesh geometry
  21582. * @param mesh defines the source mesh
  21583. * @param id defines the unique ID of the new geometry object
  21584. * @returns the new geometry object
  21585. */
  21586. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21587. /**
  21588. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21589. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21590. * Be aware Math.random() could cause collisions, but:
  21591. * "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"
  21592. * @returns a string containing a new GUID
  21593. */
  21594. static RandomId(): string;
  21595. /** @hidden */
  21596. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21597. private static _CleanMatricesWeights;
  21598. /**
  21599. * Create a new geometry from persisted data (Using .babylon file format)
  21600. * @param parsedVertexData defines the persisted data
  21601. * @param scene defines the hosting scene
  21602. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21603. * @returns the new geometry object
  21604. */
  21605. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21606. }
  21607. }
  21608. declare module BABYLON {
  21609. /**
  21610. * Define an interface for all classes that will get and set the data on vertices
  21611. */
  21612. export interface IGetSetVerticesData {
  21613. /**
  21614. * Gets a boolean indicating if specific vertex data is present
  21615. * @param kind defines the vertex data kind to use
  21616. * @returns true is data kind is present
  21617. */
  21618. isVerticesDataPresent(kind: string): boolean;
  21619. /**
  21620. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21621. * @param kind defines the data kind (Position, normal, etc...)
  21622. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21623. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21624. * @returns a float array containing vertex data
  21625. */
  21626. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21627. /**
  21628. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21629. * @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.
  21630. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21631. * @returns the indices array or an empty array if the mesh has no geometry
  21632. */
  21633. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21634. /**
  21635. * Set specific vertex data
  21636. * @param kind defines the data kind (Position, normal, etc...)
  21637. * @param data defines the vertex data to use
  21638. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21639. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21640. */
  21641. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21642. /**
  21643. * Update a specific associated vertex buffer
  21644. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21645. * - VertexBuffer.PositionKind
  21646. * - VertexBuffer.UVKind
  21647. * - VertexBuffer.UV2Kind
  21648. * - VertexBuffer.UV3Kind
  21649. * - VertexBuffer.UV4Kind
  21650. * - VertexBuffer.UV5Kind
  21651. * - VertexBuffer.UV6Kind
  21652. * - VertexBuffer.ColorKind
  21653. * - VertexBuffer.MatricesIndicesKind
  21654. * - VertexBuffer.MatricesIndicesExtraKind
  21655. * - VertexBuffer.MatricesWeightsKind
  21656. * - VertexBuffer.MatricesWeightsExtraKind
  21657. * @param data defines the data source
  21658. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21659. * @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)
  21660. */
  21661. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21662. /**
  21663. * Creates a new index buffer
  21664. * @param indices defines the indices to store in the index buffer
  21665. * @param totalVertices defines the total number of vertices (could be null)
  21666. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21667. */
  21668. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21669. }
  21670. /**
  21671. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21672. */
  21673. export class VertexData {
  21674. /**
  21675. * Mesh side orientation : usually the external or front surface
  21676. */
  21677. static readonly FRONTSIDE: number;
  21678. /**
  21679. * Mesh side orientation : usually the internal or back surface
  21680. */
  21681. static readonly BACKSIDE: number;
  21682. /**
  21683. * Mesh side orientation : both internal and external or front and back surfaces
  21684. */
  21685. static readonly DOUBLESIDE: number;
  21686. /**
  21687. * Mesh side orientation : by default, `FRONTSIDE`
  21688. */
  21689. static readonly DEFAULTSIDE: number;
  21690. /**
  21691. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21692. */
  21693. positions: Nullable<FloatArray>;
  21694. /**
  21695. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21696. */
  21697. normals: Nullable<FloatArray>;
  21698. /**
  21699. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21700. */
  21701. tangents: Nullable<FloatArray>;
  21702. /**
  21703. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21704. */
  21705. uvs: Nullable<FloatArray>;
  21706. /**
  21707. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21708. */
  21709. uvs2: Nullable<FloatArray>;
  21710. /**
  21711. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21712. */
  21713. uvs3: Nullable<FloatArray>;
  21714. /**
  21715. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21716. */
  21717. uvs4: Nullable<FloatArray>;
  21718. /**
  21719. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21720. */
  21721. uvs5: Nullable<FloatArray>;
  21722. /**
  21723. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21724. */
  21725. uvs6: Nullable<FloatArray>;
  21726. /**
  21727. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21728. */
  21729. colors: Nullable<FloatArray>;
  21730. /**
  21731. * 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).
  21732. */
  21733. matricesIndices: Nullable<FloatArray>;
  21734. /**
  21735. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21736. */
  21737. matricesWeights: Nullable<FloatArray>;
  21738. /**
  21739. * An array extending the number of possible indices
  21740. */
  21741. matricesIndicesExtra: Nullable<FloatArray>;
  21742. /**
  21743. * An array extending the number of possible weights when the number of indices is extended
  21744. */
  21745. matricesWeightsExtra: Nullable<FloatArray>;
  21746. /**
  21747. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21748. */
  21749. indices: Nullable<IndicesArray>;
  21750. /**
  21751. * Uses the passed data array to set the set the values for the specified kind of data
  21752. * @param data a linear array of floating numbers
  21753. * @param kind the type of data that is being set, eg positions, colors etc
  21754. */
  21755. set(data: FloatArray, kind: string): void;
  21756. /**
  21757. * Associates the vertexData to the passed Mesh.
  21758. * Sets it as updatable or not (default `false`)
  21759. * @param mesh the mesh the vertexData is applied to
  21760. * @param updatable when used and having the value true allows new data to update the vertexData
  21761. * @returns the VertexData
  21762. */
  21763. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21764. /**
  21765. * Associates the vertexData to the passed Geometry.
  21766. * Sets it as updatable or not (default `false`)
  21767. * @param geometry the geometry the vertexData is applied to
  21768. * @param updatable when used and having the value true allows new data to update the vertexData
  21769. * @returns VertexData
  21770. */
  21771. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21772. /**
  21773. * Updates the associated mesh
  21774. * @param mesh the mesh to be updated
  21775. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21776. * @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
  21777. * @returns VertexData
  21778. */
  21779. updateMesh(mesh: Mesh): VertexData;
  21780. /**
  21781. * Updates the associated geometry
  21782. * @param geometry the geometry to be updated
  21783. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21784. * @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
  21785. * @returns VertexData.
  21786. */
  21787. updateGeometry(geometry: Geometry): VertexData;
  21788. private _applyTo;
  21789. private _update;
  21790. /**
  21791. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21792. * @param matrix the transforming matrix
  21793. * @returns the VertexData
  21794. */
  21795. transform(matrix: Matrix): VertexData;
  21796. /**
  21797. * Merges the passed VertexData into the current one
  21798. * @param other the VertexData to be merged into the current one
  21799. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  21800. * @returns the modified VertexData
  21801. */
  21802. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  21803. private _mergeElement;
  21804. private _validate;
  21805. /**
  21806. * Serializes the VertexData
  21807. * @returns a serialized object
  21808. */
  21809. serialize(): any;
  21810. /**
  21811. * Extracts the vertexData from a mesh
  21812. * @param mesh the mesh from which to extract the VertexData
  21813. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21814. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21815. * @returns the object VertexData associated to the passed mesh
  21816. */
  21817. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21818. /**
  21819. * Extracts the vertexData from the geometry
  21820. * @param geometry the geometry from which to extract the VertexData
  21821. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21822. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21823. * @returns the object VertexData associated to the passed mesh
  21824. */
  21825. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21826. private static _ExtractFrom;
  21827. /**
  21828. * Creates the VertexData for a Ribbon
  21829. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21830. * * pathArray array of paths, each of which an array of successive Vector3
  21831. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21832. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21833. * * 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
  21834. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21835. * * 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)
  21836. * * 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)
  21837. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21838. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21839. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21840. * @returns the VertexData of the ribbon
  21841. */
  21842. static CreateRibbon(options: {
  21843. pathArray: Vector3[][];
  21844. closeArray?: boolean;
  21845. closePath?: boolean;
  21846. offset?: number;
  21847. sideOrientation?: number;
  21848. frontUVs?: Vector4;
  21849. backUVs?: Vector4;
  21850. invertUV?: boolean;
  21851. uvs?: Vector2[];
  21852. colors?: Color4[];
  21853. }): VertexData;
  21854. /**
  21855. * Creates the VertexData for a box
  21856. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21857. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21858. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21859. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21860. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21861. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21862. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21863. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21864. * * 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)
  21865. * * 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)
  21866. * @returns the VertexData of the box
  21867. */
  21868. static CreateBox(options: {
  21869. size?: number;
  21870. width?: number;
  21871. height?: number;
  21872. depth?: number;
  21873. faceUV?: Vector4[];
  21874. faceColors?: Color4[];
  21875. sideOrientation?: number;
  21876. frontUVs?: Vector4;
  21877. backUVs?: Vector4;
  21878. }): VertexData;
  21879. /**
  21880. * Creates the VertexData for a tiled box
  21881. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21882. * * faceTiles sets the pattern, tile size and number of tiles for a face
  21883. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21884. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21885. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21886. * @returns the VertexData of the box
  21887. */
  21888. static CreateTiledBox(options: {
  21889. pattern?: number;
  21890. width?: number;
  21891. height?: number;
  21892. depth?: number;
  21893. tileSize?: number;
  21894. tileWidth?: number;
  21895. tileHeight?: number;
  21896. alignHorizontal?: number;
  21897. alignVertical?: number;
  21898. faceUV?: Vector4[];
  21899. faceColors?: Color4[];
  21900. sideOrientation?: number;
  21901. }): VertexData;
  21902. /**
  21903. * Creates the VertexData for a tiled plane
  21904. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21905. * * pattern a limited pattern arrangement depending on the number
  21906. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  21907. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  21908. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  21909. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21910. * * 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)
  21911. * * 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)
  21912. * @returns the VertexData of the tiled plane
  21913. */
  21914. static CreateTiledPlane(options: {
  21915. pattern?: number;
  21916. tileSize?: number;
  21917. tileWidth?: number;
  21918. tileHeight?: number;
  21919. size?: number;
  21920. width?: number;
  21921. height?: number;
  21922. alignHorizontal?: number;
  21923. alignVertical?: number;
  21924. sideOrientation?: number;
  21925. frontUVs?: Vector4;
  21926. backUVs?: Vector4;
  21927. }): VertexData;
  21928. /**
  21929. * Creates the VertexData for an ellipsoid, defaults to a sphere
  21930. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21931. * * segments sets the number of horizontal strips optional, default 32
  21932. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  21933. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  21934. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  21935. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  21936. * * 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
  21937. * * 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
  21938. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21939. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  21940. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  21941. * @returns the VertexData of the ellipsoid
  21942. */
  21943. static CreateSphere(options: {
  21944. segments?: number;
  21945. diameter?: number;
  21946. diameterX?: number;
  21947. diameterY?: number;
  21948. diameterZ?: number;
  21949. arc?: number;
  21950. slice?: number;
  21951. sideOrientation?: number;
  21952. frontUVs?: Vector4;
  21953. backUVs?: Vector4;
  21954. }): VertexData;
  21955. /**
  21956. * Creates the VertexData for a cylinder, cone or prism
  21957. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21958. * * height sets the height (y direction) of the cylinder, optional, default 2
  21959. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  21960. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  21961. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  21962. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21963. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  21964. * * 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
  21965. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21966. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21967. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  21968. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  21969. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21970. * * 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)
  21971. * * 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)
  21972. * @returns the VertexData of the cylinder, cone or prism
  21973. */
  21974. static CreateCylinder(options: {
  21975. height?: number;
  21976. diameterTop?: number;
  21977. diameterBottom?: number;
  21978. diameter?: number;
  21979. tessellation?: number;
  21980. subdivisions?: number;
  21981. arc?: number;
  21982. faceColors?: Color4[];
  21983. faceUV?: Vector4[];
  21984. hasRings?: boolean;
  21985. enclose?: boolean;
  21986. sideOrientation?: number;
  21987. frontUVs?: Vector4;
  21988. backUVs?: Vector4;
  21989. }): VertexData;
  21990. /**
  21991. * Creates the VertexData for a torus
  21992. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21993. * * diameter the diameter of the torus, optional default 1
  21994. * * thickness the diameter of the tube forming the torus, optional default 0.5
  21995. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21996. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21997. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  21998. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  21999. * @returns the VertexData of the torus
  22000. */
  22001. static CreateTorus(options: {
  22002. diameter?: number;
  22003. thickness?: number;
  22004. tessellation?: number;
  22005. sideOrientation?: number;
  22006. frontUVs?: Vector4;
  22007. backUVs?: Vector4;
  22008. }): VertexData;
  22009. /**
  22010. * Creates the VertexData of the LineSystem
  22011. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22012. * - lines an array of lines, each line being an array of successive Vector3
  22013. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22014. * @returns the VertexData of the LineSystem
  22015. */
  22016. static CreateLineSystem(options: {
  22017. lines: Vector3[][];
  22018. colors?: Nullable<Color4[][]>;
  22019. }): VertexData;
  22020. /**
  22021. * Create the VertexData for a DashedLines
  22022. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22023. * - points an array successive Vector3
  22024. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22025. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22026. * - dashNb the intended total number of dashes, optional, default 200
  22027. * @returns the VertexData for the DashedLines
  22028. */
  22029. static CreateDashedLines(options: {
  22030. points: Vector3[];
  22031. dashSize?: number;
  22032. gapSize?: number;
  22033. dashNb?: number;
  22034. }): VertexData;
  22035. /**
  22036. * Creates the VertexData for a Ground
  22037. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22038. * - width the width (x direction) of the ground, optional, default 1
  22039. * - height the height (z direction) of the ground, optional, default 1
  22040. * - subdivisions the number of subdivisions per side, optional, default 1
  22041. * @returns the VertexData of the Ground
  22042. */
  22043. static CreateGround(options: {
  22044. width?: number;
  22045. height?: number;
  22046. subdivisions?: number;
  22047. subdivisionsX?: number;
  22048. subdivisionsY?: number;
  22049. }): VertexData;
  22050. /**
  22051. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22052. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22053. * * xmin the ground minimum X coordinate, optional, default -1
  22054. * * zmin the ground minimum Z coordinate, optional, default -1
  22055. * * xmax the ground maximum X coordinate, optional, default 1
  22056. * * zmax the ground maximum Z coordinate, optional, default 1
  22057. * * 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}
  22058. * * 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}
  22059. * @returns the VertexData of the TiledGround
  22060. */
  22061. static CreateTiledGround(options: {
  22062. xmin: number;
  22063. zmin: number;
  22064. xmax: number;
  22065. zmax: number;
  22066. subdivisions?: {
  22067. w: number;
  22068. h: number;
  22069. };
  22070. precision?: {
  22071. w: number;
  22072. h: number;
  22073. };
  22074. }): VertexData;
  22075. /**
  22076. * Creates the VertexData of the Ground designed from a heightmap
  22077. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22078. * * width the width (x direction) of the ground
  22079. * * height the height (z direction) of the ground
  22080. * * subdivisions the number of subdivisions per side
  22081. * * minHeight the minimum altitude on the ground, optional, default 0
  22082. * * maxHeight the maximum altitude on the ground, optional default 1
  22083. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22084. * * buffer the array holding the image color data
  22085. * * bufferWidth the width of image
  22086. * * bufferHeight the height of image
  22087. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22088. * @returns the VertexData of the Ground designed from a heightmap
  22089. */
  22090. static CreateGroundFromHeightMap(options: {
  22091. width: number;
  22092. height: number;
  22093. subdivisions: number;
  22094. minHeight: number;
  22095. maxHeight: number;
  22096. colorFilter: Color3;
  22097. buffer: Uint8Array;
  22098. bufferWidth: number;
  22099. bufferHeight: number;
  22100. alphaFilter: number;
  22101. }): VertexData;
  22102. /**
  22103. * Creates the VertexData for a Plane
  22104. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22105. * * size sets the width and height of the plane to the value of size, optional default 1
  22106. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22107. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22108. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22109. * * 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)
  22110. * * 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)
  22111. * @returns the VertexData of the box
  22112. */
  22113. static CreatePlane(options: {
  22114. size?: number;
  22115. width?: number;
  22116. height?: number;
  22117. sideOrientation?: number;
  22118. frontUVs?: Vector4;
  22119. backUVs?: Vector4;
  22120. }): VertexData;
  22121. /**
  22122. * Creates the VertexData of the Disc or regular Polygon
  22123. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22124. * * radius the radius of the disc, optional default 0.5
  22125. * * tessellation the number of polygon sides, optional, default 64
  22126. * * 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
  22127. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22128. * * 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)
  22129. * * 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)
  22130. * @returns the VertexData of the box
  22131. */
  22132. static CreateDisc(options: {
  22133. radius?: number;
  22134. tessellation?: number;
  22135. arc?: number;
  22136. sideOrientation?: number;
  22137. frontUVs?: Vector4;
  22138. backUVs?: Vector4;
  22139. }): VertexData;
  22140. /**
  22141. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22142. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22143. * @param polygon a mesh built from polygonTriangulation.build()
  22144. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22145. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22146. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22147. * @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)
  22148. * @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)
  22149. * @returns the VertexData of the Polygon
  22150. */
  22151. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22152. /**
  22153. * Creates the VertexData of the IcoSphere
  22154. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22155. * * radius the radius of the IcoSphere, optional default 1
  22156. * * radiusX allows stretching in the x direction, optional, default radius
  22157. * * radiusY allows stretching in the y direction, optional, default radius
  22158. * * radiusZ allows stretching in the z direction, optional, default radius
  22159. * * flat when true creates a flat shaded mesh, optional, default true
  22160. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22161. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22162. * * 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)
  22163. * * 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)
  22164. * @returns the VertexData of the IcoSphere
  22165. */
  22166. static CreateIcoSphere(options: {
  22167. radius?: number;
  22168. radiusX?: number;
  22169. radiusY?: number;
  22170. radiusZ?: number;
  22171. flat?: boolean;
  22172. subdivisions?: number;
  22173. sideOrientation?: number;
  22174. frontUVs?: Vector4;
  22175. backUVs?: Vector4;
  22176. }): VertexData;
  22177. /**
  22178. * Creates the VertexData for a Polyhedron
  22179. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22180. * * type provided types are:
  22181. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22182. * * 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)
  22183. * * size the size of the IcoSphere, optional default 1
  22184. * * sizeX allows stretching in the x direction, optional, default size
  22185. * * sizeY allows stretching in the y direction, optional, default size
  22186. * * sizeZ allows stretching in the z direction, optional, default size
  22187. * * 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
  22188. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22189. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22190. * * flat when true creates a flat shaded mesh, optional, default true
  22191. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22192. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22193. * * 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)
  22194. * * 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)
  22195. * @returns the VertexData of the Polyhedron
  22196. */
  22197. static CreatePolyhedron(options: {
  22198. type?: number;
  22199. size?: number;
  22200. sizeX?: number;
  22201. sizeY?: number;
  22202. sizeZ?: number;
  22203. custom?: any;
  22204. faceUV?: Vector4[];
  22205. faceColors?: Color4[];
  22206. flat?: boolean;
  22207. sideOrientation?: number;
  22208. frontUVs?: Vector4;
  22209. backUVs?: Vector4;
  22210. }): VertexData;
  22211. /**
  22212. * Creates the VertexData for a TorusKnot
  22213. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22214. * * radius the radius of the torus knot, optional, default 2
  22215. * * tube the thickness of the tube, optional, default 0.5
  22216. * * radialSegments the number of sides on each tube segments, optional, default 32
  22217. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22218. * * p the number of windings around the z axis, optional, default 2
  22219. * * q the number of windings around the x axis, optional, default 3
  22220. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22221. * * 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)
  22222. * * 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)
  22223. * @returns the VertexData of the Torus Knot
  22224. */
  22225. static CreateTorusKnot(options: {
  22226. radius?: number;
  22227. tube?: number;
  22228. radialSegments?: number;
  22229. tubularSegments?: number;
  22230. p?: number;
  22231. q?: number;
  22232. sideOrientation?: number;
  22233. frontUVs?: Vector4;
  22234. backUVs?: Vector4;
  22235. }): VertexData;
  22236. /**
  22237. * Compute normals for given positions and indices
  22238. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22239. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22240. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22241. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22242. * * facetNormals : optional array of facet normals (vector3)
  22243. * * facetPositions : optional array of facet positions (vector3)
  22244. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22245. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22246. * * bInfo : optional bounding info, required for facetPartitioning computation
  22247. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22248. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22249. * * useRightHandedSystem: optional boolean to for right handed system computation
  22250. * * depthSort : optional boolean to enable the facet depth sort computation
  22251. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22252. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22253. */
  22254. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22255. facetNormals?: any;
  22256. facetPositions?: any;
  22257. facetPartitioning?: any;
  22258. ratio?: number;
  22259. bInfo?: any;
  22260. bbSize?: Vector3;
  22261. subDiv?: any;
  22262. useRightHandedSystem?: boolean;
  22263. depthSort?: boolean;
  22264. distanceTo?: Vector3;
  22265. depthSortedFacets?: any;
  22266. }): void;
  22267. /** @hidden */
  22268. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22269. /**
  22270. * Applies VertexData created from the imported parameters to the geometry
  22271. * @param parsedVertexData the parsed data from an imported file
  22272. * @param geometry the geometry to apply the VertexData to
  22273. */
  22274. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22275. }
  22276. }
  22277. declare module BABYLON {
  22278. /**
  22279. * Defines a target to use with MorphTargetManager
  22280. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22281. */
  22282. export class MorphTarget implements IAnimatable {
  22283. /** defines the name of the target */
  22284. name: string;
  22285. /**
  22286. * Gets or sets the list of animations
  22287. */
  22288. animations: Animation[];
  22289. private _scene;
  22290. private _positions;
  22291. private _normals;
  22292. private _tangents;
  22293. private _uvs;
  22294. private _influence;
  22295. private _uniqueId;
  22296. /**
  22297. * Observable raised when the influence changes
  22298. */
  22299. onInfluenceChanged: Observable<boolean>;
  22300. /** @hidden */
  22301. _onDataLayoutChanged: Observable<void>;
  22302. /**
  22303. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22304. */
  22305. influence: number;
  22306. /**
  22307. * Gets or sets the id of the morph Target
  22308. */
  22309. id: string;
  22310. private _animationPropertiesOverride;
  22311. /**
  22312. * Gets or sets the animation properties override
  22313. */
  22314. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22315. /**
  22316. * Creates a new MorphTarget
  22317. * @param name defines the name of the target
  22318. * @param influence defines the influence to use
  22319. * @param scene defines the scene the morphtarget belongs to
  22320. */
  22321. constructor(
  22322. /** defines the name of the target */
  22323. name: string, influence?: number, scene?: Nullable<Scene>);
  22324. /**
  22325. * Gets the unique ID of this manager
  22326. */
  22327. readonly uniqueId: number;
  22328. /**
  22329. * Gets a boolean defining if the target contains position data
  22330. */
  22331. readonly hasPositions: boolean;
  22332. /**
  22333. * Gets a boolean defining if the target contains normal data
  22334. */
  22335. readonly hasNormals: boolean;
  22336. /**
  22337. * Gets a boolean defining if the target contains tangent data
  22338. */
  22339. readonly hasTangents: boolean;
  22340. /**
  22341. * Gets a boolean defining if the target contains texture coordinates data
  22342. */
  22343. readonly hasUVs: boolean;
  22344. /**
  22345. * Affects position data to this target
  22346. * @param data defines the position data to use
  22347. */
  22348. setPositions(data: Nullable<FloatArray>): void;
  22349. /**
  22350. * Gets the position data stored in this target
  22351. * @returns a FloatArray containing the position data (or null if not present)
  22352. */
  22353. getPositions(): Nullable<FloatArray>;
  22354. /**
  22355. * Affects normal data to this target
  22356. * @param data defines the normal data to use
  22357. */
  22358. setNormals(data: Nullable<FloatArray>): void;
  22359. /**
  22360. * Gets the normal data stored in this target
  22361. * @returns a FloatArray containing the normal data (or null if not present)
  22362. */
  22363. getNormals(): Nullable<FloatArray>;
  22364. /**
  22365. * Affects tangent data to this target
  22366. * @param data defines the tangent data to use
  22367. */
  22368. setTangents(data: Nullable<FloatArray>): void;
  22369. /**
  22370. * Gets the tangent data stored in this target
  22371. * @returns a FloatArray containing the tangent data (or null if not present)
  22372. */
  22373. getTangents(): Nullable<FloatArray>;
  22374. /**
  22375. * Affects texture coordinates data to this target
  22376. * @param data defines the texture coordinates data to use
  22377. */
  22378. setUVs(data: Nullable<FloatArray>): void;
  22379. /**
  22380. * Gets the texture coordinates data stored in this target
  22381. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22382. */
  22383. getUVs(): Nullable<FloatArray>;
  22384. /**
  22385. * Clone the current target
  22386. * @returns a new MorphTarget
  22387. */
  22388. clone(): MorphTarget;
  22389. /**
  22390. * Serializes the current target into a Serialization object
  22391. * @returns the serialized object
  22392. */
  22393. serialize(): any;
  22394. /**
  22395. * Returns the string "MorphTarget"
  22396. * @returns "MorphTarget"
  22397. */
  22398. getClassName(): string;
  22399. /**
  22400. * Creates a new target from serialized data
  22401. * @param serializationObject defines the serialized data to use
  22402. * @returns a new MorphTarget
  22403. */
  22404. static Parse(serializationObject: any): MorphTarget;
  22405. /**
  22406. * Creates a MorphTarget from mesh data
  22407. * @param mesh defines the source mesh
  22408. * @param name defines the name to use for the new target
  22409. * @param influence defines the influence to attach to the target
  22410. * @returns a new MorphTarget
  22411. */
  22412. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22413. }
  22414. }
  22415. declare module BABYLON {
  22416. /**
  22417. * This class is used to deform meshes using morphing between different targets
  22418. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22419. */
  22420. export class MorphTargetManager {
  22421. private _targets;
  22422. private _targetInfluenceChangedObservers;
  22423. private _targetDataLayoutChangedObservers;
  22424. private _activeTargets;
  22425. private _scene;
  22426. private _influences;
  22427. private _supportsNormals;
  22428. private _supportsTangents;
  22429. private _supportsUVs;
  22430. private _vertexCount;
  22431. private _uniqueId;
  22432. private _tempInfluences;
  22433. /**
  22434. * Gets or sets a boolean indicating if normals must be morphed
  22435. */
  22436. enableNormalMorphing: boolean;
  22437. /**
  22438. * Gets or sets a boolean indicating if tangents must be morphed
  22439. */
  22440. enableTangentMorphing: boolean;
  22441. /**
  22442. * Gets or sets a boolean indicating if UV must be morphed
  22443. */
  22444. enableUVMorphing: boolean;
  22445. /**
  22446. * Creates a new MorphTargetManager
  22447. * @param scene defines the current scene
  22448. */
  22449. constructor(scene?: Nullable<Scene>);
  22450. /**
  22451. * Gets the unique ID of this manager
  22452. */
  22453. readonly uniqueId: number;
  22454. /**
  22455. * Gets the number of vertices handled by this manager
  22456. */
  22457. readonly vertexCount: number;
  22458. /**
  22459. * Gets a boolean indicating if this manager supports morphing of normals
  22460. */
  22461. readonly supportsNormals: boolean;
  22462. /**
  22463. * Gets a boolean indicating if this manager supports morphing of tangents
  22464. */
  22465. readonly supportsTangents: boolean;
  22466. /**
  22467. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22468. */
  22469. readonly supportsUVs: boolean;
  22470. /**
  22471. * Gets the number of targets stored in this manager
  22472. */
  22473. readonly numTargets: number;
  22474. /**
  22475. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22476. */
  22477. readonly numInfluencers: number;
  22478. /**
  22479. * Gets the list of influences (one per target)
  22480. */
  22481. readonly influences: Float32Array;
  22482. /**
  22483. * Gets the active target at specified index. An active target is a target with an influence > 0
  22484. * @param index defines the index to check
  22485. * @returns the requested target
  22486. */
  22487. getActiveTarget(index: number): MorphTarget;
  22488. /**
  22489. * Gets the target at specified index
  22490. * @param index defines the index to check
  22491. * @returns the requested target
  22492. */
  22493. getTarget(index: number): MorphTarget;
  22494. /**
  22495. * Add a new target to this manager
  22496. * @param target defines the target to add
  22497. */
  22498. addTarget(target: MorphTarget): void;
  22499. /**
  22500. * Removes a target from the manager
  22501. * @param target defines the target to remove
  22502. */
  22503. removeTarget(target: MorphTarget): void;
  22504. /**
  22505. * Clone the current manager
  22506. * @returns a new MorphTargetManager
  22507. */
  22508. clone(): MorphTargetManager;
  22509. /**
  22510. * Serializes the current manager into a Serialization object
  22511. * @returns the serialized object
  22512. */
  22513. serialize(): any;
  22514. private _syncActiveTargets;
  22515. /**
  22516. * Syncrhonize the targets with all the meshes using this morph target manager
  22517. */
  22518. synchronize(): void;
  22519. /**
  22520. * Creates a new MorphTargetManager from serialized data
  22521. * @param serializationObject defines the serialized data
  22522. * @param scene defines the hosting scene
  22523. * @returns the new MorphTargetManager
  22524. */
  22525. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22526. }
  22527. }
  22528. declare module BABYLON {
  22529. /**
  22530. * Class used to represent a specific level of detail of a mesh
  22531. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22532. */
  22533. export class MeshLODLevel {
  22534. /** Defines the distance where this level should start being displayed */
  22535. distance: number;
  22536. /** Defines the mesh to use to render this level */
  22537. mesh: Nullable<Mesh>;
  22538. /**
  22539. * Creates a new LOD level
  22540. * @param distance defines the distance where this level should star being displayed
  22541. * @param mesh defines the mesh to use to render this level
  22542. */
  22543. constructor(
  22544. /** Defines the distance where this level should start being displayed */
  22545. distance: number,
  22546. /** Defines the mesh to use to render this level */
  22547. mesh: Nullable<Mesh>);
  22548. }
  22549. }
  22550. declare module BABYLON {
  22551. /**
  22552. * Mesh representing the gorund
  22553. */
  22554. export class GroundMesh extends Mesh {
  22555. /** If octree should be generated */
  22556. generateOctree: boolean;
  22557. private _heightQuads;
  22558. /** @hidden */
  22559. _subdivisionsX: number;
  22560. /** @hidden */
  22561. _subdivisionsY: number;
  22562. /** @hidden */
  22563. _width: number;
  22564. /** @hidden */
  22565. _height: number;
  22566. /** @hidden */
  22567. _minX: number;
  22568. /** @hidden */
  22569. _maxX: number;
  22570. /** @hidden */
  22571. _minZ: number;
  22572. /** @hidden */
  22573. _maxZ: number;
  22574. constructor(name: string, scene: Scene);
  22575. /**
  22576. * "GroundMesh"
  22577. * @returns "GroundMesh"
  22578. */
  22579. getClassName(): string;
  22580. /**
  22581. * The minimum of x and y subdivisions
  22582. */
  22583. readonly subdivisions: number;
  22584. /**
  22585. * X subdivisions
  22586. */
  22587. readonly subdivisionsX: number;
  22588. /**
  22589. * Y subdivisions
  22590. */
  22591. readonly subdivisionsY: number;
  22592. /**
  22593. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22594. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22595. * @param chunksCount the number of subdivisions for x and y
  22596. * @param octreeBlocksSize (Default: 32)
  22597. */
  22598. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22599. /**
  22600. * Returns a height (y) value in the Worl system :
  22601. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22602. * @param x x coordinate
  22603. * @param z z coordinate
  22604. * @returns the ground y position if (x, z) are outside the ground surface.
  22605. */
  22606. getHeightAtCoordinates(x: number, z: number): number;
  22607. /**
  22608. * Returns a normalized vector (Vector3) orthogonal to the ground
  22609. * at the ground coordinates (x, z) expressed in the World system.
  22610. * @param x x coordinate
  22611. * @param z z coordinate
  22612. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22613. */
  22614. getNormalAtCoordinates(x: number, z: number): Vector3;
  22615. /**
  22616. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22617. * at the ground coordinates (x, z) expressed in the World system.
  22618. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22619. * @param x x coordinate
  22620. * @param z z coordinate
  22621. * @param ref vector to store the result
  22622. * @returns the GroundMesh.
  22623. */
  22624. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22625. /**
  22626. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22627. * if the ground has been updated.
  22628. * This can be used in the render loop.
  22629. * @returns the GroundMesh.
  22630. */
  22631. updateCoordinateHeights(): GroundMesh;
  22632. private _getFacetAt;
  22633. private _initHeightQuads;
  22634. private _computeHeightQuads;
  22635. /**
  22636. * Serializes this ground mesh
  22637. * @param serializationObject object to write serialization to
  22638. */
  22639. serialize(serializationObject: any): void;
  22640. /**
  22641. * Parses a serialized ground mesh
  22642. * @param parsedMesh the serialized mesh
  22643. * @param scene the scene to create the ground mesh in
  22644. * @returns the created ground mesh
  22645. */
  22646. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22647. }
  22648. }
  22649. declare module BABYLON {
  22650. /**
  22651. * Interface for Physics-Joint data
  22652. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22653. */
  22654. export interface PhysicsJointData {
  22655. /**
  22656. * The main pivot of the joint
  22657. */
  22658. mainPivot?: Vector3;
  22659. /**
  22660. * The connected pivot of the joint
  22661. */
  22662. connectedPivot?: Vector3;
  22663. /**
  22664. * The main axis of the joint
  22665. */
  22666. mainAxis?: Vector3;
  22667. /**
  22668. * The connected axis of the joint
  22669. */
  22670. connectedAxis?: Vector3;
  22671. /**
  22672. * The collision of the joint
  22673. */
  22674. collision?: boolean;
  22675. /**
  22676. * Native Oimo/Cannon/Energy data
  22677. */
  22678. nativeParams?: any;
  22679. }
  22680. /**
  22681. * This is a holder class for the physics joint created by the physics plugin
  22682. * It holds a set of functions to control the underlying joint
  22683. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22684. */
  22685. export class PhysicsJoint {
  22686. /**
  22687. * The type of the physics joint
  22688. */
  22689. type: number;
  22690. /**
  22691. * The data for the physics joint
  22692. */
  22693. jointData: PhysicsJointData;
  22694. private _physicsJoint;
  22695. protected _physicsPlugin: IPhysicsEnginePlugin;
  22696. /**
  22697. * Initializes the physics joint
  22698. * @param type The type of the physics joint
  22699. * @param jointData The data for the physics joint
  22700. */
  22701. constructor(
  22702. /**
  22703. * The type of the physics joint
  22704. */
  22705. type: number,
  22706. /**
  22707. * The data for the physics joint
  22708. */
  22709. jointData: PhysicsJointData);
  22710. /**
  22711. * Gets the physics joint
  22712. */
  22713. /**
  22714. * Sets the physics joint
  22715. */
  22716. physicsJoint: any;
  22717. /**
  22718. * Sets the physics plugin
  22719. */
  22720. physicsPlugin: IPhysicsEnginePlugin;
  22721. /**
  22722. * Execute a function that is physics-plugin specific.
  22723. * @param {Function} func the function that will be executed.
  22724. * It accepts two parameters: the physics world and the physics joint
  22725. */
  22726. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  22727. /**
  22728. * Distance-Joint type
  22729. */
  22730. static DistanceJoint: number;
  22731. /**
  22732. * Hinge-Joint type
  22733. */
  22734. static HingeJoint: number;
  22735. /**
  22736. * Ball-and-Socket joint type
  22737. */
  22738. static BallAndSocketJoint: number;
  22739. /**
  22740. * Wheel-Joint type
  22741. */
  22742. static WheelJoint: number;
  22743. /**
  22744. * Slider-Joint type
  22745. */
  22746. static SliderJoint: number;
  22747. /**
  22748. * Prismatic-Joint type
  22749. */
  22750. static PrismaticJoint: number;
  22751. /**
  22752. * Universal-Joint type
  22753. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  22754. */
  22755. static UniversalJoint: number;
  22756. /**
  22757. * Hinge-Joint 2 type
  22758. */
  22759. static Hinge2Joint: number;
  22760. /**
  22761. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  22762. */
  22763. static PointToPointJoint: number;
  22764. /**
  22765. * Spring-Joint type
  22766. */
  22767. static SpringJoint: number;
  22768. /**
  22769. * Lock-Joint type
  22770. */
  22771. static LockJoint: number;
  22772. }
  22773. /**
  22774. * A class representing a physics distance joint
  22775. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22776. */
  22777. export class DistanceJoint extends PhysicsJoint {
  22778. /**
  22779. *
  22780. * @param jointData The data for the Distance-Joint
  22781. */
  22782. constructor(jointData: DistanceJointData);
  22783. /**
  22784. * Update the predefined distance.
  22785. * @param maxDistance The maximum preferred distance
  22786. * @param minDistance The minimum preferred distance
  22787. */
  22788. updateDistance(maxDistance: number, minDistance?: number): void;
  22789. }
  22790. /**
  22791. * Represents a Motor-Enabled Joint
  22792. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22793. */
  22794. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  22795. /**
  22796. * Initializes the Motor-Enabled Joint
  22797. * @param type The type of the joint
  22798. * @param jointData The physica joint data for the joint
  22799. */
  22800. constructor(type: number, jointData: PhysicsJointData);
  22801. /**
  22802. * Set the motor values.
  22803. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22804. * @param force the force to apply
  22805. * @param maxForce max force for this motor.
  22806. */
  22807. setMotor(force?: number, maxForce?: number): void;
  22808. /**
  22809. * Set the motor's limits.
  22810. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22811. * @param upperLimit The upper limit of the motor
  22812. * @param lowerLimit The lower limit of the motor
  22813. */
  22814. setLimit(upperLimit: number, lowerLimit?: number): void;
  22815. }
  22816. /**
  22817. * This class represents a single physics Hinge-Joint
  22818. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22819. */
  22820. export class HingeJoint extends MotorEnabledJoint {
  22821. /**
  22822. * Initializes the Hinge-Joint
  22823. * @param jointData The joint data for the Hinge-Joint
  22824. */
  22825. constructor(jointData: PhysicsJointData);
  22826. /**
  22827. * Set the motor values.
  22828. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22829. * @param {number} force the force to apply
  22830. * @param {number} maxForce max force for this motor.
  22831. */
  22832. setMotor(force?: number, maxForce?: number): void;
  22833. /**
  22834. * Set the motor's limits.
  22835. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22836. * @param upperLimit The upper limit of the motor
  22837. * @param lowerLimit The lower limit of the motor
  22838. */
  22839. setLimit(upperLimit: number, lowerLimit?: number): void;
  22840. }
  22841. /**
  22842. * This class represents a dual hinge physics joint (same as wheel joint)
  22843. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22844. */
  22845. export class Hinge2Joint extends MotorEnabledJoint {
  22846. /**
  22847. * Initializes the Hinge2-Joint
  22848. * @param jointData The joint data for the Hinge2-Joint
  22849. */
  22850. constructor(jointData: PhysicsJointData);
  22851. /**
  22852. * Set the motor values.
  22853. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22854. * @param {number} targetSpeed the speed the motor is to reach
  22855. * @param {number} maxForce max force for this motor.
  22856. * @param {motorIndex} the motor's index, 0 or 1.
  22857. */
  22858. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  22859. /**
  22860. * Set the motor limits.
  22861. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22862. * @param {number} upperLimit the upper limit
  22863. * @param {number} lowerLimit lower limit
  22864. * @param {motorIndex} the motor's index, 0 or 1.
  22865. */
  22866. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22867. }
  22868. /**
  22869. * Interface for a motor enabled joint
  22870. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22871. */
  22872. export interface IMotorEnabledJoint {
  22873. /**
  22874. * Physics joint
  22875. */
  22876. physicsJoint: any;
  22877. /**
  22878. * Sets the motor of the motor-enabled joint
  22879. * @param force The force of the motor
  22880. * @param maxForce The maximum force of the motor
  22881. * @param motorIndex The index of the motor
  22882. */
  22883. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  22884. /**
  22885. * Sets the limit of the motor
  22886. * @param upperLimit The upper limit of the motor
  22887. * @param lowerLimit The lower limit of the motor
  22888. * @param motorIndex The index of the motor
  22889. */
  22890. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22891. }
  22892. /**
  22893. * Joint data for a Distance-Joint
  22894. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22895. */
  22896. export interface DistanceJointData extends PhysicsJointData {
  22897. /**
  22898. * Max distance the 2 joint objects can be apart
  22899. */
  22900. maxDistance: number;
  22901. }
  22902. /**
  22903. * Joint data from a spring joint
  22904. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22905. */
  22906. export interface SpringJointData extends PhysicsJointData {
  22907. /**
  22908. * Length of the spring
  22909. */
  22910. length: number;
  22911. /**
  22912. * Stiffness of the spring
  22913. */
  22914. stiffness: number;
  22915. /**
  22916. * Damping of the spring
  22917. */
  22918. damping: number;
  22919. /** this callback will be called when applying the force to the impostors. */
  22920. forceApplicationCallback: () => void;
  22921. }
  22922. }
  22923. declare module BABYLON {
  22924. /**
  22925. * Holds the data for the raycast result
  22926. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22927. */
  22928. export class PhysicsRaycastResult {
  22929. private _hasHit;
  22930. private _hitDistance;
  22931. private _hitNormalWorld;
  22932. private _hitPointWorld;
  22933. private _rayFromWorld;
  22934. private _rayToWorld;
  22935. /**
  22936. * Gets if there was a hit
  22937. */
  22938. readonly hasHit: boolean;
  22939. /**
  22940. * Gets the distance from the hit
  22941. */
  22942. readonly hitDistance: number;
  22943. /**
  22944. * Gets the hit normal/direction in the world
  22945. */
  22946. readonly hitNormalWorld: Vector3;
  22947. /**
  22948. * Gets the hit point in the world
  22949. */
  22950. readonly hitPointWorld: Vector3;
  22951. /**
  22952. * Gets the ray "start point" of the ray in the world
  22953. */
  22954. readonly rayFromWorld: Vector3;
  22955. /**
  22956. * Gets the ray "end point" of the ray in the world
  22957. */
  22958. readonly rayToWorld: Vector3;
  22959. /**
  22960. * Sets the hit data (normal & point in world space)
  22961. * @param hitNormalWorld defines the normal in world space
  22962. * @param hitPointWorld defines the point in world space
  22963. */
  22964. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  22965. /**
  22966. * Sets the distance from the start point to the hit point
  22967. * @param distance
  22968. */
  22969. setHitDistance(distance: number): void;
  22970. /**
  22971. * Calculates the distance manually
  22972. */
  22973. calculateHitDistance(): void;
  22974. /**
  22975. * Resets all the values to default
  22976. * @param from The from point on world space
  22977. * @param to The to point on world space
  22978. */
  22979. reset(from?: Vector3, to?: Vector3): void;
  22980. }
  22981. /**
  22982. * Interface for the size containing width and height
  22983. */
  22984. interface IXYZ {
  22985. /**
  22986. * X
  22987. */
  22988. x: number;
  22989. /**
  22990. * Y
  22991. */
  22992. y: number;
  22993. /**
  22994. * Z
  22995. */
  22996. z: number;
  22997. }
  22998. }
  22999. declare module BABYLON {
  23000. /**
  23001. * Interface used to describe a physics joint
  23002. */
  23003. export interface PhysicsImpostorJoint {
  23004. /** Defines the main impostor to which the joint is linked */
  23005. mainImpostor: PhysicsImpostor;
  23006. /** Defines the impostor that is connected to the main impostor using this joint */
  23007. connectedImpostor: PhysicsImpostor;
  23008. /** Defines the joint itself */
  23009. joint: PhysicsJoint;
  23010. }
  23011. /** @hidden */
  23012. export interface IPhysicsEnginePlugin {
  23013. world: any;
  23014. name: string;
  23015. setGravity(gravity: Vector3): void;
  23016. setTimeStep(timeStep: number): void;
  23017. getTimeStep(): number;
  23018. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23019. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23020. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23021. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23022. removePhysicsBody(impostor: PhysicsImpostor): void;
  23023. generateJoint(joint: PhysicsImpostorJoint): void;
  23024. removeJoint(joint: PhysicsImpostorJoint): void;
  23025. isSupported(): boolean;
  23026. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23027. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23028. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23029. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23030. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23031. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23032. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23033. getBodyMass(impostor: PhysicsImpostor): number;
  23034. getBodyFriction(impostor: PhysicsImpostor): number;
  23035. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23036. getBodyRestitution(impostor: PhysicsImpostor): number;
  23037. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23038. getBodyPressure?(impostor: PhysicsImpostor): number;
  23039. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23040. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23041. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23042. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23043. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23044. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23045. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23046. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23047. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23048. sleepBody(impostor: PhysicsImpostor): void;
  23049. wakeUpBody(impostor: PhysicsImpostor): void;
  23050. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23051. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23052. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23053. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23054. getRadius(impostor: PhysicsImpostor): number;
  23055. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23056. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23057. dispose(): void;
  23058. }
  23059. /**
  23060. * Interface used to define a physics engine
  23061. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23062. */
  23063. export interface IPhysicsEngine {
  23064. /**
  23065. * Gets the gravity vector used by the simulation
  23066. */
  23067. gravity: Vector3;
  23068. /**
  23069. * Sets the gravity vector used by the simulation
  23070. * @param gravity defines the gravity vector to use
  23071. */
  23072. setGravity(gravity: Vector3): void;
  23073. /**
  23074. * Set the time step of the physics engine.
  23075. * Default is 1/60.
  23076. * To slow it down, enter 1/600 for example.
  23077. * To speed it up, 1/30
  23078. * @param newTimeStep the new timestep to apply to this world.
  23079. */
  23080. setTimeStep(newTimeStep: number): void;
  23081. /**
  23082. * Get the time step of the physics engine.
  23083. * @returns the current time step
  23084. */
  23085. getTimeStep(): number;
  23086. /**
  23087. * Set the sub time step of the physics engine.
  23088. * Default is 0 meaning there is no sub steps
  23089. * To increase physics resolution precision, set a small value (like 1 ms)
  23090. * @param subTimeStep defines the new sub timestep used for physics resolution.
  23091. */
  23092. setSubTimeStep(subTimeStep: number): void;
  23093. /**
  23094. * Get the sub time step of the physics engine.
  23095. * @returns the current sub time step
  23096. */
  23097. getSubTimeStep(): number;
  23098. /**
  23099. * Release all resources
  23100. */
  23101. dispose(): void;
  23102. /**
  23103. * Gets the name of the current physics plugin
  23104. * @returns the name of the plugin
  23105. */
  23106. getPhysicsPluginName(): string;
  23107. /**
  23108. * Adding a new impostor for the impostor tracking.
  23109. * This will be done by the impostor itself.
  23110. * @param impostor the impostor to add
  23111. */
  23112. addImpostor(impostor: PhysicsImpostor): void;
  23113. /**
  23114. * Remove an impostor from the engine.
  23115. * This impostor and its mesh will not longer be updated by the physics engine.
  23116. * @param impostor the impostor to remove
  23117. */
  23118. removeImpostor(impostor: PhysicsImpostor): void;
  23119. /**
  23120. * Add a joint to the physics engine
  23121. * @param mainImpostor defines the main impostor to which the joint is added.
  23122. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23123. * @param joint defines the joint that will connect both impostors.
  23124. */
  23125. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23126. /**
  23127. * Removes a joint from the simulation
  23128. * @param mainImpostor defines the impostor used with the joint
  23129. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23130. * @param joint defines the joint to remove
  23131. */
  23132. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23133. /**
  23134. * Gets the current plugin used to run the simulation
  23135. * @returns current plugin
  23136. */
  23137. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23138. /**
  23139. * Gets the list of physic impostors
  23140. * @returns an array of PhysicsImpostor
  23141. */
  23142. getImpostors(): Array<PhysicsImpostor>;
  23143. /**
  23144. * Gets the impostor for a physics enabled object
  23145. * @param object defines the object impersonated by the impostor
  23146. * @returns the PhysicsImpostor or null if not found
  23147. */
  23148. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23149. /**
  23150. * Gets the impostor for a physics body object
  23151. * @param body defines physics body used by the impostor
  23152. * @returns the PhysicsImpostor or null if not found
  23153. */
  23154. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23155. /**
  23156. * Does a raycast in the physics world
  23157. * @param from when should the ray start?
  23158. * @param to when should the ray end?
  23159. * @returns PhysicsRaycastResult
  23160. */
  23161. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23162. /**
  23163. * Called by the scene. No need to call it.
  23164. * @param delta defines the timespam between frames
  23165. */
  23166. _step(delta: number): void;
  23167. }
  23168. }
  23169. declare module BABYLON {
  23170. /**
  23171. * The interface for the physics imposter parameters
  23172. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23173. */
  23174. export interface PhysicsImpostorParameters {
  23175. /**
  23176. * The mass of the physics imposter
  23177. */
  23178. mass: number;
  23179. /**
  23180. * The friction of the physics imposter
  23181. */
  23182. friction?: number;
  23183. /**
  23184. * The coefficient of restitution of the physics imposter
  23185. */
  23186. restitution?: number;
  23187. /**
  23188. * The native options of the physics imposter
  23189. */
  23190. nativeOptions?: any;
  23191. /**
  23192. * Specifies if the parent should be ignored
  23193. */
  23194. ignoreParent?: boolean;
  23195. /**
  23196. * Specifies if bi-directional transformations should be disabled
  23197. */
  23198. disableBidirectionalTransformation?: boolean;
  23199. /**
  23200. * The pressure inside the physics imposter, soft object only
  23201. */
  23202. pressure?: number;
  23203. /**
  23204. * The stiffness the physics imposter, soft object only
  23205. */
  23206. stiffness?: number;
  23207. /**
  23208. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23209. */
  23210. velocityIterations?: number;
  23211. /**
  23212. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23213. */
  23214. positionIterations?: number;
  23215. /**
  23216. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23217. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23218. * Add to fix multiple points
  23219. */
  23220. fixedPoints?: number;
  23221. /**
  23222. * The collision margin around a soft object
  23223. */
  23224. margin?: number;
  23225. /**
  23226. * The collision margin around a soft object
  23227. */
  23228. damping?: number;
  23229. /**
  23230. * The path for a rope based on an extrusion
  23231. */
  23232. path?: any;
  23233. /**
  23234. * The shape of an extrusion used for a rope based on an extrusion
  23235. */
  23236. shape?: any;
  23237. }
  23238. /**
  23239. * Interface for a physics-enabled object
  23240. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23241. */
  23242. export interface IPhysicsEnabledObject {
  23243. /**
  23244. * The position of the physics-enabled object
  23245. */
  23246. position: Vector3;
  23247. /**
  23248. * The rotation of the physics-enabled object
  23249. */
  23250. rotationQuaternion: Nullable<Quaternion>;
  23251. /**
  23252. * The scale of the physics-enabled object
  23253. */
  23254. scaling: Vector3;
  23255. /**
  23256. * The rotation of the physics-enabled object
  23257. */
  23258. rotation?: Vector3;
  23259. /**
  23260. * The parent of the physics-enabled object
  23261. */
  23262. parent?: any;
  23263. /**
  23264. * The bounding info of the physics-enabled object
  23265. * @returns The bounding info of the physics-enabled object
  23266. */
  23267. getBoundingInfo(): BoundingInfo;
  23268. /**
  23269. * Computes the world matrix
  23270. * @param force Specifies if the world matrix should be computed by force
  23271. * @returns A world matrix
  23272. */
  23273. computeWorldMatrix(force: boolean): Matrix;
  23274. /**
  23275. * Gets the world matrix
  23276. * @returns A world matrix
  23277. */
  23278. getWorldMatrix?(): Matrix;
  23279. /**
  23280. * Gets the child meshes
  23281. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23282. * @returns An array of abstract meshes
  23283. */
  23284. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23285. /**
  23286. * Gets the vertex data
  23287. * @param kind The type of vertex data
  23288. * @returns A nullable array of numbers, or a float32 array
  23289. */
  23290. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23291. /**
  23292. * Gets the indices from the mesh
  23293. * @returns A nullable array of index arrays
  23294. */
  23295. getIndices?(): Nullable<IndicesArray>;
  23296. /**
  23297. * Gets the scene from the mesh
  23298. * @returns the indices array or null
  23299. */
  23300. getScene?(): Scene;
  23301. /**
  23302. * Gets the absolute position from the mesh
  23303. * @returns the absolute position
  23304. */
  23305. getAbsolutePosition(): Vector3;
  23306. /**
  23307. * Gets the absolute pivot point from the mesh
  23308. * @returns the absolute pivot point
  23309. */
  23310. getAbsolutePivotPoint(): Vector3;
  23311. /**
  23312. * Rotates the mesh
  23313. * @param axis The axis of rotation
  23314. * @param amount The amount of rotation
  23315. * @param space The space of the rotation
  23316. * @returns The rotation transform node
  23317. */
  23318. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23319. /**
  23320. * Translates the mesh
  23321. * @param axis The axis of translation
  23322. * @param distance The distance of translation
  23323. * @param space The space of the translation
  23324. * @returns The transform node
  23325. */
  23326. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23327. /**
  23328. * Sets the absolute position of the mesh
  23329. * @param absolutePosition The absolute position of the mesh
  23330. * @returns The transform node
  23331. */
  23332. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23333. /**
  23334. * Gets the class name of the mesh
  23335. * @returns The class name
  23336. */
  23337. getClassName(): string;
  23338. }
  23339. /**
  23340. * Represents a physics imposter
  23341. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23342. */
  23343. export class PhysicsImpostor {
  23344. /**
  23345. * The physics-enabled object used as the physics imposter
  23346. */
  23347. object: IPhysicsEnabledObject;
  23348. /**
  23349. * The type of the physics imposter
  23350. */
  23351. type: number;
  23352. private _options;
  23353. private _scene?;
  23354. /**
  23355. * The default object size of the imposter
  23356. */
  23357. static DEFAULT_OBJECT_SIZE: Vector3;
  23358. /**
  23359. * The identity quaternion of the imposter
  23360. */
  23361. static IDENTITY_QUATERNION: Quaternion;
  23362. /** @hidden */
  23363. _pluginData: any;
  23364. private _physicsEngine;
  23365. private _physicsBody;
  23366. private _bodyUpdateRequired;
  23367. private _onBeforePhysicsStepCallbacks;
  23368. private _onAfterPhysicsStepCallbacks;
  23369. /** @hidden */
  23370. _onPhysicsCollideCallbacks: Array<{
  23371. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23372. otherImpostors: Array<PhysicsImpostor>;
  23373. }>;
  23374. private _deltaPosition;
  23375. private _deltaRotation;
  23376. private _deltaRotationConjugated;
  23377. /** @hidden */
  23378. _isFromLine: boolean;
  23379. private _parent;
  23380. private _isDisposed;
  23381. private static _tmpVecs;
  23382. private static _tmpQuat;
  23383. /**
  23384. * Specifies if the physics imposter is disposed
  23385. */
  23386. readonly isDisposed: boolean;
  23387. /**
  23388. * Gets the mass of the physics imposter
  23389. */
  23390. mass: number;
  23391. /**
  23392. * Gets the coefficient of friction
  23393. */
  23394. /**
  23395. * Sets the coefficient of friction
  23396. */
  23397. friction: number;
  23398. /**
  23399. * Gets the coefficient of restitution
  23400. */
  23401. /**
  23402. * Sets the coefficient of restitution
  23403. */
  23404. restitution: number;
  23405. /**
  23406. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23407. */
  23408. /**
  23409. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23410. */
  23411. pressure: number;
  23412. /**
  23413. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23414. */
  23415. /**
  23416. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23417. */
  23418. stiffness: number;
  23419. /**
  23420. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23421. */
  23422. /**
  23423. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23424. */
  23425. velocityIterations: number;
  23426. /**
  23427. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23428. */
  23429. /**
  23430. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23431. */
  23432. positionIterations: number;
  23433. /**
  23434. * The unique id of the physics imposter
  23435. * set by the physics engine when adding this impostor to the array
  23436. */
  23437. uniqueId: number;
  23438. /**
  23439. * @hidden
  23440. */
  23441. soft: boolean;
  23442. /**
  23443. * @hidden
  23444. */
  23445. segments: number;
  23446. private _joints;
  23447. /**
  23448. * Initializes the physics imposter
  23449. * @param object The physics-enabled object used as the physics imposter
  23450. * @param type The type of the physics imposter
  23451. * @param _options The options for the physics imposter
  23452. * @param _scene The Babylon scene
  23453. */
  23454. constructor(
  23455. /**
  23456. * The physics-enabled object used as the physics imposter
  23457. */
  23458. object: IPhysicsEnabledObject,
  23459. /**
  23460. * The type of the physics imposter
  23461. */
  23462. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23463. /**
  23464. * This function will completly initialize this impostor.
  23465. * It will create a new body - but only if this mesh has no parent.
  23466. * If it has, this impostor will not be used other than to define the impostor
  23467. * of the child mesh.
  23468. * @hidden
  23469. */
  23470. _init(): void;
  23471. private _getPhysicsParent;
  23472. /**
  23473. * Should a new body be generated.
  23474. * @returns boolean specifying if body initialization is required
  23475. */
  23476. isBodyInitRequired(): boolean;
  23477. /**
  23478. * Sets the updated scaling
  23479. * @param updated Specifies if the scaling is updated
  23480. */
  23481. setScalingUpdated(): void;
  23482. /**
  23483. * Force a regeneration of this or the parent's impostor's body.
  23484. * Use under cautious - This will remove all joints already implemented.
  23485. */
  23486. forceUpdate(): void;
  23487. /**
  23488. * Gets the body that holds this impostor. Either its own, or its parent.
  23489. */
  23490. /**
  23491. * Set the physics body. Used mainly by the physics engine/plugin
  23492. */
  23493. physicsBody: any;
  23494. /**
  23495. * Get the parent of the physics imposter
  23496. * @returns Physics imposter or null
  23497. */
  23498. /**
  23499. * Sets the parent of the physics imposter
  23500. */
  23501. parent: Nullable<PhysicsImpostor>;
  23502. /**
  23503. * Resets the update flags
  23504. */
  23505. resetUpdateFlags(): void;
  23506. /**
  23507. * Gets the object extend size
  23508. * @returns the object extend size
  23509. */
  23510. getObjectExtendSize(): Vector3;
  23511. /**
  23512. * Gets the object center
  23513. * @returns The object center
  23514. */
  23515. getObjectCenter(): Vector3;
  23516. /**
  23517. * Get a specific parametes from the options parameter
  23518. * @param paramName The object parameter name
  23519. * @returns The object parameter
  23520. */
  23521. getParam(paramName: string): any;
  23522. /**
  23523. * Sets a specific parameter in the options given to the physics plugin
  23524. * @param paramName The parameter name
  23525. * @param value The value of the parameter
  23526. */
  23527. setParam(paramName: string, value: number): void;
  23528. /**
  23529. * Specifically change the body's mass option. Won't recreate the physics body object
  23530. * @param mass The mass of the physics imposter
  23531. */
  23532. setMass(mass: number): void;
  23533. /**
  23534. * Gets the linear velocity
  23535. * @returns linear velocity or null
  23536. */
  23537. getLinearVelocity(): Nullable<Vector3>;
  23538. /**
  23539. * Sets the linear velocity
  23540. * @param velocity linear velocity or null
  23541. */
  23542. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23543. /**
  23544. * Gets the angular velocity
  23545. * @returns angular velocity or null
  23546. */
  23547. getAngularVelocity(): Nullable<Vector3>;
  23548. /**
  23549. * Sets the angular velocity
  23550. * @param velocity The velocity or null
  23551. */
  23552. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23553. /**
  23554. * Execute a function with the physics plugin native code
  23555. * Provide a function the will have two variables - the world object and the physics body object
  23556. * @param func The function to execute with the physics plugin native code
  23557. */
  23558. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23559. /**
  23560. * Register a function that will be executed before the physics world is stepping forward
  23561. * @param func The function to execute before the physics world is stepped forward
  23562. */
  23563. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23564. /**
  23565. * Unregister a function that will be executed before the physics world is stepping forward
  23566. * @param func The function to execute before the physics world is stepped forward
  23567. */
  23568. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23569. /**
  23570. * Register a function that will be executed after the physics step
  23571. * @param func The function to execute after physics step
  23572. */
  23573. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23574. /**
  23575. * Unregisters a function that will be executed after the physics step
  23576. * @param func The function to execute after physics step
  23577. */
  23578. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23579. /**
  23580. * register a function that will be executed when this impostor collides against a different body
  23581. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23582. * @param func Callback that is executed on collision
  23583. */
  23584. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23585. /**
  23586. * Unregisters the physics imposter on contact
  23587. * @param collideAgainst The physics object to collide against
  23588. * @param func Callback to execute on collision
  23589. */
  23590. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23591. private _tmpQuat;
  23592. private _tmpQuat2;
  23593. /**
  23594. * Get the parent rotation
  23595. * @returns The parent rotation
  23596. */
  23597. getParentsRotation(): Quaternion;
  23598. /**
  23599. * this function is executed by the physics engine.
  23600. */
  23601. beforeStep: () => void;
  23602. /**
  23603. * this function is executed by the physics engine
  23604. */
  23605. afterStep: () => void;
  23606. /**
  23607. * Legacy collision detection event support
  23608. */
  23609. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23610. /**
  23611. * event and body object due to cannon's event-based architecture.
  23612. */
  23613. onCollide: (e: {
  23614. body: any;
  23615. }) => void;
  23616. /**
  23617. * Apply a force
  23618. * @param force The force to apply
  23619. * @param contactPoint The contact point for the force
  23620. * @returns The physics imposter
  23621. */
  23622. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23623. /**
  23624. * Apply an impulse
  23625. * @param force The impulse force
  23626. * @param contactPoint The contact point for the impulse force
  23627. * @returns The physics imposter
  23628. */
  23629. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23630. /**
  23631. * A help function to create a joint
  23632. * @param otherImpostor A physics imposter used to create a joint
  23633. * @param jointType The type of joint
  23634. * @param jointData The data for the joint
  23635. * @returns The physics imposter
  23636. */
  23637. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23638. /**
  23639. * Add a joint to this impostor with a different impostor
  23640. * @param otherImpostor A physics imposter used to add a joint
  23641. * @param joint The joint to add
  23642. * @returns The physics imposter
  23643. */
  23644. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23645. /**
  23646. * Add an anchor to a cloth impostor
  23647. * @param otherImpostor rigid impostor to anchor to
  23648. * @param width ratio across width from 0 to 1
  23649. * @param height ratio up height from 0 to 1
  23650. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23651. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23652. * @returns impostor the soft imposter
  23653. */
  23654. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23655. /**
  23656. * Add a hook to a rope impostor
  23657. * @param otherImpostor rigid impostor to anchor to
  23658. * @param length ratio across rope from 0 to 1
  23659. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23660. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23661. * @returns impostor the rope imposter
  23662. */
  23663. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23664. /**
  23665. * Will keep this body still, in a sleep mode.
  23666. * @returns the physics imposter
  23667. */
  23668. sleep(): PhysicsImpostor;
  23669. /**
  23670. * Wake the body up.
  23671. * @returns The physics imposter
  23672. */
  23673. wakeUp(): PhysicsImpostor;
  23674. /**
  23675. * Clones the physics imposter
  23676. * @param newObject The physics imposter clones to this physics-enabled object
  23677. * @returns A nullable physics imposter
  23678. */
  23679. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23680. /**
  23681. * Disposes the physics imposter
  23682. */
  23683. dispose(): void;
  23684. /**
  23685. * Sets the delta position
  23686. * @param position The delta position amount
  23687. */
  23688. setDeltaPosition(position: Vector3): void;
  23689. /**
  23690. * Sets the delta rotation
  23691. * @param rotation The delta rotation amount
  23692. */
  23693. setDeltaRotation(rotation: Quaternion): void;
  23694. /**
  23695. * Gets the box size of the physics imposter and stores the result in the input parameter
  23696. * @param result Stores the box size
  23697. * @returns The physics imposter
  23698. */
  23699. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23700. /**
  23701. * Gets the radius of the physics imposter
  23702. * @returns Radius of the physics imposter
  23703. */
  23704. getRadius(): number;
  23705. /**
  23706. * Sync a bone with this impostor
  23707. * @param bone The bone to sync to the impostor.
  23708. * @param boneMesh The mesh that the bone is influencing.
  23709. * @param jointPivot The pivot of the joint / bone in local space.
  23710. * @param distToJoint Optional distance from the impostor to the joint.
  23711. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23712. */
  23713. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23714. /**
  23715. * Sync impostor to a bone
  23716. * @param bone The bone that the impostor will be synced to.
  23717. * @param boneMesh The mesh that the bone is influencing.
  23718. * @param jointPivot The pivot of the joint / bone in local space.
  23719. * @param distToJoint Optional distance from the impostor to the joint.
  23720. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23721. * @param boneAxis Optional vector3 axis the bone is aligned with
  23722. */
  23723. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  23724. /**
  23725. * No-Imposter type
  23726. */
  23727. static NoImpostor: number;
  23728. /**
  23729. * Sphere-Imposter type
  23730. */
  23731. static SphereImpostor: number;
  23732. /**
  23733. * Box-Imposter type
  23734. */
  23735. static BoxImpostor: number;
  23736. /**
  23737. * Plane-Imposter type
  23738. */
  23739. static PlaneImpostor: number;
  23740. /**
  23741. * Mesh-imposter type
  23742. */
  23743. static MeshImpostor: number;
  23744. /**
  23745. * Capsule-Impostor type (Ammo.js plugin only)
  23746. */
  23747. static CapsuleImpostor: number;
  23748. /**
  23749. * Cylinder-Imposter type
  23750. */
  23751. static CylinderImpostor: number;
  23752. /**
  23753. * Particle-Imposter type
  23754. */
  23755. static ParticleImpostor: number;
  23756. /**
  23757. * Heightmap-Imposter type
  23758. */
  23759. static HeightmapImpostor: number;
  23760. /**
  23761. * ConvexHull-Impostor type (Ammo.js plugin only)
  23762. */
  23763. static ConvexHullImpostor: number;
  23764. /**
  23765. * Custom-Imposter type (Ammo.js plugin only)
  23766. */
  23767. static CustomImpostor: number;
  23768. /**
  23769. * Rope-Imposter type
  23770. */
  23771. static RopeImpostor: number;
  23772. /**
  23773. * Cloth-Imposter type
  23774. */
  23775. static ClothImpostor: number;
  23776. /**
  23777. * Softbody-Imposter type
  23778. */
  23779. static SoftbodyImpostor: number;
  23780. }
  23781. }
  23782. declare module BABYLON {
  23783. /**
  23784. * @hidden
  23785. **/
  23786. export class _CreationDataStorage {
  23787. closePath?: boolean;
  23788. closeArray?: boolean;
  23789. idx: number[];
  23790. dashSize: number;
  23791. gapSize: number;
  23792. path3D: Path3D;
  23793. pathArray: Vector3[][];
  23794. arc: number;
  23795. radius: number;
  23796. cap: number;
  23797. tessellation: number;
  23798. }
  23799. /**
  23800. * @hidden
  23801. **/
  23802. class _InstanceDataStorage {
  23803. visibleInstances: any;
  23804. batchCache: _InstancesBatch;
  23805. instancesBufferSize: number;
  23806. instancesBuffer: Nullable<Buffer>;
  23807. instancesData: Float32Array;
  23808. overridenInstanceCount: number;
  23809. isFrozen: boolean;
  23810. previousBatch: Nullable<_InstancesBatch>;
  23811. hardwareInstancedRendering: boolean;
  23812. sideOrientation: number;
  23813. manualUpdate: boolean;
  23814. }
  23815. /**
  23816. * @hidden
  23817. **/
  23818. export class _InstancesBatch {
  23819. mustReturn: boolean;
  23820. visibleInstances: Nullable<InstancedMesh[]>[];
  23821. renderSelf: boolean[];
  23822. hardwareInstancedRendering: boolean[];
  23823. }
  23824. /**
  23825. * Class used to represent renderable models
  23826. */
  23827. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  23828. /**
  23829. * Mesh side orientation : usually the external or front surface
  23830. */
  23831. static readonly FRONTSIDE: number;
  23832. /**
  23833. * Mesh side orientation : usually the internal or back surface
  23834. */
  23835. static readonly BACKSIDE: number;
  23836. /**
  23837. * Mesh side orientation : both internal and external or front and back surfaces
  23838. */
  23839. static readonly DOUBLESIDE: number;
  23840. /**
  23841. * Mesh side orientation : by default, `FRONTSIDE`
  23842. */
  23843. static readonly DEFAULTSIDE: number;
  23844. /**
  23845. * Mesh cap setting : no cap
  23846. */
  23847. static readonly NO_CAP: number;
  23848. /**
  23849. * Mesh cap setting : one cap at the beginning of the mesh
  23850. */
  23851. static readonly CAP_START: number;
  23852. /**
  23853. * Mesh cap setting : one cap at the end of the mesh
  23854. */
  23855. static readonly CAP_END: number;
  23856. /**
  23857. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  23858. */
  23859. static readonly CAP_ALL: number;
  23860. /**
  23861. * Mesh pattern setting : no flip or rotate
  23862. */
  23863. static readonly NO_FLIP: number;
  23864. /**
  23865. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  23866. */
  23867. static readonly FLIP_TILE: number;
  23868. /**
  23869. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  23870. */
  23871. static readonly ROTATE_TILE: number;
  23872. /**
  23873. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  23874. */
  23875. static readonly FLIP_ROW: number;
  23876. /**
  23877. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  23878. */
  23879. static readonly ROTATE_ROW: number;
  23880. /**
  23881. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  23882. */
  23883. static readonly FLIP_N_ROTATE_TILE: number;
  23884. /**
  23885. * Mesh pattern setting : rotate pattern and rotate
  23886. */
  23887. static readonly FLIP_N_ROTATE_ROW: number;
  23888. /**
  23889. * Mesh tile positioning : part tiles same on left/right or top/bottom
  23890. */
  23891. static readonly CENTER: number;
  23892. /**
  23893. * Mesh tile positioning : part tiles on left
  23894. */
  23895. static readonly LEFT: number;
  23896. /**
  23897. * Mesh tile positioning : part tiles on right
  23898. */
  23899. static readonly RIGHT: number;
  23900. /**
  23901. * Mesh tile positioning : part tiles on top
  23902. */
  23903. static readonly TOP: number;
  23904. /**
  23905. * Mesh tile positioning : part tiles on bottom
  23906. */
  23907. static readonly BOTTOM: number;
  23908. /**
  23909. * Gets the default side orientation.
  23910. * @param orientation the orientation to value to attempt to get
  23911. * @returns the default orientation
  23912. * @hidden
  23913. */
  23914. static _GetDefaultSideOrientation(orientation?: number): number;
  23915. private _internalMeshDataInfo;
  23916. /**
  23917. * An event triggered before rendering the mesh
  23918. */
  23919. readonly onBeforeRenderObservable: Observable<Mesh>;
  23920. /**
  23921. * An event triggered before binding the mesh
  23922. */
  23923. readonly onBeforeBindObservable: Observable<Mesh>;
  23924. /**
  23925. * An event triggered after rendering the mesh
  23926. */
  23927. readonly onAfterRenderObservable: Observable<Mesh>;
  23928. /**
  23929. * An event triggered before drawing the mesh
  23930. */
  23931. readonly onBeforeDrawObservable: Observable<Mesh>;
  23932. private _onBeforeDrawObserver;
  23933. /**
  23934. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  23935. */
  23936. onBeforeDraw: () => void;
  23937. readonly hasInstances: boolean;
  23938. /**
  23939. * Gets the delay loading state of the mesh (when delay loading is turned on)
  23940. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  23941. */
  23942. delayLoadState: number;
  23943. /**
  23944. * Gets the list of instances created from this mesh
  23945. * it is not supposed to be modified manually.
  23946. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  23947. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  23948. */
  23949. instances: InstancedMesh[];
  23950. /**
  23951. * Gets the file containing delay loading data for this mesh
  23952. */
  23953. delayLoadingFile: string;
  23954. /** @hidden */
  23955. _binaryInfo: any;
  23956. /**
  23957. * User defined function used to change how LOD level selection is done
  23958. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23959. */
  23960. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  23961. /**
  23962. * Gets or sets the morph target manager
  23963. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23964. */
  23965. morphTargetManager: Nullable<MorphTargetManager>;
  23966. /** @hidden */
  23967. _creationDataStorage: Nullable<_CreationDataStorage>;
  23968. /** @hidden */
  23969. _geometry: Nullable<Geometry>;
  23970. /** @hidden */
  23971. _delayInfo: Array<string>;
  23972. /** @hidden */
  23973. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  23974. /** @hidden */
  23975. _instanceDataStorage: _InstanceDataStorage;
  23976. private _effectiveMaterial;
  23977. /** @hidden */
  23978. _shouldGenerateFlatShading: boolean;
  23979. /** @hidden */
  23980. _originalBuilderSideOrientation: number;
  23981. /**
  23982. * Use this property to change the original side orientation defined at construction time
  23983. */
  23984. overrideMaterialSideOrientation: Nullable<number>;
  23985. /**
  23986. * Gets the source mesh (the one used to clone this one from)
  23987. */
  23988. readonly source: Nullable<Mesh>;
  23989. /**
  23990. * Gets or sets a boolean indicating that this mesh does not use index buffer
  23991. */
  23992. isUnIndexed: boolean;
  23993. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  23994. readonly worldMatrixInstancedBuffer: Float32Array;
  23995. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  23996. manualUpdateOfWorldMatrixInstancedBuffer: boolean;
  23997. /**
  23998. * @constructor
  23999. * @param name The value used by scene.getMeshByName() to do a lookup.
  24000. * @param scene The scene to add this mesh to.
  24001. * @param parent The parent of this mesh, if it has one
  24002. * @param source An optional Mesh from which geometry is shared, cloned.
  24003. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24004. * When false, achieved by calling a clone(), also passing False.
  24005. * This will make creation of children, recursive.
  24006. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24007. */
  24008. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24009. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  24010. doNotInstantiate: boolean;
  24011. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  24012. /**
  24013. * Gets the class name
  24014. * @returns the string "Mesh".
  24015. */
  24016. getClassName(): string;
  24017. /** @hidden */
  24018. readonly _isMesh: boolean;
  24019. /**
  24020. * Returns a description of this mesh
  24021. * @param fullDetails define if full details about this mesh must be used
  24022. * @returns a descriptive string representing this mesh
  24023. */
  24024. toString(fullDetails?: boolean): string;
  24025. /** @hidden */
  24026. _unBindEffect(): void;
  24027. /**
  24028. * Gets a boolean indicating if this mesh has LOD
  24029. */
  24030. readonly hasLODLevels: boolean;
  24031. /**
  24032. * Gets the list of MeshLODLevel associated with the current mesh
  24033. * @returns an array of MeshLODLevel
  24034. */
  24035. getLODLevels(): MeshLODLevel[];
  24036. private _sortLODLevels;
  24037. /**
  24038. * Add a mesh as LOD level triggered at the given distance.
  24039. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24040. * @param distance The distance from the center of the object to show this level
  24041. * @param mesh The mesh to be added as LOD level (can be null)
  24042. * @return This mesh (for chaining)
  24043. */
  24044. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24045. /**
  24046. * Returns the LOD level mesh at the passed distance or null if not found.
  24047. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24048. * @param distance The distance from the center of the object to show this level
  24049. * @returns a Mesh or `null`
  24050. */
  24051. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24052. /**
  24053. * Remove a mesh from the LOD array
  24054. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24055. * @param mesh defines the mesh to be removed
  24056. * @return This mesh (for chaining)
  24057. */
  24058. removeLODLevel(mesh: Mesh): Mesh;
  24059. /**
  24060. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24061. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24062. * @param camera defines the camera to use to compute distance
  24063. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24064. * @return This mesh (for chaining)
  24065. */
  24066. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24067. /**
  24068. * Gets the mesh internal Geometry object
  24069. */
  24070. readonly geometry: Nullable<Geometry>;
  24071. /**
  24072. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24073. * @returns the total number of vertices
  24074. */
  24075. getTotalVertices(): number;
  24076. /**
  24077. * Returns the content of an associated vertex buffer
  24078. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24079. * - VertexBuffer.PositionKind
  24080. * - VertexBuffer.UVKind
  24081. * - VertexBuffer.UV2Kind
  24082. * - VertexBuffer.UV3Kind
  24083. * - VertexBuffer.UV4Kind
  24084. * - VertexBuffer.UV5Kind
  24085. * - VertexBuffer.UV6Kind
  24086. * - VertexBuffer.ColorKind
  24087. * - VertexBuffer.MatricesIndicesKind
  24088. * - VertexBuffer.MatricesIndicesExtraKind
  24089. * - VertexBuffer.MatricesWeightsKind
  24090. * - VertexBuffer.MatricesWeightsExtraKind
  24091. * @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
  24092. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24093. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24094. */
  24095. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24096. /**
  24097. * Returns the mesh VertexBuffer object from the requested `kind`
  24098. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24099. * - VertexBuffer.PositionKind
  24100. * - VertexBuffer.NormalKind
  24101. * - VertexBuffer.UVKind
  24102. * - VertexBuffer.UV2Kind
  24103. * - VertexBuffer.UV3Kind
  24104. * - VertexBuffer.UV4Kind
  24105. * - VertexBuffer.UV5Kind
  24106. * - VertexBuffer.UV6Kind
  24107. * - VertexBuffer.ColorKind
  24108. * - VertexBuffer.MatricesIndicesKind
  24109. * - VertexBuffer.MatricesIndicesExtraKind
  24110. * - VertexBuffer.MatricesWeightsKind
  24111. * - VertexBuffer.MatricesWeightsExtraKind
  24112. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24113. */
  24114. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24115. /**
  24116. * Tests if a specific vertex buffer is associated with this mesh
  24117. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24118. * - VertexBuffer.PositionKind
  24119. * - VertexBuffer.NormalKind
  24120. * - VertexBuffer.UVKind
  24121. * - VertexBuffer.UV2Kind
  24122. * - VertexBuffer.UV3Kind
  24123. * - VertexBuffer.UV4Kind
  24124. * - VertexBuffer.UV5Kind
  24125. * - VertexBuffer.UV6Kind
  24126. * - VertexBuffer.ColorKind
  24127. * - VertexBuffer.MatricesIndicesKind
  24128. * - VertexBuffer.MatricesIndicesExtraKind
  24129. * - VertexBuffer.MatricesWeightsKind
  24130. * - VertexBuffer.MatricesWeightsExtraKind
  24131. * @returns a boolean
  24132. */
  24133. isVerticesDataPresent(kind: string): boolean;
  24134. /**
  24135. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24136. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24137. * - VertexBuffer.PositionKind
  24138. * - VertexBuffer.UVKind
  24139. * - VertexBuffer.UV2Kind
  24140. * - VertexBuffer.UV3Kind
  24141. * - VertexBuffer.UV4Kind
  24142. * - VertexBuffer.UV5Kind
  24143. * - VertexBuffer.UV6Kind
  24144. * - VertexBuffer.ColorKind
  24145. * - VertexBuffer.MatricesIndicesKind
  24146. * - VertexBuffer.MatricesIndicesExtraKind
  24147. * - VertexBuffer.MatricesWeightsKind
  24148. * - VertexBuffer.MatricesWeightsExtraKind
  24149. * @returns a boolean
  24150. */
  24151. isVertexBufferUpdatable(kind: string): boolean;
  24152. /**
  24153. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24154. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24155. * - VertexBuffer.PositionKind
  24156. * - VertexBuffer.NormalKind
  24157. * - VertexBuffer.UVKind
  24158. * - VertexBuffer.UV2Kind
  24159. * - VertexBuffer.UV3Kind
  24160. * - VertexBuffer.UV4Kind
  24161. * - VertexBuffer.UV5Kind
  24162. * - VertexBuffer.UV6Kind
  24163. * - VertexBuffer.ColorKind
  24164. * - VertexBuffer.MatricesIndicesKind
  24165. * - VertexBuffer.MatricesIndicesExtraKind
  24166. * - VertexBuffer.MatricesWeightsKind
  24167. * - VertexBuffer.MatricesWeightsExtraKind
  24168. * @returns an array of strings
  24169. */
  24170. getVerticesDataKinds(): string[];
  24171. /**
  24172. * Returns a positive integer : the total number of indices in this mesh geometry.
  24173. * @returns the numner of indices or zero if the mesh has no geometry.
  24174. */
  24175. getTotalIndices(): number;
  24176. /**
  24177. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24178. * @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.
  24179. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24180. * @returns the indices array or an empty array if the mesh has no geometry
  24181. */
  24182. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24183. readonly isBlocked: boolean;
  24184. /**
  24185. * Determine if the current mesh is ready to be rendered
  24186. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24187. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24188. * @returns true if all associated assets are ready (material, textures, shaders)
  24189. */
  24190. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24191. /**
  24192. * 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.
  24193. */
  24194. readonly areNormalsFrozen: boolean;
  24195. /**
  24196. * 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.
  24197. * @returns the current mesh
  24198. */
  24199. freezeNormals(): Mesh;
  24200. /**
  24201. * 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
  24202. * @returns the current mesh
  24203. */
  24204. unfreezeNormals(): Mesh;
  24205. /**
  24206. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24207. */
  24208. overridenInstanceCount: number;
  24209. /** @hidden */
  24210. _preActivate(): Mesh;
  24211. /** @hidden */
  24212. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24213. /** @hidden */
  24214. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24215. /**
  24216. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24217. * This means the mesh underlying bounding box and sphere are recomputed.
  24218. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24219. * @returns the current mesh
  24220. */
  24221. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24222. /** @hidden */
  24223. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24224. /**
  24225. * This function will subdivide the mesh into multiple submeshes
  24226. * @param count defines the expected number of submeshes
  24227. */
  24228. subdivide(count: number): void;
  24229. /**
  24230. * Copy a FloatArray into a specific associated vertex buffer
  24231. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24232. * - VertexBuffer.PositionKind
  24233. * - VertexBuffer.UVKind
  24234. * - VertexBuffer.UV2Kind
  24235. * - VertexBuffer.UV3Kind
  24236. * - VertexBuffer.UV4Kind
  24237. * - VertexBuffer.UV5Kind
  24238. * - VertexBuffer.UV6Kind
  24239. * - VertexBuffer.ColorKind
  24240. * - VertexBuffer.MatricesIndicesKind
  24241. * - VertexBuffer.MatricesIndicesExtraKind
  24242. * - VertexBuffer.MatricesWeightsKind
  24243. * - VertexBuffer.MatricesWeightsExtraKind
  24244. * @param data defines the data source
  24245. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24246. * @param stride defines the data stride size (can be null)
  24247. * @returns the current mesh
  24248. */
  24249. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24250. /**
  24251. * Delete a vertex buffer associated with this mesh
  24252. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  24253. * - VertexBuffer.PositionKind
  24254. * - VertexBuffer.UVKind
  24255. * - VertexBuffer.UV2Kind
  24256. * - VertexBuffer.UV3Kind
  24257. * - VertexBuffer.UV4Kind
  24258. * - VertexBuffer.UV5Kind
  24259. * - VertexBuffer.UV6Kind
  24260. * - VertexBuffer.ColorKind
  24261. * - VertexBuffer.MatricesIndicesKind
  24262. * - VertexBuffer.MatricesIndicesExtraKind
  24263. * - VertexBuffer.MatricesWeightsKind
  24264. * - VertexBuffer.MatricesWeightsExtraKind
  24265. */
  24266. removeVerticesData(kind: string): void;
  24267. /**
  24268. * Flags an associated vertex buffer as updatable
  24269. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24270. * - VertexBuffer.PositionKind
  24271. * - VertexBuffer.UVKind
  24272. * - VertexBuffer.UV2Kind
  24273. * - VertexBuffer.UV3Kind
  24274. * - VertexBuffer.UV4Kind
  24275. * - VertexBuffer.UV5Kind
  24276. * - VertexBuffer.UV6Kind
  24277. * - VertexBuffer.ColorKind
  24278. * - VertexBuffer.MatricesIndicesKind
  24279. * - VertexBuffer.MatricesIndicesExtraKind
  24280. * - VertexBuffer.MatricesWeightsKind
  24281. * - VertexBuffer.MatricesWeightsExtraKind
  24282. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24283. */
  24284. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24285. /**
  24286. * Sets the mesh global Vertex Buffer
  24287. * @param buffer defines the buffer to use
  24288. * @returns the current mesh
  24289. */
  24290. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24291. /**
  24292. * Update a specific associated vertex buffer
  24293. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24294. * - VertexBuffer.PositionKind
  24295. * - VertexBuffer.UVKind
  24296. * - VertexBuffer.UV2Kind
  24297. * - VertexBuffer.UV3Kind
  24298. * - VertexBuffer.UV4Kind
  24299. * - VertexBuffer.UV5Kind
  24300. * - VertexBuffer.UV6Kind
  24301. * - VertexBuffer.ColorKind
  24302. * - VertexBuffer.MatricesIndicesKind
  24303. * - VertexBuffer.MatricesIndicesExtraKind
  24304. * - VertexBuffer.MatricesWeightsKind
  24305. * - VertexBuffer.MatricesWeightsExtraKind
  24306. * @param data defines the data source
  24307. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24308. * @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)
  24309. * @returns the current mesh
  24310. */
  24311. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24312. /**
  24313. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24314. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24315. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24316. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24317. * @returns the current mesh
  24318. */
  24319. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24320. /**
  24321. * Creates a un-shared specific occurence of the geometry for the mesh.
  24322. * @returns the current mesh
  24323. */
  24324. makeGeometryUnique(): Mesh;
  24325. /**
  24326. * Set the index buffer of this mesh
  24327. * @param indices defines the source data
  24328. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24329. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24330. * @returns the current mesh
  24331. */
  24332. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24333. /**
  24334. * Update the current index buffer
  24335. * @param indices defines the source data
  24336. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24337. * @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)
  24338. * @returns the current mesh
  24339. */
  24340. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24341. /**
  24342. * Invert the geometry to move from a right handed system to a left handed one.
  24343. * @returns the current mesh
  24344. */
  24345. toLeftHanded(): Mesh;
  24346. /** @hidden */
  24347. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24348. /** @hidden */
  24349. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24350. /**
  24351. * Registers for this mesh a javascript function called just before the rendering process
  24352. * @param func defines the function to call before rendering this mesh
  24353. * @returns the current mesh
  24354. */
  24355. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24356. /**
  24357. * Disposes a previously registered javascript function called before the rendering
  24358. * @param func defines the function to remove
  24359. * @returns the current mesh
  24360. */
  24361. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24362. /**
  24363. * Registers for this mesh a javascript function called just after the rendering is complete
  24364. * @param func defines the function to call after rendering this mesh
  24365. * @returns the current mesh
  24366. */
  24367. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24368. /**
  24369. * Disposes a previously registered javascript function called after the rendering.
  24370. * @param func defines the function to remove
  24371. * @returns the current mesh
  24372. */
  24373. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24374. /** @hidden */
  24375. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  24376. /** @hidden */
  24377. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24378. /** @hidden */
  24379. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  24380. /** @hidden */
  24381. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24382. /** @hidden */
  24383. _rebuild(): void;
  24384. /** @hidden */
  24385. _freeze(): void;
  24386. /** @hidden */
  24387. _unFreeze(): void;
  24388. /**
  24389. * 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
  24390. * @param subMesh defines the subMesh to render
  24391. * @param enableAlphaMode defines if alpha mode can be changed
  24392. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  24393. * @returns the current mesh
  24394. */
  24395. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  24396. private _onBeforeDraw;
  24397. /**
  24398. * Renormalize the mesh and patch it up if there are no weights
  24399. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24400. * However in the case of zero weights then we set just a single influence to 1.
  24401. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24402. */
  24403. cleanMatrixWeights(): void;
  24404. private normalizeSkinFourWeights;
  24405. private normalizeSkinWeightsAndExtra;
  24406. /**
  24407. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24408. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24409. * the user know there was an issue with importing the mesh
  24410. * @returns a validation object with skinned, valid and report string
  24411. */
  24412. validateSkinning(): {
  24413. skinned: boolean;
  24414. valid: boolean;
  24415. report: string;
  24416. };
  24417. /** @hidden */
  24418. _checkDelayState(): Mesh;
  24419. private _queueLoad;
  24420. /**
  24421. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24422. * A mesh is in the frustum if its bounding box intersects the frustum
  24423. * @param frustumPlanes defines the frustum to test
  24424. * @returns true if the mesh is in the frustum planes
  24425. */
  24426. isInFrustum(frustumPlanes: Plane[]): boolean;
  24427. /**
  24428. * Sets the mesh material by the material or multiMaterial `id` property
  24429. * @param id is a string identifying the material or the multiMaterial
  24430. * @returns the current mesh
  24431. */
  24432. setMaterialByID(id: string): Mesh;
  24433. /**
  24434. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24435. * @returns an array of IAnimatable
  24436. */
  24437. getAnimatables(): IAnimatable[];
  24438. /**
  24439. * Modifies the mesh geometry according to the passed transformation matrix.
  24440. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24441. * The mesh normals are modified using the same transformation.
  24442. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24443. * @param transform defines the transform matrix to use
  24444. * @see http://doc.babylonjs.com/resources/baking_transformations
  24445. * @returns the current mesh
  24446. */
  24447. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24448. /**
  24449. * Modifies the mesh geometry according to its own current World Matrix.
  24450. * The mesh World Matrix is then reset.
  24451. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24452. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24453. * @see http://doc.babylonjs.com/resources/baking_transformations
  24454. * @returns the current mesh
  24455. */
  24456. bakeCurrentTransformIntoVertices(): Mesh;
  24457. /** @hidden */
  24458. readonly _positions: Nullable<Vector3[]>;
  24459. /** @hidden */
  24460. _resetPointsArrayCache(): Mesh;
  24461. /** @hidden */
  24462. _generatePointsArray(): boolean;
  24463. /**
  24464. * Returns a new Mesh object generated from the current mesh properties.
  24465. * This method must not get confused with createInstance()
  24466. * @param name is a string, the name given to the new mesh
  24467. * @param newParent can be any Node object (default `null`)
  24468. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24469. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24470. * @returns a new mesh
  24471. */
  24472. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  24473. /**
  24474. * Releases resources associated with this mesh.
  24475. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24476. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24477. */
  24478. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24479. /** @hidden */
  24480. _disposeInstanceSpecificData(): void;
  24481. /**
  24482. * Modifies the mesh geometry according to a displacement map.
  24483. * 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.
  24484. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24485. * @param url is a string, the URL from the image file is to be downloaded.
  24486. * @param minHeight is the lower limit of the displacement.
  24487. * @param maxHeight is the upper limit of the displacement.
  24488. * @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.
  24489. * @param uvOffset is an optional vector2 used to offset UV.
  24490. * @param uvScale is an optional vector2 used to scale UV.
  24491. * @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.
  24492. * @returns the Mesh.
  24493. */
  24494. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24495. /**
  24496. * Modifies the mesh geometry according to a displacementMap buffer.
  24497. * 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.
  24498. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24499. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24500. * @param heightMapWidth is the width of the buffer image.
  24501. * @param heightMapHeight is the height of the buffer image.
  24502. * @param minHeight is the lower limit of the displacement.
  24503. * @param maxHeight is the upper limit of the displacement.
  24504. * @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.
  24505. * @param uvOffset is an optional vector2 used to offset UV.
  24506. * @param uvScale is an optional vector2 used to scale UV.
  24507. * @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.
  24508. * @returns the Mesh.
  24509. */
  24510. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24511. /**
  24512. * Modify the mesh to get a flat shading rendering.
  24513. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24514. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24515. * @returns current mesh
  24516. */
  24517. convertToFlatShadedMesh(): Mesh;
  24518. /**
  24519. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24520. * In other words, more vertices, no more indices and a single bigger VBO.
  24521. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24522. * @returns current mesh
  24523. */
  24524. convertToUnIndexedMesh(): Mesh;
  24525. /**
  24526. * Inverses facet orientations.
  24527. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24528. * @param flipNormals will also inverts the normals
  24529. * @returns current mesh
  24530. */
  24531. flipFaces(flipNormals?: boolean): Mesh;
  24532. /**
  24533. * Increase the number of facets and hence vertices in a mesh
  24534. * Vertex normals are interpolated from existing vertex normals
  24535. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24536. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24537. */
  24538. increaseVertices(numberPerEdge: number): void;
  24539. /**
  24540. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24541. * This will undo any application of covertToFlatShadedMesh
  24542. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24543. */
  24544. forceSharedVertices(): void;
  24545. /** @hidden */
  24546. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24547. /** @hidden */
  24548. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24549. /**
  24550. * Creates a new InstancedMesh object from the mesh model.
  24551. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24552. * @param name defines the name of the new instance
  24553. * @returns a new InstancedMesh
  24554. */
  24555. createInstance(name: string): InstancedMesh;
  24556. /**
  24557. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24558. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24559. * @returns the current mesh
  24560. */
  24561. synchronizeInstances(): Mesh;
  24562. /**
  24563. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24564. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24565. * This should be used together with the simplification to avoid disappearing triangles.
  24566. * @param successCallback an optional success callback to be called after the optimization finished.
  24567. * @returns the current mesh
  24568. */
  24569. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24570. /**
  24571. * Serialize current mesh
  24572. * @param serializationObject defines the object which will receive the serialization data
  24573. */
  24574. serialize(serializationObject: any): void;
  24575. /** @hidden */
  24576. _syncGeometryWithMorphTargetManager(): void;
  24577. /** @hidden */
  24578. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24579. /**
  24580. * Returns a new Mesh object parsed from the source provided.
  24581. * @param parsedMesh is the source
  24582. * @param scene defines the hosting scene
  24583. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24584. * @returns a new Mesh
  24585. */
  24586. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24587. /**
  24588. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24589. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24590. * @param name defines the name of the mesh to create
  24591. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24592. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24593. * @param closePath creates a seam between the first and the last points of each path of the path array
  24594. * @param offset is taken in account only if the `pathArray` is containing a single path
  24595. * @param scene defines the hosting scene
  24596. * @param updatable defines if the mesh must be flagged as updatable
  24597. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24598. * @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)
  24599. * @returns a new Mesh
  24600. */
  24601. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24602. /**
  24603. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24604. * @param name defines the name of the mesh to create
  24605. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24606. * @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
  24607. * @param scene defines the hosting scene
  24608. * @param updatable defines if the mesh must be flagged as updatable
  24609. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24610. * @returns a new Mesh
  24611. */
  24612. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24613. /**
  24614. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24615. * @param name defines the name of the mesh to create
  24616. * @param size sets the size (float) of each box side (default 1)
  24617. * @param scene defines the hosting scene
  24618. * @param updatable defines if the mesh must be flagged as updatable
  24619. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24620. * @returns a new Mesh
  24621. */
  24622. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24623. /**
  24624. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24625. * @param name defines the name of the mesh to create
  24626. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24627. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24628. * @param scene defines the hosting scene
  24629. * @param updatable defines if the mesh must be flagged as updatable
  24630. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24631. * @returns a new Mesh
  24632. */
  24633. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24634. /**
  24635. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24636. * @param name defines the name of the mesh to create
  24637. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24638. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24639. * @param scene defines the hosting scene
  24640. * @returns a new Mesh
  24641. */
  24642. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24643. /**
  24644. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24645. * @param name defines the name of the mesh to create
  24646. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24647. * @param diameterTop set the top cap diameter (floats, default 1)
  24648. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24649. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24650. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24651. * @param scene defines the hosting scene
  24652. * @param updatable defines if the mesh must be flagged as updatable
  24653. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24654. * @returns a new Mesh
  24655. */
  24656. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24657. /**
  24658. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24659. * @param name defines the name of the mesh to create
  24660. * @param diameter sets the diameter size (float) of the torus (default 1)
  24661. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24662. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24663. * @param scene defines the hosting scene
  24664. * @param updatable defines if the mesh must be flagged as updatable
  24665. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24666. * @returns a new Mesh
  24667. */
  24668. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24669. /**
  24670. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24671. * @param name defines the name of the mesh to create
  24672. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24673. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24674. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24675. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24676. * @param p the number of windings on X axis (positive integers, default 2)
  24677. * @param q the number of windings on Y axis (positive integers, default 3)
  24678. * @param scene defines the hosting scene
  24679. * @param updatable defines if the mesh must be flagged as updatable
  24680. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24681. * @returns a new Mesh
  24682. */
  24683. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24684. /**
  24685. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24686. * @param name defines the name of the mesh to create
  24687. * @param points is an array successive Vector3
  24688. * @param scene defines the hosting scene
  24689. * @param updatable defines if the mesh must be flagged as updatable
  24690. * @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).
  24691. * @returns a new Mesh
  24692. */
  24693. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24694. /**
  24695. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  24696. * @param name defines the name of the mesh to create
  24697. * @param points is an array successive Vector3
  24698. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24699. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24700. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24701. * @param scene defines the hosting scene
  24702. * @param updatable defines if the mesh must be flagged as updatable
  24703. * @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)
  24704. * @returns a new Mesh
  24705. */
  24706. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24707. /**
  24708. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24709. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24710. * 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.
  24711. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24712. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24713. * Remember you can only change the shape positions, not their number when updating a polygon.
  24714. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24715. * @param name defines the name of the mesh to create
  24716. * @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
  24717. * @param scene defines the hosting scene
  24718. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24719. * @param updatable defines if the mesh must be flagged as updatable
  24720. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24721. * @param earcutInjection can be used to inject your own earcut reference
  24722. * @returns a new Mesh
  24723. */
  24724. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24725. /**
  24726. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  24727. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  24728. * @param name defines the name of the mesh to create
  24729. * @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
  24730. * @param depth defines the height of extrusion
  24731. * @param scene defines the hosting scene
  24732. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24733. * @param updatable defines if the mesh must be flagged as updatable
  24734. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24735. * @param earcutInjection can be used to inject your own earcut reference
  24736. * @returns a new Mesh
  24737. */
  24738. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24739. /**
  24740. * Creates an extruded shape mesh.
  24741. * 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
  24742. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24743. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24744. * @param name defines the name of the mesh to create
  24745. * @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
  24746. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24747. * @param scale is the value to scale the shape
  24748. * @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
  24749. * @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
  24750. * @param scene defines the hosting scene
  24751. * @param updatable defines if the mesh must be flagged as updatable
  24752. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24753. * @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)
  24754. * @returns a new Mesh
  24755. */
  24756. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24757. /**
  24758. * Creates an custom extruded shape mesh.
  24759. * The custom extrusion is a parametric shape.
  24760. * It has no predefined shape. Its final shape will depend on the input parameters.
  24761. * Please consider using the same method from the MeshBuilder class instead
  24762. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24763. * @param name defines the name of the mesh to create
  24764. * @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
  24765. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24766. * @param scaleFunction is a custom Javascript function called on each path point
  24767. * @param rotationFunction is a custom Javascript function called on each path point
  24768. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  24769. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  24770. * @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
  24771. * @param scene defines the hosting scene
  24772. * @param updatable defines if the mesh must be flagged as updatable
  24773. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24774. * @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)
  24775. * @returns a new Mesh
  24776. */
  24777. 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;
  24778. /**
  24779. * Creates lathe mesh.
  24780. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  24781. * Please consider using the same method from the MeshBuilder class instead
  24782. * @param name defines the name of the mesh to create
  24783. * @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
  24784. * @param radius is the radius value of the lathe
  24785. * @param tessellation is the side number of the lathe.
  24786. * @param scene defines the hosting scene
  24787. * @param updatable defines if the mesh must be flagged as updatable
  24788. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24789. * @returns a new Mesh
  24790. */
  24791. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24792. /**
  24793. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  24794. * @param name defines the name of the mesh to create
  24795. * @param size sets the size (float) of both sides of the plane at once (default 1)
  24796. * @param scene defines the hosting scene
  24797. * @param updatable defines if the mesh must be flagged as updatable
  24798. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24799. * @returns a new Mesh
  24800. */
  24801. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24802. /**
  24803. * Creates a ground mesh.
  24804. * Please consider using the same method from the MeshBuilder class instead
  24805. * @param name defines the name of the mesh to create
  24806. * @param width set the width of the ground
  24807. * @param height set the height of the ground
  24808. * @param subdivisions sets the number of subdivisions per side
  24809. * @param scene defines the hosting scene
  24810. * @param updatable defines if the mesh must be flagged as updatable
  24811. * @returns a new Mesh
  24812. */
  24813. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  24814. /**
  24815. * Creates a tiled ground mesh.
  24816. * Please consider using the same method from the MeshBuilder class instead
  24817. * @param name defines the name of the mesh to create
  24818. * @param xmin set the ground minimum X coordinate
  24819. * @param zmin set the ground minimum Y coordinate
  24820. * @param xmax set the ground maximum X coordinate
  24821. * @param zmax set the ground maximum Z coordinate
  24822. * @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
  24823. * @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
  24824. * @param scene defines the hosting scene
  24825. * @param updatable defines if the mesh must be flagged as updatable
  24826. * @returns a new Mesh
  24827. */
  24828. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  24829. w: number;
  24830. h: number;
  24831. }, precision: {
  24832. w: number;
  24833. h: number;
  24834. }, scene: Scene, updatable?: boolean): Mesh;
  24835. /**
  24836. * Creates a ground mesh from a height map.
  24837. * Please consider using the same method from the MeshBuilder class instead
  24838. * @see http://doc.babylonjs.com/babylon101/height_map
  24839. * @param name defines the name of the mesh to create
  24840. * @param url sets the URL of the height map image resource
  24841. * @param width set the ground width size
  24842. * @param height set the ground height size
  24843. * @param subdivisions sets the number of subdivision per side
  24844. * @param minHeight is the minimum altitude on the ground
  24845. * @param maxHeight is the maximum altitude on the ground
  24846. * @param scene defines the hosting scene
  24847. * @param updatable defines if the mesh must be flagged as updatable
  24848. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  24849. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  24850. * @returns a new Mesh
  24851. */
  24852. 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;
  24853. /**
  24854. * Creates a tube mesh.
  24855. * The tube is a parametric shape.
  24856. * It has no predefined shape. Its final shape will depend on the input parameters.
  24857. * Please consider using the same method from the MeshBuilder class instead
  24858. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24859. * @param name defines the name of the mesh to create
  24860. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  24861. * @param radius sets the tube radius size
  24862. * @param tessellation is the number of sides on the tubular surface
  24863. * @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
  24864. * @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
  24865. * @param scene defines the hosting scene
  24866. * @param updatable defines if the mesh must be flagged as updatable
  24867. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24868. * @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)
  24869. * @returns a new Mesh
  24870. */
  24871. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  24872. (i: number, distance: number): number;
  24873. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24874. /**
  24875. * Creates a polyhedron mesh.
  24876. * Please consider using the same method from the MeshBuilder class instead.
  24877. * * 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
  24878. * * The parameter `size` (positive float, default 1) sets the polygon size
  24879. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  24880. * * 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`
  24881. * * 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
  24882. * * 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)`)
  24883. * * 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
  24884. * * 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
  24885. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24886. * * 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
  24887. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24888. * @param name defines the name of the mesh to create
  24889. * @param options defines the options used to create the mesh
  24890. * @param scene defines the hosting scene
  24891. * @returns a new Mesh
  24892. */
  24893. static CreatePolyhedron(name: string, options: {
  24894. type?: number;
  24895. size?: number;
  24896. sizeX?: number;
  24897. sizeY?: number;
  24898. sizeZ?: number;
  24899. custom?: any;
  24900. faceUV?: Vector4[];
  24901. faceColors?: Color4[];
  24902. updatable?: boolean;
  24903. sideOrientation?: number;
  24904. }, scene: Scene): Mesh;
  24905. /**
  24906. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  24907. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  24908. * * 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`)
  24909. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  24910. * * 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
  24911. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24912. * * 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
  24913. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24914. * @param name defines the name of the mesh
  24915. * @param options defines the options used to create the mesh
  24916. * @param scene defines the hosting scene
  24917. * @returns a new Mesh
  24918. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  24919. */
  24920. static CreateIcoSphere(name: string, options: {
  24921. radius?: number;
  24922. flat?: boolean;
  24923. subdivisions?: number;
  24924. sideOrientation?: number;
  24925. updatable?: boolean;
  24926. }, scene: Scene): Mesh;
  24927. /**
  24928. * Creates a decal mesh.
  24929. * Please consider using the same method from the MeshBuilder class instead.
  24930. * A decal is a mesh usually applied as a model onto the surface of another mesh
  24931. * @param name defines the name of the mesh
  24932. * @param sourceMesh defines the mesh receiving the decal
  24933. * @param position sets the position of the decal in world coordinates
  24934. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  24935. * @param size sets the decal scaling
  24936. * @param angle sets the angle to rotate the decal
  24937. * @returns a new Mesh
  24938. */
  24939. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  24940. /**
  24941. * Prepare internal position array for software CPU skinning
  24942. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  24943. */
  24944. setPositionsForCPUSkinning(): Float32Array;
  24945. /**
  24946. * Prepare internal normal array for software CPU skinning
  24947. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  24948. */
  24949. setNormalsForCPUSkinning(): Float32Array;
  24950. /**
  24951. * Updates the vertex buffer by applying transformation from the bones
  24952. * @param skeleton defines the skeleton to apply to current mesh
  24953. * @returns the current mesh
  24954. */
  24955. applySkeleton(skeleton: Skeleton): Mesh;
  24956. /**
  24957. * 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
  24958. * @param meshes defines the list of meshes to scan
  24959. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  24960. */
  24961. static MinMax(meshes: AbstractMesh[]): {
  24962. min: Vector3;
  24963. max: Vector3;
  24964. };
  24965. /**
  24966. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  24967. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  24968. * @returns a vector3
  24969. */
  24970. static Center(meshesOrMinMaxVector: {
  24971. min: Vector3;
  24972. max: Vector3;
  24973. } | AbstractMesh[]): Vector3;
  24974. /**
  24975. * Merge the array of meshes into a single mesh for performance reasons.
  24976. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  24977. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  24978. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  24979. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  24980. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  24981. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  24982. * @returns a new mesh
  24983. */
  24984. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  24985. /** @hidden */
  24986. addInstance(instance: InstancedMesh): void;
  24987. /** @hidden */
  24988. removeInstance(instance: InstancedMesh): void;
  24989. }
  24990. }
  24991. declare module BABYLON {
  24992. /**
  24993. * This is the base class of all the camera used in the application.
  24994. * @see http://doc.babylonjs.com/features/cameras
  24995. */
  24996. export class Camera extends Node {
  24997. /** @hidden */
  24998. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  24999. /**
  25000. * This is the default projection mode used by the cameras.
  25001. * It helps recreating a feeling of perspective and better appreciate depth.
  25002. * This is the best way to simulate real life cameras.
  25003. */
  25004. static readonly PERSPECTIVE_CAMERA: number;
  25005. /**
  25006. * This helps creating camera with an orthographic mode.
  25007. * 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.
  25008. */
  25009. static readonly ORTHOGRAPHIC_CAMERA: number;
  25010. /**
  25011. * This is the default FOV mode for perspective cameras.
  25012. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25013. */
  25014. static readonly FOVMODE_VERTICAL_FIXED: number;
  25015. /**
  25016. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25017. */
  25018. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25019. /**
  25020. * This specifies ther is no need for a camera rig.
  25021. * Basically only one eye is rendered corresponding to the camera.
  25022. */
  25023. static readonly RIG_MODE_NONE: number;
  25024. /**
  25025. * Simulates a camera Rig with one blue eye and one red eye.
  25026. * This can be use with 3d blue and red glasses.
  25027. */
  25028. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25029. /**
  25030. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25031. */
  25032. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25033. /**
  25034. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25035. */
  25036. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25037. /**
  25038. * Defines that both eyes of the camera will be rendered over under each other.
  25039. */
  25040. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25041. /**
  25042. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25043. */
  25044. static readonly RIG_MODE_VR: number;
  25045. /**
  25046. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25047. */
  25048. static readonly RIG_MODE_WEBVR: number;
  25049. /**
  25050. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25051. */
  25052. static readonly RIG_MODE_CUSTOM: number;
  25053. /**
  25054. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25055. */
  25056. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25057. /**
  25058. * Define the input manager associated with the camera.
  25059. */
  25060. inputs: CameraInputsManager<Camera>;
  25061. /** @hidden */
  25062. _position: Vector3;
  25063. /**
  25064. * Define the current local position of the camera in the scene
  25065. */
  25066. position: Vector3;
  25067. /**
  25068. * The vector the camera should consider as up.
  25069. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25070. */
  25071. upVector: Vector3;
  25072. /**
  25073. * Define the current limit on the left side for an orthographic camera
  25074. * In scene unit
  25075. */
  25076. orthoLeft: Nullable<number>;
  25077. /**
  25078. * Define the current limit on the right side for an orthographic camera
  25079. * In scene unit
  25080. */
  25081. orthoRight: Nullable<number>;
  25082. /**
  25083. * Define the current limit on the bottom side for an orthographic camera
  25084. * In scene unit
  25085. */
  25086. orthoBottom: Nullable<number>;
  25087. /**
  25088. * Define the current limit on the top side for an orthographic camera
  25089. * In scene unit
  25090. */
  25091. orthoTop: Nullable<number>;
  25092. /**
  25093. * Field Of View is set in Radians. (default is 0.8)
  25094. */
  25095. fov: number;
  25096. /**
  25097. * Define the minimum distance the camera can see from.
  25098. * This is important to note that the depth buffer are not infinite and the closer it starts
  25099. * the more your scene might encounter depth fighting issue.
  25100. */
  25101. minZ: number;
  25102. /**
  25103. * Define the maximum distance the camera can see to.
  25104. * This is important to note that the depth buffer are not infinite and the further it end
  25105. * the more your scene might encounter depth fighting issue.
  25106. */
  25107. maxZ: number;
  25108. /**
  25109. * Define the default inertia of the camera.
  25110. * This helps giving a smooth feeling to the camera movement.
  25111. */
  25112. inertia: number;
  25113. /**
  25114. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25115. */
  25116. mode: number;
  25117. /**
  25118. * Define wether the camera is intermediate.
  25119. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25120. */
  25121. isIntermediate: boolean;
  25122. /**
  25123. * Define the viewport of the camera.
  25124. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25125. */
  25126. viewport: Viewport;
  25127. /**
  25128. * Restricts the camera to viewing objects with the same layerMask.
  25129. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25130. */
  25131. layerMask: number;
  25132. /**
  25133. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25134. */
  25135. fovMode: number;
  25136. /**
  25137. * Rig mode of the camera.
  25138. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25139. * This is normally controlled byt the camera themselves as internal use.
  25140. */
  25141. cameraRigMode: number;
  25142. /**
  25143. * Defines the distance between both "eyes" in case of a RIG
  25144. */
  25145. interaxialDistance: number;
  25146. /**
  25147. * Defines if stereoscopic rendering is done side by side or over under.
  25148. */
  25149. isStereoscopicSideBySide: boolean;
  25150. /**
  25151. * 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
  25152. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25153. * else in the scene. (Eg. security camera)
  25154. *
  25155. * 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)
  25156. */
  25157. customRenderTargets: RenderTargetTexture[];
  25158. /**
  25159. * When set, the camera will render to this render target instead of the default canvas
  25160. *
  25161. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25162. */
  25163. outputRenderTarget: Nullable<RenderTargetTexture>;
  25164. /**
  25165. * Observable triggered when the camera view matrix has changed.
  25166. */
  25167. onViewMatrixChangedObservable: Observable<Camera>;
  25168. /**
  25169. * Observable triggered when the camera Projection matrix has changed.
  25170. */
  25171. onProjectionMatrixChangedObservable: Observable<Camera>;
  25172. /**
  25173. * Observable triggered when the inputs have been processed.
  25174. */
  25175. onAfterCheckInputsObservable: Observable<Camera>;
  25176. /**
  25177. * Observable triggered when reset has been called and applied to the camera.
  25178. */
  25179. onRestoreStateObservable: Observable<Camera>;
  25180. /** @hidden */
  25181. _cameraRigParams: any;
  25182. /** @hidden */
  25183. _rigCameras: Camera[];
  25184. /** @hidden */
  25185. _rigPostProcess: Nullable<PostProcess>;
  25186. protected _webvrViewMatrix: Matrix;
  25187. /** @hidden */
  25188. _skipRendering: boolean;
  25189. /** @hidden */
  25190. _projectionMatrix: Matrix;
  25191. /** @hidden */
  25192. _postProcesses: Nullable<PostProcess>[];
  25193. /** @hidden */
  25194. _activeMeshes: SmartArray<AbstractMesh>;
  25195. protected _globalPosition: Vector3;
  25196. /** @hidden */
  25197. _computedViewMatrix: Matrix;
  25198. private _doNotComputeProjectionMatrix;
  25199. private _transformMatrix;
  25200. private _frustumPlanes;
  25201. private _refreshFrustumPlanes;
  25202. private _storedFov;
  25203. private _stateStored;
  25204. /**
  25205. * Instantiates a new camera object.
  25206. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25207. * @see http://doc.babylonjs.com/features/cameras
  25208. * @param name Defines the name of the camera in the scene
  25209. * @param position Defines the position of the camera
  25210. * @param scene Defines the scene the camera belongs too
  25211. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25212. */
  25213. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25214. /**
  25215. * Store current camera state (fov, position, etc..)
  25216. * @returns the camera
  25217. */
  25218. storeState(): Camera;
  25219. /**
  25220. * Restores the camera state values if it has been stored. You must call storeState() first
  25221. */
  25222. protected _restoreStateValues(): boolean;
  25223. /**
  25224. * Restored camera state. You must call storeState() first.
  25225. * @returns true if restored and false otherwise
  25226. */
  25227. restoreState(): boolean;
  25228. /**
  25229. * Gets the class name of the camera.
  25230. * @returns the class name
  25231. */
  25232. getClassName(): string;
  25233. /** @hidden */
  25234. readonly _isCamera: boolean;
  25235. /**
  25236. * Gets a string representation of the camera useful for debug purpose.
  25237. * @param fullDetails Defines that a more verboe level of logging is required
  25238. * @returns the string representation
  25239. */
  25240. toString(fullDetails?: boolean): string;
  25241. /**
  25242. * Gets the current world space position of the camera.
  25243. */
  25244. readonly globalPosition: Vector3;
  25245. /**
  25246. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25247. * @returns the active meshe list
  25248. */
  25249. getActiveMeshes(): SmartArray<AbstractMesh>;
  25250. /**
  25251. * Check wether a mesh is part of the current active mesh list of the camera
  25252. * @param mesh Defines the mesh to check
  25253. * @returns true if active, false otherwise
  25254. */
  25255. isActiveMesh(mesh: Mesh): boolean;
  25256. /**
  25257. * Is this camera ready to be used/rendered
  25258. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25259. * @return true if the camera is ready
  25260. */
  25261. isReady(completeCheck?: boolean): boolean;
  25262. /** @hidden */
  25263. _initCache(): void;
  25264. /** @hidden */
  25265. _updateCache(ignoreParentClass?: boolean): void;
  25266. /** @hidden */
  25267. _isSynchronized(): boolean;
  25268. /** @hidden */
  25269. _isSynchronizedViewMatrix(): boolean;
  25270. /** @hidden */
  25271. _isSynchronizedProjectionMatrix(): boolean;
  25272. /**
  25273. * Attach the input controls to a specific dom element to get the input from.
  25274. * @param element Defines the element the controls should be listened from
  25275. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25276. */
  25277. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25278. /**
  25279. * Detach the current controls from the specified dom element.
  25280. * @param element Defines the element to stop listening the inputs from
  25281. */
  25282. detachControl(element: HTMLElement): void;
  25283. /**
  25284. * Update the camera state according to the different inputs gathered during the frame.
  25285. */
  25286. update(): void;
  25287. /** @hidden */
  25288. _checkInputs(): void;
  25289. /** @hidden */
  25290. readonly rigCameras: Camera[];
  25291. /**
  25292. * Gets the post process used by the rig cameras
  25293. */
  25294. readonly rigPostProcess: Nullable<PostProcess>;
  25295. /**
  25296. * Internal, gets the first post proces.
  25297. * @returns the first post process to be run on this camera.
  25298. */
  25299. _getFirstPostProcess(): Nullable<PostProcess>;
  25300. private _cascadePostProcessesToRigCams;
  25301. /**
  25302. * Attach a post process to the camera.
  25303. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25304. * @param postProcess The post process to attach to the camera
  25305. * @param insertAt The position of the post process in case several of them are in use in the scene
  25306. * @returns the position the post process has been inserted at
  25307. */
  25308. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25309. /**
  25310. * Detach a post process to the camera.
  25311. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25312. * @param postProcess The post process to detach from the camera
  25313. */
  25314. detachPostProcess(postProcess: PostProcess): void;
  25315. /**
  25316. * Gets the current world matrix of the camera
  25317. */
  25318. getWorldMatrix(): Matrix;
  25319. /** @hidden */
  25320. _getViewMatrix(): Matrix;
  25321. /**
  25322. * Gets the current view matrix of the camera.
  25323. * @param force forces the camera to recompute the matrix without looking at the cached state
  25324. * @returns the view matrix
  25325. */
  25326. getViewMatrix(force?: boolean): Matrix;
  25327. /**
  25328. * Freeze the projection matrix.
  25329. * It will prevent the cache check of the camera projection compute and can speed up perf
  25330. * if no parameter of the camera are meant to change
  25331. * @param projection Defines manually a projection if necessary
  25332. */
  25333. freezeProjectionMatrix(projection?: Matrix): void;
  25334. /**
  25335. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25336. */
  25337. unfreezeProjectionMatrix(): void;
  25338. /**
  25339. * Gets the current projection matrix of the camera.
  25340. * @param force forces the camera to recompute the matrix without looking at the cached state
  25341. * @returns the projection matrix
  25342. */
  25343. getProjectionMatrix(force?: boolean): Matrix;
  25344. /**
  25345. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25346. * @returns a Matrix
  25347. */
  25348. getTransformationMatrix(): Matrix;
  25349. private _updateFrustumPlanes;
  25350. /**
  25351. * Checks if a cullable object (mesh...) is in the camera frustum
  25352. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25353. * @param target The object to check
  25354. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25355. * @returns true if the object is in frustum otherwise false
  25356. */
  25357. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25358. /**
  25359. * Checks if a cullable object (mesh...) is in the camera frustum
  25360. * Unlike isInFrustum this cheks the full bounding box
  25361. * @param target The object to check
  25362. * @returns true if the object is in frustum otherwise false
  25363. */
  25364. isCompletelyInFrustum(target: ICullable): boolean;
  25365. /**
  25366. * Gets a ray in the forward direction from the camera.
  25367. * @param length Defines the length of the ray to create
  25368. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25369. * @param origin Defines the start point of the ray which defaults to the camera position
  25370. * @returns the forward ray
  25371. */
  25372. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25373. /**
  25374. * Releases resources associated with this node.
  25375. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25376. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25377. */
  25378. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25379. /** @hidden */
  25380. _isLeftCamera: boolean;
  25381. /**
  25382. * Gets the left camera of a rig setup in case of Rigged Camera
  25383. */
  25384. readonly isLeftCamera: boolean;
  25385. /** @hidden */
  25386. _isRightCamera: boolean;
  25387. /**
  25388. * Gets the right camera of a rig setup in case of Rigged Camera
  25389. */
  25390. readonly isRightCamera: boolean;
  25391. /**
  25392. * Gets the left camera of a rig setup in case of Rigged Camera
  25393. */
  25394. readonly leftCamera: Nullable<FreeCamera>;
  25395. /**
  25396. * Gets the right camera of a rig setup in case of Rigged Camera
  25397. */
  25398. readonly rightCamera: Nullable<FreeCamera>;
  25399. /**
  25400. * Gets the left camera target of a rig setup in case of Rigged Camera
  25401. * @returns the target position
  25402. */
  25403. getLeftTarget(): Nullable<Vector3>;
  25404. /**
  25405. * Gets the right camera target of a rig setup in case of Rigged Camera
  25406. * @returns the target position
  25407. */
  25408. getRightTarget(): Nullable<Vector3>;
  25409. /**
  25410. * @hidden
  25411. */
  25412. setCameraRigMode(mode: number, rigParams: any): void;
  25413. /** @hidden */
  25414. static _setStereoscopicRigMode(camera: Camera): void;
  25415. /** @hidden */
  25416. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25417. /** @hidden */
  25418. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25419. /** @hidden */
  25420. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25421. /** @hidden */
  25422. _getVRProjectionMatrix(): Matrix;
  25423. protected _updateCameraRotationMatrix(): void;
  25424. protected _updateWebVRCameraRotationMatrix(): void;
  25425. /**
  25426. * This function MUST be overwritten by the different WebVR cameras available.
  25427. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25428. * @hidden
  25429. */
  25430. _getWebVRProjectionMatrix(): Matrix;
  25431. /**
  25432. * This function MUST be overwritten by the different WebVR cameras available.
  25433. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25434. * @hidden
  25435. */
  25436. _getWebVRViewMatrix(): Matrix;
  25437. /** @hidden */
  25438. setCameraRigParameter(name: string, value: any): void;
  25439. /**
  25440. * needs to be overridden by children so sub has required properties to be copied
  25441. * @hidden
  25442. */
  25443. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25444. /**
  25445. * May need to be overridden by children
  25446. * @hidden
  25447. */
  25448. _updateRigCameras(): void;
  25449. /** @hidden */
  25450. _setupInputs(): void;
  25451. /**
  25452. * Serialiaze the camera setup to a json represention
  25453. * @returns the JSON representation
  25454. */
  25455. serialize(): any;
  25456. /**
  25457. * Clones the current camera.
  25458. * @param name The cloned camera name
  25459. * @returns the cloned camera
  25460. */
  25461. clone(name: string): Camera;
  25462. /**
  25463. * Gets the direction of the camera relative to a given local axis.
  25464. * @param localAxis Defines the reference axis to provide a relative direction.
  25465. * @return the direction
  25466. */
  25467. getDirection(localAxis: Vector3): Vector3;
  25468. /**
  25469. * Returns the current camera absolute rotation
  25470. */
  25471. readonly absoluteRotation: Quaternion;
  25472. /**
  25473. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25474. * @param localAxis Defines the reference axis to provide a relative direction.
  25475. * @param result Defines the vector to store the result in
  25476. */
  25477. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25478. /**
  25479. * Gets a camera constructor for a given camera type
  25480. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25481. * @param name The name of the camera the result will be able to instantiate
  25482. * @param scene The scene the result will construct the camera in
  25483. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25484. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25485. * @returns a factory method to construc the camera
  25486. */
  25487. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25488. /**
  25489. * Compute the world matrix of the camera.
  25490. * @returns the camera world matrix
  25491. */
  25492. computeWorldMatrix(): Matrix;
  25493. /**
  25494. * Parse a JSON and creates the camera from the parsed information
  25495. * @param parsedCamera The JSON to parse
  25496. * @param scene The scene to instantiate the camera in
  25497. * @returns the newly constructed camera
  25498. */
  25499. static Parse(parsedCamera: any, scene: Scene): Camera;
  25500. }
  25501. }
  25502. declare module BABYLON {
  25503. /**
  25504. * Class containing static functions to help procedurally build meshes
  25505. */
  25506. export class DiscBuilder {
  25507. /**
  25508. * Creates a plane polygonal mesh. By default, this is a disc
  25509. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25510. * * 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
  25511. * * 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
  25512. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25513. * * 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
  25514. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25515. * @param name defines the name of the mesh
  25516. * @param options defines the options used to create the mesh
  25517. * @param scene defines the hosting scene
  25518. * @returns the plane polygonal mesh
  25519. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25520. */
  25521. static CreateDisc(name: string, options: {
  25522. radius?: number;
  25523. tessellation?: number;
  25524. arc?: number;
  25525. updatable?: boolean;
  25526. sideOrientation?: number;
  25527. frontUVs?: Vector4;
  25528. backUVs?: Vector4;
  25529. }, scene?: Nullable<Scene>): Mesh;
  25530. }
  25531. }
  25532. declare module BABYLON {
  25533. /**
  25534. * This represents all the required information to add a fresnel effect on a material:
  25535. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25536. */
  25537. export class FresnelParameters {
  25538. private _isEnabled;
  25539. /**
  25540. * Define if the fresnel effect is enable or not.
  25541. */
  25542. isEnabled: boolean;
  25543. /**
  25544. * Define the color used on edges (grazing angle)
  25545. */
  25546. leftColor: Color3;
  25547. /**
  25548. * Define the color used on center
  25549. */
  25550. rightColor: Color3;
  25551. /**
  25552. * Define bias applied to computed fresnel term
  25553. */
  25554. bias: number;
  25555. /**
  25556. * Defined the power exponent applied to fresnel term
  25557. */
  25558. power: number;
  25559. /**
  25560. * Clones the current fresnel and its valuues
  25561. * @returns a clone fresnel configuration
  25562. */
  25563. clone(): FresnelParameters;
  25564. /**
  25565. * Serializes the current fresnel parameters to a JSON representation.
  25566. * @return the JSON serialization
  25567. */
  25568. serialize(): any;
  25569. /**
  25570. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  25571. * @param parsedFresnelParameters Define the JSON representation
  25572. * @returns the parsed parameters
  25573. */
  25574. static Parse(parsedFresnelParameters: any): FresnelParameters;
  25575. }
  25576. }
  25577. declare module BABYLON {
  25578. /**
  25579. * Base class of materials working in push mode in babylon JS
  25580. * @hidden
  25581. */
  25582. export class PushMaterial extends Material {
  25583. protected _activeEffect: Effect;
  25584. protected _normalMatrix: Matrix;
  25585. /**
  25586. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  25587. * This means that the material can keep using a previous shader while a new one is being compiled.
  25588. * This is mostly used when shader parallel compilation is supported (true by default)
  25589. */
  25590. allowShaderHotSwapping: boolean;
  25591. constructor(name: string, scene: Scene);
  25592. getEffect(): Effect;
  25593. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  25594. /**
  25595. * Binds the given world matrix to the active effect
  25596. *
  25597. * @param world the matrix to bind
  25598. */
  25599. bindOnlyWorldMatrix(world: Matrix): void;
  25600. /**
  25601. * Binds the given normal matrix to the active effect
  25602. *
  25603. * @param normalMatrix the matrix to bind
  25604. */
  25605. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  25606. bind(world: Matrix, mesh?: Mesh): void;
  25607. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  25608. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  25609. }
  25610. }
  25611. declare module BABYLON {
  25612. /**
  25613. * This groups all the flags used to control the materials channel.
  25614. */
  25615. export class MaterialFlags {
  25616. private static _DiffuseTextureEnabled;
  25617. /**
  25618. * Are diffuse textures enabled in the application.
  25619. */
  25620. static DiffuseTextureEnabled: boolean;
  25621. private static _AmbientTextureEnabled;
  25622. /**
  25623. * Are ambient textures enabled in the application.
  25624. */
  25625. static AmbientTextureEnabled: boolean;
  25626. private static _OpacityTextureEnabled;
  25627. /**
  25628. * Are opacity textures enabled in the application.
  25629. */
  25630. static OpacityTextureEnabled: boolean;
  25631. private static _ReflectionTextureEnabled;
  25632. /**
  25633. * Are reflection textures enabled in the application.
  25634. */
  25635. static ReflectionTextureEnabled: boolean;
  25636. private static _EmissiveTextureEnabled;
  25637. /**
  25638. * Are emissive textures enabled in the application.
  25639. */
  25640. static EmissiveTextureEnabled: boolean;
  25641. private static _SpecularTextureEnabled;
  25642. /**
  25643. * Are specular textures enabled in the application.
  25644. */
  25645. static SpecularTextureEnabled: boolean;
  25646. private static _BumpTextureEnabled;
  25647. /**
  25648. * Are bump textures enabled in the application.
  25649. */
  25650. static BumpTextureEnabled: boolean;
  25651. private static _LightmapTextureEnabled;
  25652. /**
  25653. * Are lightmap textures enabled in the application.
  25654. */
  25655. static LightmapTextureEnabled: boolean;
  25656. private static _RefractionTextureEnabled;
  25657. /**
  25658. * Are refraction textures enabled in the application.
  25659. */
  25660. static RefractionTextureEnabled: boolean;
  25661. private static _ColorGradingTextureEnabled;
  25662. /**
  25663. * Are color grading textures enabled in the application.
  25664. */
  25665. static ColorGradingTextureEnabled: boolean;
  25666. private static _FresnelEnabled;
  25667. /**
  25668. * Are fresnels enabled in the application.
  25669. */
  25670. static FresnelEnabled: boolean;
  25671. private static _ClearCoatTextureEnabled;
  25672. /**
  25673. * Are clear coat textures enabled in the application.
  25674. */
  25675. static ClearCoatTextureEnabled: boolean;
  25676. private static _ClearCoatBumpTextureEnabled;
  25677. /**
  25678. * Are clear coat bump textures enabled in the application.
  25679. */
  25680. static ClearCoatBumpTextureEnabled: boolean;
  25681. private static _ClearCoatTintTextureEnabled;
  25682. /**
  25683. * Are clear coat tint textures enabled in the application.
  25684. */
  25685. static ClearCoatTintTextureEnabled: boolean;
  25686. private static _SheenTextureEnabled;
  25687. /**
  25688. * Are sheen textures enabled in the application.
  25689. */
  25690. static SheenTextureEnabled: boolean;
  25691. private static _AnisotropicTextureEnabled;
  25692. /**
  25693. * Are anisotropic textures enabled in the application.
  25694. */
  25695. static AnisotropicTextureEnabled: boolean;
  25696. private static _ThicknessTextureEnabled;
  25697. /**
  25698. * Are thickness textures enabled in the application.
  25699. */
  25700. static ThicknessTextureEnabled: boolean;
  25701. }
  25702. }
  25703. declare module BABYLON {
  25704. /** @hidden */
  25705. export var defaultFragmentDeclaration: {
  25706. name: string;
  25707. shader: string;
  25708. };
  25709. }
  25710. declare module BABYLON {
  25711. /** @hidden */
  25712. export var defaultUboDeclaration: {
  25713. name: string;
  25714. shader: string;
  25715. };
  25716. }
  25717. declare module BABYLON {
  25718. /** @hidden */
  25719. export var lightFragmentDeclaration: {
  25720. name: string;
  25721. shader: string;
  25722. };
  25723. }
  25724. declare module BABYLON {
  25725. /** @hidden */
  25726. export var lightUboDeclaration: {
  25727. name: string;
  25728. shader: string;
  25729. };
  25730. }
  25731. declare module BABYLON {
  25732. /** @hidden */
  25733. export var lightsFragmentFunctions: {
  25734. name: string;
  25735. shader: string;
  25736. };
  25737. }
  25738. declare module BABYLON {
  25739. /** @hidden */
  25740. export var shadowsFragmentFunctions: {
  25741. name: string;
  25742. shader: string;
  25743. };
  25744. }
  25745. declare module BABYLON {
  25746. /** @hidden */
  25747. export var fresnelFunction: {
  25748. name: string;
  25749. shader: string;
  25750. };
  25751. }
  25752. declare module BABYLON {
  25753. /** @hidden */
  25754. export var reflectionFunction: {
  25755. name: string;
  25756. shader: string;
  25757. };
  25758. }
  25759. declare module BABYLON {
  25760. /** @hidden */
  25761. export var bumpFragmentFunctions: {
  25762. name: string;
  25763. shader: string;
  25764. };
  25765. }
  25766. declare module BABYLON {
  25767. /** @hidden */
  25768. export var logDepthDeclaration: {
  25769. name: string;
  25770. shader: string;
  25771. };
  25772. }
  25773. declare module BABYLON {
  25774. /** @hidden */
  25775. export var bumpFragment: {
  25776. name: string;
  25777. shader: string;
  25778. };
  25779. }
  25780. declare module BABYLON {
  25781. /** @hidden */
  25782. export var depthPrePass: {
  25783. name: string;
  25784. shader: string;
  25785. };
  25786. }
  25787. declare module BABYLON {
  25788. /** @hidden */
  25789. export var lightFragment: {
  25790. name: string;
  25791. shader: string;
  25792. };
  25793. }
  25794. declare module BABYLON {
  25795. /** @hidden */
  25796. export var logDepthFragment: {
  25797. name: string;
  25798. shader: string;
  25799. };
  25800. }
  25801. declare module BABYLON {
  25802. /** @hidden */
  25803. export var defaultPixelShader: {
  25804. name: string;
  25805. shader: string;
  25806. };
  25807. }
  25808. declare module BABYLON {
  25809. /** @hidden */
  25810. export var defaultVertexDeclaration: {
  25811. name: string;
  25812. shader: string;
  25813. };
  25814. }
  25815. declare module BABYLON {
  25816. /** @hidden */
  25817. export var bumpVertexDeclaration: {
  25818. name: string;
  25819. shader: string;
  25820. };
  25821. }
  25822. declare module BABYLON {
  25823. /** @hidden */
  25824. export var bumpVertex: {
  25825. name: string;
  25826. shader: string;
  25827. };
  25828. }
  25829. declare module BABYLON {
  25830. /** @hidden */
  25831. export var fogVertex: {
  25832. name: string;
  25833. shader: string;
  25834. };
  25835. }
  25836. declare module BABYLON {
  25837. /** @hidden */
  25838. export var shadowsVertex: {
  25839. name: string;
  25840. shader: string;
  25841. };
  25842. }
  25843. declare module BABYLON {
  25844. /** @hidden */
  25845. export var pointCloudVertex: {
  25846. name: string;
  25847. shader: string;
  25848. };
  25849. }
  25850. declare module BABYLON {
  25851. /** @hidden */
  25852. export var logDepthVertex: {
  25853. name: string;
  25854. shader: string;
  25855. };
  25856. }
  25857. declare module BABYLON {
  25858. /** @hidden */
  25859. export var defaultVertexShader: {
  25860. name: string;
  25861. shader: string;
  25862. };
  25863. }
  25864. declare module BABYLON {
  25865. /** @hidden */
  25866. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  25867. MAINUV1: boolean;
  25868. MAINUV2: boolean;
  25869. DIFFUSE: boolean;
  25870. DIFFUSEDIRECTUV: number;
  25871. AMBIENT: boolean;
  25872. AMBIENTDIRECTUV: number;
  25873. OPACITY: boolean;
  25874. OPACITYDIRECTUV: number;
  25875. OPACITYRGB: boolean;
  25876. REFLECTION: boolean;
  25877. EMISSIVE: boolean;
  25878. EMISSIVEDIRECTUV: number;
  25879. SPECULAR: boolean;
  25880. SPECULARDIRECTUV: number;
  25881. BUMP: boolean;
  25882. BUMPDIRECTUV: number;
  25883. PARALLAX: boolean;
  25884. PARALLAXOCCLUSION: boolean;
  25885. SPECULAROVERALPHA: boolean;
  25886. CLIPPLANE: boolean;
  25887. CLIPPLANE2: boolean;
  25888. CLIPPLANE3: boolean;
  25889. CLIPPLANE4: boolean;
  25890. ALPHATEST: boolean;
  25891. DEPTHPREPASS: boolean;
  25892. ALPHAFROMDIFFUSE: boolean;
  25893. POINTSIZE: boolean;
  25894. FOG: boolean;
  25895. SPECULARTERM: boolean;
  25896. DIFFUSEFRESNEL: boolean;
  25897. OPACITYFRESNEL: boolean;
  25898. REFLECTIONFRESNEL: boolean;
  25899. REFRACTIONFRESNEL: boolean;
  25900. EMISSIVEFRESNEL: boolean;
  25901. FRESNEL: boolean;
  25902. NORMAL: boolean;
  25903. UV1: boolean;
  25904. UV2: boolean;
  25905. VERTEXCOLOR: boolean;
  25906. VERTEXALPHA: boolean;
  25907. NUM_BONE_INFLUENCERS: number;
  25908. BonesPerMesh: number;
  25909. BONETEXTURE: boolean;
  25910. INSTANCES: boolean;
  25911. GLOSSINESS: boolean;
  25912. ROUGHNESS: boolean;
  25913. EMISSIVEASILLUMINATION: boolean;
  25914. LINKEMISSIVEWITHDIFFUSE: boolean;
  25915. REFLECTIONFRESNELFROMSPECULAR: boolean;
  25916. LIGHTMAP: boolean;
  25917. LIGHTMAPDIRECTUV: number;
  25918. OBJECTSPACE_NORMALMAP: boolean;
  25919. USELIGHTMAPASSHADOWMAP: boolean;
  25920. REFLECTIONMAP_3D: boolean;
  25921. REFLECTIONMAP_SPHERICAL: boolean;
  25922. REFLECTIONMAP_PLANAR: boolean;
  25923. REFLECTIONMAP_CUBIC: boolean;
  25924. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  25925. REFLECTIONMAP_PROJECTION: boolean;
  25926. REFLECTIONMAP_SKYBOX: boolean;
  25927. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  25928. REFLECTIONMAP_EXPLICIT: boolean;
  25929. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  25930. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  25931. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  25932. INVERTCUBICMAP: boolean;
  25933. LOGARITHMICDEPTH: boolean;
  25934. REFRACTION: boolean;
  25935. REFRACTIONMAP_3D: boolean;
  25936. REFLECTIONOVERALPHA: boolean;
  25937. TWOSIDEDLIGHTING: boolean;
  25938. SHADOWFLOAT: boolean;
  25939. MORPHTARGETS: boolean;
  25940. MORPHTARGETS_NORMAL: boolean;
  25941. MORPHTARGETS_TANGENT: boolean;
  25942. MORPHTARGETS_UV: boolean;
  25943. NUM_MORPH_INFLUENCERS: number;
  25944. NONUNIFORMSCALING: boolean;
  25945. PREMULTIPLYALPHA: boolean;
  25946. IMAGEPROCESSING: boolean;
  25947. VIGNETTE: boolean;
  25948. VIGNETTEBLENDMODEMULTIPLY: boolean;
  25949. VIGNETTEBLENDMODEOPAQUE: boolean;
  25950. TONEMAPPING: boolean;
  25951. TONEMAPPING_ACES: boolean;
  25952. CONTRAST: boolean;
  25953. COLORCURVES: boolean;
  25954. COLORGRADING: boolean;
  25955. COLORGRADING3D: boolean;
  25956. SAMPLER3DGREENDEPTH: boolean;
  25957. SAMPLER3DBGRMAP: boolean;
  25958. IMAGEPROCESSINGPOSTPROCESS: boolean;
  25959. MULTIVIEW: boolean;
  25960. /**
  25961. * If the reflection texture on this material is in linear color space
  25962. * @hidden
  25963. */
  25964. IS_REFLECTION_LINEAR: boolean;
  25965. /**
  25966. * If the refraction texture on this material is in linear color space
  25967. * @hidden
  25968. */
  25969. IS_REFRACTION_LINEAR: boolean;
  25970. EXPOSURE: boolean;
  25971. constructor();
  25972. setReflectionMode(modeToEnable: string): void;
  25973. }
  25974. /**
  25975. * This is the default material used in Babylon. It is the best trade off between quality
  25976. * and performances.
  25977. * @see http://doc.babylonjs.com/babylon101/materials
  25978. */
  25979. export class StandardMaterial extends PushMaterial {
  25980. private _diffuseTexture;
  25981. /**
  25982. * The basic texture of the material as viewed under a light.
  25983. */
  25984. diffuseTexture: Nullable<BaseTexture>;
  25985. private _ambientTexture;
  25986. /**
  25987. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  25988. */
  25989. ambientTexture: Nullable<BaseTexture>;
  25990. private _opacityTexture;
  25991. /**
  25992. * Define the transparency of the material from a texture.
  25993. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  25994. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  25995. */
  25996. opacityTexture: Nullable<BaseTexture>;
  25997. private _reflectionTexture;
  25998. /**
  25999. * Define the texture used to display the reflection.
  26000. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26001. */
  26002. reflectionTexture: Nullable<BaseTexture>;
  26003. private _emissiveTexture;
  26004. /**
  26005. * Define texture of the material as if self lit.
  26006. * This will be mixed in the final result even in the absence of light.
  26007. */
  26008. emissiveTexture: Nullable<BaseTexture>;
  26009. private _specularTexture;
  26010. /**
  26011. * Define how the color and intensity of the highlight given by the light in the material.
  26012. */
  26013. specularTexture: Nullable<BaseTexture>;
  26014. private _bumpTexture;
  26015. /**
  26016. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  26017. * 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.
  26018. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  26019. */
  26020. bumpTexture: Nullable<BaseTexture>;
  26021. private _lightmapTexture;
  26022. /**
  26023. * Complex lighting can be computationally expensive to compute at runtime.
  26024. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  26025. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  26026. */
  26027. lightmapTexture: Nullable<BaseTexture>;
  26028. private _refractionTexture;
  26029. /**
  26030. * Define the texture used to display the refraction.
  26031. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26032. */
  26033. refractionTexture: Nullable<BaseTexture>;
  26034. /**
  26035. * The color of the material lit by the environmental background lighting.
  26036. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  26037. */
  26038. ambientColor: Color3;
  26039. /**
  26040. * The basic color of the material as viewed under a light.
  26041. */
  26042. diffuseColor: Color3;
  26043. /**
  26044. * Define how the color and intensity of the highlight given by the light in the material.
  26045. */
  26046. specularColor: Color3;
  26047. /**
  26048. * Define the color of the material as if self lit.
  26049. * This will be mixed in the final result even in the absence of light.
  26050. */
  26051. emissiveColor: Color3;
  26052. /**
  26053. * Defines how sharp are the highlights in the material.
  26054. * The bigger the value the sharper giving a more glossy feeling to the result.
  26055. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  26056. */
  26057. specularPower: number;
  26058. private _useAlphaFromDiffuseTexture;
  26059. /**
  26060. * Does the transparency come from the diffuse texture alpha channel.
  26061. */
  26062. useAlphaFromDiffuseTexture: boolean;
  26063. private _useEmissiveAsIllumination;
  26064. /**
  26065. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  26066. */
  26067. useEmissiveAsIllumination: boolean;
  26068. private _linkEmissiveWithDiffuse;
  26069. /**
  26070. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  26071. * the emissive level when the final color is close to one.
  26072. */
  26073. linkEmissiveWithDiffuse: boolean;
  26074. private _useSpecularOverAlpha;
  26075. /**
  26076. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  26077. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  26078. */
  26079. useSpecularOverAlpha: boolean;
  26080. private _useReflectionOverAlpha;
  26081. /**
  26082. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  26083. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  26084. */
  26085. useReflectionOverAlpha: boolean;
  26086. private _disableLighting;
  26087. /**
  26088. * Does lights from the scene impacts this material.
  26089. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  26090. */
  26091. disableLighting: boolean;
  26092. private _useObjectSpaceNormalMap;
  26093. /**
  26094. * Allows using an object space normal map (instead of tangent space).
  26095. */
  26096. useObjectSpaceNormalMap: boolean;
  26097. private _useParallax;
  26098. /**
  26099. * Is parallax enabled or not.
  26100. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26101. */
  26102. useParallax: boolean;
  26103. private _useParallaxOcclusion;
  26104. /**
  26105. * Is parallax occlusion enabled or not.
  26106. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  26107. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26108. */
  26109. useParallaxOcclusion: boolean;
  26110. /**
  26111. * 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.
  26112. */
  26113. parallaxScaleBias: number;
  26114. private _roughness;
  26115. /**
  26116. * Helps to define how blurry the reflections should appears in the material.
  26117. */
  26118. roughness: number;
  26119. /**
  26120. * In case of refraction, define the value of the index of refraction.
  26121. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26122. */
  26123. indexOfRefraction: number;
  26124. /**
  26125. * Invert the refraction texture alongside the y axis.
  26126. * It can be useful with procedural textures or probe for instance.
  26127. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26128. */
  26129. invertRefractionY: boolean;
  26130. /**
  26131. * Defines the alpha limits in alpha test mode.
  26132. */
  26133. alphaCutOff: number;
  26134. private _useLightmapAsShadowmap;
  26135. /**
  26136. * In case of light mapping, define whether the map contains light or shadow informations.
  26137. */
  26138. useLightmapAsShadowmap: boolean;
  26139. private _diffuseFresnelParameters;
  26140. /**
  26141. * Define the diffuse fresnel parameters of the material.
  26142. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26143. */
  26144. diffuseFresnelParameters: FresnelParameters;
  26145. private _opacityFresnelParameters;
  26146. /**
  26147. * Define the opacity fresnel parameters of the material.
  26148. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26149. */
  26150. opacityFresnelParameters: FresnelParameters;
  26151. private _reflectionFresnelParameters;
  26152. /**
  26153. * Define the reflection fresnel parameters of the material.
  26154. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26155. */
  26156. reflectionFresnelParameters: FresnelParameters;
  26157. private _refractionFresnelParameters;
  26158. /**
  26159. * Define the refraction fresnel parameters of the material.
  26160. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26161. */
  26162. refractionFresnelParameters: FresnelParameters;
  26163. private _emissiveFresnelParameters;
  26164. /**
  26165. * Define the emissive fresnel parameters of the material.
  26166. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26167. */
  26168. emissiveFresnelParameters: FresnelParameters;
  26169. private _useReflectionFresnelFromSpecular;
  26170. /**
  26171. * If true automatically deducts the fresnels values from the material specularity.
  26172. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26173. */
  26174. useReflectionFresnelFromSpecular: boolean;
  26175. private _useGlossinessFromSpecularMapAlpha;
  26176. /**
  26177. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  26178. */
  26179. useGlossinessFromSpecularMapAlpha: boolean;
  26180. private _maxSimultaneousLights;
  26181. /**
  26182. * Defines the maximum number of lights that can be used in the material
  26183. */
  26184. maxSimultaneousLights: number;
  26185. private _invertNormalMapX;
  26186. /**
  26187. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  26188. */
  26189. invertNormalMapX: boolean;
  26190. private _invertNormalMapY;
  26191. /**
  26192. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  26193. */
  26194. invertNormalMapY: boolean;
  26195. private _twoSidedLighting;
  26196. /**
  26197. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  26198. */
  26199. twoSidedLighting: boolean;
  26200. /**
  26201. * Default configuration related to image processing available in the standard Material.
  26202. */
  26203. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  26204. /**
  26205. * Gets the image processing configuration used either in this material.
  26206. */
  26207. /**
  26208. * Sets the Default image processing configuration used either in the this material.
  26209. *
  26210. * If sets to null, the scene one is in use.
  26211. */
  26212. imageProcessingConfiguration: ImageProcessingConfiguration;
  26213. /**
  26214. * Keep track of the image processing observer to allow dispose and replace.
  26215. */
  26216. private _imageProcessingObserver;
  26217. /**
  26218. * Attaches a new image processing configuration to the Standard Material.
  26219. * @param configuration
  26220. */
  26221. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  26222. /**
  26223. * Gets wether the color curves effect is enabled.
  26224. */
  26225. /**
  26226. * Sets wether the color curves effect is enabled.
  26227. */
  26228. cameraColorCurvesEnabled: boolean;
  26229. /**
  26230. * Gets wether the color grading effect is enabled.
  26231. */
  26232. /**
  26233. * Gets wether the color grading effect is enabled.
  26234. */
  26235. cameraColorGradingEnabled: boolean;
  26236. /**
  26237. * Gets wether tonemapping is enabled or not.
  26238. */
  26239. /**
  26240. * Sets wether tonemapping is enabled or not
  26241. */
  26242. cameraToneMappingEnabled: boolean;
  26243. /**
  26244. * The camera exposure used on this material.
  26245. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26246. * This corresponds to a photographic exposure.
  26247. */
  26248. /**
  26249. * The camera exposure used on this material.
  26250. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26251. * This corresponds to a photographic exposure.
  26252. */
  26253. cameraExposure: number;
  26254. /**
  26255. * Gets The camera contrast used on this material.
  26256. */
  26257. /**
  26258. * Sets The camera contrast used on this material.
  26259. */
  26260. cameraContrast: number;
  26261. /**
  26262. * Gets the Color Grading 2D Lookup Texture.
  26263. */
  26264. /**
  26265. * Sets the Color Grading 2D Lookup Texture.
  26266. */
  26267. cameraColorGradingTexture: Nullable<BaseTexture>;
  26268. /**
  26269. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  26270. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  26271. * 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;
  26272. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  26273. */
  26274. /**
  26275. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  26276. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  26277. * 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;
  26278. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  26279. */
  26280. cameraColorCurves: Nullable<ColorCurves>;
  26281. /**
  26282. * Custom callback helping to override the default shader used in the material.
  26283. */
  26284. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  26285. protected _renderTargets: SmartArray<RenderTargetTexture>;
  26286. protected _worldViewProjectionMatrix: Matrix;
  26287. protected _globalAmbientColor: Color3;
  26288. protected _useLogarithmicDepth: boolean;
  26289. protected _rebuildInParallel: boolean;
  26290. /**
  26291. * Instantiates a new standard material.
  26292. * This is the default material used in Babylon. It is the best trade off between quality
  26293. * and performances.
  26294. * @see http://doc.babylonjs.com/babylon101/materials
  26295. * @param name Define the name of the material in the scene
  26296. * @param scene Define the scene the material belong to
  26297. */
  26298. constructor(name: string, scene: Scene);
  26299. /**
  26300. * Gets a boolean indicating that current material needs to register RTT
  26301. */
  26302. readonly hasRenderTargetTextures: boolean;
  26303. /**
  26304. * Gets the current class name of the material e.g. "StandardMaterial"
  26305. * Mainly use in serialization.
  26306. * @returns the class name
  26307. */
  26308. getClassName(): string;
  26309. /**
  26310. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  26311. * You can try switching to logarithmic depth.
  26312. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  26313. */
  26314. useLogarithmicDepth: boolean;
  26315. /**
  26316. * Specifies if the material will require alpha blending
  26317. * @returns a boolean specifying if alpha blending is needed
  26318. */
  26319. needAlphaBlending(): boolean;
  26320. /**
  26321. * Specifies if this material should be rendered in alpha test mode
  26322. * @returns a boolean specifying if an alpha test is needed.
  26323. */
  26324. needAlphaTesting(): boolean;
  26325. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  26326. /**
  26327. * Get the texture used for alpha test purpose.
  26328. * @returns the diffuse texture in case of the standard material.
  26329. */
  26330. getAlphaTestTexture(): Nullable<BaseTexture>;
  26331. /**
  26332. * Get if the submesh is ready to be used and all its information available.
  26333. * Child classes can use it to update shaders
  26334. * @param mesh defines the mesh to check
  26335. * @param subMesh defines which submesh to check
  26336. * @param useInstances specifies that instances should be used
  26337. * @returns a boolean indicating that the submesh is ready or not
  26338. */
  26339. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  26340. /**
  26341. * Builds the material UBO layouts.
  26342. * Used internally during the effect preparation.
  26343. */
  26344. buildUniformLayout(): void;
  26345. /**
  26346. * Unbinds the material from the mesh
  26347. */
  26348. unbind(): void;
  26349. /**
  26350. * Binds the submesh to this material by preparing the effect and shader to draw
  26351. * @param world defines the world transformation matrix
  26352. * @param mesh defines the mesh containing the submesh
  26353. * @param subMesh defines the submesh to bind the material to
  26354. */
  26355. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  26356. /**
  26357. * Get the list of animatables in the material.
  26358. * @returns the list of animatables object used in the material
  26359. */
  26360. getAnimatables(): IAnimatable[];
  26361. /**
  26362. * Gets the active textures from the material
  26363. * @returns an array of textures
  26364. */
  26365. getActiveTextures(): BaseTexture[];
  26366. /**
  26367. * Specifies if the material uses a texture
  26368. * @param texture defines the texture to check against the material
  26369. * @returns a boolean specifying if the material uses the texture
  26370. */
  26371. hasTexture(texture: BaseTexture): boolean;
  26372. /**
  26373. * Disposes the material
  26374. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  26375. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  26376. */
  26377. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  26378. /**
  26379. * Makes a duplicate of the material, and gives it a new name
  26380. * @param name defines the new name for the duplicated material
  26381. * @returns the cloned material
  26382. */
  26383. clone(name: string): StandardMaterial;
  26384. /**
  26385. * Serializes this material in a JSON representation
  26386. * @returns the serialized material object
  26387. */
  26388. serialize(): any;
  26389. /**
  26390. * Creates a standard material from parsed material data
  26391. * @param source defines the JSON representation of the material
  26392. * @param scene defines the hosting scene
  26393. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  26394. * @returns a new standard material
  26395. */
  26396. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  26397. /**
  26398. * Are diffuse textures enabled in the application.
  26399. */
  26400. static DiffuseTextureEnabled: boolean;
  26401. /**
  26402. * Are ambient textures enabled in the application.
  26403. */
  26404. static AmbientTextureEnabled: boolean;
  26405. /**
  26406. * Are opacity textures enabled in the application.
  26407. */
  26408. static OpacityTextureEnabled: boolean;
  26409. /**
  26410. * Are reflection textures enabled in the application.
  26411. */
  26412. static ReflectionTextureEnabled: boolean;
  26413. /**
  26414. * Are emissive textures enabled in the application.
  26415. */
  26416. static EmissiveTextureEnabled: boolean;
  26417. /**
  26418. * Are specular textures enabled in the application.
  26419. */
  26420. static SpecularTextureEnabled: boolean;
  26421. /**
  26422. * Are bump textures enabled in the application.
  26423. */
  26424. static BumpTextureEnabled: boolean;
  26425. /**
  26426. * Are lightmap textures enabled in the application.
  26427. */
  26428. static LightmapTextureEnabled: boolean;
  26429. /**
  26430. * Are refraction textures enabled in the application.
  26431. */
  26432. static RefractionTextureEnabled: boolean;
  26433. /**
  26434. * Are color grading textures enabled in the application.
  26435. */
  26436. static ColorGradingTextureEnabled: boolean;
  26437. /**
  26438. * Are fresnels enabled in the application.
  26439. */
  26440. static FresnelEnabled: boolean;
  26441. }
  26442. }
  26443. declare module BABYLON {
  26444. /**
  26445. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  26446. *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.
  26447. * The SPS is also a particle system. It provides some methods to manage the particles.
  26448. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  26449. *
  26450. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  26451. */
  26452. export class SolidParticleSystem implements IDisposable {
  26453. /**
  26454. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  26455. * Example : var p = SPS.particles[i];
  26456. */
  26457. particles: SolidParticle[];
  26458. /**
  26459. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  26460. */
  26461. nbParticles: number;
  26462. /**
  26463. * If the particles must ever face the camera (default false). Useful for planar particles.
  26464. */
  26465. billboard: boolean;
  26466. /**
  26467. * Recompute normals when adding a shape
  26468. */
  26469. recomputeNormals: boolean;
  26470. /**
  26471. * This a counter ofr your own usage. It's not set by any SPS functions.
  26472. */
  26473. counter: number;
  26474. /**
  26475. * The SPS name. This name is also given to the underlying mesh.
  26476. */
  26477. name: string;
  26478. /**
  26479. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  26480. */
  26481. mesh: Mesh;
  26482. /**
  26483. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  26484. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  26485. */
  26486. vars: any;
  26487. /**
  26488. * This array is populated when the SPS is set as 'pickable'.
  26489. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  26490. * Each element of this array is an object `{idx: int, faceId: int}`.
  26491. * `idx` is the picked particle index in the `SPS.particles` array
  26492. * `faceId` is the picked face index counted within this particle.
  26493. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  26494. */
  26495. pickedParticles: {
  26496. idx: number;
  26497. faceId: number;
  26498. }[];
  26499. /**
  26500. * This array is populated when `enableDepthSort` is set to true.
  26501. * Each element of this array is an instance of the class DepthSortedParticle.
  26502. */
  26503. depthSortedParticles: DepthSortedParticle[];
  26504. /**
  26505. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  26506. * @hidden
  26507. */
  26508. _bSphereOnly: boolean;
  26509. /**
  26510. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  26511. * @hidden
  26512. */
  26513. _bSphereRadiusFactor: number;
  26514. private _scene;
  26515. private _positions;
  26516. private _indices;
  26517. private _normals;
  26518. private _colors;
  26519. private _uvs;
  26520. private _indices32;
  26521. private _positions32;
  26522. private _normals32;
  26523. private _fixedNormal32;
  26524. private _colors32;
  26525. private _uvs32;
  26526. private _index;
  26527. private _updatable;
  26528. private _pickable;
  26529. private _isVisibilityBoxLocked;
  26530. private _alwaysVisible;
  26531. private _depthSort;
  26532. private _expandable;
  26533. private _shapeCounter;
  26534. private _copy;
  26535. private _color;
  26536. private _computeParticleColor;
  26537. private _computeParticleTexture;
  26538. private _computeParticleRotation;
  26539. private _computeParticleVertex;
  26540. private _computeBoundingBox;
  26541. private _depthSortParticles;
  26542. private _camera;
  26543. private _mustUnrotateFixedNormals;
  26544. private _particlesIntersect;
  26545. private _needs32Bits;
  26546. private _isNotBuilt;
  26547. private _lastParticleId;
  26548. private _idxOfId;
  26549. private _multimaterialEnabled;
  26550. private _useModelMaterial;
  26551. private _indicesByMaterial;
  26552. private _materialIndexes;
  26553. private _depthSortFunction;
  26554. private _materialSortFunction;
  26555. private _materials;
  26556. private _multimaterial;
  26557. private _materialIndexesById;
  26558. private _defaultMaterial;
  26559. private _autoUpdateSubMeshes;
  26560. /**
  26561. * Creates a SPS (Solid Particle System) object.
  26562. * @param name (String) is the SPS name, this will be the underlying mesh name.
  26563. * @param scene (Scene) is the scene in which the SPS is added.
  26564. * @param options defines the options of the sps e.g.
  26565. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  26566. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  26567. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  26568. * * useModelMaterial (optional boolean, defaut false) : if the model materials must be used to create the SPS multimaterial. This enables the multimaterial supports of the SPS.
  26569. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  26570. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  26571. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  26572. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  26573. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  26574. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  26575. */
  26576. constructor(name: string, scene: Scene, options?: {
  26577. updatable?: boolean;
  26578. isPickable?: boolean;
  26579. enableDepthSort?: boolean;
  26580. particleIntersection?: boolean;
  26581. boundingSphereOnly?: boolean;
  26582. bSphereRadiusFactor?: number;
  26583. expandable?: boolean;
  26584. useModelMaterial?: boolean;
  26585. enableMultiMaterial?: boolean;
  26586. });
  26587. /**
  26588. * Builds the SPS underlying mesh. Returns a standard Mesh.
  26589. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  26590. * @returns the created mesh
  26591. */
  26592. buildMesh(): Mesh;
  26593. /**
  26594. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  26595. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  26596. * Thus the particles generated from `digest()` have their property `position` set yet.
  26597. * @param mesh ( Mesh ) is the mesh to be digested
  26598. * @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
  26599. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  26600. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  26601. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  26602. * @returns the current SPS
  26603. */
  26604. digest(mesh: Mesh, options?: {
  26605. facetNb?: number;
  26606. number?: number;
  26607. delta?: number;
  26608. storage?: [];
  26609. }): SolidParticleSystem;
  26610. /**
  26611. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  26612. * @hidden
  26613. */
  26614. private _unrotateFixedNormals;
  26615. /**
  26616. * Resets the temporary working copy particle
  26617. * @hidden
  26618. */
  26619. private _resetCopy;
  26620. /**
  26621. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  26622. * @param p the current index in the positions array to be updated
  26623. * @param ind the current index in the indices array
  26624. * @param shape a Vector3 array, the shape geometry
  26625. * @param positions the positions array to be updated
  26626. * @param meshInd the shape indices array
  26627. * @param indices the indices array to be updated
  26628. * @param meshUV the shape uv array
  26629. * @param uvs the uv array to be updated
  26630. * @param meshCol the shape color array
  26631. * @param colors the color array to be updated
  26632. * @param meshNor the shape normals array
  26633. * @param normals the normals array to be updated
  26634. * @param idx the particle index
  26635. * @param idxInShape the particle index in its shape
  26636. * @param options the addShape() method passed options
  26637. * @model the particle model
  26638. * @hidden
  26639. */
  26640. private _meshBuilder;
  26641. /**
  26642. * Returns a shape Vector3 array from positions float array
  26643. * @param positions float array
  26644. * @returns a vector3 array
  26645. * @hidden
  26646. */
  26647. private _posToShape;
  26648. /**
  26649. * Returns a shapeUV array from a float uvs (array deep copy)
  26650. * @param uvs as a float array
  26651. * @returns a shapeUV array
  26652. * @hidden
  26653. */
  26654. private _uvsToShapeUV;
  26655. /**
  26656. * Adds a new particle object in the particles array
  26657. * @param idx particle index in particles array
  26658. * @param id particle id
  26659. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  26660. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  26661. * @param model particle ModelShape object
  26662. * @param shapeId model shape identifier
  26663. * @param idxInShape index of the particle in the current model
  26664. * @param bInfo model bounding info object
  26665. * @param storage target storage array, if any
  26666. * @hidden
  26667. */
  26668. private _addParticle;
  26669. /**
  26670. * Adds some particles to the SPS from the model shape. Returns the shape id.
  26671. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  26672. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  26673. * @param nb (positive integer) the number of particles to be created from this model
  26674. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  26675. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  26676. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  26677. * @returns the number of shapes in the system
  26678. */
  26679. addShape(mesh: Mesh, nb: number, options?: {
  26680. positionFunction?: any;
  26681. vertexFunction?: any;
  26682. storage?: [];
  26683. }): number;
  26684. /**
  26685. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  26686. * @hidden
  26687. */
  26688. private _rebuildParticle;
  26689. /**
  26690. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  26691. * @param reset boolean, default false : if the particles must be reset at position and rotation zero, scaling 1, color white, initial UVs and not parented.
  26692. * @returns the SPS.
  26693. */
  26694. rebuildMesh(reset?: boolean): SolidParticleSystem;
  26695. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  26696. * Returns an array with the removed particles.
  26697. * If the number of particles to remove is lower than zero or greater than the global remaining particle number, then an empty array is returned.
  26698. * The SPS can't be empty so at least one particle needs to remain in place.
  26699. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  26700. * @param start index of the first particle to remove
  26701. * @param end index of the last particle to remove (included)
  26702. * @returns an array populated with the removed particles
  26703. */
  26704. removeParticles(start: number, end: number): SolidParticle[];
  26705. /**
  26706. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  26707. * @param solidParticleArray an array populated with Solid Particles objects
  26708. * @returns the SPS
  26709. */
  26710. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  26711. /**
  26712. * Creates a new particle and modifies the SPS mesh geometry :
  26713. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  26714. * - calls _addParticle() to populate the particle array
  26715. * factorized code from addShape() and insertParticlesFromArray()
  26716. * @param idx particle index in the particles array
  26717. * @param i particle index in its shape
  26718. * @param modelShape particle ModelShape object
  26719. * @param shape shape vertex array
  26720. * @param meshInd shape indices array
  26721. * @param meshUV shape uv array
  26722. * @param meshCol shape color array
  26723. * @param meshNor shape normals array
  26724. * @param bbInfo shape bounding info
  26725. * @param storage target particle storage
  26726. * @options addShape() passed options
  26727. * @hidden
  26728. */
  26729. private _insertNewParticle;
  26730. /**
  26731. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  26732. * This method calls `updateParticle()` for each particle of the SPS.
  26733. * For an animated SPS, it is usually called within the render loop.
  26734. * This methods does nothing if called on a non updatable or not yet built SPS. Example : buildMesh() not called after having added or removed particles from an expandable SPS.
  26735. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  26736. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  26737. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  26738. * @returns the SPS.
  26739. */
  26740. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  26741. /**
  26742. * Disposes the SPS.
  26743. */
  26744. dispose(): void;
  26745. /**
  26746. * Returns a SolidParticle object from its identifier : particle.id
  26747. * @param id (integer) the particle Id
  26748. * @returns the searched particle or null if not found in the SPS.
  26749. */
  26750. getParticleById(id: number): Nullable<SolidParticle>;
  26751. /**
  26752. * Returns a new array populated with the particles having the passed shapeId.
  26753. * @param shapeId (integer) the shape identifier
  26754. * @returns a new solid particle array
  26755. */
  26756. getParticlesByShapeId(shapeId: number): SolidParticle[];
  26757. /**
  26758. * Populates the passed array "ref" with the particles having the passed shapeId.
  26759. * @param shapeId the shape identifier
  26760. * @returns the SPS
  26761. * @param ref
  26762. */
  26763. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  26764. /**
  26765. * Computes the required SubMeshes according the materials assigned to the particles.
  26766. * @returns the solid particle system.
  26767. * Does nothing if called before the SPS mesh is built.
  26768. */
  26769. computeSubMeshes(): SolidParticleSystem;
  26770. /**
  26771. * Sorts the solid particles by material when MultiMaterial is enabled.
  26772. * Updates the indices32 array.
  26773. * Updates the indicesByMaterial array.
  26774. * Updates the mesh indices array.
  26775. * @returns the SPS
  26776. * @hidden
  26777. */
  26778. private _sortParticlesByMaterial;
  26779. /**
  26780. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  26781. * @hidden
  26782. */
  26783. private _setMaterialIndexesById;
  26784. /**
  26785. * Returns an array with unique values of Materials from the passed array
  26786. * @param array the material array to be checked and filtered
  26787. * @hidden
  26788. */
  26789. private _filterUniqueMaterialId;
  26790. /**
  26791. * Sets a new Standard Material as _defaultMaterial if not already set.
  26792. * @hidden
  26793. */
  26794. private _setDefaultMaterial;
  26795. /**
  26796. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  26797. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26798. * @returns the SPS.
  26799. */
  26800. refreshVisibleSize(): SolidParticleSystem;
  26801. /**
  26802. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  26803. * @param size the size (float) of the visibility box
  26804. * note : this doesn't lock the SPS mesh bounding box.
  26805. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26806. */
  26807. setVisibilityBox(size: number): void;
  26808. /**
  26809. * Gets whether the SPS as always visible or not
  26810. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26811. */
  26812. /**
  26813. * Sets the SPS as always visible or not
  26814. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26815. */
  26816. isAlwaysVisible: boolean;
  26817. /**
  26818. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26819. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26820. */
  26821. /**
  26822. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26823. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26824. */
  26825. isVisibilityBoxLocked: boolean;
  26826. /**
  26827. * Tells to `setParticles()` to compute the particle rotations or not.
  26828. * Default value : true. The SPS is faster when it's set to false.
  26829. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26830. */
  26831. /**
  26832. * Gets if `setParticles()` computes the particle rotations or not.
  26833. * Default value : true. The SPS is faster when it's set to false.
  26834. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26835. */
  26836. computeParticleRotation: boolean;
  26837. /**
  26838. * Tells to `setParticles()` to compute the particle colors or not.
  26839. * Default value : true. The SPS is faster when it's set to false.
  26840. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26841. */
  26842. /**
  26843. * Gets if `setParticles()` computes the particle colors or not.
  26844. * Default value : true. The SPS is faster when it's set to false.
  26845. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26846. */
  26847. computeParticleColor: boolean;
  26848. /**
  26849. * Gets if `setParticles()` computes the particle textures or not.
  26850. * Default value : true. The SPS is faster when it's set to false.
  26851. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  26852. */
  26853. computeParticleTexture: boolean;
  26854. /**
  26855. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  26856. * Default value : false. The SPS is faster when it's set to false.
  26857. * Note : the particle custom vertex positions aren't stored values.
  26858. */
  26859. /**
  26860. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  26861. * Default value : false. The SPS is faster when it's set to false.
  26862. * Note : the particle custom vertex positions aren't stored values.
  26863. */
  26864. computeParticleVertex: boolean;
  26865. /**
  26866. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  26867. */
  26868. /**
  26869. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  26870. */
  26871. computeBoundingBox: boolean;
  26872. /**
  26873. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  26874. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26875. * Default : `true`
  26876. */
  26877. /**
  26878. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  26879. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26880. * Default : `true`
  26881. */
  26882. depthSortParticles: boolean;
  26883. /**
  26884. * Gets if the SPS is created as expandable at construction time.
  26885. * Default : `false`
  26886. */
  26887. readonly expandable: boolean;
  26888. /**
  26889. * Gets if the SPS supports the Multi Materials
  26890. */
  26891. readonly multimaterialEnabled: boolean;
  26892. /**
  26893. * Gets if the SPS uses the model materials for its own multimaterial.
  26894. */
  26895. readonly useModelMaterial: boolean;
  26896. /**
  26897. * The SPS used material array.
  26898. */
  26899. readonly materials: Material[];
  26900. /**
  26901. * Sets the SPS MultiMaterial from the passed materials.
  26902. * Note : the passed array is internally copied and not used then by reference.
  26903. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  26904. */
  26905. setMultiMaterial(materials: Material[]): void;
  26906. /**
  26907. * The SPS computed multimaterial object
  26908. */
  26909. multimaterial: MultiMaterial;
  26910. /**
  26911. * If the subMeshes must be updated on the next call to setParticles()
  26912. */
  26913. autoUpdateSubMeshes: boolean;
  26914. /**
  26915. * This function does nothing. It may be overwritten to set all the particle first values.
  26916. * The SPS doesn't call this function, you may have to call it by your own.
  26917. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26918. */
  26919. initParticles(): void;
  26920. /**
  26921. * This function does nothing. It may be overwritten to recycle a particle.
  26922. * The SPS doesn't call this function, you may have to call it by your own.
  26923. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26924. * @param particle The particle to recycle
  26925. * @returns the recycled particle
  26926. */
  26927. recycleParticle(particle: SolidParticle): SolidParticle;
  26928. /**
  26929. * Updates a particle : this function should be overwritten by the user.
  26930. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  26931. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26932. * @example : just set a particle position or velocity and recycle conditions
  26933. * @param particle The particle to update
  26934. * @returns the updated particle
  26935. */
  26936. updateParticle(particle: SolidParticle): SolidParticle;
  26937. /**
  26938. * Updates a vertex of a particle : it can be overwritten by the user.
  26939. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  26940. * @param particle the current particle
  26941. * @param vertex the current index of the current particle
  26942. * @param pt the index of the current vertex in the particle shape
  26943. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  26944. * @example : just set a vertex particle position
  26945. * @returns the updated vertex
  26946. */
  26947. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  26948. /**
  26949. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  26950. * This does nothing and may be overwritten by the user.
  26951. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26952. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26953. * @param update the boolean update value actually passed to setParticles()
  26954. */
  26955. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26956. /**
  26957. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  26958. * This will be passed three parameters.
  26959. * This does nothing and may be overwritten by the user.
  26960. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26961. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26962. * @param update the boolean update value actually passed to setParticles()
  26963. */
  26964. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26965. }
  26966. }
  26967. declare module BABYLON {
  26968. /**
  26969. * Represents one particle of a solid particle system.
  26970. */
  26971. export class SolidParticle {
  26972. /**
  26973. * particle global index
  26974. */
  26975. idx: number;
  26976. /**
  26977. * particle identifier
  26978. */
  26979. id: number;
  26980. /**
  26981. * The color of the particle
  26982. */
  26983. color: Nullable<Color4>;
  26984. /**
  26985. * The world space position of the particle.
  26986. */
  26987. position: Vector3;
  26988. /**
  26989. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  26990. */
  26991. rotation: Vector3;
  26992. /**
  26993. * The world space rotation quaternion of the particle.
  26994. */
  26995. rotationQuaternion: Nullable<Quaternion>;
  26996. /**
  26997. * The scaling of the particle.
  26998. */
  26999. scaling: Vector3;
  27000. /**
  27001. * The uvs of the particle.
  27002. */
  27003. uvs: Vector4;
  27004. /**
  27005. * The current speed of the particle.
  27006. */
  27007. velocity: Vector3;
  27008. /**
  27009. * The pivot point in the particle local space.
  27010. */
  27011. pivot: Vector3;
  27012. /**
  27013. * Must the particle be translated from its pivot point in its local space ?
  27014. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  27015. * Default : false
  27016. */
  27017. translateFromPivot: boolean;
  27018. /**
  27019. * Is the particle active or not ?
  27020. */
  27021. alive: boolean;
  27022. /**
  27023. * Is the particle visible or not ?
  27024. */
  27025. isVisible: boolean;
  27026. /**
  27027. * Index of this particle in the global "positions" array (Internal use)
  27028. * @hidden
  27029. */
  27030. _pos: number;
  27031. /**
  27032. * @hidden Index of this particle in the global "indices" array (Internal use)
  27033. */
  27034. _ind: number;
  27035. /**
  27036. * @hidden ModelShape of this particle (Internal use)
  27037. */
  27038. _model: ModelShape;
  27039. /**
  27040. * ModelShape id of this particle
  27041. */
  27042. shapeId: number;
  27043. /**
  27044. * Index of the particle in its shape id
  27045. */
  27046. idxInShape: number;
  27047. /**
  27048. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  27049. */
  27050. _modelBoundingInfo: BoundingInfo;
  27051. /**
  27052. * @hidden Particle BoundingInfo object (Internal use)
  27053. */
  27054. _boundingInfo: BoundingInfo;
  27055. /**
  27056. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  27057. */
  27058. _sps: SolidParticleSystem;
  27059. /**
  27060. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  27061. */
  27062. _stillInvisible: boolean;
  27063. /**
  27064. * @hidden Last computed particle rotation matrix
  27065. */
  27066. _rotationMatrix: number[];
  27067. /**
  27068. * Parent particle Id, if any.
  27069. * Default null.
  27070. */
  27071. parentId: Nullable<number>;
  27072. /**
  27073. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  27074. */
  27075. materialIndex: Nullable<number>;
  27076. /**
  27077. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  27078. * The possible values are :
  27079. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27080. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27081. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27082. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27083. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27084. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  27085. * */
  27086. cullingStrategy: number;
  27087. /**
  27088. * @hidden Internal global position in the SPS.
  27089. */
  27090. _globalPosition: Vector3;
  27091. /**
  27092. * Creates a Solid Particle object.
  27093. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  27094. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  27095. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  27096. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  27097. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  27098. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  27099. * @param shapeId (integer) is the model shape identifier in the SPS.
  27100. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  27101. * @param sps defines the sps it is associated to
  27102. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  27103. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  27104. */
  27105. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  27106. /**
  27107. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  27108. * @param target the particle target
  27109. * @returns the current particle
  27110. */
  27111. copyToRef(target: SolidParticle): SolidParticle;
  27112. /**
  27113. * Legacy support, changed scale to scaling
  27114. */
  27115. /**
  27116. * Legacy support, changed scale to scaling
  27117. */
  27118. scale: Vector3;
  27119. /**
  27120. * Legacy support, changed quaternion to rotationQuaternion
  27121. */
  27122. /**
  27123. * Legacy support, changed quaternion to rotationQuaternion
  27124. */
  27125. quaternion: Nullable<Quaternion>;
  27126. /**
  27127. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  27128. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  27129. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  27130. * @returns true if it intersects
  27131. */
  27132. intersectsMesh(target: Mesh | SolidParticle): boolean;
  27133. /**
  27134. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  27135. * A particle is in the frustum if its bounding box intersects the frustum
  27136. * @param frustumPlanes defines the frustum to test
  27137. * @returns true if the particle is in the frustum planes
  27138. */
  27139. isInFrustum(frustumPlanes: Plane[]): boolean;
  27140. /**
  27141. * get the rotation matrix of the particle
  27142. * @hidden
  27143. */
  27144. getRotationMatrix(m: Matrix): void;
  27145. }
  27146. /**
  27147. * Represents the shape of the model used by one particle of a solid particle system.
  27148. * SPS internal tool, don't use it manually.
  27149. */
  27150. export class ModelShape {
  27151. /**
  27152. * The shape id
  27153. * @hidden
  27154. */
  27155. shapeID: number;
  27156. /**
  27157. * flat array of model positions (internal use)
  27158. * @hidden
  27159. */
  27160. _shape: Vector3[];
  27161. /**
  27162. * flat array of model UVs (internal use)
  27163. * @hidden
  27164. */
  27165. _shapeUV: number[];
  27166. /**
  27167. * color array of the model
  27168. * @hidden
  27169. */
  27170. _shapeColors: number[];
  27171. /**
  27172. * indices array of the model
  27173. * @hidden
  27174. */
  27175. _indices: number[];
  27176. /**
  27177. * normals array of the model
  27178. * @hidden
  27179. */
  27180. _normals: number[];
  27181. /**
  27182. * length of the shape in the model indices array (internal use)
  27183. * @hidden
  27184. */
  27185. _indicesLength: number;
  27186. /**
  27187. * Custom position function (internal use)
  27188. * @hidden
  27189. */
  27190. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  27191. /**
  27192. * Custom vertex function (internal use)
  27193. * @hidden
  27194. */
  27195. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  27196. /**
  27197. * Model material (internal use)
  27198. * @hidden
  27199. */
  27200. _material: Nullable<Material>;
  27201. /**
  27202. * 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.
  27203. * SPS internal tool, don't use it manually.
  27204. * @hidden
  27205. */
  27206. constructor(id: number, shape: Vector3[], indices: number[], normals: number[], colors: number[], shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>, material: Nullable<Material>);
  27207. }
  27208. /**
  27209. * Represents a Depth Sorted Particle in the solid particle system.
  27210. * @hidden
  27211. */
  27212. export class DepthSortedParticle {
  27213. /**
  27214. * Index of the particle in the "indices" array
  27215. */
  27216. ind: number;
  27217. /**
  27218. * Length of the particle shape in the "indices" array
  27219. */
  27220. indicesLength: number;
  27221. /**
  27222. * Squared distance from the particle to the camera
  27223. */
  27224. sqDistance: number;
  27225. /**
  27226. * Material index when used with MultiMaterials
  27227. */
  27228. materialIndex: number;
  27229. /**
  27230. * Creates a new sorted particle
  27231. * @param materialIndex
  27232. */
  27233. constructor(ind: number, indLength: number, materialIndex: number);
  27234. }
  27235. }
  27236. declare module BABYLON {
  27237. /**
  27238. * @hidden
  27239. */
  27240. export class _MeshCollisionData {
  27241. _checkCollisions: boolean;
  27242. _collisionMask: number;
  27243. _collisionGroup: number;
  27244. _collider: Nullable<Collider>;
  27245. _oldPositionForCollisions: Vector3;
  27246. _diffPositionForCollisions: Vector3;
  27247. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  27248. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  27249. }
  27250. }
  27251. declare module BABYLON {
  27252. /** @hidden */
  27253. class _FacetDataStorage {
  27254. facetPositions: Vector3[];
  27255. facetNormals: Vector3[];
  27256. facetPartitioning: number[][];
  27257. facetNb: number;
  27258. partitioningSubdivisions: number;
  27259. partitioningBBoxRatio: number;
  27260. facetDataEnabled: boolean;
  27261. facetParameters: any;
  27262. bbSize: Vector3;
  27263. subDiv: {
  27264. max: number;
  27265. X: number;
  27266. Y: number;
  27267. Z: number;
  27268. };
  27269. facetDepthSort: boolean;
  27270. facetDepthSortEnabled: boolean;
  27271. depthSortedIndices: IndicesArray;
  27272. depthSortedFacets: {
  27273. ind: number;
  27274. sqDistance: number;
  27275. }[];
  27276. facetDepthSortFunction: (f1: {
  27277. ind: number;
  27278. sqDistance: number;
  27279. }, f2: {
  27280. ind: number;
  27281. sqDistance: number;
  27282. }) => number;
  27283. facetDepthSortFrom: Vector3;
  27284. facetDepthSortOrigin: Vector3;
  27285. invertedMatrix: Matrix;
  27286. }
  27287. /**
  27288. * @hidden
  27289. **/
  27290. class _InternalAbstractMeshDataInfo {
  27291. _hasVertexAlpha: boolean;
  27292. _useVertexColors: boolean;
  27293. _numBoneInfluencers: number;
  27294. _applyFog: boolean;
  27295. _receiveShadows: boolean;
  27296. _facetData: _FacetDataStorage;
  27297. _visibility: number;
  27298. _skeleton: Nullable<Skeleton>;
  27299. _layerMask: number;
  27300. _computeBonesUsingShaders: boolean;
  27301. _isActive: boolean;
  27302. _onlyForInstances: boolean;
  27303. _isActiveIntermediate: boolean;
  27304. _onlyForInstancesIntermediate: boolean;
  27305. _actAsRegularMesh: boolean;
  27306. }
  27307. /**
  27308. * Class used to store all common mesh properties
  27309. */
  27310. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  27311. /** No occlusion */
  27312. static OCCLUSION_TYPE_NONE: number;
  27313. /** Occlusion set to optimisitic */
  27314. static OCCLUSION_TYPE_OPTIMISTIC: number;
  27315. /** Occlusion set to strict */
  27316. static OCCLUSION_TYPE_STRICT: number;
  27317. /** Use an accurante occlusion algorithm */
  27318. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  27319. /** Use a conservative occlusion algorithm */
  27320. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  27321. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  27322. * Test order :
  27323. * Is the bounding sphere outside the frustum ?
  27324. * If not, are the bounding box vertices outside the frustum ?
  27325. * It not, then the cullable object is in the frustum.
  27326. */
  27327. static readonly CULLINGSTRATEGY_STANDARD: number;
  27328. /** Culling strategy : Bounding Sphere Only.
  27329. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  27330. * It's also less accurate than the standard because some not visible objects can still be selected.
  27331. * Test : is the bounding sphere outside the frustum ?
  27332. * If not, then the cullable object is in the frustum.
  27333. */
  27334. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  27335. /** Culling strategy : Optimistic Inclusion.
  27336. * This in an inclusion test first, then the standard exclusion test.
  27337. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  27338. * 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.
  27339. * Anyway, it's as accurate as the standard strategy.
  27340. * Test :
  27341. * Is the cullable object bounding sphere center in the frustum ?
  27342. * If not, apply the default culling strategy.
  27343. */
  27344. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  27345. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  27346. * This in an inclusion test first, then the bounding sphere only exclusion test.
  27347. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  27348. * 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.
  27349. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  27350. * Test :
  27351. * Is the cullable object bounding sphere center in the frustum ?
  27352. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  27353. */
  27354. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  27355. /**
  27356. * No billboard
  27357. */
  27358. static readonly BILLBOARDMODE_NONE: number;
  27359. /** Billboard on X axis */
  27360. static readonly BILLBOARDMODE_X: number;
  27361. /** Billboard on Y axis */
  27362. static readonly BILLBOARDMODE_Y: number;
  27363. /** Billboard on Z axis */
  27364. static readonly BILLBOARDMODE_Z: number;
  27365. /** Billboard on all axes */
  27366. static readonly BILLBOARDMODE_ALL: number;
  27367. /** Billboard on using position instead of orientation */
  27368. static readonly BILLBOARDMODE_USE_POSITION: number;
  27369. /** @hidden */
  27370. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  27371. /**
  27372. * The culling strategy to use to check whether the mesh must be rendered or not.
  27373. * This value can be changed at any time and will be used on the next render mesh selection.
  27374. * The possible values are :
  27375. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27376. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27377. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27378. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27379. * Please read each static variable documentation to get details about the culling process.
  27380. * */
  27381. cullingStrategy: number;
  27382. /**
  27383. * Gets the number of facets in the mesh
  27384. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  27385. */
  27386. readonly facetNb: number;
  27387. /**
  27388. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  27389. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  27390. */
  27391. partitioningSubdivisions: number;
  27392. /**
  27393. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  27394. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  27395. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  27396. */
  27397. partitioningBBoxRatio: number;
  27398. /**
  27399. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  27400. * Works only for updatable meshes.
  27401. * Doesn't work with multi-materials
  27402. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  27403. */
  27404. mustDepthSortFacets: boolean;
  27405. /**
  27406. * The location (Vector3) where the facet depth sort must be computed from.
  27407. * By default, the active camera position.
  27408. * Used only when facet depth sort is enabled
  27409. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  27410. */
  27411. facetDepthSortFrom: Vector3;
  27412. /**
  27413. * gets a boolean indicating if facetData is enabled
  27414. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  27415. */
  27416. readonly isFacetDataEnabled: boolean;
  27417. /** @hidden */
  27418. _updateNonUniformScalingState(value: boolean): boolean;
  27419. /**
  27420. * An event triggered when this mesh collides with another one
  27421. */
  27422. onCollideObservable: Observable<AbstractMesh>;
  27423. /** Set a function to call when this mesh collides with another one */
  27424. onCollide: () => void;
  27425. /**
  27426. * An event triggered when the collision's position changes
  27427. */
  27428. onCollisionPositionChangeObservable: Observable<Vector3>;
  27429. /** Set a function to call when the collision's position changes */
  27430. onCollisionPositionChange: () => void;
  27431. /**
  27432. * An event triggered when material is changed
  27433. */
  27434. onMaterialChangedObservable: Observable<AbstractMesh>;
  27435. /**
  27436. * Gets or sets the orientation for POV movement & rotation
  27437. */
  27438. definedFacingForward: boolean;
  27439. /** @hidden */
  27440. _occlusionQuery: Nullable<WebGLQuery>;
  27441. /** @hidden */
  27442. _renderingGroup: Nullable<RenderingGroup>;
  27443. /**
  27444. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  27445. */
  27446. /**
  27447. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  27448. */
  27449. visibility: number;
  27450. /** Gets or sets the alpha index used to sort transparent meshes
  27451. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  27452. */
  27453. alphaIndex: number;
  27454. /**
  27455. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  27456. */
  27457. isVisible: boolean;
  27458. /**
  27459. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  27460. */
  27461. isPickable: boolean;
  27462. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  27463. showSubMeshesBoundingBox: boolean;
  27464. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  27465. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  27466. */
  27467. isBlocker: boolean;
  27468. /**
  27469. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  27470. */
  27471. enablePointerMoveEvents: boolean;
  27472. /**
  27473. * Specifies the rendering group id for this mesh (0 by default)
  27474. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  27475. */
  27476. renderingGroupId: number;
  27477. private _material;
  27478. /** Gets or sets current material */
  27479. material: Nullable<Material>;
  27480. /**
  27481. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  27482. * @see http://doc.babylonjs.com/babylon101/shadows
  27483. */
  27484. receiveShadows: boolean;
  27485. /** Defines color to use when rendering outline */
  27486. outlineColor: Color3;
  27487. /** Define width to use when rendering outline */
  27488. outlineWidth: number;
  27489. /** Defines color to use when rendering overlay */
  27490. overlayColor: Color3;
  27491. /** Defines alpha to use when rendering overlay */
  27492. overlayAlpha: number;
  27493. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  27494. hasVertexAlpha: boolean;
  27495. /** 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) */
  27496. useVertexColors: boolean;
  27497. /**
  27498. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  27499. */
  27500. computeBonesUsingShaders: boolean;
  27501. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  27502. numBoneInfluencers: number;
  27503. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  27504. applyFog: boolean;
  27505. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  27506. useOctreeForRenderingSelection: boolean;
  27507. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  27508. useOctreeForPicking: boolean;
  27509. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  27510. useOctreeForCollisions: boolean;
  27511. /**
  27512. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  27513. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  27514. */
  27515. layerMask: number;
  27516. /**
  27517. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  27518. */
  27519. alwaysSelectAsActiveMesh: boolean;
  27520. /**
  27521. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  27522. */
  27523. doNotSyncBoundingInfo: boolean;
  27524. /**
  27525. * Gets or sets the current action manager
  27526. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27527. */
  27528. actionManager: Nullable<AbstractActionManager>;
  27529. private _meshCollisionData;
  27530. /**
  27531. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  27532. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27533. */
  27534. ellipsoid: Vector3;
  27535. /**
  27536. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  27537. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27538. */
  27539. ellipsoidOffset: Vector3;
  27540. /**
  27541. * Gets or sets a collision mask used to mask collisions (default is -1).
  27542. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  27543. */
  27544. collisionMask: number;
  27545. /**
  27546. * Gets or sets the current collision group mask (-1 by default).
  27547. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  27548. */
  27549. collisionGroup: number;
  27550. /**
  27551. * Defines edge width used when edgesRenderer is enabled
  27552. * @see https://www.babylonjs-playground.com/#10OJSG#13
  27553. */
  27554. edgesWidth: number;
  27555. /**
  27556. * Defines edge color used when edgesRenderer is enabled
  27557. * @see https://www.babylonjs-playground.com/#10OJSG#13
  27558. */
  27559. edgesColor: Color4;
  27560. /** @hidden */
  27561. _edgesRenderer: Nullable<IEdgesRenderer>;
  27562. /** @hidden */
  27563. _masterMesh: Nullable<AbstractMesh>;
  27564. /** @hidden */
  27565. _boundingInfo: Nullable<BoundingInfo>;
  27566. /** @hidden */
  27567. _renderId: number;
  27568. /**
  27569. * Gets or sets the list of subMeshes
  27570. * @see http://doc.babylonjs.com/how_to/multi_materials
  27571. */
  27572. subMeshes: SubMesh[];
  27573. /** @hidden */
  27574. _intersectionsInProgress: AbstractMesh[];
  27575. /** @hidden */
  27576. _unIndexed: boolean;
  27577. /** @hidden */
  27578. _lightSources: Light[];
  27579. /** Gets the list of lights affecting that mesh */
  27580. readonly lightSources: Light[];
  27581. /** @hidden */
  27582. readonly _positions: Nullable<Vector3[]>;
  27583. /** @hidden */
  27584. _waitingData: {
  27585. lods: Nullable<any>;
  27586. actions: Nullable<any>;
  27587. freezeWorldMatrix: Nullable<boolean>;
  27588. };
  27589. /** @hidden */
  27590. _bonesTransformMatrices: Nullable<Float32Array>;
  27591. /** @hidden */
  27592. _transformMatrixTexture: Nullable<RawTexture>;
  27593. /**
  27594. * Gets or sets a skeleton to apply skining transformations
  27595. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  27596. */
  27597. skeleton: Nullable<Skeleton>;
  27598. /**
  27599. * An event triggered when the mesh is rebuilt.
  27600. */
  27601. onRebuildObservable: Observable<AbstractMesh>;
  27602. /**
  27603. * Creates a new AbstractMesh
  27604. * @param name defines the name of the mesh
  27605. * @param scene defines the hosting scene
  27606. */
  27607. constructor(name: string, scene?: Nullable<Scene>);
  27608. /**
  27609. * Returns the string "AbstractMesh"
  27610. * @returns "AbstractMesh"
  27611. */
  27612. getClassName(): string;
  27613. /**
  27614. * Gets a string representation of the current mesh
  27615. * @param fullDetails defines a boolean indicating if full details must be included
  27616. * @returns a string representation of the current mesh
  27617. */
  27618. toString(fullDetails?: boolean): string;
  27619. /**
  27620. * @hidden
  27621. */
  27622. protected _getEffectiveParent(): Nullable<Node>;
  27623. /** @hidden */
  27624. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27625. /** @hidden */
  27626. _rebuild(): void;
  27627. /** @hidden */
  27628. _resyncLightSources(): void;
  27629. /** @hidden */
  27630. _resyncLightSource(light: Light): void;
  27631. /** @hidden */
  27632. _unBindEffect(): void;
  27633. /** @hidden */
  27634. _removeLightSource(light: Light, dispose: boolean): void;
  27635. private _markSubMeshesAsDirty;
  27636. /** @hidden */
  27637. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  27638. /** @hidden */
  27639. _markSubMeshesAsAttributesDirty(): void;
  27640. /** @hidden */
  27641. _markSubMeshesAsMiscDirty(): void;
  27642. /**
  27643. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  27644. */
  27645. scaling: Vector3;
  27646. /**
  27647. * Returns true if the mesh is blocked. Implemented by child classes
  27648. */
  27649. readonly isBlocked: boolean;
  27650. /**
  27651. * Returns the mesh itself by default. Implemented by child classes
  27652. * @param camera defines the camera to use to pick the right LOD level
  27653. * @returns the currentAbstractMesh
  27654. */
  27655. getLOD(camera: Camera): Nullable<AbstractMesh>;
  27656. /**
  27657. * Returns 0 by default. Implemented by child classes
  27658. * @returns an integer
  27659. */
  27660. getTotalVertices(): number;
  27661. /**
  27662. * Returns a positive integer : the total number of indices in this mesh geometry.
  27663. * @returns the numner of indices or zero if the mesh has no geometry.
  27664. */
  27665. getTotalIndices(): number;
  27666. /**
  27667. * Returns null by default. Implemented by child classes
  27668. * @returns null
  27669. */
  27670. getIndices(): Nullable<IndicesArray>;
  27671. /**
  27672. * Returns the array of the requested vertex data kind. Implemented by child classes
  27673. * @param kind defines the vertex data kind to use
  27674. * @returns null
  27675. */
  27676. getVerticesData(kind: string): Nullable<FloatArray>;
  27677. /**
  27678. * Sets the vertex data of the mesh geometry for the requested `kind`.
  27679. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  27680. * Note that a new underlying VertexBuffer object is created each call.
  27681. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  27682. * @param kind defines vertex data kind:
  27683. * * VertexBuffer.PositionKind
  27684. * * VertexBuffer.UVKind
  27685. * * VertexBuffer.UV2Kind
  27686. * * VertexBuffer.UV3Kind
  27687. * * VertexBuffer.UV4Kind
  27688. * * VertexBuffer.UV5Kind
  27689. * * VertexBuffer.UV6Kind
  27690. * * VertexBuffer.ColorKind
  27691. * * VertexBuffer.MatricesIndicesKind
  27692. * * VertexBuffer.MatricesIndicesExtraKind
  27693. * * VertexBuffer.MatricesWeightsKind
  27694. * * VertexBuffer.MatricesWeightsExtraKind
  27695. * @param data defines the data source
  27696. * @param updatable defines if the data must be flagged as updatable (or static)
  27697. * @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
  27698. * @returns the current mesh
  27699. */
  27700. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  27701. /**
  27702. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  27703. * If the mesh has no geometry, it is simply returned as it is.
  27704. * @param kind defines vertex data kind:
  27705. * * VertexBuffer.PositionKind
  27706. * * VertexBuffer.UVKind
  27707. * * VertexBuffer.UV2Kind
  27708. * * VertexBuffer.UV3Kind
  27709. * * VertexBuffer.UV4Kind
  27710. * * VertexBuffer.UV5Kind
  27711. * * VertexBuffer.UV6Kind
  27712. * * VertexBuffer.ColorKind
  27713. * * VertexBuffer.MatricesIndicesKind
  27714. * * VertexBuffer.MatricesIndicesExtraKind
  27715. * * VertexBuffer.MatricesWeightsKind
  27716. * * VertexBuffer.MatricesWeightsExtraKind
  27717. * @param data defines the data source
  27718. * @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
  27719. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  27720. * @returns the current mesh
  27721. */
  27722. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  27723. /**
  27724. * Sets the mesh indices,
  27725. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  27726. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  27727. * @param totalVertices Defines the total number of vertices
  27728. * @returns the current mesh
  27729. */
  27730. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  27731. /**
  27732. * Gets a boolean indicating if specific vertex data is present
  27733. * @param kind defines the vertex data kind to use
  27734. * @returns true is data kind is present
  27735. */
  27736. isVerticesDataPresent(kind: string): boolean;
  27737. /**
  27738. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  27739. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  27740. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  27741. * @returns a BoundingInfo
  27742. */
  27743. getBoundingInfo(): BoundingInfo;
  27744. /**
  27745. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  27746. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  27747. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  27748. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  27749. * @returns the current mesh
  27750. */
  27751. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  27752. /**
  27753. * Overwrite the current bounding info
  27754. * @param boundingInfo defines the new bounding info
  27755. * @returns the current mesh
  27756. */
  27757. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  27758. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  27759. readonly useBones: boolean;
  27760. /** @hidden */
  27761. _preActivate(): void;
  27762. /** @hidden */
  27763. _preActivateForIntermediateRendering(renderId: number): void;
  27764. /** @hidden */
  27765. _activate(renderId: number, intermediateRendering: boolean): boolean;
  27766. /** @hidden */
  27767. _postActivate(): void;
  27768. /** @hidden */
  27769. _freeze(): void;
  27770. /** @hidden */
  27771. _unFreeze(): void;
  27772. /**
  27773. * Gets the current world matrix
  27774. * @returns a Matrix
  27775. */
  27776. getWorldMatrix(): Matrix;
  27777. /** @hidden */
  27778. _getWorldMatrixDeterminant(): number;
  27779. /**
  27780. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  27781. */
  27782. readonly isAnInstance: boolean;
  27783. /**
  27784. * Gets a boolean indicating if this mesh has instances
  27785. */
  27786. readonly hasInstances: boolean;
  27787. /**
  27788. * Perform relative position change from the point of view of behind the front of the mesh.
  27789. * This is performed taking into account the meshes current rotation, so you do not have to care.
  27790. * Supports definition of mesh facing forward or backward
  27791. * @param amountRight defines the distance on the right axis
  27792. * @param amountUp defines the distance on the up axis
  27793. * @param amountForward defines the distance on the forward axis
  27794. * @returns the current mesh
  27795. */
  27796. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  27797. /**
  27798. * Calculate relative position change from the point of view of behind the front of the mesh.
  27799. * This is performed taking into account the meshes current rotation, so you do not have to care.
  27800. * Supports definition of mesh facing forward or backward
  27801. * @param amountRight defines the distance on the right axis
  27802. * @param amountUp defines the distance on the up axis
  27803. * @param amountForward defines the distance on the forward axis
  27804. * @returns the new displacement vector
  27805. */
  27806. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  27807. /**
  27808. * Perform relative rotation change from the point of view of behind the front of the mesh.
  27809. * Supports definition of mesh facing forward or backward
  27810. * @param flipBack defines the flip
  27811. * @param twirlClockwise defines the twirl
  27812. * @param tiltRight defines the tilt
  27813. * @returns the current mesh
  27814. */
  27815. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  27816. /**
  27817. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  27818. * Supports definition of mesh facing forward or backward.
  27819. * @param flipBack defines the flip
  27820. * @param twirlClockwise defines the twirl
  27821. * @param tiltRight defines the tilt
  27822. * @returns the new rotation vector
  27823. */
  27824. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  27825. /**
  27826. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  27827. * This means the mesh underlying bounding box and sphere are recomputed.
  27828. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  27829. * @returns the current mesh
  27830. */
  27831. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  27832. /** @hidden */
  27833. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  27834. /** @hidden */
  27835. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  27836. /** @hidden */
  27837. _updateBoundingInfo(): AbstractMesh;
  27838. /** @hidden */
  27839. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  27840. /** @hidden */
  27841. protected _afterComputeWorldMatrix(): void;
  27842. /** @hidden */
  27843. readonly _effectiveMesh: AbstractMesh;
  27844. /**
  27845. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  27846. * A mesh is in the frustum if its bounding box intersects the frustum
  27847. * @param frustumPlanes defines the frustum to test
  27848. * @returns true if the mesh is in the frustum planes
  27849. */
  27850. isInFrustum(frustumPlanes: Plane[]): boolean;
  27851. /**
  27852. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  27853. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  27854. * @param frustumPlanes defines the frustum to test
  27855. * @returns true if the mesh is completely in the frustum planes
  27856. */
  27857. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  27858. /**
  27859. * True if the mesh intersects another mesh or a SolidParticle object
  27860. * @param mesh defines a target mesh or SolidParticle to test
  27861. * @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)
  27862. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  27863. * @returns true if there is an intersection
  27864. */
  27865. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  27866. /**
  27867. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  27868. * @param point defines the point to test
  27869. * @returns true if there is an intersection
  27870. */
  27871. intersectsPoint(point: Vector3): boolean;
  27872. /**
  27873. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  27874. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27875. */
  27876. checkCollisions: boolean;
  27877. /**
  27878. * Gets Collider object used to compute collisions (not physics)
  27879. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27880. */
  27881. readonly collider: Nullable<Collider>;
  27882. /**
  27883. * Move the mesh using collision engine
  27884. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27885. * @param displacement defines the requested displacement vector
  27886. * @returns the current mesh
  27887. */
  27888. moveWithCollisions(displacement: Vector3): AbstractMesh;
  27889. private _onCollisionPositionChange;
  27890. /** @hidden */
  27891. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  27892. /** @hidden */
  27893. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  27894. /** @hidden */
  27895. _checkCollision(collider: Collider): AbstractMesh;
  27896. /** @hidden */
  27897. _generatePointsArray(): boolean;
  27898. /**
  27899. * Checks if the passed Ray intersects with the mesh
  27900. * @param ray defines the ray to use
  27901. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  27902. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  27903. * @returns the picking info
  27904. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  27905. */
  27906. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  27907. /**
  27908. * Clones the current mesh
  27909. * @param name defines the mesh name
  27910. * @param newParent defines the new mesh parent
  27911. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  27912. * @returns the new mesh
  27913. */
  27914. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  27915. /**
  27916. * Disposes all the submeshes of the current meshnp
  27917. * @returns the current mesh
  27918. */
  27919. releaseSubMeshes(): AbstractMesh;
  27920. /**
  27921. * Releases resources associated with this abstract mesh.
  27922. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27923. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27924. */
  27925. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27926. /**
  27927. * Adds the passed mesh as a child to the current mesh
  27928. * @param mesh defines the child mesh
  27929. * @returns the current mesh
  27930. */
  27931. addChild(mesh: AbstractMesh): AbstractMesh;
  27932. /**
  27933. * Removes the passed mesh from the current mesh children list
  27934. * @param mesh defines the child mesh
  27935. * @returns the current mesh
  27936. */
  27937. removeChild(mesh: AbstractMesh): AbstractMesh;
  27938. /** @hidden */
  27939. private _initFacetData;
  27940. /**
  27941. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  27942. * This method can be called within the render loop.
  27943. * 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
  27944. * @returns the current mesh
  27945. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27946. */
  27947. updateFacetData(): AbstractMesh;
  27948. /**
  27949. * Returns the facetLocalNormals array.
  27950. * The normals are expressed in the mesh local spac
  27951. * @returns an array of Vector3
  27952. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27953. */
  27954. getFacetLocalNormals(): Vector3[];
  27955. /**
  27956. * Returns the facetLocalPositions array.
  27957. * The facet positions are expressed in the mesh local space
  27958. * @returns an array of Vector3
  27959. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27960. */
  27961. getFacetLocalPositions(): Vector3[];
  27962. /**
  27963. * Returns the facetLocalPartioning array
  27964. * @returns an array of array of numbers
  27965. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27966. */
  27967. getFacetLocalPartitioning(): number[][];
  27968. /**
  27969. * Returns the i-th facet position in the world system.
  27970. * This method allocates a new Vector3 per call
  27971. * @param i defines the facet index
  27972. * @returns a new Vector3
  27973. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27974. */
  27975. getFacetPosition(i: number): Vector3;
  27976. /**
  27977. * Sets the reference Vector3 with the i-th facet position in the world system
  27978. * @param i defines the facet index
  27979. * @param ref defines the target vector
  27980. * @returns the current mesh
  27981. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27982. */
  27983. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  27984. /**
  27985. * Returns the i-th facet normal in the world system.
  27986. * This method allocates a new Vector3 per call
  27987. * @param i defines the facet index
  27988. * @returns a new Vector3
  27989. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27990. */
  27991. getFacetNormal(i: number): Vector3;
  27992. /**
  27993. * Sets the reference Vector3 with the i-th facet normal in the world system
  27994. * @param i defines the facet index
  27995. * @param ref defines the target vector
  27996. * @returns the current mesh
  27997. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27998. */
  27999. getFacetNormalToRef(i: number, ref: Vector3): this;
  28000. /**
  28001. * 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)
  28002. * @param x defines x coordinate
  28003. * @param y defines y coordinate
  28004. * @param z defines z coordinate
  28005. * @returns the array of facet indexes
  28006. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28007. */
  28008. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  28009. /**
  28010. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  28011. * @param projected sets as the (x,y,z) world projection on the facet
  28012. * @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
  28013. * @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
  28014. * @param x defines x coordinate
  28015. * @param y defines y coordinate
  28016. * @param z defines z coordinate
  28017. * @returns the face index if found (or null instead)
  28018. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28019. */
  28020. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28021. /**
  28022. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  28023. * @param projected sets as the (x,y,z) local projection on the facet
  28024. * @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
  28025. * @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
  28026. * @param x defines x coordinate
  28027. * @param y defines y coordinate
  28028. * @param z defines z coordinate
  28029. * @returns the face index if found (or null instead)
  28030. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28031. */
  28032. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28033. /**
  28034. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  28035. * @returns the parameters
  28036. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28037. */
  28038. getFacetDataParameters(): any;
  28039. /**
  28040. * Disables the feature FacetData and frees the related memory
  28041. * @returns the current mesh
  28042. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28043. */
  28044. disableFacetData(): AbstractMesh;
  28045. /**
  28046. * Updates the AbstractMesh indices array
  28047. * @param indices defines the data source
  28048. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28049. * @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)
  28050. * @returns the current mesh
  28051. */
  28052. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28053. /**
  28054. * Creates new normals data for the mesh
  28055. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  28056. * @returns the current mesh
  28057. */
  28058. createNormals(updatable: boolean): AbstractMesh;
  28059. /**
  28060. * Align the mesh with a normal
  28061. * @param normal defines the normal to use
  28062. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  28063. * @returns the current mesh
  28064. */
  28065. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  28066. /** @hidden */
  28067. _checkOcclusionQuery(): boolean;
  28068. /**
  28069. * Disables the mesh edge rendering mode
  28070. * @returns the currentAbstractMesh
  28071. */
  28072. disableEdgesRendering(): AbstractMesh;
  28073. /**
  28074. * Enables the edge rendering mode on the mesh.
  28075. * This mode makes the mesh edges visible
  28076. * @param epsilon defines the maximal distance between two angles to detect a face
  28077. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28078. * @returns the currentAbstractMesh
  28079. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28080. */
  28081. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  28082. }
  28083. }
  28084. declare module BABYLON {
  28085. /**
  28086. * Interface used to define ActionEvent
  28087. */
  28088. export interface IActionEvent {
  28089. /** The mesh or sprite that triggered the action */
  28090. source: any;
  28091. /** The X mouse cursor position at the time of the event */
  28092. pointerX: number;
  28093. /** The Y mouse cursor position at the time of the event */
  28094. pointerY: number;
  28095. /** The mesh that is currently pointed at (can be null) */
  28096. meshUnderPointer: Nullable<AbstractMesh>;
  28097. /** the original (browser) event that triggered the ActionEvent */
  28098. sourceEvent?: any;
  28099. /** additional data for the event */
  28100. additionalData?: any;
  28101. }
  28102. /**
  28103. * ActionEvent is the event being sent when an action is triggered.
  28104. */
  28105. export class ActionEvent implements IActionEvent {
  28106. /** The mesh or sprite that triggered the action */
  28107. source: any;
  28108. /** The X mouse cursor position at the time of the event */
  28109. pointerX: number;
  28110. /** The Y mouse cursor position at the time of the event */
  28111. pointerY: number;
  28112. /** The mesh that is currently pointed at (can be null) */
  28113. meshUnderPointer: Nullable<AbstractMesh>;
  28114. /** the original (browser) event that triggered the ActionEvent */
  28115. sourceEvent?: any;
  28116. /** additional data for the event */
  28117. additionalData?: any;
  28118. /**
  28119. * Creates a new ActionEvent
  28120. * @param source The mesh or sprite that triggered the action
  28121. * @param pointerX The X mouse cursor position at the time of the event
  28122. * @param pointerY The Y mouse cursor position at the time of the event
  28123. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  28124. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  28125. * @param additionalData additional data for the event
  28126. */
  28127. constructor(
  28128. /** The mesh or sprite that triggered the action */
  28129. source: any,
  28130. /** The X mouse cursor position at the time of the event */
  28131. pointerX: number,
  28132. /** The Y mouse cursor position at the time of the event */
  28133. pointerY: number,
  28134. /** The mesh that is currently pointed at (can be null) */
  28135. meshUnderPointer: Nullable<AbstractMesh>,
  28136. /** the original (browser) event that triggered the ActionEvent */
  28137. sourceEvent?: any,
  28138. /** additional data for the event */
  28139. additionalData?: any);
  28140. /**
  28141. * Helper function to auto-create an ActionEvent from a source mesh.
  28142. * @param source The source mesh that triggered the event
  28143. * @param evt The original (browser) event
  28144. * @param additionalData additional data for the event
  28145. * @returns the new ActionEvent
  28146. */
  28147. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  28148. /**
  28149. * Helper function to auto-create an ActionEvent from a source sprite
  28150. * @param source The source sprite that triggered the event
  28151. * @param scene Scene associated with the sprite
  28152. * @param evt The original (browser) event
  28153. * @param additionalData additional data for the event
  28154. * @returns the new ActionEvent
  28155. */
  28156. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  28157. /**
  28158. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  28159. * @param scene the scene where the event occurred
  28160. * @param evt The original (browser) event
  28161. * @returns the new ActionEvent
  28162. */
  28163. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  28164. /**
  28165. * Helper function to auto-create an ActionEvent from a primitive
  28166. * @param prim defines the target primitive
  28167. * @param pointerPos defines the pointer position
  28168. * @param evt The original (browser) event
  28169. * @param additionalData additional data for the event
  28170. * @returns the new ActionEvent
  28171. */
  28172. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  28173. }
  28174. }
  28175. declare module BABYLON {
  28176. /**
  28177. * Abstract class used to decouple action Manager from scene and meshes.
  28178. * Do not instantiate.
  28179. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28180. */
  28181. export abstract class AbstractActionManager implements IDisposable {
  28182. /** Gets the list of active triggers */
  28183. static Triggers: {
  28184. [key: string]: number;
  28185. };
  28186. /** Gets the cursor to use when hovering items */
  28187. hoverCursor: string;
  28188. /** Gets the list of actions */
  28189. actions: IAction[];
  28190. /**
  28191. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  28192. */
  28193. isRecursive: boolean;
  28194. /**
  28195. * Releases all associated resources
  28196. */
  28197. abstract dispose(): void;
  28198. /**
  28199. * Does this action manager has pointer triggers
  28200. */
  28201. abstract readonly hasPointerTriggers: boolean;
  28202. /**
  28203. * Does this action manager has pick triggers
  28204. */
  28205. abstract readonly hasPickTriggers: boolean;
  28206. /**
  28207. * Process a specific trigger
  28208. * @param trigger defines the trigger to process
  28209. * @param evt defines the event details to be processed
  28210. */
  28211. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  28212. /**
  28213. * Does this action manager handles actions of any of the given triggers
  28214. * @param triggers defines the triggers to be tested
  28215. * @return a boolean indicating whether one (or more) of the triggers is handled
  28216. */
  28217. abstract hasSpecificTriggers(triggers: number[]): boolean;
  28218. /**
  28219. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  28220. * speed.
  28221. * @param triggerA defines the trigger to be tested
  28222. * @param triggerB defines the trigger to be tested
  28223. * @return a boolean indicating whether one (or more) of the triggers is handled
  28224. */
  28225. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  28226. /**
  28227. * Does this action manager handles actions of a given trigger
  28228. * @param trigger defines the trigger to be tested
  28229. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  28230. * @return whether the trigger is handled
  28231. */
  28232. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  28233. /**
  28234. * Serialize this manager to a JSON object
  28235. * @param name defines the property name to store this manager
  28236. * @returns a JSON representation of this manager
  28237. */
  28238. abstract serialize(name: string): any;
  28239. /**
  28240. * Registers an action to this action manager
  28241. * @param action defines the action to be registered
  28242. * @return the action amended (prepared) after registration
  28243. */
  28244. abstract registerAction(action: IAction): Nullable<IAction>;
  28245. /**
  28246. * Unregisters an action to this action manager
  28247. * @param action defines the action to be unregistered
  28248. * @return a boolean indicating whether the action has been unregistered
  28249. */
  28250. abstract unregisterAction(action: IAction): Boolean;
  28251. /**
  28252. * Does exist one action manager with at least one trigger
  28253. **/
  28254. static readonly HasTriggers: boolean;
  28255. /**
  28256. * Does exist one action manager with at least one pick trigger
  28257. **/
  28258. static readonly HasPickTriggers: boolean;
  28259. /**
  28260. * Does exist one action manager that handles actions of a given trigger
  28261. * @param trigger defines the trigger to be tested
  28262. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  28263. **/
  28264. static HasSpecificTrigger(trigger: number): boolean;
  28265. }
  28266. }
  28267. declare module BABYLON {
  28268. /**
  28269. * Defines how a node can be built from a string name.
  28270. */
  28271. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  28272. /**
  28273. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  28274. */
  28275. export class Node implements IBehaviorAware<Node> {
  28276. /** @hidden */
  28277. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  28278. private static _NodeConstructors;
  28279. /**
  28280. * Add a new node constructor
  28281. * @param type defines the type name of the node to construct
  28282. * @param constructorFunc defines the constructor function
  28283. */
  28284. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  28285. /**
  28286. * Returns a node constructor based on type name
  28287. * @param type defines the type name
  28288. * @param name defines the new node name
  28289. * @param scene defines the hosting scene
  28290. * @param options defines optional options to transmit to constructors
  28291. * @returns the new constructor or null
  28292. */
  28293. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  28294. /**
  28295. * Gets or sets the name of the node
  28296. */
  28297. name: string;
  28298. /**
  28299. * Gets or sets the id of the node
  28300. */
  28301. id: string;
  28302. /**
  28303. * Gets or sets the unique id of the node
  28304. */
  28305. uniqueId: number;
  28306. /**
  28307. * Gets or sets a string used to store user defined state for the node
  28308. */
  28309. state: string;
  28310. /**
  28311. * Gets or sets an object used to store user defined information for the node
  28312. */
  28313. metadata: any;
  28314. /**
  28315. * For internal use only. Please do not use.
  28316. */
  28317. reservedDataStore: any;
  28318. /**
  28319. * List of inspectable custom properties (used by the Inspector)
  28320. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  28321. */
  28322. inspectableCustomProperties: IInspectable[];
  28323. private _doNotSerialize;
  28324. /**
  28325. * Gets or sets a boolean used to define if the node must be serialized
  28326. */
  28327. doNotSerialize: boolean;
  28328. /** @hidden */
  28329. _isDisposed: boolean;
  28330. /**
  28331. * Gets a list of Animations associated with the node
  28332. */
  28333. animations: Animation[];
  28334. protected _ranges: {
  28335. [name: string]: Nullable<AnimationRange>;
  28336. };
  28337. /**
  28338. * Callback raised when the node is ready to be used
  28339. */
  28340. onReady: Nullable<(node: Node) => void>;
  28341. private _isEnabled;
  28342. private _isParentEnabled;
  28343. private _isReady;
  28344. /** @hidden */
  28345. _currentRenderId: number;
  28346. private _parentUpdateId;
  28347. /** @hidden */
  28348. _childUpdateId: number;
  28349. /** @hidden */
  28350. _waitingParentId: Nullable<string>;
  28351. /** @hidden */
  28352. _scene: Scene;
  28353. /** @hidden */
  28354. _cache: any;
  28355. private _parentNode;
  28356. private _children;
  28357. /** @hidden */
  28358. _worldMatrix: Matrix;
  28359. /** @hidden */
  28360. _worldMatrixDeterminant: number;
  28361. /** @hidden */
  28362. _worldMatrixDeterminantIsDirty: boolean;
  28363. /** @hidden */
  28364. private _sceneRootNodesIndex;
  28365. /**
  28366. * Gets a boolean indicating if the node has been disposed
  28367. * @returns true if the node was disposed
  28368. */
  28369. isDisposed(): boolean;
  28370. /**
  28371. * Gets or sets the parent of the node (without keeping the current position in the scene)
  28372. * @see https://doc.babylonjs.com/how_to/parenting
  28373. */
  28374. parent: Nullable<Node>;
  28375. /** @hidden */
  28376. _addToSceneRootNodes(): void;
  28377. /** @hidden */
  28378. _removeFromSceneRootNodes(): void;
  28379. private _animationPropertiesOverride;
  28380. /**
  28381. * Gets or sets the animation properties override
  28382. */
  28383. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  28384. /**
  28385. * Gets a string idenfifying the name of the class
  28386. * @returns "Node" string
  28387. */
  28388. getClassName(): string;
  28389. /** @hidden */
  28390. readonly _isNode: boolean;
  28391. /**
  28392. * An event triggered when the mesh is disposed
  28393. */
  28394. onDisposeObservable: Observable<Node>;
  28395. private _onDisposeObserver;
  28396. /**
  28397. * Sets a callback that will be raised when the node will be disposed
  28398. */
  28399. onDispose: () => void;
  28400. /**
  28401. * Creates a new Node
  28402. * @param name the name and id to be given to this node
  28403. * @param scene the scene this node will be added to
  28404. */
  28405. constructor(name: string, scene?: Nullable<Scene>);
  28406. /**
  28407. * Gets the scene of the node
  28408. * @returns a scene
  28409. */
  28410. getScene(): Scene;
  28411. /**
  28412. * Gets the engine of the node
  28413. * @returns a Engine
  28414. */
  28415. getEngine(): Engine;
  28416. private _behaviors;
  28417. /**
  28418. * Attach a behavior to the node
  28419. * @see http://doc.babylonjs.com/features/behaviour
  28420. * @param behavior defines the behavior to attach
  28421. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  28422. * @returns the current Node
  28423. */
  28424. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  28425. /**
  28426. * Remove an attached behavior
  28427. * @see http://doc.babylonjs.com/features/behaviour
  28428. * @param behavior defines the behavior to attach
  28429. * @returns the current Node
  28430. */
  28431. removeBehavior(behavior: Behavior<Node>): Node;
  28432. /**
  28433. * Gets the list of attached behaviors
  28434. * @see http://doc.babylonjs.com/features/behaviour
  28435. */
  28436. readonly behaviors: Behavior<Node>[];
  28437. /**
  28438. * Gets an attached behavior by name
  28439. * @param name defines the name of the behavior to look for
  28440. * @see http://doc.babylonjs.com/features/behaviour
  28441. * @returns null if behavior was not found else the requested behavior
  28442. */
  28443. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  28444. /**
  28445. * Returns the latest update of the World matrix
  28446. * @returns a Matrix
  28447. */
  28448. getWorldMatrix(): Matrix;
  28449. /** @hidden */
  28450. _getWorldMatrixDeterminant(): number;
  28451. /**
  28452. * Returns directly the latest state of the mesh World matrix.
  28453. * A Matrix is returned.
  28454. */
  28455. readonly worldMatrixFromCache: Matrix;
  28456. /** @hidden */
  28457. _initCache(): void;
  28458. /** @hidden */
  28459. updateCache(force?: boolean): void;
  28460. /** @hidden */
  28461. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28462. /** @hidden */
  28463. _updateCache(ignoreParentClass?: boolean): void;
  28464. /** @hidden */
  28465. _isSynchronized(): boolean;
  28466. /** @hidden */
  28467. _markSyncedWithParent(): void;
  28468. /** @hidden */
  28469. isSynchronizedWithParent(): boolean;
  28470. /** @hidden */
  28471. isSynchronized(): boolean;
  28472. /**
  28473. * Is this node ready to be used/rendered
  28474. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28475. * @return true if the node is ready
  28476. */
  28477. isReady(completeCheck?: boolean): boolean;
  28478. /**
  28479. * Is this node enabled?
  28480. * 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
  28481. * @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
  28482. * @return whether this node (and its parent) is enabled
  28483. */
  28484. isEnabled(checkAncestors?: boolean): boolean;
  28485. /** @hidden */
  28486. protected _syncParentEnabledState(): void;
  28487. /**
  28488. * Set the enabled state of this node
  28489. * @param value defines the new enabled state
  28490. */
  28491. setEnabled(value: boolean): void;
  28492. /**
  28493. * Is this node a descendant of the given node?
  28494. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  28495. * @param ancestor defines the parent node to inspect
  28496. * @returns a boolean indicating if this node is a descendant of the given node
  28497. */
  28498. isDescendantOf(ancestor: Node): boolean;
  28499. /** @hidden */
  28500. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  28501. /**
  28502. * Will return all nodes that have this node as ascendant
  28503. * @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
  28504. * @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
  28505. * @return all children nodes of all types
  28506. */
  28507. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  28508. /**
  28509. * Get all child-meshes of this node
  28510. * @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)
  28511. * @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
  28512. * @returns an array of AbstractMesh
  28513. */
  28514. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  28515. /**
  28516. * Get all direct children of this node
  28517. * @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
  28518. * @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)
  28519. * @returns an array of Node
  28520. */
  28521. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  28522. /** @hidden */
  28523. _setReady(state: boolean): void;
  28524. /**
  28525. * Get an animation by name
  28526. * @param name defines the name of the animation to look for
  28527. * @returns null if not found else the requested animation
  28528. */
  28529. getAnimationByName(name: string): Nullable<Animation>;
  28530. /**
  28531. * Creates an animation range for this node
  28532. * @param name defines the name of the range
  28533. * @param from defines the starting key
  28534. * @param to defines the end key
  28535. */
  28536. createAnimationRange(name: string, from: number, to: number): void;
  28537. /**
  28538. * Delete a specific animation range
  28539. * @param name defines the name of the range to delete
  28540. * @param deleteFrames defines if animation frames from the range must be deleted as well
  28541. */
  28542. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  28543. /**
  28544. * Get an animation range by name
  28545. * @param name defines the name of the animation range to look for
  28546. * @returns null if not found else the requested animation range
  28547. */
  28548. getAnimationRange(name: string): Nullable<AnimationRange>;
  28549. /**
  28550. * Gets the list of all animation ranges defined on this node
  28551. * @returns an array
  28552. */
  28553. getAnimationRanges(): Nullable<AnimationRange>[];
  28554. /**
  28555. * Will start the animation sequence
  28556. * @param name defines the range frames for animation sequence
  28557. * @param loop defines if the animation should loop (false by default)
  28558. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  28559. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  28560. * @returns the object created for this animation. If range does not exist, it will return null
  28561. */
  28562. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  28563. /**
  28564. * Serialize animation ranges into a JSON compatible object
  28565. * @returns serialization object
  28566. */
  28567. serializeAnimationRanges(): any;
  28568. /**
  28569. * Computes the world matrix of the node
  28570. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  28571. * @returns the world matrix
  28572. */
  28573. computeWorldMatrix(force?: boolean): Matrix;
  28574. /**
  28575. * Releases resources associated with this node.
  28576. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28577. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28578. */
  28579. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28580. /**
  28581. * Parse animation range data from a serialization object and store them into a given node
  28582. * @param node defines where to store the animation ranges
  28583. * @param parsedNode defines the serialization object to read data from
  28584. * @param scene defines the hosting scene
  28585. */
  28586. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  28587. /**
  28588. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  28589. * @param includeDescendants Include bounding info from descendants as well (true by default)
  28590. * @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
  28591. * @returns the new bounding vectors
  28592. */
  28593. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  28594. min: Vector3;
  28595. max: Vector3;
  28596. };
  28597. }
  28598. }
  28599. declare module BABYLON {
  28600. /**
  28601. * @hidden
  28602. */
  28603. export class _IAnimationState {
  28604. key: number;
  28605. repeatCount: number;
  28606. workValue?: any;
  28607. loopMode?: number;
  28608. offsetValue?: any;
  28609. highLimitValue?: any;
  28610. }
  28611. /**
  28612. * Class used to store any kind of animation
  28613. */
  28614. export class Animation {
  28615. /**Name of the animation */
  28616. name: string;
  28617. /**Property to animate */
  28618. targetProperty: string;
  28619. /**The frames per second of the animation */
  28620. framePerSecond: number;
  28621. /**The data type of the animation */
  28622. dataType: number;
  28623. /**The loop mode of the animation */
  28624. loopMode?: number | undefined;
  28625. /**Specifies if blending should be enabled */
  28626. enableBlending?: boolean | undefined;
  28627. /**
  28628. * Use matrix interpolation instead of using direct key value when animating matrices
  28629. */
  28630. static AllowMatricesInterpolation: boolean;
  28631. /**
  28632. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  28633. */
  28634. static AllowMatrixDecomposeForInterpolation: boolean;
  28635. /**
  28636. * Stores the key frames of the animation
  28637. */
  28638. private _keys;
  28639. /**
  28640. * Stores the easing function of the animation
  28641. */
  28642. private _easingFunction;
  28643. /**
  28644. * @hidden Internal use only
  28645. */
  28646. _runtimeAnimations: RuntimeAnimation[];
  28647. /**
  28648. * The set of event that will be linked to this animation
  28649. */
  28650. private _events;
  28651. /**
  28652. * Stores an array of target property paths
  28653. */
  28654. targetPropertyPath: string[];
  28655. /**
  28656. * Stores the blending speed of the animation
  28657. */
  28658. blendingSpeed: number;
  28659. /**
  28660. * Stores the animation ranges for the animation
  28661. */
  28662. private _ranges;
  28663. /**
  28664. * @hidden Internal use
  28665. */
  28666. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  28667. /**
  28668. * Sets up an animation
  28669. * @param property The property to animate
  28670. * @param animationType The animation type to apply
  28671. * @param framePerSecond The frames per second of the animation
  28672. * @param easingFunction The easing function used in the animation
  28673. * @returns The created animation
  28674. */
  28675. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  28676. /**
  28677. * Create and start an animation on a node
  28678. * @param name defines the name of the global animation that will be run on all nodes
  28679. * @param node defines the root node where the animation will take place
  28680. * @param targetProperty defines property to animate
  28681. * @param framePerSecond defines the number of frame per second yo use
  28682. * @param totalFrame defines the number of frames in total
  28683. * @param from defines the initial value
  28684. * @param to defines the final value
  28685. * @param loopMode defines which loop mode you want to use (off by default)
  28686. * @param easingFunction defines the easing function to use (linear by default)
  28687. * @param onAnimationEnd defines the callback to call when animation end
  28688. * @returns the animatable created for this animation
  28689. */
  28690. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  28691. /**
  28692. * Create and start an animation on a node and its descendants
  28693. * @param name defines the name of the global animation that will be run on all nodes
  28694. * @param node defines the root node where the animation will take place
  28695. * @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
  28696. * @param targetProperty defines property to animate
  28697. * @param framePerSecond defines the number of frame per second to use
  28698. * @param totalFrame defines the number of frames in total
  28699. * @param from defines the initial value
  28700. * @param to defines the final value
  28701. * @param loopMode defines which loop mode you want to use (off by default)
  28702. * @param easingFunction defines the easing function to use (linear by default)
  28703. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  28704. * @returns the list of animatables created for all nodes
  28705. * @example https://www.babylonjs-playground.com/#MH0VLI
  28706. */
  28707. 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[]>;
  28708. /**
  28709. * Creates a new animation, merges it with the existing animations and starts it
  28710. * @param name Name of the animation
  28711. * @param node Node which contains the scene that begins the animations
  28712. * @param targetProperty Specifies which property to animate
  28713. * @param framePerSecond The frames per second of the animation
  28714. * @param totalFrame The total number of frames
  28715. * @param from The frame at the beginning of the animation
  28716. * @param to The frame at the end of the animation
  28717. * @param loopMode Specifies the loop mode of the animation
  28718. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  28719. * @param onAnimationEnd Callback to run once the animation is complete
  28720. * @returns Nullable animation
  28721. */
  28722. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  28723. /**
  28724. * Transition property of an host to the target Value
  28725. * @param property The property to transition
  28726. * @param targetValue The target Value of the property
  28727. * @param host The object where the property to animate belongs
  28728. * @param scene Scene used to run the animation
  28729. * @param frameRate Framerate (in frame/s) to use
  28730. * @param transition The transition type we want to use
  28731. * @param duration The duration of the animation, in milliseconds
  28732. * @param onAnimationEnd Callback trigger at the end of the animation
  28733. * @returns Nullable animation
  28734. */
  28735. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  28736. /**
  28737. * Return the array of runtime animations currently using this animation
  28738. */
  28739. readonly runtimeAnimations: RuntimeAnimation[];
  28740. /**
  28741. * Specifies if any of the runtime animations are currently running
  28742. */
  28743. readonly hasRunningRuntimeAnimations: boolean;
  28744. /**
  28745. * Initializes the animation
  28746. * @param name Name of the animation
  28747. * @param targetProperty Property to animate
  28748. * @param framePerSecond The frames per second of the animation
  28749. * @param dataType The data type of the animation
  28750. * @param loopMode The loop mode of the animation
  28751. * @param enableBlending Specifies if blending should be enabled
  28752. */
  28753. constructor(
  28754. /**Name of the animation */
  28755. name: string,
  28756. /**Property to animate */
  28757. targetProperty: string,
  28758. /**The frames per second of the animation */
  28759. framePerSecond: number,
  28760. /**The data type of the animation */
  28761. dataType: number,
  28762. /**The loop mode of the animation */
  28763. loopMode?: number | undefined,
  28764. /**Specifies if blending should be enabled */
  28765. enableBlending?: boolean | undefined);
  28766. /**
  28767. * Converts the animation to a string
  28768. * @param fullDetails support for multiple levels of logging within scene loading
  28769. * @returns String form of the animation
  28770. */
  28771. toString(fullDetails?: boolean): string;
  28772. /**
  28773. * Add an event to this animation
  28774. * @param event Event to add
  28775. */
  28776. addEvent(event: AnimationEvent): void;
  28777. /**
  28778. * Remove all events found at the given frame
  28779. * @param frame The frame to remove events from
  28780. */
  28781. removeEvents(frame: number): void;
  28782. /**
  28783. * Retrieves all the events from the animation
  28784. * @returns Events from the animation
  28785. */
  28786. getEvents(): AnimationEvent[];
  28787. /**
  28788. * Creates an animation range
  28789. * @param name Name of the animation range
  28790. * @param from Starting frame of the animation range
  28791. * @param to Ending frame of the animation
  28792. */
  28793. createRange(name: string, from: number, to: number): void;
  28794. /**
  28795. * Deletes an animation range by name
  28796. * @param name Name of the animation range to delete
  28797. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  28798. */
  28799. deleteRange(name: string, deleteFrames?: boolean): void;
  28800. /**
  28801. * Gets the animation range by name, or null if not defined
  28802. * @param name Name of the animation range
  28803. * @returns Nullable animation range
  28804. */
  28805. getRange(name: string): Nullable<AnimationRange>;
  28806. /**
  28807. * Gets the key frames from the animation
  28808. * @returns The key frames of the animation
  28809. */
  28810. getKeys(): Array<IAnimationKey>;
  28811. /**
  28812. * Gets the highest frame rate of the animation
  28813. * @returns Highest frame rate of the animation
  28814. */
  28815. getHighestFrame(): number;
  28816. /**
  28817. * Gets the easing function of the animation
  28818. * @returns Easing function of the animation
  28819. */
  28820. getEasingFunction(): IEasingFunction;
  28821. /**
  28822. * Sets the easing function of the animation
  28823. * @param easingFunction A custom mathematical formula for animation
  28824. */
  28825. setEasingFunction(easingFunction: EasingFunction): void;
  28826. /**
  28827. * Interpolates a scalar linearly
  28828. * @param startValue Start value of the animation curve
  28829. * @param endValue End value of the animation curve
  28830. * @param gradient Scalar amount to interpolate
  28831. * @returns Interpolated scalar value
  28832. */
  28833. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  28834. /**
  28835. * Interpolates a scalar cubically
  28836. * @param startValue Start value of the animation curve
  28837. * @param outTangent End tangent of the animation
  28838. * @param endValue End value of the animation curve
  28839. * @param inTangent Start tangent of the animation curve
  28840. * @param gradient Scalar amount to interpolate
  28841. * @returns Interpolated scalar value
  28842. */
  28843. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  28844. /**
  28845. * Interpolates a quaternion using a spherical linear interpolation
  28846. * @param startValue Start value of the animation curve
  28847. * @param endValue End value of the animation curve
  28848. * @param gradient Scalar amount to interpolate
  28849. * @returns Interpolated quaternion value
  28850. */
  28851. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  28852. /**
  28853. * Interpolates a quaternion cubically
  28854. * @param startValue Start value of the animation curve
  28855. * @param outTangent End tangent of the animation curve
  28856. * @param endValue End value of the animation curve
  28857. * @param inTangent Start tangent of the animation curve
  28858. * @param gradient Scalar amount to interpolate
  28859. * @returns Interpolated quaternion value
  28860. */
  28861. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  28862. /**
  28863. * Interpolates a Vector3 linearl
  28864. * @param startValue Start value of the animation curve
  28865. * @param endValue End value of the animation curve
  28866. * @param gradient Scalar amount to interpolate
  28867. * @returns Interpolated scalar value
  28868. */
  28869. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  28870. /**
  28871. * Interpolates a Vector3 cubically
  28872. * @param startValue Start value of the animation curve
  28873. * @param outTangent End tangent of the animation
  28874. * @param endValue End value of the animation curve
  28875. * @param inTangent Start tangent of the animation curve
  28876. * @param gradient Scalar amount to interpolate
  28877. * @returns InterpolatedVector3 value
  28878. */
  28879. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  28880. /**
  28881. * Interpolates a Vector2 linearly
  28882. * @param startValue Start value of the animation curve
  28883. * @param endValue End value of the animation curve
  28884. * @param gradient Scalar amount to interpolate
  28885. * @returns Interpolated Vector2 value
  28886. */
  28887. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  28888. /**
  28889. * Interpolates a Vector2 cubically
  28890. * @param startValue Start value of the animation curve
  28891. * @param outTangent End tangent of the animation
  28892. * @param endValue End value of the animation curve
  28893. * @param inTangent Start tangent of the animation curve
  28894. * @param gradient Scalar amount to interpolate
  28895. * @returns Interpolated Vector2 value
  28896. */
  28897. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  28898. /**
  28899. * Interpolates a size linearly
  28900. * @param startValue Start value of the animation curve
  28901. * @param endValue End value of the animation curve
  28902. * @param gradient Scalar amount to interpolate
  28903. * @returns Interpolated Size value
  28904. */
  28905. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  28906. /**
  28907. * Interpolates a Color3 linearly
  28908. * @param startValue Start value of the animation curve
  28909. * @param endValue End value of the animation curve
  28910. * @param gradient Scalar amount to interpolate
  28911. * @returns Interpolated Color3 value
  28912. */
  28913. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  28914. /**
  28915. * Interpolates a Color4 linearly
  28916. * @param startValue Start value of the animation curve
  28917. * @param endValue End value of the animation curve
  28918. * @param gradient Scalar amount to interpolate
  28919. * @returns Interpolated Color3 value
  28920. */
  28921. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  28922. /**
  28923. * @hidden Internal use only
  28924. */
  28925. _getKeyValue(value: any): any;
  28926. /**
  28927. * @hidden Internal use only
  28928. */
  28929. _interpolate(currentFrame: number, state: _IAnimationState): any;
  28930. /**
  28931. * Defines the function to use to interpolate matrices
  28932. * @param startValue defines the start matrix
  28933. * @param endValue defines the end matrix
  28934. * @param gradient defines the gradient between both matrices
  28935. * @param result defines an optional target matrix where to store the interpolation
  28936. * @returns the interpolated matrix
  28937. */
  28938. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  28939. /**
  28940. * Makes a copy of the animation
  28941. * @returns Cloned animation
  28942. */
  28943. clone(): Animation;
  28944. /**
  28945. * Sets the key frames of the animation
  28946. * @param values The animation key frames to set
  28947. */
  28948. setKeys(values: Array<IAnimationKey>): void;
  28949. /**
  28950. * Serializes the animation to an object
  28951. * @returns Serialized object
  28952. */
  28953. serialize(): any;
  28954. /**
  28955. * Float animation type
  28956. */
  28957. static readonly ANIMATIONTYPE_FLOAT: number;
  28958. /**
  28959. * Vector3 animation type
  28960. */
  28961. static readonly ANIMATIONTYPE_VECTOR3: number;
  28962. /**
  28963. * Quaternion animation type
  28964. */
  28965. static readonly ANIMATIONTYPE_QUATERNION: number;
  28966. /**
  28967. * Matrix animation type
  28968. */
  28969. static readonly ANIMATIONTYPE_MATRIX: number;
  28970. /**
  28971. * Color3 animation type
  28972. */
  28973. static readonly ANIMATIONTYPE_COLOR3: number;
  28974. /**
  28975. * Color3 animation type
  28976. */
  28977. static readonly ANIMATIONTYPE_COLOR4: number;
  28978. /**
  28979. * Vector2 animation type
  28980. */
  28981. static readonly ANIMATIONTYPE_VECTOR2: number;
  28982. /**
  28983. * Size animation type
  28984. */
  28985. static readonly ANIMATIONTYPE_SIZE: number;
  28986. /**
  28987. * Relative Loop Mode
  28988. */
  28989. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  28990. /**
  28991. * Cycle Loop Mode
  28992. */
  28993. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  28994. /**
  28995. * Constant Loop Mode
  28996. */
  28997. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  28998. /** @hidden */
  28999. static _UniversalLerp(left: any, right: any, amount: number): any;
  29000. /**
  29001. * Parses an animation object and creates an animation
  29002. * @param parsedAnimation Parsed animation object
  29003. * @returns Animation object
  29004. */
  29005. static Parse(parsedAnimation: any): Animation;
  29006. /**
  29007. * Appends the serialized animations from the source animations
  29008. * @param source Source containing the animations
  29009. * @param destination Target to store the animations
  29010. */
  29011. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29012. }
  29013. }
  29014. declare module BABYLON {
  29015. /**
  29016. * Interface containing an array of animations
  29017. */
  29018. export interface IAnimatable {
  29019. /**
  29020. * Array of animations
  29021. */
  29022. animations: Nullable<Array<Animation>>;
  29023. }
  29024. }
  29025. declare module BABYLON {
  29026. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29027. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29028. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29029. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29030. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29031. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29032. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29033. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29034. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29035. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29036. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29037. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29038. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29039. /**
  29040. * Decorator used to define property that can be serialized as reference to a camera
  29041. * @param sourceName defines the name of the property to decorate
  29042. */
  29043. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29044. /**
  29045. * Class used to help serialization objects
  29046. */
  29047. export class SerializationHelper {
  29048. /** @hidden */
  29049. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  29050. /** @hidden */
  29051. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  29052. /** @hidden */
  29053. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  29054. /** @hidden */
  29055. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  29056. /**
  29057. * Appends the serialized animations from the source animations
  29058. * @param source Source containing the animations
  29059. * @param destination Target to store the animations
  29060. */
  29061. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29062. /**
  29063. * Static function used to serialized a specific entity
  29064. * @param entity defines the entity to serialize
  29065. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  29066. * @returns a JSON compatible object representing the serialization of the entity
  29067. */
  29068. static Serialize<T>(entity: T, serializationObject?: any): any;
  29069. /**
  29070. * Creates a new entity from a serialization data object
  29071. * @param creationFunction defines a function used to instanciated the new entity
  29072. * @param source defines the source serialization data
  29073. * @param scene defines the hosting scene
  29074. * @param rootUrl defines the root url for resources
  29075. * @returns a new entity
  29076. */
  29077. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  29078. /**
  29079. * Clones an object
  29080. * @param creationFunction defines the function used to instanciate the new object
  29081. * @param source defines the source object
  29082. * @returns the cloned object
  29083. */
  29084. static Clone<T>(creationFunction: () => T, source: T): T;
  29085. /**
  29086. * Instanciates a new object based on a source one (some data will be shared between both object)
  29087. * @param creationFunction defines the function used to instanciate the new object
  29088. * @param source defines the source object
  29089. * @returns the new object
  29090. */
  29091. static Instanciate<T>(creationFunction: () => T, source: T): T;
  29092. }
  29093. }
  29094. declare module BABYLON {
  29095. /**
  29096. * Class used to manipulate GUIDs
  29097. */
  29098. export class GUID {
  29099. /**
  29100. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  29101. * Be aware Math.random() could cause collisions, but:
  29102. * "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"
  29103. * @returns a pseudo random id
  29104. */
  29105. static RandomId(): string;
  29106. }
  29107. }
  29108. declare module BABYLON {
  29109. /**
  29110. * Base class of all the textures in babylon.
  29111. * It groups all the common properties the materials, post process, lights... might need
  29112. * in order to make a correct use of the texture.
  29113. */
  29114. export class BaseTexture implements IAnimatable {
  29115. /**
  29116. * Default anisotropic filtering level for the application.
  29117. * It is set to 4 as a good tradeoff between perf and quality.
  29118. */
  29119. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  29120. /**
  29121. * Gets or sets the unique id of the texture
  29122. */
  29123. uniqueId: number;
  29124. /**
  29125. * Define the name of the texture.
  29126. */
  29127. name: string;
  29128. /**
  29129. * Gets or sets an object used to store user defined information.
  29130. */
  29131. metadata: any;
  29132. /**
  29133. * For internal use only. Please do not use.
  29134. */
  29135. reservedDataStore: any;
  29136. private _hasAlpha;
  29137. /**
  29138. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  29139. */
  29140. hasAlpha: boolean;
  29141. /**
  29142. * Defines if the alpha value should be determined via the rgb values.
  29143. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  29144. */
  29145. getAlphaFromRGB: boolean;
  29146. /**
  29147. * Intensity or strength of the texture.
  29148. * It is commonly used by materials to fine tune the intensity of the texture
  29149. */
  29150. level: number;
  29151. /**
  29152. * Define the UV chanel to use starting from 0 and defaulting to 0.
  29153. * This is part of the texture as textures usually maps to one uv set.
  29154. */
  29155. coordinatesIndex: number;
  29156. private _coordinatesMode;
  29157. /**
  29158. * How a texture is mapped.
  29159. *
  29160. * | Value | Type | Description |
  29161. * | ----- | ----------------------------------- | ----------- |
  29162. * | 0 | EXPLICIT_MODE | |
  29163. * | 1 | SPHERICAL_MODE | |
  29164. * | 2 | PLANAR_MODE | |
  29165. * | 3 | CUBIC_MODE | |
  29166. * | 4 | PROJECTION_MODE | |
  29167. * | 5 | SKYBOX_MODE | |
  29168. * | 6 | INVCUBIC_MODE | |
  29169. * | 7 | EQUIRECTANGULAR_MODE | |
  29170. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  29171. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  29172. */
  29173. coordinatesMode: number;
  29174. /**
  29175. * | Value | Type | Description |
  29176. * | ----- | ------------------ | ----------- |
  29177. * | 0 | CLAMP_ADDRESSMODE | |
  29178. * | 1 | WRAP_ADDRESSMODE | |
  29179. * | 2 | MIRROR_ADDRESSMODE | |
  29180. */
  29181. wrapU: number;
  29182. /**
  29183. * | Value | Type | Description |
  29184. * | ----- | ------------------ | ----------- |
  29185. * | 0 | CLAMP_ADDRESSMODE | |
  29186. * | 1 | WRAP_ADDRESSMODE | |
  29187. * | 2 | MIRROR_ADDRESSMODE | |
  29188. */
  29189. wrapV: number;
  29190. /**
  29191. * | Value | Type | Description |
  29192. * | ----- | ------------------ | ----------- |
  29193. * | 0 | CLAMP_ADDRESSMODE | |
  29194. * | 1 | WRAP_ADDRESSMODE | |
  29195. * | 2 | MIRROR_ADDRESSMODE | |
  29196. */
  29197. wrapR: number;
  29198. /**
  29199. * With compliant hardware and browser (supporting anisotropic filtering)
  29200. * this defines the level of anisotropic filtering in the texture.
  29201. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  29202. */
  29203. anisotropicFilteringLevel: number;
  29204. /**
  29205. * Define if the texture is a cube texture or if false a 2d texture.
  29206. */
  29207. isCube: boolean;
  29208. /**
  29209. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  29210. */
  29211. is3D: boolean;
  29212. /**
  29213. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  29214. */
  29215. is2DArray: boolean;
  29216. /**
  29217. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  29218. * HDR texture are usually stored in linear space.
  29219. * This only impacts the PBR and Background materials
  29220. */
  29221. gammaSpace: boolean;
  29222. /**
  29223. * Gets or sets whether or not the texture contains RGBD data.
  29224. */
  29225. isRGBD: boolean;
  29226. /**
  29227. * Is Z inverted in the texture (useful in a cube texture).
  29228. */
  29229. invertZ: boolean;
  29230. /**
  29231. * Are mip maps generated for this texture or not.
  29232. */
  29233. readonly noMipmap: boolean;
  29234. /**
  29235. * @hidden
  29236. */
  29237. lodLevelInAlpha: boolean;
  29238. /**
  29239. * With prefiltered texture, defined the offset used during the prefiltering steps.
  29240. */
  29241. lodGenerationOffset: number;
  29242. /**
  29243. * With prefiltered texture, defined the scale used during the prefiltering steps.
  29244. */
  29245. lodGenerationScale: number;
  29246. /**
  29247. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  29248. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  29249. * average roughness values.
  29250. */
  29251. linearSpecularLOD: boolean;
  29252. /**
  29253. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  29254. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  29255. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  29256. */
  29257. irradianceTexture: Nullable<BaseTexture>;
  29258. /**
  29259. * Define if the texture is a render target.
  29260. */
  29261. isRenderTarget: boolean;
  29262. /**
  29263. * Define the unique id of the texture in the scene.
  29264. */
  29265. readonly uid: string;
  29266. /**
  29267. * Return a string representation of the texture.
  29268. * @returns the texture as a string
  29269. */
  29270. toString(): string;
  29271. /**
  29272. * Get the class name of the texture.
  29273. * @returns "BaseTexture"
  29274. */
  29275. getClassName(): string;
  29276. /**
  29277. * Define the list of animation attached to the texture.
  29278. */
  29279. animations: Animation[];
  29280. /**
  29281. * An event triggered when the texture is disposed.
  29282. */
  29283. onDisposeObservable: Observable<BaseTexture>;
  29284. private _onDisposeObserver;
  29285. /**
  29286. * Callback triggered when the texture has been disposed.
  29287. * Kept for back compatibility, you can use the onDisposeObservable instead.
  29288. */
  29289. onDispose: () => void;
  29290. /**
  29291. * Define the current state of the loading sequence when in delayed load mode.
  29292. */
  29293. delayLoadState: number;
  29294. private _scene;
  29295. /** @hidden */
  29296. _texture: Nullable<InternalTexture>;
  29297. private _uid;
  29298. /**
  29299. * Define if the texture is preventinga material to render or not.
  29300. * If not and the texture is not ready, the engine will use a default black texture instead.
  29301. */
  29302. readonly isBlocking: boolean;
  29303. /**
  29304. * Instantiates a new BaseTexture.
  29305. * Base class of all the textures in babylon.
  29306. * It groups all the common properties the materials, post process, lights... might need
  29307. * in order to make a correct use of the texture.
  29308. * @param scene Define the scene the texture blongs to
  29309. */
  29310. constructor(scene: Nullable<Scene>);
  29311. /**
  29312. * Get the scene the texture belongs to.
  29313. * @returns the scene or null if undefined
  29314. */
  29315. getScene(): Nullable<Scene>;
  29316. /**
  29317. * Get the texture transform matrix used to offset tile the texture for istance.
  29318. * @returns the transformation matrix
  29319. */
  29320. getTextureMatrix(): Matrix;
  29321. /**
  29322. * Get the texture reflection matrix used to rotate/transform the reflection.
  29323. * @returns the reflection matrix
  29324. */
  29325. getReflectionTextureMatrix(): Matrix;
  29326. /**
  29327. * Get the underlying lower level texture from Babylon.
  29328. * @returns the insternal texture
  29329. */
  29330. getInternalTexture(): Nullable<InternalTexture>;
  29331. /**
  29332. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  29333. * @returns true if ready or not blocking
  29334. */
  29335. isReadyOrNotBlocking(): boolean;
  29336. /**
  29337. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  29338. * @returns true if fully ready
  29339. */
  29340. isReady(): boolean;
  29341. private _cachedSize;
  29342. /**
  29343. * Get the size of the texture.
  29344. * @returns the texture size.
  29345. */
  29346. getSize(): ISize;
  29347. /**
  29348. * Get the base size of the texture.
  29349. * It can be different from the size if the texture has been resized for POT for instance
  29350. * @returns the base size
  29351. */
  29352. getBaseSize(): ISize;
  29353. /**
  29354. * Update the sampling mode of the texture.
  29355. * Default is Trilinear mode.
  29356. *
  29357. * | Value | Type | Description |
  29358. * | ----- | ------------------ | ----------- |
  29359. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  29360. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  29361. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  29362. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  29363. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  29364. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  29365. * | 7 | NEAREST_LINEAR | |
  29366. * | 8 | NEAREST_NEAREST | |
  29367. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  29368. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  29369. * | 11 | LINEAR_LINEAR | |
  29370. * | 12 | LINEAR_NEAREST | |
  29371. *
  29372. * > _mag_: magnification filter (close to the viewer)
  29373. * > _min_: minification filter (far from the viewer)
  29374. * > _mip_: filter used between mip map levels
  29375. *@param samplingMode Define the new sampling mode of the texture
  29376. */
  29377. updateSamplingMode(samplingMode: number): void;
  29378. /**
  29379. * Scales the texture if is `canRescale()`
  29380. * @param ratio the resize factor we want to use to rescale
  29381. */
  29382. scale(ratio: number): void;
  29383. /**
  29384. * Get if the texture can rescale.
  29385. */
  29386. readonly canRescale: boolean;
  29387. /** @hidden */
  29388. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  29389. /** @hidden */
  29390. _rebuild(): void;
  29391. /**
  29392. * Triggers the load sequence in delayed load mode.
  29393. */
  29394. delayLoad(): void;
  29395. /**
  29396. * Clones the texture.
  29397. * @returns the cloned texture
  29398. */
  29399. clone(): Nullable<BaseTexture>;
  29400. /**
  29401. * Get the texture underlying type (INT, FLOAT...)
  29402. */
  29403. readonly textureType: number;
  29404. /**
  29405. * Get the texture underlying format (RGB, RGBA...)
  29406. */
  29407. readonly textureFormat: number;
  29408. /**
  29409. * Indicates that textures need to be re-calculated for all materials
  29410. */
  29411. protected _markAllSubMeshesAsTexturesDirty(): void;
  29412. /**
  29413. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  29414. * This will returns an RGBA array buffer containing either in values (0-255) or
  29415. * float values (0-1) depending of the underlying buffer type.
  29416. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  29417. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  29418. * @param buffer defines a user defined buffer to fill with data (can be null)
  29419. * @returns The Array buffer containing the pixels data.
  29420. */
  29421. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  29422. /**
  29423. * Release and destroy the underlying lower level texture aka internalTexture.
  29424. */
  29425. releaseInternalTexture(): void;
  29426. /** @hidden */
  29427. readonly _lodTextureHigh: Nullable<BaseTexture>;
  29428. /** @hidden */
  29429. readonly _lodTextureMid: Nullable<BaseTexture>;
  29430. /** @hidden */
  29431. readonly _lodTextureLow: Nullable<BaseTexture>;
  29432. /**
  29433. * Dispose the texture and release its associated resources.
  29434. */
  29435. dispose(): void;
  29436. /**
  29437. * Serialize the texture into a JSON representation that can be parsed later on.
  29438. * @returns the JSON representation of the texture
  29439. */
  29440. serialize(): any;
  29441. /**
  29442. * Helper function to be called back once a list of texture contains only ready textures.
  29443. * @param textures Define the list of textures to wait for
  29444. * @param callback Define the callback triggered once the entire list will be ready
  29445. */
  29446. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  29447. }
  29448. }
  29449. declare module BABYLON {
  29450. /**
  29451. * Options to be used when creating an effect.
  29452. */
  29453. export interface IEffectCreationOptions {
  29454. /**
  29455. * Atrributes that will be used in the shader.
  29456. */
  29457. attributes: string[];
  29458. /**
  29459. * Uniform varible names that will be set in the shader.
  29460. */
  29461. uniformsNames: string[];
  29462. /**
  29463. * Uniform buffer variable names that will be set in the shader.
  29464. */
  29465. uniformBuffersNames: string[];
  29466. /**
  29467. * Sampler texture variable names that will be set in the shader.
  29468. */
  29469. samplers: string[];
  29470. /**
  29471. * Define statements that will be set in the shader.
  29472. */
  29473. defines: any;
  29474. /**
  29475. * Possible fallbacks for this effect to improve performance when needed.
  29476. */
  29477. fallbacks: Nullable<IEffectFallbacks>;
  29478. /**
  29479. * Callback that will be called when the shader is compiled.
  29480. */
  29481. onCompiled: Nullable<(effect: Effect) => void>;
  29482. /**
  29483. * Callback that will be called if an error occurs during shader compilation.
  29484. */
  29485. onError: Nullable<(effect: Effect, errors: string) => void>;
  29486. /**
  29487. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29488. */
  29489. indexParameters?: any;
  29490. /**
  29491. * Max number of lights that can be used in the shader.
  29492. */
  29493. maxSimultaneousLights?: number;
  29494. /**
  29495. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29496. */
  29497. transformFeedbackVaryings?: Nullable<string[]>;
  29498. }
  29499. /**
  29500. * Effect containing vertex and fragment shader that can be executed on an object.
  29501. */
  29502. export class Effect implements IDisposable {
  29503. /**
  29504. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29505. */
  29506. static ShadersRepository: string;
  29507. /**
  29508. * Name of the effect.
  29509. */
  29510. name: any;
  29511. /**
  29512. * String container all the define statements that should be set on the shader.
  29513. */
  29514. defines: string;
  29515. /**
  29516. * Callback that will be called when the shader is compiled.
  29517. */
  29518. onCompiled: Nullable<(effect: Effect) => void>;
  29519. /**
  29520. * Callback that will be called if an error occurs during shader compilation.
  29521. */
  29522. onError: Nullable<(effect: Effect, errors: string) => void>;
  29523. /**
  29524. * Callback that will be called when effect is bound.
  29525. */
  29526. onBind: Nullable<(effect: Effect) => void>;
  29527. /**
  29528. * Unique ID of the effect.
  29529. */
  29530. uniqueId: number;
  29531. /**
  29532. * Observable that will be called when the shader is compiled.
  29533. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29534. */
  29535. onCompileObservable: Observable<Effect>;
  29536. /**
  29537. * Observable that will be called if an error occurs during shader compilation.
  29538. */
  29539. onErrorObservable: Observable<Effect>;
  29540. /** @hidden */
  29541. _onBindObservable: Nullable<Observable<Effect>>;
  29542. /**
  29543. * Observable that will be called when effect is bound.
  29544. */
  29545. readonly onBindObservable: Observable<Effect>;
  29546. /** @hidden */
  29547. _bonesComputationForcedToCPU: boolean;
  29548. private static _uniqueIdSeed;
  29549. private _engine;
  29550. private _uniformBuffersNames;
  29551. private _uniformsNames;
  29552. private _samplerList;
  29553. private _samplers;
  29554. private _isReady;
  29555. private _compilationError;
  29556. private _allFallbacksProcessed;
  29557. private _attributesNames;
  29558. private _attributes;
  29559. private _uniforms;
  29560. /**
  29561. * Key for the effect.
  29562. * @hidden
  29563. */
  29564. _key: string;
  29565. private _indexParameters;
  29566. private _fallbacks;
  29567. private _vertexSourceCode;
  29568. private _fragmentSourceCode;
  29569. private _vertexSourceCodeOverride;
  29570. private _fragmentSourceCodeOverride;
  29571. private _transformFeedbackVaryings;
  29572. /**
  29573. * Compiled shader to webGL program.
  29574. * @hidden
  29575. */
  29576. _pipelineContext: Nullable<IPipelineContext>;
  29577. private _valueCache;
  29578. private static _baseCache;
  29579. /**
  29580. * Instantiates an effect.
  29581. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29582. * @param baseName Name of the effect.
  29583. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29584. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29585. * @param samplers List of sampler variables that will be passed to the shader.
  29586. * @param engine Engine to be used to render the effect
  29587. * @param defines Define statements to be added to the shader.
  29588. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29589. * @param onCompiled Callback that will be called when the shader is compiled.
  29590. * @param onError Callback that will be called if an error occurs during shader compilation.
  29591. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29592. */
  29593. 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);
  29594. private _useFinalCode;
  29595. /**
  29596. * Unique key for this effect
  29597. */
  29598. readonly key: string;
  29599. /**
  29600. * If the effect has been compiled and prepared.
  29601. * @returns if the effect is compiled and prepared.
  29602. */
  29603. isReady(): boolean;
  29604. private _isReadyInternal;
  29605. /**
  29606. * The engine the effect was initialized with.
  29607. * @returns the engine.
  29608. */
  29609. getEngine(): Engine;
  29610. /**
  29611. * The pipeline context for this effect
  29612. * @returns the associated pipeline context
  29613. */
  29614. getPipelineContext(): Nullable<IPipelineContext>;
  29615. /**
  29616. * The set of names of attribute variables for the shader.
  29617. * @returns An array of attribute names.
  29618. */
  29619. getAttributesNames(): string[];
  29620. /**
  29621. * Returns the attribute at the given index.
  29622. * @param index The index of the attribute.
  29623. * @returns The location of the attribute.
  29624. */
  29625. getAttributeLocation(index: number): number;
  29626. /**
  29627. * Returns the attribute based on the name of the variable.
  29628. * @param name of the attribute to look up.
  29629. * @returns the attribute location.
  29630. */
  29631. getAttributeLocationByName(name: string): number;
  29632. /**
  29633. * The number of attributes.
  29634. * @returns the numnber of attributes.
  29635. */
  29636. getAttributesCount(): number;
  29637. /**
  29638. * Gets the index of a uniform variable.
  29639. * @param uniformName of the uniform to look up.
  29640. * @returns the index.
  29641. */
  29642. getUniformIndex(uniformName: string): number;
  29643. /**
  29644. * Returns the attribute based on the name of the variable.
  29645. * @param uniformName of the uniform to look up.
  29646. * @returns the location of the uniform.
  29647. */
  29648. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29649. /**
  29650. * Returns an array of sampler variable names
  29651. * @returns The array of sampler variable neames.
  29652. */
  29653. getSamplers(): string[];
  29654. /**
  29655. * The error from the last compilation.
  29656. * @returns the error string.
  29657. */
  29658. getCompilationError(): string;
  29659. /**
  29660. * Gets a boolean indicating that all fallbacks were used during compilation
  29661. * @returns true if all fallbacks were used
  29662. */
  29663. allFallbacksProcessed(): boolean;
  29664. /**
  29665. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29666. * @param func The callback to be used.
  29667. */
  29668. executeWhenCompiled(func: (effect: Effect) => void): void;
  29669. private _checkIsReady;
  29670. private _loadShader;
  29671. /**
  29672. * Recompiles the webGL program
  29673. * @param vertexSourceCode The source code for the vertex shader.
  29674. * @param fragmentSourceCode The source code for the fragment shader.
  29675. * @param onCompiled Callback called when completed.
  29676. * @param onError Callback called on error.
  29677. * @hidden
  29678. */
  29679. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29680. /**
  29681. * Prepares the effect
  29682. * @hidden
  29683. */
  29684. _prepareEffect(): void;
  29685. private _processCompilationErrors;
  29686. /**
  29687. * Checks if the effect is supported. (Must be called after compilation)
  29688. */
  29689. readonly isSupported: boolean;
  29690. /**
  29691. * Binds a texture to the engine to be used as output of the shader.
  29692. * @param channel Name of the output variable.
  29693. * @param texture Texture to bind.
  29694. * @hidden
  29695. */
  29696. _bindTexture(channel: string, texture: InternalTexture): void;
  29697. /**
  29698. * Sets a texture on the engine to be used in the shader.
  29699. * @param channel Name of the sampler variable.
  29700. * @param texture Texture to set.
  29701. */
  29702. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29703. /**
  29704. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29705. * @param channel Name of the sampler variable.
  29706. * @param texture Texture to set.
  29707. */
  29708. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29709. /**
  29710. * Sets an array of textures on the engine to be used in the shader.
  29711. * @param channel Name of the variable.
  29712. * @param textures Textures to set.
  29713. */
  29714. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29715. /**
  29716. * 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)
  29717. * @param channel Name of the sampler variable.
  29718. * @param postProcess Post process to get the input texture from.
  29719. */
  29720. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29721. /**
  29722. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29723. * 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)
  29724. * @param channel Name of the sampler variable.
  29725. * @param postProcess Post process to get the output texture from.
  29726. */
  29727. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29728. /** @hidden */
  29729. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  29730. /** @hidden */
  29731. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29732. /** @hidden */
  29733. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29734. /** @hidden */
  29735. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29736. /**
  29737. * Binds a buffer to a uniform.
  29738. * @param buffer Buffer to bind.
  29739. * @param name Name of the uniform variable to bind to.
  29740. */
  29741. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29742. /**
  29743. * Binds block to a uniform.
  29744. * @param blockName Name of the block to bind.
  29745. * @param index Index to bind.
  29746. */
  29747. bindUniformBlock(blockName: string, index: number): void;
  29748. /**
  29749. * Sets an interger value on a uniform variable.
  29750. * @param uniformName Name of the variable.
  29751. * @param value Value to be set.
  29752. * @returns this effect.
  29753. */
  29754. setInt(uniformName: string, value: number): Effect;
  29755. /**
  29756. * Sets an int array on a uniform variable.
  29757. * @param uniformName Name of the variable.
  29758. * @param array array to be set.
  29759. * @returns this effect.
  29760. */
  29761. setIntArray(uniformName: string, array: Int32Array): Effect;
  29762. /**
  29763. * 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)
  29764. * @param uniformName Name of the variable.
  29765. * @param array array to be set.
  29766. * @returns this effect.
  29767. */
  29768. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29769. /**
  29770. * 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)
  29771. * @param uniformName Name of the variable.
  29772. * @param array array to be set.
  29773. * @returns this effect.
  29774. */
  29775. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29776. /**
  29777. * 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)
  29778. * @param uniformName Name of the variable.
  29779. * @param array array to be set.
  29780. * @returns this effect.
  29781. */
  29782. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29783. /**
  29784. * Sets an float array on a uniform variable.
  29785. * @param uniformName Name of the variable.
  29786. * @param array array to be set.
  29787. * @returns this effect.
  29788. */
  29789. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29790. /**
  29791. * 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)
  29792. * @param uniformName Name of the variable.
  29793. * @param array array to be set.
  29794. * @returns this effect.
  29795. */
  29796. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29797. /**
  29798. * 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)
  29799. * @param uniformName Name of the variable.
  29800. * @param array array to be set.
  29801. * @returns this effect.
  29802. */
  29803. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29804. /**
  29805. * 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)
  29806. * @param uniformName Name of the variable.
  29807. * @param array array to be set.
  29808. * @returns this effect.
  29809. */
  29810. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29811. /**
  29812. * Sets an array on a uniform variable.
  29813. * @param uniformName Name of the variable.
  29814. * @param array array to be set.
  29815. * @returns this effect.
  29816. */
  29817. setArray(uniformName: string, array: number[]): Effect;
  29818. /**
  29819. * 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)
  29820. * @param uniformName Name of the variable.
  29821. * @param array array to be set.
  29822. * @returns this effect.
  29823. */
  29824. setArray2(uniformName: string, array: number[]): Effect;
  29825. /**
  29826. * 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)
  29827. * @param uniformName Name of the variable.
  29828. * @param array array to be set.
  29829. * @returns this effect.
  29830. */
  29831. setArray3(uniformName: string, array: number[]): Effect;
  29832. /**
  29833. * 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)
  29834. * @param uniformName Name of the variable.
  29835. * @param array array to be set.
  29836. * @returns this effect.
  29837. */
  29838. setArray4(uniformName: string, array: number[]): Effect;
  29839. /**
  29840. * Sets matrices on a uniform variable.
  29841. * @param uniformName Name of the variable.
  29842. * @param matrices matrices to be set.
  29843. * @returns this effect.
  29844. */
  29845. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29846. /**
  29847. * Sets matrix on a uniform variable.
  29848. * @param uniformName Name of the variable.
  29849. * @param matrix matrix to be set.
  29850. * @returns this effect.
  29851. */
  29852. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  29853. /**
  29854. * 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)
  29855. * @param uniformName Name of the variable.
  29856. * @param matrix matrix to be set.
  29857. * @returns this effect.
  29858. */
  29859. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29860. /**
  29861. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29862. * @param uniformName Name of the variable.
  29863. * @param matrix matrix to be set.
  29864. * @returns this effect.
  29865. */
  29866. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29867. /**
  29868. * Sets a float on a uniform variable.
  29869. * @param uniformName Name of the variable.
  29870. * @param value value to be set.
  29871. * @returns this effect.
  29872. */
  29873. setFloat(uniformName: string, value: number): Effect;
  29874. /**
  29875. * Sets a boolean on a uniform variable.
  29876. * @param uniformName Name of the variable.
  29877. * @param bool value to be set.
  29878. * @returns this effect.
  29879. */
  29880. setBool(uniformName: string, bool: boolean): Effect;
  29881. /**
  29882. * Sets a Vector2 on a uniform variable.
  29883. * @param uniformName Name of the variable.
  29884. * @param vector2 vector2 to be set.
  29885. * @returns this effect.
  29886. */
  29887. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  29888. /**
  29889. * Sets a float2 on a uniform variable.
  29890. * @param uniformName Name of the variable.
  29891. * @param x First float in float2.
  29892. * @param y Second float in float2.
  29893. * @returns this effect.
  29894. */
  29895. setFloat2(uniformName: string, x: number, y: number): Effect;
  29896. /**
  29897. * Sets a Vector3 on a uniform variable.
  29898. * @param uniformName Name of the variable.
  29899. * @param vector3 Value to be set.
  29900. * @returns this effect.
  29901. */
  29902. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  29903. /**
  29904. * Sets a float3 on a uniform variable.
  29905. * @param uniformName Name of the variable.
  29906. * @param x First float in float3.
  29907. * @param y Second float in float3.
  29908. * @param z Third float in float3.
  29909. * @returns this effect.
  29910. */
  29911. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29912. /**
  29913. * Sets a Vector4 on a uniform variable.
  29914. * @param uniformName Name of the variable.
  29915. * @param vector4 Value to be set.
  29916. * @returns this effect.
  29917. */
  29918. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  29919. /**
  29920. * Sets a float4 on a uniform variable.
  29921. * @param uniformName Name of the variable.
  29922. * @param x First float in float4.
  29923. * @param y Second float in float4.
  29924. * @param z Third float in float4.
  29925. * @param w Fourth float in float4.
  29926. * @returns this effect.
  29927. */
  29928. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29929. /**
  29930. * Sets a Color3 on a uniform variable.
  29931. * @param uniformName Name of the variable.
  29932. * @param color3 Value to be set.
  29933. * @returns this effect.
  29934. */
  29935. setColor3(uniformName: string, color3: IColor3Like): Effect;
  29936. /**
  29937. * Sets a Color4 on a uniform variable.
  29938. * @param uniformName Name of the variable.
  29939. * @param color3 Value to be set.
  29940. * @param alpha Alpha value to be set.
  29941. * @returns this effect.
  29942. */
  29943. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  29944. /**
  29945. * Sets a Color4 on a uniform variable
  29946. * @param uniformName defines the name of the variable
  29947. * @param color4 defines the value to be set
  29948. * @returns this effect.
  29949. */
  29950. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  29951. /** Release all associated resources */
  29952. dispose(): void;
  29953. /**
  29954. * This function will add a new shader to the shader store
  29955. * @param name the name of the shader
  29956. * @param pixelShader optional pixel shader content
  29957. * @param vertexShader optional vertex shader content
  29958. */
  29959. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29960. /**
  29961. * Store of each shader (The can be looked up using effect.key)
  29962. */
  29963. static ShadersStore: {
  29964. [key: string]: string;
  29965. };
  29966. /**
  29967. * Store of each included file for a shader (The can be looked up using effect.key)
  29968. */
  29969. static IncludesShadersStore: {
  29970. [key: string]: string;
  29971. };
  29972. /**
  29973. * Resets the cache of effects.
  29974. */
  29975. static ResetCache(): void;
  29976. }
  29977. }
  29978. declare module BABYLON {
  29979. /**
  29980. * Interface used to describe the capabilities of the engine relatively to the current browser
  29981. */
  29982. export interface EngineCapabilities {
  29983. /** Maximum textures units per fragment shader */
  29984. maxTexturesImageUnits: number;
  29985. /** Maximum texture units per vertex shader */
  29986. maxVertexTextureImageUnits: number;
  29987. /** Maximum textures units in the entire pipeline */
  29988. maxCombinedTexturesImageUnits: number;
  29989. /** Maximum texture size */
  29990. maxTextureSize: number;
  29991. /** Maximum texture samples */
  29992. maxSamples?: number;
  29993. /** Maximum cube texture size */
  29994. maxCubemapTextureSize: number;
  29995. /** Maximum render texture size */
  29996. maxRenderTextureSize: number;
  29997. /** Maximum number of vertex attributes */
  29998. maxVertexAttribs: number;
  29999. /** Maximum number of varyings */
  30000. maxVaryingVectors: number;
  30001. /** Maximum number of uniforms per vertex shader */
  30002. maxVertexUniformVectors: number;
  30003. /** Maximum number of uniforms per fragment shader */
  30004. maxFragmentUniformVectors: number;
  30005. /** Defines if standard derivates (dx/dy) are supported */
  30006. standardDerivatives: boolean;
  30007. /** Defines if s3tc texture compression is supported */
  30008. s3tc?: WEBGL_compressed_texture_s3tc;
  30009. /** Defines if pvrtc texture compression is supported */
  30010. pvrtc: any;
  30011. /** Defines if etc1 texture compression is supported */
  30012. etc1: any;
  30013. /** Defines if etc2 texture compression is supported */
  30014. etc2: any;
  30015. /** Defines if astc texture compression is supported */
  30016. astc: any;
  30017. /** Defines if float textures are supported */
  30018. textureFloat: boolean;
  30019. /** Defines if vertex array objects are supported */
  30020. vertexArrayObject: boolean;
  30021. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  30022. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  30023. /** Gets the maximum level of anisotropy supported */
  30024. maxAnisotropy: number;
  30025. /** Defines if instancing is supported */
  30026. instancedArrays: boolean;
  30027. /** Defines if 32 bits indices are supported */
  30028. uintIndices: boolean;
  30029. /** Defines if high precision shaders are supported */
  30030. highPrecisionShaderSupported: boolean;
  30031. /** Defines if depth reading in the fragment shader is supported */
  30032. fragmentDepthSupported: boolean;
  30033. /** Defines if float texture linear filtering is supported*/
  30034. textureFloatLinearFiltering: boolean;
  30035. /** Defines if rendering to float textures is supported */
  30036. textureFloatRender: boolean;
  30037. /** Defines if half float textures are supported*/
  30038. textureHalfFloat: boolean;
  30039. /** Defines if half float texture linear filtering is supported*/
  30040. textureHalfFloatLinearFiltering: boolean;
  30041. /** Defines if rendering to half float textures is supported */
  30042. textureHalfFloatRender: boolean;
  30043. /** Defines if textureLOD shader command is supported */
  30044. textureLOD: boolean;
  30045. /** Defines if draw buffers extension is supported */
  30046. drawBuffersExtension: boolean;
  30047. /** Defines if depth textures are supported */
  30048. depthTextureExtension: boolean;
  30049. /** Defines if float color buffer are supported */
  30050. colorBufferFloat: boolean;
  30051. /** Gets disjoint timer query extension (null if not supported) */
  30052. timerQuery?: EXT_disjoint_timer_query;
  30053. /** Defines if timestamp can be used with timer query */
  30054. canUseTimestampForTimerQuery: boolean;
  30055. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  30056. multiview?: any;
  30057. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  30058. oculusMultiview?: any;
  30059. /** Function used to let the system compiles shaders in background */
  30060. parallelShaderCompile?: {
  30061. COMPLETION_STATUS_KHR: number;
  30062. };
  30063. /** Max number of texture samples for MSAA */
  30064. maxMSAASamples: number;
  30065. /** Defines if the blend min max extension is supported */
  30066. blendMinMax: boolean;
  30067. }
  30068. }
  30069. declare module BABYLON {
  30070. /**
  30071. * @hidden
  30072. **/
  30073. export class DepthCullingState {
  30074. private _isDepthTestDirty;
  30075. private _isDepthMaskDirty;
  30076. private _isDepthFuncDirty;
  30077. private _isCullFaceDirty;
  30078. private _isCullDirty;
  30079. private _isZOffsetDirty;
  30080. private _isFrontFaceDirty;
  30081. private _depthTest;
  30082. private _depthMask;
  30083. private _depthFunc;
  30084. private _cull;
  30085. private _cullFace;
  30086. private _zOffset;
  30087. private _frontFace;
  30088. /**
  30089. * Initializes the state.
  30090. */
  30091. constructor();
  30092. readonly isDirty: boolean;
  30093. zOffset: number;
  30094. cullFace: Nullable<number>;
  30095. cull: Nullable<boolean>;
  30096. depthFunc: Nullable<number>;
  30097. depthMask: boolean;
  30098. depthTest: boolean;
  30099. frontFace: Nullable<number>;
  30100. reset(): void;
  30101. apply(gl: WebGLRenderingContext): void;
  30102. }
  30103. }
  30104. declare module BABYLON {
  30105. /**
  30106. * @hidden
  30107. **/
  30108. export class StencilState {
  30109. /** 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 */
  30110. static readonly ALWAYS: number;
  30111. /** Passed to stencilOperation to specify that stencil value must be kept */
  30112. static readonly KEEP: number;
  30113. /** Passed to stencilOperation to specify that stencil value must be replaced */
  30114. static readonly REPLACE: number;
  30115. private _isStencilTestDirty;
  30116. private _isStencilMaskDirty;
  30117. private _isStencilFuncDirty;
  30118. private _isStencilOpDirty;
  30119. private _stencilTest;
  30120. private _stencilMask;
  30121. private _stencilFunc;
  30122. private _stencilFuncRef;
  30123. private _stencilFuncMask;
  30124. private _stencilOpStencilFail;
  30125. private _stencilOpDepthFail;
  30126. private _stencilOpStencilDepthPass;
  30127. readonly isDirty: boolean;
  30128. stencilFunc: number;
  30129. stencilFuncRef: number;
  30130. stencilFuncMask: number;
  30131. stencilOpStencilFail: number;
  30132. stencilOpDepthFail: number;
  30133. stencilOpStencilDepthPass: number;
  30134. stencilMask: number;
  30135. stencilTest: boolean;
  30136. constructor();
  30137. reset(): void;
  30138. apply(gl: WebGLRenderingContext): void;
  30139. }
  30140. }
  30141. declare module BABYLON {
  30142. /**
  30143. * @hidden
  30144. **/
  30145. export class AlphaState {
  30146. private _isAlphaBlendDirty;
  30147. private _isBlendFunctionParametersDirty;
  30148. private _isBlendEquationParametersDirty;
  30149. private _isBlendConstantsDirty;
  30150. private _alphaBlend;
  30151. private _blendFunctionParameters;
  30152. private _blendEquationParameters;
  30153. private _blendConstants;
  30154. /**
  30155. * Initializes the state.
  30156. */
  30157. constructor();
  30158. readonly isDirty: boolean;
  30159. alphaBlend: boolean;
  30160. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  30161. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  30162. setAlphaEquationParameters(rgb: number, alpha: number): void;
  30163. reset(): void;
  30164. apply(gl: WebGLRenderingContext): void;
  30165. }
  30166. }
  30167. declare module BABYLON {
  30168. /** @hidden */
  30169. export class WebGL2ShaderProcessor implements IShaderProcessor {
  30170. attributeProcessor(attribute: string): string;
  30171. varyingProcessor(varying: string, isFragment: boolean): string;
  30172. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  30173. }
  30174. }
  30175. declare module BABYLON {
  30176. /**
  30177. * Interface for attribute information associated with buffer instanciation
  30178. */
  30179. export interface InstancingAttributeInfo {
  30180. /**
  30181. * Index/offset of the attribute in the vertex shader
  30182. */
  30183. index: number;
  30184. /**
  30185. * size of the attribute, 1, 2, 3 or 4
  30186. */
  30187. attributeSize: number;
  30188. /**
  30189. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  30190. * default is FLOAT
  30191. */
  30192. attributeType: number;
  30193. /**
  30194. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  30195. */
  30196. normalized: boolean;
  30197. /**
  30198. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  30199. */
  30200. offset: number;
  30201. /**
  30202. * Name of the GLSL attribute, for debugging purpose only
  30203. */
  30204. attributeName: string;
  30205. }
  30206. }
  30207. declare module BABYLON {
  30208. interface ThinEngine {
  30209. /**
  30210. * Update a video texture
  30211. * @param texture defines the texture to update
  30212. * @param video defines the video element to use
  30213. * @param invertY defines if data must be stored with Y axis inverted
  30214. */
  30215. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  30216. }
  30217. }
  30218. declare module BABYLON {
  30219. /**
  30220. * Settings for finer control over video usage
  30221. */
  30222. export interface VideoTextureSettings {
  30223. /**
  30224. * Applies `autoplay` to video, if specified
  30225. */
  30226. autoPlay?: boolean;
  30227. /**
  30228. * Applies `loop` to video, if specified
  30229. */
  30230. loop?: boolean;
  30231. /**
  30232. * Automatically updates internal texture from video at every frame in the render loop
  30233. */
  30234. autoUpdateTexture: boolean;
  30235. /**
  30236. * Image src displayed during the video loading or until the user interacts with the video.
  30237. */
  30238. poster?: string;
  30239. }
  30240. /**
  30241. * If you want to display a video in your scene, this is the special texture for that.
  30242. * This special texture works similar to other textures, with the exception of a few parameters.
  30243. * @see https://doc.babylonjs.com/how_to/video_texture
  30244. */
  30245. export class VideoTexture extends Texture {
  30246. /**
  30247. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  30248. */
  30249. readonly autoUpdateTexture: boolean;
  30250. /**
  30251. * The video instance used by the texture internally
  30252. */
  30253. readonly video: HTMLVideoElement;
  30254. private _onUserActionRequestedObservable;
  30255. /**
  30256. * Event triggerd when a dom action is required by the user to play the video.
  30257. * This happens due to recent changes in browser policies preventing video to auto start.
  30258. */
  30259. readonly onUserActionRequestedObservable: Observable<Texture>;
  30260. private _generateMipMaps;
  30261. private _engine;
  30262. private _stillImageCaptured;
  30263. private _displayingPosterTexture;
  30264. private _settings;
  30265. private _createInternalTextureOnEvent;
  30266. private _frameId;
  30267. /**
  30268. * Creates a video texture.
  30269. * If you want to display a video in your scene, this is the special texture for that.
  30270. * This special texture works similar to other textures, with the exception of a few parameters.
  30271. * @see https://doc.babylonjs.com/how_to/video_texture
  30272. * @param name optional name, will detect from video source, if not defined
  30273. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  30274. * @param scene is obviously the current scene.
  30275. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  30276. * @param invertY is false by default but can be used to invert video on Y axis
  30277. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  30278. * @param settings allows finer control over video usage
  30279. */
  30280. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  30281. private _getName;
  30282. private _getVideo;
  30283. private _createInternalTexture;
  30284. private reset;
  30285. /**
  30286. * @hidden Internal method to initiate `update`.
  30287. */
  30288. _rebuild(): void;
  30289. /**
  30290. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  30291. */
  30292. update(): void;
  30293. /**
  30294. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  30295. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  30296. */
  30297. updateTexture(isVisible: boolean): void;
  30298. protected _updateInternalTexture: () => void;
  30299. /**
  30300. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  30301. * @param url New url.
  30302. */
  30303. updateURL(url: string): void;
  30304. /**
  30305. * Dispose the texture and release its associated resources.
  30306. */
  30307. dispose(): void;
  30308. /**
  30309. * Creates a video texture straight from a stream.
  30310. * @param scene Define the scene the texture should be created in
  30311. * @param stream Define the stream the texture should be created from
  30312. * @returns The created video texture as a promise
  30313. */
  30314. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  30315. /**
  30316. * Creates a video texture straight from your WebCam video feed.
  30317. * @param scene Define the scene the texture should be created in
  30318. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30319. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30320. * @returns The created video texture as a promise
  30321. */
  30322. static CreateFromWebCamAsync(scene: Scene, constraints: {
  30323. minWidth: number;
  30324. maxWidth: number;
  30325. minHeight: number;
  30326. maxHeight: number;
  30327. deviceId: string;
  30328. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  30329. /**
  30330. * Creates a video texture straight from your WebCam video feed.
  30331. * @param scene Define the scene the texture should be created in
  30332. * @param onReady Define a callback to triggered once the texture will be ready
  30333. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30334. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30335. */
  30336. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  30337. minWidth: number;
  30338. maxWidth: number;
  30339. minHeight: number;
  30340. maxHeight: number;
  30341. deviceId: string;
  30342. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  30343. }
  30344. }
  30345. declare module BABYLON {
  30346. /**
  30347. * Defines the interface used by objects working like Scene
  30348. * @hidden
  30349. */
  30350. interface ISceneLike {
  30351. _addPendingData(data: any): void;
  30352. _removePendingData(data: any): void;
  30353. offlineProvider: IOfflineProvider;
  30354. }
  30355. /** Interface defining initialization parameters for Engine class */
  30356. export interface EngineOptions extends WebGLContextAttributes {
  30357. /**
  30358. * Defines if the engine should no exceed a specified device ratio
  30359. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  30360. */
  30361. limitDeviceRatio?: number;
  30362. /**
  30363. * Defines if webvr should be enabled automatically
  30364. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30365. */
  30366. autoEnableWebVR?: boolean;
  30367. /**
  30368. * Defines if webgl2 should be turned off even if supported
  30369. * @see http://doc.babylonjs.com/features/webgl2
  30370. */
  30371. disableWebGL2Support?: boolean;
  30372. /**
  30373. * Defines if webaudio should be initialized as well
  30374. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30375. */
  30376. audioEngine?: boolean;
  30377. /**
  30378. * Defines if animations should run using a deterministic lock step
  30379. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30380. */
  30381. deterministicLockstep?: boolean;
  30382. /** Defines the maximum steps to use with deterministic lock step mode */
  30383. lockstepMaxSteps?: number;
  30384. /** Defines the seconds between each deterministic lock step */
  30385. timeStep?: number;
  30386. /**
  30387. * Defines that engine should ignore context lost events
  30388. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  30389. */
  30390. doNotHandleContextLost?: boolean;
  30391. /**
  30392. * Defines that engine should ignore modifying touch action attribute and style
  30393. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  30394. */
  30395. doNotHandleTouchAction?: boolean;
  30396. /**
  30397. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  30398. */
  30399. useHighPrecisionFloats?: boolean;
  30400. }
  30401. /**
  30402. * The base engine class (root of all engines)
  30403. */
  30404. export class ThinEngine {
  30405. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  30406. static ExceptionList: ({
  30407. key: string;
  30408. capture: string;
  30409. captureConstraint: number;
  30410. targets: string[];
  30411. } | {
  30412. key: string;
  30413. capture: null;
  30414. captureConstraint: null;
  30415. targets: string[];
  30416. })[];
  30417. /** @hidden */
  30418. static _TextureLoaders: IInternalTextureLoader[];
  30419. /**
  30420. * Returns the current npm package of the sdk
  30421. */
  30422. static readonly NpmPackage: string;
  30423. /**
  30424. * Returns the current version of the framework
  30425. */
  30426. static readonly Version: string;
  30427. /**
  30428. * Returns a string describing the current engine
  30429. */
  30430. readonly description: string;
  30431. /**
  30432. * Gets or sets the epsilon value used by collision engine
  30433. */
  30434. static CollisionsEpsilon: number;
  30435. /**
  30436. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30437. */
  30438. static ShadersRepository: string;
  30439. /**
  30440. * Gets or sets the textures that the engine should not attempt to load as compressed
  30441. */
  30442. protected _excludedCompressedTextures: string[];
  30443. /**
  30444. * Filters the compressed texture formats to only include
  30445. * files that are not included in the skippable list
  30446. *
  30447. * @param url the current extension
  30448. * @param textureFormatInUse the current compressed texture format
  30449. * @returns "format" string
  30450. */
  30451. excludedCompressedTextureFormats(url: Nullable<string>, textureFormatInUse: Nullable<string>): Nullable<string>;
  30452. /** @hidden */
  30453. _shaderProcessor: IShaderProcessor;
  30454. /**
  30455. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30456. */
  30457. forcePOTTextures: boolean;
  30458. /**
  30459. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30460. */
  30461. isFullscreen: boolean;
  30462. /**
  30463. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  30464. */
  30465. cullBackFaces: boolean;
  30466. /**
  30467. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  30468. */
  30469. renderEvenInBackground: boolean;
  30470. /**
  30471. * Gets or sets a boolean indicating that cache can be kept between frames
  30472. */
  30473. preventCacheWipeBetweenFrames: boolean;
  30474. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  30475. validateShaderPrograms: boolean;
  30476. /**
  30477. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  30478. * This can provide greater z depth for distant objects.
  30479. */
  30480. useReverseDepthBuffer: boolean;
  30481. /**
  30482. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  30483. */
  30484. disableUniformBuffers: boolean;
  30485. /** @hidden */
  30486. _uniformBuffers: UniformBuffer[];
  30487. /**
  30488. * Gets a boolean indicating that the engine supports uniform buffers
  30489. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30490. */
  30491. readonly supportsUniformBuffers: boolean;
  30492. /** @hidden */
  30493. _gl: WebGLRenderingContext;
  30494. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  30495. protected _windowIsBackground: boolean;
  30496. protected _webGLVersion: number;
  30497. protected _creationOptions: EngineOptions;
  30498. protected _highPrecisionShadersAllowed: boolean;
  30499. /** @hidden */
  30500. readonly _shouldUseHighPrecisionShader: boolean;
  30501. /**
  30502. * Gets a boolean indicating that only power of 2 textures are supported
  30503. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  30504. */
  30505. readonly needPOTTextures: boolean;
  30506. /** @hidden */
  30507. _badOS: boolean;
  30508. /** @hidden */
  30509. _badDesktopOS: boolean;
  30510. private _hardwareScalingLevel;
  30511. /** @hidden */
  30512. _caps: EngineCapabilities;
  30513. private _isStencilEnable;
  30514. protected _colorWrite: boolean;
  30515. private _glVersion;
  30516. private _glRenderer;
  30517. private _glVendor;
  30518. /** @hidden */
  30519. _videoTextureSupported: boolean;
  30520. protected _renderingQueueLaunched: boolean;
  30521. protected _activeRenderLoops: (() => void)[];
  30522. /**
  30523. * Observable signaled when a context lost event is raised
  30524. */
  30525. onContextLostObservable: Observable<ThinEngine>;
  30526. /**
  30527. * Observable signaled when a context restored event is raised
  30528. */
  30529. onContextRestoredObservable: Observable<ThinEngine>;
  30530. private _onContextLost;
  30531. private _onContextRestored;
  30532. protected _contextWasLost: boolean;
  30533. /** @hidden */
  30534. _doNotHandleContextLost: boolean;
  30535. /**
  30536. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  30537. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  30538. */
  30539. doNotHandleContextLost: boolean;
  30540. /**
  30541. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  30542. */
  30543. disableVertexArrayObjects: boolean;
  30544. /** @hidden */
  30545. protected _depthCullingState: DepthCullingState;
  30546. /** @hidden */
  30547. protected _stencilState: StencilState;
  30548. /** @hidden */
  30549. protected _alphaState: AlphaState;
  30550. /** @hidden */
  30551. _internalTexturesCache: InternalTexture[];
  30552. /** @hidden */
  30553. protected _activeChannel: number;
  30554. private _currentTextureChannel;
  30555. /** @hidden */
  30556. protected _boundTexturesCache: {
  30557. [key: string]: Nullable<InternalTexture>;
  30558. };
  30559. /** @hidden */
  30560. protected _currentEffect: Nullable<Effect>;
  30561. /** @hidden */
  30562. protected _currentProgram: Nullable<WebGLProgram>;
  30563. private _compiledEffects;
  30564. private _vertexAttribArraysEnabled;
  30565. /** @hidden */
  30566. protected _cachedViewport: Nullable<IViewportLike>;
  30567. private _cachedVertexArrayObject;
  30568. /** @hidden */
  30569. protected _cachedVertexBuffers: any;
  30570. /** @hidden */
  30571. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  30572. /** @hidden */
  30573. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  30574. /** @hidden */
  30575. _currentRenderTarget: Nullable<InternalTexture>;
  30576. private _uintIndicesCurrentlySet;
  30577. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  30578. /** @hidden */
  30579. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  30580. private _currentBufferPointers;
  30581. private _currentInstanceLocations;
  30582. private _currentInstanceBuffers;
  30583. private _textureUnits;
  30584. /** @hidden */
  30585. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  30586. /** @hidden */
  30587. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  30588. /** @hidden */
  30589. _boundRenderFunction: any;
  30590. private _vaoRecordInProgress;
  30591. private _mustWipeVertexAttributes;
  30592. private _emptyTexture;
  30593. private _emptyCubeTexture;
  30594. private _emptyTexture3D;
  30595. private _emptyTexture2DArray;
  30596. /** @hidden */
  30597. _frameHandler: number;
  30598. private _nextFreeTextureSlots;
  30599. private _maxSimultaneousTextures;
  30600. private _activeRequests;
  30601. protected _texturesSupported: string[];
  30602. /** @hidden */
  30603. _textureFormatInUse: Nullable<string>;
  30604. protected readonly _supportsHardwareTextureRescaling: boolean;
  30605. /**
  30606. * Gets the list of texture formats supported
  30607. */
  30608. readonly texturesSupported: Array<string>;
  30609. /**
  30610. * Gets the list of texture formats in use
  30611. */
  30612. readonly textureFormatInUse: Nullable<string>;
  30613. /**
  30614. * Gets the current viewport
  30615. */
  30616. readonly currentViewport: Nullable<IViewportLike>;
  30617. /**
  30618. * Gets the default empty texture
  30619. */
  30620. readonly emptyTexture: InternalTexture;
  30621. /**
  30622. * Gets the default empty 3D texture
  30623. */
  30624. readonly emptyTexture3D: InternalTexture;
  30625. /**
  30626. * Gets the default empty 2D array texture
  30627. */
  30628. readonly emptyTexture2DArray: InternalTexture;
  30629. /**
  30630. * Gets the default empty cube texture
  30631. */
  30632. readonly emptyCubeTexture: InternalTexture;
  30633. /**
  30634. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  30635. */
  30636. readonly premultipliedAlpha: boolean;
  30637. /**
  30638. * Observable event triggered before each texture is initialized
  30639. */
  30640. onBeforeTextureInitObservable: Observable<Texture>;
  30641. /**
  30642. * Creates a new engine
  30643. * @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
  30644. * @param antialias defines enable antialiasing (default: false)
  30645. * @param options defines further options to be sent to the getContext() function
  30646. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  30647. */
  30648. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  30649. private _rebuildInternalTextures;
  30650. private _rebuildEffects;
  30651. /**
  30652. * Gets a boolean indicating if all created effects are ready
  30653. * @returns true if all effects are ready
  30654. */
  30655. areAllEffectsReady(): boolean;
  30656. protected _rebuildBuffers(): void;
  30657. private _initGLContext;
  30658. /**
  30659. * Gets version of the current webGL context
  30660. */
  30661. readonly webGLVersion: number;
  30662. /**
  30663. * Gets a string idenfifying the name of the class
  30664. * @returns "Engine" string
  30665. */
  30666. getClassName(): string;
  30667. /**
  30668. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  30669. */
  30670. readonly isStencilEnable: boolean;
  30671. /** @hidden */
  30672. _prepareWorkingCanvas(): void;
  30673. /**
  30674. * Reset the texture cache to empty state
  30675. */
  30676. resetTextureCache(): void;
  30677. /**
  30678. * Gets an object containing information about the current webGL context
  30679. * @returns an object containing the vender, the renderer and the version of the current webGL context
  30680. */
  30681. getGlInfo(): {
  30682. vendor: string;
  30683. renderer: string;
  30684. version: string;
  30685. };
  30686. /**
  30687. * Defines the hardware scaling level.
  30688. * By default the hardware scaling level is computed from the window device ratio.
  30689. * 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.
  30690. * @param level defines the level to use
  30691. */
  30692. setHardwareScalingLevel(level: number): void;
  30693. /**
  30694. * Gets the current hardware scaling level.
  30695. * By default the hardware scaling level is computed from the window device ratio.
  30696. * 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.
  30697. * @returns a number indicating the current hardware scaling level
  30698. */
  30699. getHardwareScalingLevel(): number;
  30700. /**
  30701. * Gets the list of loaded textures
  30702. * @returns an array containing all loaded textures
  30703. */
  30704. getLoadedTexturesCache(): InternalTexture[];
  30705. /**
  30706. * Gets the object containing all engine capabilities
  30707. * @returns the EngineCapabilities object
  30708. */
  30709. getCaps(): EngineCapabilities;
  30710. /**
  30711. * stop executing a render loop function and remove it from the execution array
  30712. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  30713. */
  30714. stopRenderLoop(renderFunction?: () => void): void;
  30715. /** @hidden */
  30716. _renderLoop(): void;
  30717. /**
  30718. * Gets the HTML canvas attached with the current webGL context
  30719. * @returns a HTML canvas
  30720. */
  30721. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  30722. /**
  30723. * Gets host window
  30724. * @returns the host window object
  30725. */
  30726. getHostWindow(): Nullable<Window>;
  30727. /**
  30728. * Gets the current render width
  30729. * @param useScreen defines if screen size must be used (or the current render target if any)
  30730. * @returns a number defining the current render width
  30731. */
  30732. getRenderWidth(useScreen?: boolean): number;
  30733. /**
  30734. * Gets the current render height
  30735. * @param useScreen defines if screen size must be used (or the current render target if any)
  30736. * @returns a number defining the current render height
  30737. */
  30738. getRenderHeight(useScreen?: boolean): number;
  30739. /**
  30740. * Can be used to override the current requestAnimationFrame requester.
  30741. * @hidden
  30742. */
  30743. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  30744. /**
  30745. * Register and execute a render loop. The engine can have more than one render function
  30746. * @param renderFunction defines the function to continuously execute
  30747. */
  30748. runRenderLoop(renderFunction: () => void): void;
  30749. /**
  30750. * Clear the current render buffer or the current render target (if any is set up)
  30751. * @param color defines the color to use
  30752. * @param backBuffer defines if the back buffer must be cleared
  30753. * @param depth defines if the depth buffer must be cleared
  30754. * @param stencil defines if the stencil buffer must be cleared
  30755. */
  30756. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  30757. private _viewportCached;
  30758. /** @hidden */
  30759. _viewport(x: number, y: number, width: number, height: number): void;
  30760. /**
  30761. * Set the WebGL's viewport
  30762. * @param viewport defines the viewport element to be used
  30763. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  30764. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  30765. */
  30766. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  30767. /**
  30768. * Begin a new frame
  30769. */
  30770. beginFrame(): void;
  30771. /**
  30772. * Enf the current frame
  30773. */
  30774. endFrame(): void;
  30775. /**
  30776. * Resize the view according to the canvas' size
  30777. */
  30778. resize(): void;
  30779. /**
  30780. * Force a specific size of the canvas
  30781. * @param width defines the new canvas' width
  30782. * @param height defines the new canvas' height
  30783. */
  30784. setSize(width: number, height: number): void;
  30785. /**
  30786. * Binds the frame buffer to the specified texture.
  30787. * @param texture The texture to render to or null for the default canvas
  30788. * @param faceIndex The face of the texture to render to in case of cube texture
  30789. * @param requiredWidth The width of the target to render to
  30790. * @param requiredHeight The height of the target to render to
  30791. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  30792. * @param depthStencilTexture The depth stencil texture to use to render
  30793. * @param lodLevel defines le lod level to bind to the frame buffer
  30794. */
  30795. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  30796. /** @hidden */
  30797. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  30798. /**
  30799. * Unbind the current render target texture from the webGL context
  30800. * @param texture defines the render target texture to unbind
  30801. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  30802. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  30803. */
  30804. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  30805. /**
  30806. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  30807. */
  30808. flushFramebuffer(): void;
  30809. /**
  30810. * Unbind the current render target and bind the default framebuffer
  30811. */
  30812. restoreDefaultFramebuffer(): void;
  30813. /** @hidden */
  30814. protected _resetVertexBufferBinding(): void;
  30815. /**
  30816. * Creates a vertex buffer
  30817. * @param data the data for the vertex buffer
  30818. * @returns the new WebGL static buffer
  30819. */
  30820. createVertexBuffer(data: DataArray): DataBuffer;
  30821. private _createVertexBuffer;
  30822. /**
  30823. * Creates a dynamic vertex buffer
  30824. * @param data the data for the dynamic vertex buffer
  30825. * @returns the new WebGL dynamic buffer
  30826. */
  30827. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  30828. protected _resetIndexBufferBinding(): void;
  30829. /**
  30830. * Creates a new index buffer
  30831. * @param indices defines the content of the index buffer
  30832. * @param updatable defines if the index buffer must be updatable
  30833. * @returns a new webGL buffer
  30834. */
  30835. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  30836. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  30837. /**
  30838. * Bind a webGL buffer to the webGL context
  30839. * @param buffer defines the buffer to bind
  30840. */
  30841. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  30842. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  30843. private bindBuffer;
  30844. /**
  30845. * update the bound buffer with the given data
  30846. * @param data defines the data to update
  30847. */
  30848. updateArrayBuffer(data: Float32Array): void;
  30849. private _vertexAttribPointer;
  30850. private _bindIndexBufferWithCache;
  30851. private _bindVertexBuffersAttributes;
  30852. /**
  30853. * Records a vertex array object
  30854. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30855. * @param vertexBuffers defines the list of vertex buffers to store
  30856. * @param indexBuffer defines the index buffer to store
  30857. * @param effect defines the effect to store
  30858. * @returns the new vertex array object
  30859. */
  30860. recordVertexArrayObject(vertexBuffers: {
  30861. [key: string]: VertexBuffer;
  30862. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  30863. /**
  30864. * Bind a specific vertex array object
  30865. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30866. * @param vertexArrayObject defines the vertex array object to bind
  30867. * @param indexBuffer defines the index buffer to bind
  30868. */
  30869. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  30870. /**
  30871. * Bind webGl buffers directly to the webGL context
  30872. * @param vertexBuffer defines the vertex buffer to bind
  30873. * @param indexBuffer defines the index buffer to bind
  30874. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  30875. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  30876. * @param effect defines the effect associated with the vertex buffer
  30877. */
  30878. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  30879. private _unbindVertexArrayObject;
  30880. /**
  30881. * Bind a list of vertex buffers to the webGL context
  30882. * @param vertexBuffers defines the list of vertex buffers to bind
  30883. * @param indexBuffer defines the index buffer to bind
  30884. * @param effect defines the effect associated with the vertex buffers
  30885. */
  30886. bindBuffers(vertexBuffers: {
  30887. [key: string]: Nullable<VertexBuffer>;
  30888. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  30889. /**
  30890. * Unbind all instance attributes
  30891. */
  30892. unbindInstanceAttributes(): void;
  30893. /**
  30894. * Release and free the memory of a vertex array object
  30895. * @param vao defines the vertex array object to delete
  30896. */
  30897. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  30898. /** @hidden */
  30899. _releaseBuffer(buffer: DataBuffer): boolean;
  30900. protected _deleteBuffer(buffer: DataBuffer): void;
  30901. /**
  30902. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  30903. * @param instancesBuffer defines the webGL buffer to update and bind
  30904. * @param data defines the data to store in the buffer
  30905. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  30906. */
  30907. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  30908. /**
  30909. * Apply all cached states (depth, culling, stencil and alpha)
  30910. */
  30911. applyStates(): void;
  30912. /**
  30913. * Send a draw order
  30914. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30915. * @param indexStart defines the starting index
  30916. * @param indexCount defines the number of index to draw
  30917. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30918. */
  30919. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  30920. /**
  30921. * Draw a list of points
  30922. * @param verticesStart defines the index of first vertex to draw
  30923. * @param verticesCount defines the count of vertices to draw
  30924. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30925. */
  30926. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30927. /**
  30928. * Draw a list of unindexed primitives
  30929. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30930. * @param verticesStart defines the index of first vertex to draw
  30931. * @param verticesCount defines the count of vertices to draw
  30932. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30933. */
  30934. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30935. /**
  30936. * Draw a list of indexed primitives
  30937. * @param fillMode defines the primitive to use
  30938. * @param indexStart defines the starting index
  30939. * @param indexCount defines the number of index to draw
  30940. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30941. */
  30942. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  30943. /**
  30944. * Draw a list of unindexed primitives
  30945. * @param fillMode defines the primitive to use
  30946. * @param verticesStart defines the index of first vertex to draw
  30947. * @param verticesCount defines the count of vertices to draw
  30948. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30949. */
  30950. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30951. private _drawMode;
  30952. /** @hidden */
  30953. protected _reportDrawCall(): void;
  30954. /** @hidden */
  30955. _releaseEffect(effect: Effect): void;
  30956. /** @hidden */
  30957. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  30958. /**
  30959. * Create a new effect (used to store vertex/fragment shaders)
  30960. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  30961. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  30962. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  30963. * @param samplers defines an array of string used to represent textures
  30964. * @param defines defines the string containing the defines to use to compile the shaders
  30965. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  30966. * @param onCompiled defines a function to call when the effect creation is successful
  30967. * @param onError defines a function to call when the effect creation has failed
  30968. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  30969. * @returns the new Effect
  30970. */
  30971. 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;
  30972. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  30973. private _compileShader;
  30974. private _compileRawShader;
  30975. /**
  30976. * Directly creates a webGL program
  30977. * @param pipelineContext defines the pipeline context to attach to
  30978. * @param vertexCode defines the vertex shader code to use
  30979. * @param fragmentCode defines the fragment shader code to use
  30980. * @param context defines the webGL context to use (if not set, the current one will be used)
  30981. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30982. * @returns the new webGL program
  30983. */
  30984. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30985. /**
  30986. * Creates a webGL program
  30987. * @param pipelineContext defines the pipeline context to attach to
  30988. * @param vertexCode defines the vertex shader code to use
  30989. * @param fragmentCode defines the fragment shader code to use
  30990. * @param defines defines the string containing the defines to use to compile the shaders
  30991. * @param context defines the webGL context to use (if not set, the current one will be used)
  30992. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30993. * @returns the new webGL program
  30994. */
  30995. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30996. /**
  30997. * Creates a new pipeline context
  30998. * @returns the new pipeline
  30999. */
  31000. createPipelineContext(): IPipelineContext;
  31001. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31002. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  31003. /** @hidden */
  31004. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  31005. /** @hidden */
  31006. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  31007. /** @hidden */
  31008. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  31009. /**
  31010. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  31011. * @param pipelineContext defines the pipeline context to use
  31012. * @param uniformsNames defines the list of uniform names
  31013. * @returns an array of webGL uniform locations
  31014. */
  31015. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  31016. /**
  31017. * Gets the lsit of active attributes for a given webGL program
  31018. * @param pipelineContext defines the pipeline context to use
  31019. * @param attributesNames defines the list of attribute names to get
  31020. * @returns an array of indices indicating the offset of each attribute
  31021. */
  31022. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  31023. /**
  31024. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  31025. * @param effect defines the effect to activate
  31026. */
  31027. enableEffect(effect: Nullable<Effect>): void;
  31028. /**
  31029. * Set the value of an uniform to a number (int)
  31030. * @param uniform defines the webGL uniform location where to store the value
  31031. * @param value defines the int number to store
  31032. */
  31033. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31034. /**
  31035. * Set the value of an uniform to an array of int32
  31036. * @param uniform defines the webGL uniform location where to store the value
  31037. * @param array defines the array of int32 to store
  31038. */
  31039. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31040. /**
  31041. * Set the value of an uniform to an array of int32 (stored as vec2)
  31042. * @param uniform defines the webGL uniform location where to store the value
  31043. * @param array defines the array of int32 to store
  31044. */
  31045. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31046. /**
  31047. * Set the value of an uniform to an array of int32 (stored as vec3)
  31048. * @param uniform defines the webGL uniform location where to store the value
  31049. * @param array defines the array of int32 to store
  31050. */
  31051. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31052. /**
  31053. * Set the value of an uniform to an array of int32 (stored as vec4)
  31054. * @param uniform defines the webGL uniform location where to store the value
  31055. * @param array defines the array of int32 to store
  31056. */
  31057. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31058. /**
  31059. * Set the value of an uniform to an array of number
  31060. * @param uniform defines the webGL uniform location where to store the value
  31061. * @param array defines the array of number to store
  31062. */
  31063. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31064. /**
  31065. * Set the value of an uniform to an array of number (stored as vec2)
  31066. * @param uniform defines the webGL uniform location where to store the value
  31067. * @param array defines the array of number to store
  31068. */
  31069. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31070. /**
  31071. * Set the value of an uniform to an array of number (stored as vec3)
  31072. * @param uniform defines the webGL uniform location where to store the value
  31073. * @param array defines the array of number to store
  31074. */
  31075. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31076. /**
  31077. * Set the value of an uniform to an array of number (stored as vec4)
  31078. * @param uniform defines the webGL uniform location where to store the value
  31079. * @param array defines the array of number to store
  31080. */
  31081. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31082. /**
  31083. * Set the value of an uniform to an array of float32 (stored as matrices)
  31084. * @param uniform defines the webGL uniform location where to store the value
  31085. * @param matrices defines the array of float32 to store
  31086. */
  31087. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  31088. /**
  31089. * Set the value of an uniform to a matrix (3x3)
  31090. * @param uniform defines the webGL uniform location where to store the value
  31091. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  31092. */
  31093. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31094. /**
  31095. * Set the value of an uniform to a matrix (2x2)
  31096. * @param uniform defines the webGL uniform location where to store the value
  31097. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  31098. */
  31099. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31100. /**
  31101. * Set the value of an uniform to a number (float)
  31102. * @param uniform defines the webGL uniform location where to store the value
  31103. * @param value defines the float number to store
  31104. */
  31105. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31106. /**
  31107. * Set the value of an uniform to a vec2
  31108. * @param uniform defines the webGL uniform location where to store the value
  31109. * @param x defines the 1st component of the value
  31110. * @param y defines the 2nd component of the value
  31111. */
  31112. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  31113. /**
  31114. * Set the value of an uniform to a vec3
  31115. * @param uniform defines the webGL uniform location where to store the value
  31116. * @param x defines the 1st component of the value
  31117. * @param y defines the 2nd component of the value
  31118. * @param z defines the 3rd component of the value
  31119. */
  31120. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  31121. /**
  31122. * Set the value of an uniform to a vec4
  31123. * @param uniform defines the webGL uniform location where to store the value
  31124. * @param x defines the 1st component of the value
  31125. * @param y defines the 2nd component of the value
  31126. * @param z defines the 3rd component of the value
  31127. * @param w defines the 4th component of the value
  31128. */
  31129. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  31130. /**
  31131. * Gets the depth culling state manager
  31132. */
  31133. readonly depthCullingState: DepthCullingState;
  31134. /**
  31135. * Gets the alpha state manager
  31136. */
  31137. readonly alphaState: AlphaState;
  31138. /**
  31139. * Gets the stencil state manager
  31140. */
  31141. readonly stencilState: StencilState;
  31142. /**
  31143. * Clears the list of texture accessible through engine.
  31144. * This can help preventing texture load conflict due to name collision.
  31145. */
  31146. clearInternalTexturesCache(): void;
  31147. /**
  31148. * Force the entire cache to be cleared
  31149. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  31150. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  31151. */
  31152. wipeCaches(bruteForce?: boolean): void;
  31153. /** @hidden */
  31154. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  31155. min: number;
  31156. mag: number;
  31157. };
  31158. /** @hidden */
  31159. _createTexture(): WebGLTexture;
  31160. /**
  31161. * Usually called from Texture.ts.
  31162. * Passed information to create a WebGLTexture
  31163. * @param urlArg defines a value which contains one of the following:
  31164. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  31165. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  31166. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  31167. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  31168. * @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)
  31169. * @param scene needed for loading to the correct scene
  31170. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  31171. * @param onLoad optional callback to be called upon successful completion
  31172. * @param onError optional callback to be called upon failure
  31173. * @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
  31174. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  31175. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  31176. * @param forcedExtension defines the extension to use to pick the right loader
  31177. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  31178. * @param mimeType defines an optional mime type
  31179. * @returns a InternalTexture for assignment back into BABYLON.Texture
  31180. */
  31181. 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 | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>, mimeType?: string): InternalTexture;
  31182. /**
  31183. * @hidden
  31184. */
  31185. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  31186. /**
  31187. * Creates a raw texture
  31188. * @param data defines the data to store in the texture
  31189. * @param width defines the width of the texture
  31190. * @param height defines the height of the texture
  31191. * @param format defines the format of the data
  31192. * @param generateMipMaps defines if the engine should generate the mip levels
  31193. * @param invertY defines if data must be stored with Y axis inverted
  31194. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  31195. * @param compression defines the compression used (null by default)
  31196. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  31197. * @returns the raw texture inside an InternalTexture
  31198. */
  31199. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  31200. /**
  31201. * Creates a new raw cube texture
  31202. * @param data defines the array of data to use to create each face
  31203. * @param size defines the size of the textures
  31204. * @param format defines the format of the data
  31205. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  31206. * @param generateMipMaps defines if the engine should generate the mip levels
  31207. * @param invertY defines if data must be stored with Y axis inverted
  31208. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31209. * @param compression defines the compression used (null by default)
  31210. * @returns the cube texture as an InternalTexture
  31211. */
  31212. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  31213. /**
  31214. * Creates a new raw 3D texture
  31215. * @param data defines the data used to create the texture
  31216. * @param width defines the width of the texture
  31217. * @param height defines the height of the texture
  31218. * @param depth defines the depth of the texture
  31219. * @param format defines the format of the texture
  31220. * @param generateMipMaps defines if the engine must generate mip levels
  31221. * @param invertY defines if data must be stored with Y axis inverted
  31222. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31223. * @param compression defines the compressed used (can be null)
  31224. * @param textureType defines the compressed used (can be null)
  31225. * @returns a new raw 3D texture (stored in an InternalTexture)
  31226. */
  31227. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  31228. /**
  31229. * Creates a new raw 2D array texture
  31230. * @param data defines the data used to create the texture
  31231. * @param width defines the width of the texture
  31232. * @param height defines the height of the texture
  31233. * @param depth defines the number of layers of the texture
  31234. * @param format defines the format of the texture
  31235. * @param generateMipMaps defines if the engine must generate mip levels
  31236. * @param invertY defines if data must be stored with Y axis inverted
  31237. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31238. * @param compression defines the compressed used (can be null)
  31239. * @param textureType defines the compressed used (can be null)
  31240. * @returns a new raw 2D array texture (stored in an InternalTexture)
  31241. */
  31242. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  31243. private _unpackFlipYCached;
  31244. /**
  31245. * In case you are sharing the context with other applications, it might
  31246. * be interested to not cache the unpack flip y state to ensure a consistent
  31247. * value would be set.
  31248. */
  31249. enableUnpackFlipYCached: boolean;
  31250. /** @hidden */
  31251. _unpackFlipY(value: boolean): void;
  31252. /** @hidden */
  31253. _getUnpackAlignement(): number;
  31254. /**
  31255. * Update the sampling mode of a given texture
  31256. * @param samplingMode defines the required sampling mode
  31257. * @param texture defines the texture to update
  31258. */
  31259. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  31260. /** @hidden */
  31261. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  31262. width: number;
  31263. height: number;
  31264. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  31265. /** @hidden */
  31266. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31267. /** @hidden */
  31268. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  31269. /** @hidden */
  31270. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31271. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  31272. private _prepareWebGLTexture;
  31273. /** @hidden */
  31274. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  31275. /** @hidden */
  31276. _releaseFramebufferObjects(texture: InternalTexture): void;
  31277. /** @hidden */
  31278. _releaseTexture(texture: InternalTexture): void;
  31279. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  31280. protected _setProgram(program: WebGLProgram): void;
  31281. protected _boundUniforms: {
  31282. [key: number]: WebGLUniformLocation;
  31283. };
  31284. /**
  31285. * Binds an effect to the webGL context
  31286. * @param effect defines the effect to bind
  31287. */
  31288. bindSamplers(effect: Effect): void;
  31289. private _activateCurrentTexture;
  31290. /** @hidden */
  31291. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  31292. /** @hidden */
  31293. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  31294. /**
  31295. * Unbind all textures from the webGL context
  31296. */
  31297. unbindAllTextures(): void;
  31298. /**
  31299. * Sets a texture to the according uniform.
  31300. * @param channel The texture channel
  31301. * @param uniform The uniform to set
  31302. * @param texture The texture to apply
  31303. */
  31304. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  31305. private _bindSamplerUniformToChannel;
  31306. private _getTextureWrapMode;
  31307. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  31308. /**
  31309. * Sets an array of texture to the webGL context
  31310. * @param channel defines the channel where the texture array must be set
  31311. * @param uniform defines the associated uniform location
  31312. * @param textures defines the array of textures to bind
  31313. */
  31314. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  31315. /** @hidden */
  31316. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  31317. private _setTextureParameterFloat;
  31318. private _setTextureParameterInteger;
  31319. /**
  31320. * Unbind all vertex attributes from the webGL context
  31321. */
  31322. unbindAllAttributes(): void;
  31323. /**
  31324. * 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
  31325. */
  31326. releaseEffects(): void;
  31327. /**
  31328. * Dispose and release all associated resources
  31329. */
  31330. dispose(): void;
  31331. /**
  31332. * Attach a new callback raised when context lost event is fired
  31333. * @param callback defines the callback to call
  31334. */
  31335. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31336. /**
  31337. * Attach a new callback raised when context restored event is fired
  31338. * @param callback defines the callback to call
  31339. */
  31340. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31341. /**
  31342. * Get the current error code of the webGL context
  31343. * @returns the error code
  31344. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  31345. */
  31346. getError(): number;
  31347. private _canRenderToFloatFramebuffer;
  31348. private _canRenderToHalfFloatFramebuffer;
  31349. private _canRenderToFramebuffer;
  31350. /** @hidden */
  31351. _getWebGLTextureType(type: number): number;
  31352. /** @hidden */
  31353. _getInternalFormat(format: number): number;
  31354. /** @hidden */
  31355. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  31356. /** @hidden */
  31357. _getRGBAMultiSampleBufferFormat(type: number): number;
  31358. /** @hidden */
  31359. _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;
  31360. /**
  31361. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  31362. * @returns true if the engine can be created
  31363. * @ignorenaming
  31364. */
  31365. static isSupported(): boolean;
  31366. /**
  31367. * Find the next highest power of two.
  31368. * @param x Number to start search from.
  31369. * @return Next highest power of two.
  31370. */
  31371. static CeilingPOT(x: number): number;
  31372. /**
  31373. * Find the next lowest power of two.
  31374. * @param x Number to start search from.
  31375. * @return Next lowest power of two.
  31376. */
  31377. static FloorPOT(x: number): number;
  31378. /**
  31379. * Find the nearest power of two.
  31380. * @param x Number to start search from.
  31381. * @return Next nearest power of two.
  31382. */
  31383. static NearestPOT(x: number): number;
  31384. /**
  31385. * Get the closest exponent of two
  31386. * @param value defines the value to approximate
  31387. * @param max defines the maximum value to return
  31388. * @param mode defines how to define the closest value
  31389. * @returns closest exponent of two of the given value
  31390. */
  31391. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31392. /**
  31393. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31394. * @param func - the function to be called
  31395. * @param requester - the object that will request the next frame. Falls back to window.
  31396. * @returns frame number
  31397. */
  31398. static QueueNewFrame(func: () => void, requester?: any): number;
  31399. /**
  31400. * Gets host document
  31401. * @returns the host document object
  31402. */
  31403. getHostDocument(): Document;
  31404. }
  31405. }
  31406. declare module BABYLON {
  31407. /**
  31408. * Class representing spherical harmonics coefficients to the 3rd degree
  31409. */
  31410. export class SphericalHarmonics {
  31411. /**
  31412. * Defines whether or not the harmonics have been prescaled for rendering.
  31413. */
  31414. preScaled: boolean;
  31415. /**
  31416. * The l0,0 coefficients of the spherical harmonics
  31417. */
  31418. l00: Vector3;
  31419. /**
  31420. * The l1,-1 coefficients of the spherical harmonics
  31421. */
  31422. l1_1: Vector3;
  31423. /**
  31424. * The l1,0 coefficients of the spherical harmonics
  31425. */
  31426. l10: Vector3;
  31427. /**
  31428. * The l1,1 coefficients of the spherical harmonics
  31429. */
  31430. l11: Vector3;
  31431. /**
  31432. * The l2,-2 coefficients of the spherical harmonics
  31433. */
  31434. l2_2: Vector3;
  31435. /**
  31436. * The l2,-1 coefficients of the spherical harmonics
  31437. */
  31438. l2_1: Vector3;
  31439. /**
  31440. * The l2,0 coefficients of the spherical harmonics
  31441. */
  31442. l20: Vector3;
  31443. /**
  31444. * The l2,1 coefficients of the spherical harmonics
  31445. */
  31446. l21: Vector3;
  31447. /**
  31448. * The l2,2 coefficients of the spherical harmonics
  31449. */
  31450. l22: Vector3;
  31451. /**
  31452. * Adds a light to the spherical harmonics
  31453. * @param direction the direction of the light
  31454. * @param color the color of the light
  31455. * @param deltaSolidAngle the delta solid angle of the light
  31456. */
  31457. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  31458. /**
  31459. * Scales the spherical harmonics by the given amount
  31460. * @param scale the amount to scale
  31461. */
  31462. scaleInPlace(scale: number): void;
  31463. /**
  31464. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  31465. *
  31466. * ```
  31467. * E_lm = A_l * L_lm
  31468. * ```
  31469. *
  31470. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  31471. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  31472. * the scaling factors are given in equation 9.
  31473. */
  31474. convertIncidentRadianceToIrradiance(): void;
  31475. /**
  31476. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  31477. *
  31478. * ```
  31479. * L = (1/pi) * E * rho
  31480. * ```
  31481. *
  31482. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  31483. */
  31484. convertIrradianceToLambertianRadiance(): void;
  31485. /**
  31486. * Integrates the reconstruction coefficients directly in to the SH preventing further
  31487. * required operations at run time.
  31488. *
  31489. * This is simply done by scaling back the SH with Ylm constants parameter.
  31490. * The trigonometric part being applied by the shader at run time.
  31491. */
  31492. preScaleForRendering(): void;
  31493. /**
  31494. * Constructs a spherical harmonics from an array.
  31495. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  31496. * @returns the spherical harmonics
  31497. */
  31498. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  31499. /**
  31500. * Gets the spherical harmonics from polynomial
  31501. * @param polynomial the spherical polynomial
  31502. * @returns the spherical harmonics
  31503. */
  31504. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  31505. }
  31506. /**
  31507. * Class representing spherical polynomial coefficients to the 3rd degree
  31508. */
  31509. export class SphericalPolynomial {
  31510. private _harmonics;
  31511. /**
  31512. * The spherical harmonics used to create the polynomials.
  31513. */
  31514. readonly preScaledHarmonics: SphericalHarmonics;
  31515. /**
  31516. * The x coefficients of the spherical polynomial
  31517. */
  31518. x: Vector3;
  31519. /**
  31520. * The y coefficients of the spherical polynomial
  31521. */
  31522. y: Vector3;
  31523. /**
  31524. * The z coefficients of the spherical polynomial
  31525. */
  31526. z: Vector3;
  31527. /**
  31528. * The xx coefficients of the spherical polynomial
  31529. */
  31530. xx: Vector3;
  31531. /**
  31532. * The yy coefficients of the spherical polynomial
  31533. */
  31534. yy: Vector3;
  31535. /**
  31536. * The zz coefficients of the spherical polynomial
  31537. */
  31538. zz: Vector3;
  31539. /**
  31540. * The xy coefficients of the spherical polynomial
  31541. */
  31542. xy: Vector3;
  31543. /**
  31544. * The yz coefficients of the spherical polynomial
  31545. */
  31546. yz: Vector3;
  31547. /**
  31548. * The zx coefficients of the spherical polynomial
  31549. */
  31550. zx: Vector3;
  31551. /**
  31552. * Adds an ambient color to the spherical polynomial
  31553. * @param color the color to add
  31554. */
  31555. addAmbient(color: Color3): void;
  31556. /**
  31557. * Scales the spherical polynomial by the given amount
  31558. * @param scale the amount to scale
  31559. */
  31560. scaleInPlace(scale: number): void;
  31561. /**
  31562. * Gets the spherical polynomial from harmonics
  31563. * @param harmonics the spherical harmonics
  31564. * @returns the spherical polynomial
  31565. */
  31566. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  31567. /**
  31568. * Constructs a spherical polynomial from an array.
  31569. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  31570. * @returns the spherical polynomial
  31571. */
  31572. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  31573. }
  31574. }
  31575. declare module BABYLON {
  31576. /**
  31577. * Defines the source of the internal texture
  31578. */
  31579. export enum InternalTextureSource {
  31580. /**
  31581. * The source of the texture data is unknown
  31582. */
  31583. Unknown = 0,
  31584. /**
  31585. * Texture data comes from an URL
  31586. */
  31587. Url = 1,
  31588. /**
  31589. * Texture data is only used for temporary storage
  31590. */
  31591. Temp = 2,
  31592. /**
  31593. * Texture data comes from raw data (ArrayBuffer)
  31594. */
  31595. Raw = 3,
  31596. /**
  31597. * Texture content is dynamic (video or dynamic texture)
  31598. */
  31599. Dynamic = 4,
  31600. /**
  31601. * Texture content is generated by rendering to it
  31602. */
  31603. RenderTarget = 5,
  31604. /**
  31605. * Texture content is part of a multi render target process
  31606. */
  31607. MultiRenderTarget = 6,
  31608. /**
  31609. * Texture data comes from a cube data file
  31610. */
  31611. Cube = 7,
  31612. /**
  31613. * Texture data comes from a raw cube data
  31614. */
  31615. CubeRaw = 8,
  31616. /**
  31617. * Texture data come from a prefiltered cube data file
  31618. */
  31619. CubePrefiltered = 9,
  31620. /**
  31621. * Texture content is raw 3D data
  31622. */
  31623. Raw3D = 10,
  31624. /**
  31625. * Texture content is raw 2D array data
  31626. */
  31627. Raw2DArray = 11,
  31628. /**
  31629. * Texture content is a depth texture
  31630. */
  31631. Depth = 12,
  31632. /**
  31633. * Texture data comes from a raw cube data encoded with RGBD
  31634. */
  31635. CubeRawRGBD = 13
  31636. }
  31637. /**
  31638. * Class used to store data associated with WebGL texture data for the engine
  31639. * This class should not be used directly
  31640. */
  31641. export class InternalTexture {
  31642. /** @hidden */
  31643. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  31644. /**
  31645. * Defines if the texture is ready
  31646. */
  31647. isReady: boolean;
  31648. /**
  31649. * Defines if the texture is a cube texture
  31650. */
  31651. isCube: boolean;
  31652. /**
  31653. * Defines if the texture contains 3D data
  31654. */
  31655. is3D: boolean;
  31656. /**
  31657. * Defines if the texture contains 2D array data
  31658. */
  31659. is2DArray: boolean;
  31660. /**
  31661. * Defines if the texture contains multiview data
  31662. */
  31663. isMultiview: boolean;
  31664. /**
  31665. * Gets the URL used to load this texture
  31666. */
  31667. url: string;
  31668. /**
  31669. * Gets the sampling mode of the texture
  31670. */
  31671. samplingMode: number;
  31672. /**
  31673. * Gets a boolean indicating if the texture needs mipmaps generation
  31674. */
  31675. generateMipMaps: boolean;
  31676. /**
  31677. * Gets the number of samples used by the texture (WebGL2+ only)
  31678. */
  31679. samples: number;
  31680. /**
  31681. * Gets the type of the texture (int, float...)
  31682. */
  31683. type: number;
  31684. /**
  31685. * Gets the format of the texture (RGB, RGBA...)
  31686. */
  31687. format: number;
  31688. /**
  31689. * Observable called when the texture is loaded
  31690. */
  31691. onLoadedObservable: Observable<InternalTexture>;
  31692. /**
  31693. * Gets the width of the texture
  31694. */
  31695. width: number;
  31696. /**
  31697. * Gets the height of the texture
  31698. */
  31699. height: number;
  31700. /**
  31701. * Gets the depth of the texture
  31702. */
  31703. depth: number;
  31704. /**
  31705. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  31706. */
  31707. baseWidth: number;
  31708. /**
  31709. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  31710. */
  31711. baseHeight: number;
  31712. /**
  31713. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  31714. */
  31715. baseDepth: number;
  31716. /**
  31717. * Gets a boolean indicating if the texture is inverted on Y axis
  31718. */
  31719. invertY: boolean;
  31720. /** @hidden */
  31721. _invertVScale: boolean;
  31722. /** @hidden */
  31723. _associatedChannel: number;
  31724. /** @hidden */
  31725. _source: InternalTextureSource;
  31726. /** @hidden */
  31727. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  31728. /** @hidden */
  31729. _bufferView: Nullable<ArrayBufferView>;
  31730. /** @hidden */
  31731. _bufferViewArray: Nullable<ArrayBufferView[]>;
  31732. /** @hidden */
  31733. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  31734. /** @hidden */
  31735. _size: number;
  31736. /** @hidden */
  31737. _extension: string;
  31738. /** @hidden */
  31739. _files: Nullable<string[]>;
  31740. /** @hidden */
  31741. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31742. /** @hidden */
  31743. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31744. /** @hidden */
  31745. _framebuffer: Nullable<WebGLFramebuffer>;
  31746. /** @hidden */
  31747. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  31748. /** @hidden */
  31749. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  31750. /** @hidden */
  31751. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  31752. /** @hidden */
  31753. _attachments: Nullable<number[]>;
  31754. /** @hidden */
  31755. _cachedCoordinatesMode: Nullable<number>;
  31756. /** @hidden */
  31757. _cachedWrapU: Nullable<number>;
  31758. /** @hidden */
  31759. _cachedWrapV: Nullable<number>;
  31760. /** @hidden */
  31761. _cachedWrapR: Nullable<number>;
  31762. /** @hidden */
  31763. _cachedAnisotropicFilteringLevel: Nullable<number>;
  31764. /** @hidden */
  31765. _isDisabled: boolean;
  31766. /** @hidden */
  31767. _compression: Nullable<string>;
  31768. /** @hidden */
  31769. _generateStencilBuffer: boolean;
  31770. /** @hidden */
  31771. _generateDepthBuffer: boolean;
  31772. /** @hidden */
  31773. _comparisonFunction: number;
  31774. /** @hidden */
  31775. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  31776. /** @hidden */
  31777. _lodGenerationScale: number;
  31778. /** @hidden */
  31779. _lodGenerationOffset: number;
  31780. /** @hidden */
  31781. _colorTextureArray: Nullable<WebGLTexture>;
  31782. /** @hidden */
  31783. _depthStencilTextureArray: Nullable<WebGLTexture>;
  31784. /** @hidden */
  31785. _lodTextureHigh: Nullable<BaseTexture>;
  31786. /** @hidden */
  31787. _lodTextureMid: Nullable<BaseTexture>;
  31788. /** @hidden */
  31789. _lodTextureLow: Nullable<BaseTexture>;
  31790. /** @hidden */
  31791. _isRGBD: boolean;
  31792. /** @hidden */
  31793. _linearSpecularLOD: boolean;
  31794. /** @hidden */
  31795. _irradianceTexture: Nullable<BaseTexture>;
  31796. /** @hidden */
  31797. _webGLTexture: Nullable<WebGLTexture>;
  31798. /** @hidden */
  31799. _references: number;
  31800. private _engine;
  31801. /**
  31802. * Gets the Engine the texture belongs to.
  31803. * @returns The babylon engine
  31804. */
  31805. getEngine(): ThinEngine;
  31806. /**
  31807. * Gets the data source type of the texture
  31808. */
  31809. readonly source: InternalTextureSource;
  31810. /**
  31811. * Creates a new InternalTexture
  31812. * @param engine defines the engine to use
  31813. * @param source defines the type of data that will be used
  31814. * @param delayAllocation if the texture allocation should be delayed (default: false)
  31815. */
  31816. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  31817. /**
  31818. * Increments the number of references (ie. the number of Texture that point to it)
  31819. */
  31820. incrementReferences(): void;
  31821. /**
  31822. * Change the size of the texture (not the size of the content)
  31823. * @param width defines the new width
  31824. * @param height defines the new height
  31825. * @param depth defines the new depth (1 by default)
  31826. */
  31827. updateSize(width: int, height: int, depth?: int): void;
  31828. /** @hidden */
  31829. _rebuild(): void;
  31830. /** @hidden */
  31831. _swapAndDie(target: InternalTexture): void;
  31832. /**
  31833. * Dispose the current allocated resources
  31834. */
  31835. dispose(): void;
  31836. }
  31837. }
  31838. declare module BABYLON {
  31839. /**
  31840. * Class used to work with sound analyzer using fast fourier transform (FFT)
  31841. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31842. */
  31843. export class Analyser {
  31844. /**
  31845. * Gets or sets the smoothing
  31846. * @ignorenaming
  31847. */
  31848. SMOOTHING: number;
  31849. /**
  31850. * Gets or sets the FFT table size
  31851. * @ignorenaming
  31852. */
  31853. FFT_SIZE: number;
  31854. /**
  31855. * Gets or sets the bar graph amplitude
  31856. * @ignorenaming
  31857. */
  31858. BARGRAPHAMPLITUDE: number;
  31859. /**
  31860. * Gets or sets the position of the debug canvas
  31861. * @ignorenaming
  31862. */
  31863. DEBUGCANVASPOS: {
  31864. x: number;
  31865. y: number;
  31866. };
  31867. /**
  31868. * Gets or sets the debug canvas size
  31869. * @ignorenaming
  31870. */
  31871. DEBUGCANVASSIZE: {
  31872. width: number;
  31873. height: number;
  31874. };
  31875. private _byteFreqs;
  31876. private _byteTime;
  31877. private _floatFreqs;
  31878. private _webAudioAnalyser;
  31879. private _debugCanvas;
  31880. private _debugCanvasContext;
  31881. private _scene;
  31882. private _registerFunc;
  31883. private _audioEngine;
  31884. /**
  31885. * Creates a new analyser
  31886. * @param scene defines hosting scene
  31887. */
  31888. constructor(scene: Scene);
  31889. /**
  31890. * Get the number of data values you will have to play with for the visualization
  31891. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  31892. * @returns a number
  31893. */
  31894. getFrequencyBinCount(): number;
  31895. /**
  31896. * Gets the current frequency data as a byte array
  31897. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31898. * @returns a Uint8Array
  31899. */
  31900. getByteFrequencyData(): Uint8Array;
  31901. /**
  31902. * Gets the current waveform as a byte array
  31903. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  31904. * @returns a Uint8Array
  31905. */
  31906. getByteTimeDomainData(): Uint8Array;
  31907. /**
  31908. * Gets the current frequency data as a float array
  31909. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31910. * @returns a Float32Array
  31911. */
  31912. getFloatFrequencyData(): Float32Array;
  31913. /**
  31914. * Renders the debug canvas
  31915. */
  31916. drawDebugCanvas(): void;
  31917. /**
  31918. * Stops rendering the debug canvas and removes it
  31919. */
  31920. stopDebugCanvas(): void;
  31921. /**
  31922. * Connects two audio nodes
  31923. * @param inputAudioNode defines first node to connect
  31924. * @param outputAudioNode defines second node to connect
  31925. */
  31926. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  31927. /**
  31928. * Releases all associated resources
  31929. */
  31930. dispose(): void;
  31931. }
  31932. }
  31933. declare module BABYLON {
  31934. /**
  31935. * This represents an audio engine and it is responsible
  31936. * to play, synchronize and analyse sounds throughout the application.
  31937. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31938. */
  31939. export interface IAudioEngine extends IDisposable {
  31940. /**
  31941. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  31942. */
  31943. readonly canUseWebAudio: boolean;
  31944. /**
  31945. * Gets the current AudioContext if available.
  31946. */
  31947. readonly audioContext: Nullable<AudioContext>;
  31948. /**
  31949. * The master gain node defines the global audio volume of your audio engine.
  31950. */
  31951. readonly masterGain: GainNode;
  31952. /**
  31953. * Gets whether or not mp3 are supported by your browser.
  31954. */
  31955. readonly isMP3supported: boolean;
  31956. /**
  31957. * Gets whether or not ogg are supported by your browser.
  31958. */
  31959. readonly isOGGsupported: boolean;
  31960. /**
  31961. * Defines if Babylon should emit a warning if WebAudio is not supported.
  31962. * @ignoreNaming
  31963. */
  31964. WarnedWebAudioUnsupported: boolean;
  31965. /**
  31966. * Defines if the audio engine relies on a custom unlocked button.
  31967. * In this case, the embedded button will not be displayed.
  31968. */
  31969. useCustomUnlockedButton: boolean;
  31970. /**
  31971. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  31972. */
  31973. readonly unlocked: boolean;
  31974. /**
  31975. * Event raised when audio has been unlocked on the browser.
  31976. */
  31977. onAudioUnlockedObservable: Observable<AudioEngine>;
  31978. /**
  31979. * Event raised when audio has been locked on the browser.
  31980. */
  31981. onAudioLockedObservable: Observable<AudioEngine>;
  31982. /**
  31983. * Flags the audio engine in Locked state.
  31984. * This happens due to new browser policies preventing audio to autoplay.
  31985. */
  31986. lock(): void;
  31987. /**
  31988. * Unlocks the audio engine once a user action has been done on the dom.
  31989. * This is helpful to resume play once browser policies have been satisfied.
  31990. */
  31991. unlock(): void;
  31992. }
  31993. /**
  31994. * This represents the default audio engine used in babylon.
  31995. * It is responsible to play, synchronize and analyse sounds throughout the application.
  31996. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31997. */
  31998. export class AudioEngine implements IAudioEngine {
  31999. private _audioContext;
  32000. private _audioContextInitialized;
  32001. private _muteButton;
  32002. private _hostElement;
  32003. /**
  32004. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32005. */
  32006. canUseWebAudio: boolean;
  32007. /**
  32008. * The master gain node defines the global audio volume of your audio engine.
  32009. */
  32010. masterGain: GainNode;
  32011. /**
  32012. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32013. * @ignoreNaming
  32014. */
  32015. WarnedWebAudioUnsupported: boolean;
  32016. /**
  32017. * Gets whether or not mp3 are supported by your browser.
  32018. */
  32019. isMP3supported: boolean;
  32020. /**
  32021. * Gets whether or not ogg are supported by your browser.
  32022. */
  32023. isOGGsupported: boolean;
  32024. /**
  32025. * Gets whether audio has been unlocked on the device.
  32026. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  32027. * a user interaction has happened.
  32028. */
  32029. unlocked: boolean;
  32030. /**
  32031. * Defines if the audio engine relies on a custom unlocked button.
  32032. * In this case, the embedded button will not be displayed.
  32033. */
  32034. useCustomUnlockedButton: boolean;
  32035. /**
  32036. * Event raised when audio has been unlocked on the browser.
  32037. */
  32038. onAudioUnlockedObservable: Observable<AudioEngine>;
  32039. /**
  32040. * Event raised when audio has been locked on the browser.
  32041. */
  32042. onAudioLockedObservable: Observable<AudioEngine>;
  32043. /**
  32044. * Gets the current AudioContext if available.
  32045. */
  32046. readonly audioContext: Nullable<AudioContext>;
  32047. private _connectedAnalyser;
  32048. /**
  32049. * Instantiates a new audio engine.
  32050. *
  32051. * There should be only one per page as some browsers restrict the number
  32052. * of audio contexts you can create.
  32053. * @param hostElement defines the host element where to display the mute icon if necessary
  32054. */
  32055. constructor(hostElement?: Nullable<HTMLElement>);
  32056. /**
  32057. * Flags the audio engine in Locked state.
  32058. * This happens due to new browser policies preventing audio to autoplay.
  32059. */
  32060. lock(): void;
  32061. /**
  32062. * Unlocks the audio engine once a user action has been done on the dom.
  32063. * This is helpful to resume play once browser policies have been satisfied.
  32064. */
  32065. unlock(): void;
  32066. private _resumeAudioContext;
  32067. private _initializeAudioContext;
  32068. private _tryToRun;
  32069. private _triggerRunningState;
  32070. private _triggerSuspendedState;
  32071. private _displayMuteButton;
  32072. private _moveButtonToTopLeft;
  32073. private _onResize;
  32074. private _hideMuteButton;
  32075. /**
  32076. * Destroy and release the resources associated with the audio ccontext.
  32077. */
  32078. dispose(): void;
  32079. /**
  32080. * Gets the global volume sets on the master gain.
  32081. * @returns the global volume if set or -1 otherwise
  32082. */
  32083. getGlobalVolume(): number;
  32084. /**
  32085. * Sets the global volume of your experience (sets on the master gain).
  32086. * @param newVolume Defines the new global volume of the application
  32087. */
  32088. setGlobalVolume(newVolume: number): void;
  32089. /**
  32090. * Connect the audio engine to an audio analyser allowing some amazing
  32091. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  32092. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  32093. * @param analyser The analyser to connect to the engine
  32094. */
  32095. connectToAnalyser(analyser: Analyser): void;
  32096. }
  32097. }
  32098. declare module BABYLON {
  32099. /**
  32100. * Interface used to present a loading screen while loading a scene
  32101. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32102. */
  32103. export interface ILoadingScreen {
  32104. /**
  32105. * Function called to display the loading screen
  32106. */
  32107. displayLoadingUI: () => void;
  32108. /**
  32109. * Function called to hide the loading screen
  32110. */
  32111. hideLoadingUI: () => void;
  32112. /**
  32113. * Gets or sets the color to use for the background
  32114. */
  32115. loadingUIBackgroundColor: string;
  32116. /**
  32117. * Gets or sets the text to display while loading
  32118. */
  32119. loadingUIText: string;
  32120. }
  32121. /**
  32122. * Class used for the default loading screen
  32123. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32124. */
  32125. export class DefaultLoadingScreen implements ILoadingScreen {
  32126. private _renderingCanvas;
  32127. private _loadingText;
  32128. private _loadingDivBackgroundColor;
  32129. private _loadingDiv;
  32130. private _loadingTextDiv;
  32131. /** Gets or sets the logo url to use for the default loading screen */
  32132. static DefaultLogoUrl: string;
  32133. /** Gets or sets the spinner url to use for the default loading screen */
  32134. static DefaultSpinnerUrl: string;
  32135. /**
  32136. * Creates a new default loading screen
  32137. * @param _renderingCanvas defines the canvas used to render the scene
  32138. * @param _loadingText defines the default text to display
  32139. * @param _loadingDivBackgroundColor defines the default background color
  32140. */
  32141. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  32142. /**
  32143. * Function called to display the loading screen
  32144. */
  32145. displayLoadingUI(): void;
  32146. /**
  32147. * Function called to hide the loading screen
  32148. */
  32149. hideLoadingUI(): void;
  32150. /**
  32151. * Gets or sets the text to display while loading
  32152. */
  32153. loadingUIText: string;
  32154. /**
  32155. * Gets or sets the color to use for the background
  32156. */
  32157. loadingUIBackgroundColor: string;
  32158. private _resizeLoadingUI;
  32159. }
  32160. }
  32161. declare module BABYLON {
  32162. /**
  32163. * Interface for any object that can request an animation frame
  32164. */
  32165. export interface ICustomAnimationFrameRequester {
  32166. /**
  32167. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  32168. */
  32169. renderFunction?: Function;
  32170. /**
  32171. * Called to request the next frame to render to
  32172. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  32173. */
  32174. requestAnimationFrame: Function;
  32175. /**
  32176. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  32177. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  32178. */
  32179. requestID?: number;
  32180. }
  32181. }
  32182. declare module BABYLON {
  32183. /**
  32184. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  32185. */
  32186. export class PerformanceMonitor {
  32187. private _enabled;
  32188. private _rollingFrameTime;
  32189. private _lastFrameTimeMs;
  32190. /**
  32191. * constructor
  32192. * @param frameSampleSize The number of samples required to saturate the sliding window
  32193. */
  32194. constructor(frameSampleSize?: number);
  32195. /**
  32196. * Samples current frame
  32197. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  32198. */
  32199. sampleFrame(timeMs?: number): void;
  32200. /**
  32201. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  32202. */
  32203. readonly averageFrameTime: number;
  32204. /**
  32205. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  32206. */
  32207. readonly averageFrameTimeVariance: number;
  32208. /**
  32209. * Returns the frame time of the most recent frame
  32210. */
  32211. readonly instantaneousFrameTime: number;
  32212. /**
  32213. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  32214. */
  32215. readonly averageFPS: number;
  32216. /**
  32217. * Returns the average framerate in frames per second using the most recent frame time
  32218. */
  32219. readonly instantaneousFPS: number;
  32220. /**
  32221. * Returns true if enough samples have been taken to completely fill the sliding window
  32222. */
  32223. readonly isSaturated: boolean;
  32224. /**
  32225. * Enables contributions to the sliding window sample set
  32226. */
  32227. enable(): void;
  32228. /**
  32229. * Disables contributions to the sliding window sample set
  32230. * Samples will not be interpolated over the disabled period
  32231. */
  32232. disable(): void;
  32233. /**
  32234. * Returns true if sampling is enabled
  32235. */
  32236. readonly isEnabled: boolean;
  32237. /**
  32238. * Resets performance monitor
  32239. */
  32240. reset(): void;
  32241. }
  32242. /**
  32243. * RollingAverage
  32244. *
  32245. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  32246. */
  32247. export class RollingAverage {
  32248. /**
  32249. * Current average
  32250. */
  32251. average: number;
  32252. /**
  32253. * Current variance
  32254. */
  32255. variance: number;
  32256. protected _samples: Array<number>;
  32257. protected _sampleCount: number;
  32258. protected _pos: number;
  32259. protected _m2: number;
  32260. /**
  32261. * constructor
  32262. * @param length The number of samples required to saturate the sliding window
  32263. */
  32264. constructor(length: number);
  32265. /**
  32266. * Adds a sample to the sample set
  32267. * @param v The sample value
  32268. */
  32269. add(v: number): void;
  32270. /**
  32271. * Returns previously added values or null if outside of history or outside the sliding window domain
  32272. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  32273. * @return Value previously recorded with add() or null if outside of range
  32274. */
  32275. history(i: number): number;
  32276. /**
  32277. * Returns true if enough samples have been taken to completely fill the sliding window
  32278. * @return true if sample-set saturated
  32279. */
  32280. isSaturated(): boolean;
  32281. /**
  32282. * Resets the rolling average (equivalent to 0 samples taken so far)
  32283. */
  32284. reset(): void;
  32285. /**
  32286. * Wraps a value around the sample range boundaries
  32287. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  32288. * @return Wrapped position in sample range
  32289. */
  32290. protected _wrapPosition(i: number): number;
  32291. }
  32292. }
  32293. declare module BABYLON {
  32294. /**
  32295. * This class is used to track a performance counter which is number based.
  32296. * The user has access to many properties which give statistics of different nature.
  32297. *
  32298. * The implementer can track two kinds of Performance Counter: time and count.
  32299. * 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.
  32300. * 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.
  32301. */
  32302. export class PerfCounter {
  32303. /**
  32304. * Gets or sets a global boolean to turn on and off all the counters
  32305. */
  32306. static Enabled: boolean;
  32307. /**
  32308. * Returns the smallest value ever
  32309. */
  32310. readonly min: number;
  32311. /**
  32312. * Returns the biggest value ever
  32313. */
  32314. readonly max: number;
  32315. /**
  32316. * Returns the average value since the performance counter is running
  32317. */
  32318. readonly average: number;
  32319. /**
  32320. * Returns the average value of the last second the counter was monitored
  32321. */
  32322. readonly lastSecAverage: number;
  32323. /**
  32324. * Returns the current value
  32325. */
  32326. readonly current: number;
  32327. /**
  32328. * Gets the accumulated total
  32329. */
  32330. readonly total: number;
  32331. /**
  32332. * Gets the total value count
  32333. */
  32334. readonly count: number;
  32335. /**
  32336. * Creates a new counter
  32337. */
  32338. constructor();
  32339. /**
  32340. * Call this method to start monitoring a new frame.
  32341. * 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.
  32342. */
  32343. fetchNewFrame(): void;
  32344. /**
  32345. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32346. * @param newCount the count value to add to the monitored count
  32347. * @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.
  32348. */
  32349. addCount(newCount: number, fetchResult: boolean): void;
  32350. /**
  32351. * Start monitoring this performance counter
  32352. */
  32353. beginMonitoring(): void;
  32354. /**
  32355. * Compute the time lapsed since the previous beginMonitoring() call.
  32356. * @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
  32357. */
  32358. endMonitoring(newFrame?: boolean): void;
  32359. private _fetchResult;
  32360. private _startMonitoringTime;
  32361. private _min;
  32362. private _max;
  32363. private _average;
  32364. private _current;
  32365. private _totalValueCount;
  32366. private _totalAccumulated;
  32367. private _lastSecAverage;
  32368. private _lastSecAccumulated;
  32369. private _lastSecTime;
  32370. private _lastSecValueCount;
  32371. }
  32372. }
  32373. declare module BABYLON {
  32374. /**
  32375. * Defines the interface used by display changed events
  32376. */
  32377. export interface IDisplayChangedEventArgs {
  32378. /** Gets the vrDisplay object (if any) */
  32379. vrDisplay: Nullable<any>;
  32380. /** Gets a boolean indicating if webVR is supported */
  32381. vrSupported: boolean;
  32382. }
  32383. /**
  32384. * Defines the interface used by objects containing a viewport (like a camera)
  32385. */
  32386. interface IViewportOwnerLike {
  32387. /**
  32388. * Gets or sets the viewport
  32389. */
  32390. viewport: IViewportLike;
  32391. }
  32392. /**
  32393. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  32394. */
  32395. export class Engine extends ThinEngine {
  32396. /** Defines that alpha blending is disabled */
  32397. static readonly ALPHA_DISABLE: number;
  32398. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  32399. static readonly ALPHA_ADD: number;
  32400. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  32401. static readonly ALPHA_COMBINE: number;
  32402. /** Defines that alpha blending to DEST - SRC * DEST */
  32403. static readonly ALPHA_SUBTRACT: number;
  32404. /** Defines that alpha blending to SRC * DEST */
  32405. static readonly ALPHA_MULTIPLY: number;
  32406. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  32407. static readonly ALPHA_MAXIMIZED: number;
  32408. /** Defines that alpha blending to SRC + DEST */
  32409. static readonly ALPHA_ONEONE: number;
  32410. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  32411. static readonly ALPHA_PREMULTIPLIED: number;
  32412. /**
  32413. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  32414. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  32415. */
  32416. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  32417. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  32418. static readonly ALPHA_INTERPOLATE: number;
  32419. /**
  32420. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  32421. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  32422. */
  32423. static readonly ALPHA_SCREENMODE: number;
  32424. /** Defines that the ressource is not delayed*/
  32425. static readonly DELAYLOADSTATE_NONE: number;
  32426. /** Defines that the ressource was successfully delay loaded */
  32427. static readonly DELAYLOADSTATE_LOADED: number;
  32428. /** Defines that the ressource is currently delay loading */
  32429. static readonly DELAYLOADSTATE_LOADING: number;
  32430. /** Defines that the ressource is delayed and has not started loading */
  32431. static readonly DELAYLOADSTATE_NOTLOADED: number;
  32432. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  32433. static readonly NEVER: number;
  32434. /** 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 */
  32435. static readonly ALWAYS: number;
  32436. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  32437. static readonly LESS: number;
  32438. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  32439. static readonly EQUAL: number;
  32440. /** 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 */
  32441. static readonly LEQUAL: number;
  32442. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  32443. static readonly GREATER: number;
  32444. /** 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 */
  32445. static readonly GEQUAL: number;
  32446. /** 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 */
  32447. static readonly NOTEQUAL: number;
  32448. /** Passed to stencilOperation to specify that stencil value must be kept */
  32449. static readonly KEEP: number;
  32450. /** Passed to stencilOperation to specify that stencil value must be replaced */
  32451. static readonly REPLACE: number;
  32452. /** Passed to stencilOperation to specify that stencil value must be incremented */
  32453. static readonly INCR: number;
  32454. /** Passed to stencilOperation to specify that stencil value must be decremented */
  32455. static readonly DECR: number;
  32456. /** Passed to stencilOperation to specify that stencil value must be inverted */
  32457. static readonly INVERT: number;
  32458. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  32459. static readonly INCR_WRAP: number;
  32460. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  32461. static readonly DECR_WRAP: number;
  32462. /** Texture is not repeating outside of 0..1 UVs */
  32463. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  32464. /** Texture is repeating outside of 0..1 UVs */
  32465. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  32466. /** Texture is repeating and mirrored */
  32467. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  32468. /** ALPHA */
  32469. static readonly TEXTUREFORMAT_ALPHA: number;
  32470. /** LUMINANCE */
  32471. static readonly TEXTUREFORMAT_LUMINANCE: number;
  32472. /** LUMINANCE_ALPHA */
  32473. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  32474. /** RGB */
  32475. static readonly TEXTUREFORMAT_RGB: number;
  32476. /** RGBA */
  32477. static readonly TEXTUREFORMAT_RGBA: number;
  32478. /** RED */
  32479. static readonly TEXTUREFORMAT_RED: number;
  32480. /** RED (2nd reference) */
  32481. static readonly TEXTUREFORMAT_R: number;
  32482. /** RG */
  32483. static readonly TEXTUREFORMAT_RG: number;
  32484. /** RED_INTEGER */
  32485. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  32486. /** RED_INTEGER (2nd reference) */
  32487. static readonly TEXTUREFORMAT_R_INTEGER: number;
  32488. /** RG_INTEGER */
  32489. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  32490. /** RGB_INTEGER */
  32491. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  32492. /** RGBA_INTEGER */
  32493. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  32494. /** UNSIGNED_BYTE */
  32495. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  32496. /** UNSIGNED_BYTE (2nd reference) */
  32497. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  32498. /** FLOAT */
  32499. static readonly TEXTURETYPE_FLOAT: number;
  32500. /** HALF_FLOAT */
  32501. static readonly TEXTURETYPE_HALF_FLOAT: number;
  32502. /** BYTE */
  32503. static readonly TEXTURETYPE_BYTE: number;
  32504. /** SHORT */
  32505. static readonly TEXTURETYPE_SHORT: number;
  32506. /** UNSIGNED_SHORT */
  32507. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  32508. /** INT */
  32509. static readonly TEXTURETYPE_INT: number;
  32510. /** UNSIGNED_INT */
  32511. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  32512. /** UNSIGNED_SHORT_4_4_4_4 */
  32513. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  32514. /** UNSIGNED_SHORT_5_5_5_1 */
  32515. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  32516. /** UNSIGNED_SHORT_5_6_5 */
  32517. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  32518. /** UNSIGNED_INT_2_10_10_10_REV */
  32519. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  32520. /** UNSIGNED_INT_24_8 */
  32521. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  32522. /** UNSIGNED_INT_10F_11F_11F_REV */
  32523. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  32524. /** UNSIGNED_INT_5_9_9_9_REV */
  32525. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  32526. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  32527. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  32528. /** nearest is mag = nearest and min = nearest and mip = linear */
  32529. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  32530. /** Bilinear is mag = linear and min = linear and mip = nearest */
  32531. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  32532. /** Trilinear is mag = linear and min = linear and mip = linear */
  32533. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  32534. /** nearest is mag = nearest and min = nearest and mip = linear */
  32535. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  32536. /** Bilinear is mag = linear and min = linear and mip = nearest */
  32537. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  32538. /** Trilinear is mag = linear and min = linear and mip = linear */
  32539. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  32540. /** mag = nearest and min = nearest and mip = nearest */
  32541. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  32542. /** mag = nearest and min = linear and mip = nearest */
  32543. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  32544. /** mag = nearest and min = linear and mip = linear */
  32545. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  32546. /** mag = nearest and min = linear and mip = none */
  32547. static readonly TEXTURE_NEAREST_LINEAR: number;
  32548. /** mag = nearest and min = nearest and mip = none */
  32549. static readonly TEXTURE_NEAREST_NEAREST: number;
  32550. /** mag = linear and min = nearest and mip = nearest */
  32551. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  32552. /** mag = linear and min = nearest and mip = linear */
  32553. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  32554. /** mag = linear and min = linear and mip = none */
  32555. static readonly TEXTURE_LINEAR_LINEAR: number;
  32556. /** mag = linear and min = nearest and mip = none */
  32557. static readonly TEXTURE_LINEAR_NEAREST: number;
  32558. /** Explicit coordinates mode */
  32559. static readonly TEXTURE_EXPLICIT_MODE: number;
  32560. /** Spherical coordinates mode */
  32561. static readonly TEXTURE_SPHERICAL_MODE: number;
  32562. /** Planar coordinates mode */
  32563. static readonly TEXTURE_PLANAR_MODE: number;
  32564. /** Cubic coordinates mode */
  32565. static readonly TEXTURE_CUBIC_MODE: number;
  32566. /** Projection coordinates mode */
  32567. static readonly TEXTURE_PROJECTION_MODE: number;
  32568. /** Skybox coordinates mode */
  32569. static readonly TEXTURE_SKYBOX_MODE: number;
  32570. /** Inverse Cubic coordinates mode */
  32571. static readonly TEXTURE_INVCUBIC_MODE: number;
  32572. /** Equirectangular coordinates mode */
  32573. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  32574. /** Equirectangular Fixed coordinates mode */
  32575. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  32576. /** Equirectangular Fixed Mirrored coordinates mode */
  32577. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  32578. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  32579. static readonly SCALEMODE_FLOOR: number;
  32580. /** Defines that texture rescaling will look for the nearest power of 2 size */
  32581. static readonly SCALEMODE_NEAREST: number;
  32582. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  32583. static readonly SCALEMODE_CEILING: number;
  32584. /**
  32585. * Returns the current npm package of the sdk
  32586. */
  32587. static readonly NpmPackage: string;
  32588. /**
  32589. * Returns the current version of the framework
  32590. */
  32591. static readonly Version: string;
  32592. /** Gets the list of created engines */
  32593. static readonly Instances: Engine[];
  32594. /**
  32595. * Gets the latest created engine
  32596. */
  32597. static readonly LastCreatedEngine: Nullable<Engine>;
  32598. /**
  32599. * Gets the latest created scene
  32600. */
  32601. static readonly LastCreatedScene: Nullable<Scene>;
  32602. /**
  32603. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  32604. * @param flag defines which part of the materials must be marked as dirty
  32605. * @param predicate defines a predicate used to filter which materials should be affected
  32606. */
  32607. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  32608. /**
  32609. * Method called to create the default loading screen.
  32610. * This can be overriden in your own app.
  32611. * @param canvas The rendering canvas element
  32612. * @returns The loading screen
  32613. */
  32614. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  32615. /**
  32616. * Method called to create the default rescale post process on each engine.
  32617. */
  32618. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  32619. /**
  32620. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  32621. **/
  32622. enableOfflineSupport: boolean;
  32623. /**
  32624. * 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)
  32625. **/
  32626. disableManifestCheck: boolean;
  32627. /**
  32628. * Gets the list of created scenes
  32629. */
  32630. scenes: Scene[];
  32631. /**
  32632. * Event raised when a new scene is created
  32633. */
  32634. onNewSceneAddedObservable: Observable<Scene>;
  32635. /**
  32636. * Gets the list of created postprocesses
  32637. */
  32638. postProcesses: PostProcess[];
  32639. /**
  32640. * Gets a boolean indicating if the pointer is currently locked
  32641. */
  32642. isPointerLock: boolean;
  32643. /**
  32644. * Observable event triggered each time the rendering canvas is resized
  32645. */
  32646. onResizeObservable: Observable<Engine>;
  32647. /**
  32648. * Observable event triggered each time the canvas loses focus
  32649. */
  32650. onCanvasBlurObservable: Observable<Engine>;
  32651. /**
  32652. * Observable event triggered each time the canvas gains focus
  32653. */
  32654. onCanvasFocusObservable: Observable<Engine>;
  32655. /**
  32656. * Observable event triggered each time the canvas receives pointerout event
  32657. */
  32658. onCanvasPointerOutObservable: Observable<PointerEvent>;
  32659. /**
  32660. * Observable raised when the engine begins a new frame
  32661. */
  32662. onBeginFrameObservable: Observable<Engine>;
  32663. /**
  32664. * If set, will be used to request the next animation frame for the render loop
  32665. */
  32666. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  32667. /**
  32668. * Observable raised when the engine ends the current frame
  32669. */
  32670. onEndFrameObservable: Observable<Engine>;
  32671. /**
  32672. * Observable raised when the engine is about to compile a shader
  32673. */
  32674. onBeforeShaderCompilationObservable: Observable<Engine>;
  32675. /**
  32676. * Observable raised when the engine has jsut compiled a shader
  32677. */
  32678. onAfterShaderCompilationObservable: Observable<Engine>;
  32679. /**
  32680. * Gets the audio engine
  32681. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32682. * @ignorenaming
  32683. */
  32684. static audioEngine: IAudioEngine;
  32685. /**
  32686. * Default AudioEngine factory responsible of creating the Audio Engine.
  32687. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  32688. */
  32689. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  32690. /**
  32691. * Default offline support factory responsible of creating a tool used to store data locally.
  32692. * By default, this will create a Database object if the workload has been embedded.
  32693. */
  32694. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  32695. private _loadingScreen;
  32696. private _pointerLockRequested;
  32697. private _dummyFramebuffer;
  32698. private _rescalePostProcess;
  32699. /** @hidden */
  32700. protected _alphaMode: number;
  32701. /** @hidden */
  32702. protected _alphaEquation: number;
  32703. private _deterministicLockstep;
  32704. private _lockstepMaxSteps;
  32705. private _timeStep;
  32706. protected readonly _supportsHardwareTextureRescaling: boolean;
  32707. private _fps;
  32708. private _deltaTime;
  32709. /** @hidden */
  32710. _drawCalls: PerfCounter;
  32711. /**
  32712. * Turn this value on if you want to pause FPS computation when in background
  32713. */
  32714. disablePerformanceMonitorInBackground: boolean;
  32715. private _performanceMonitor;
  32716. /**
  32717. * Gets the performance monitor attached to this engine
  32718. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  32719. */
  32720. readonly performanceMonitor: PerformanceMonitor;
  32721. private _onFocus;
  32722. private _onBlur;
  32723. private _onCanvasPointerOut;
  32724. private _onCanvasBlur;
  32725. private _onCanvasFocus;
  32726. private _onFullscreenChange;
  32727. private _onPointerLockChange;
  32728. /**
  32729. * Gets the HTML element used to attach event listeners
  32730. * @returns a HTML element
  32731. */
  32732. getInputElement(): Nullable<HTMLElement>;
  32733. /**
  32734. * Creates a new engine
  32735. * @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
  32736. * @param antialias defines enable antialiasing (default: false)
  32737. * @param options defines further options to be sent to the getContext() function
  32738. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  32739. */
  32740. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  32741. /**
  32742. * Gets current aspect ratio
  32743. * @param viewportOwner defines the camera to use to get the aspect ratio
  32744. * @param useScreen defines if screen size must be used (or the current render target if any)
  32745. * @returns a number defining the aspect ratio
  32746. */
  32747. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  32748. /**
  32749. * Gets current screen aspect ratio
  32750. * @returns a number defining the aspect ratio
  32751. */
  32752. getScreenAspectRatio(): number;
  32753. /**
  32754. * Gets the client rect of the HTML canvas attached with the current webGL context
  32755. * @returns a client rectanglee
  32756. */
  32757. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  32758. /**
  32759. * Gets the client rect of the HTML element used for events
  32760. * @returns a client rectanglee
  32761. */
  32762. getInputElementClientRect(): Nullable<ClientRect>;
  32763. /**
  32764. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  32765. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32766. * @returns true if engine is in deterministic lock step mode
  32767. */
  32768. isDeterministicLockStep(): boolean;
  32769. /**
  32770. * Gets the max steps when engine is running in deterministic lock step
  32771. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32772. * @returns the max steps
  32773. */
  32774. getLockstepMaxSteps(): number;
  32775. /**
  32776. * Returns the time in ms between steps when using deterministic lock step.
  32777. * @returns time step in (ms)
  32778. */
  32779. getTimeStep(): number;
  32780. /**
  32781. * Force the mipmap generation for the given render target texture
  32782. * @param texture defines the render target texture to use
  32783. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  32784. */
  32785. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  32786. /** States */
  32787. /**
  32788. * Set various states to the webGL context
  32789. * @param culling defines backface culling state
  32790. * @param zOffset defines the value to apply to zOffset (0 by default)
  32791. * @param force defines if states must be applied even if cache is up to date
  32792. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  32793. */
  32794. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  32795. /**
  32796. * Set the z offset to apply to current rendering
  32797. * @param value defines the offset to apply
  32798. */
  32799. setZOffset(value: number): void;
  32800. /**
  32801. * Gets the current value of the zOffset
  32802. * @returns the current zOffset state
  32803. */
  32804. getZOffset(): number;
  32805. /**
  32806. * Enable or disable depth buffering
  32807. * @param enable defines the state to set
  32808. */
  32809. setDepthBuffer(enable: boolean): void;
  32810. /**
  32811. * Gets a boolean indicating if depth writing is enabled
  32812. * @returns the current depth writing state
  32813. */
  32814. getDepthWrite(): boolean;
  32815. /**
  32816. * Enable or disable depth writing
  32817. * @param enable defines the state to set
  32818. */
  32819. setDepthWrite(enable: boolean): void;
  32820. /**
  32821. * Enable or disable color writing
  32822. * @param enable defines the state to set
  32823. */
  32824. setColorWrite(enable: boolean): void;
  32825. /**
  32826. * Gets a boolean indicating if color writing is enabled
  32827. * @returns the current color writing state
  32828. */
  32829. getColorWrite(): boolean;
  32830. /**
  32831. * Sets alpha constants used by some alpha blending modes
  32832. * @param r defines the red component
  32833. * @param g defines the green component
  32834. * @param b defines the blue component
  32835. * @param a defines the alpha component
  32836. */
  32837. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  32838. /**
  32839. * Sets the current alpha mode
  32840. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  32841. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  32842. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32843. */
  32844. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  32845. /**
  32846. * Gets the current alpha mode
  32847. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32848. * @returns the current alpha mode
  32849. */
  32850. getAlphaMode(): number;
  32851. /**
  32852. * Sets the current alpha equation
  32853. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  32854. */
  32855. setAlphaEquation(equation: number): void;
  32856. /**
  32857. * Gets the current alpha equation.
  32858. * @returns the current alpha equation
  32859. */
  32860. getAlphaEquation(): number;
  32861. /**
  32862. * Gets a boolean indicating if stencil buffer is enabled
  32863. * @returns the current stencil buffer state
  32864. */
  32865. getStencilBuffer(): boolean;
  32866. /**
  32867. * Enable or disable the stencil buffer
  32868. * @param enable defines if the stencil buffer must be enabled or disabled
  32869. */
  32870. setStencilBuffer(enable: boolean): void;
  32871. /**
  32872. * Gets the current stencil mask
  32873. * @returns a number defining the new stencil mask to use
  32874. */
  32875. getStencilMask(): number;
  32876. /**
  32877. * Sets the current stencil mask
  32878. * @param mask defines the new stencil mask to use
  32879. */
  32880. setStencilMask(mask: number): void;
  32881. /**
  32882. * Gets the current stencil function
  32883. * @returns a number defining the stencil function to use
  32884. */
  32885. getStencilFunction(): number;
  32886. /**
  32887. * Gets the current stencil reference value
  32888. * @returns a number defining the stencil reference value to use
  32889. */
  32890. getStencilFunctionReference(): number;
  32891. /**
  32892. * Gets the current stencil mask
  32893. * @returns a number defining the stencil mask to use
  32894. */
  32895. getStencilFunctionMask(): number;
  32896. /**
  32897. * Sets the current stencil function
  32898. * @param stencilFunc defines the new stencil function to use
  32899. */
  32900. setStencilFunction(stencilFunc: number): void;
  32901. /**
  32902. * Sets the current stencil reference
  32903. * @param reference defines the new stencil reference to use
  32904. */
  32905. setStencilFunctionReference(reference: number): void;
  32906. /**
  32907. * Sets the current stencil mask
  32908. * @param mask defines the new stencil mask to use
  32909. */
  32910. setStencilFunctionMask(mask: number): void;
  32911. /**
  32912. * Gets the current stencil operation when stencil fails
  32913. * @returns a number defining stencil operation to use when stencil fails
  32914. */
  32915. getStencilOperationFail(): number;
  32916. /**
  32917. * Gets the current stencil operation when depth fails
  32918. * @returns a number defining stencil operation to use when depth fails
  32919. */
  32920. getStencilOperationDepthFail(): number;
  32921. /**
  32922. * Gets the current stencil operation when stencil passes
  32923. * @returns a number defining stencil operation to use when stencil passes
  32924. */
  32925. getStencilOperationPass(): number;
  32926. /**
  32927. * Sets the stencil operation to use when stencil fails
  32928. * @param operation defines the stencil operation to use when stencil fails
  32929. */
  32930. setStencilOperationFail(operation: number): void;
  32931. /**
  32932. * Sets the stencil operation to use when depth fails
  32933. * @param operation defines the stencil operation to use when depth fails
  32934. */
  32935. setStencilOperationDepthFail(operation: number): void;
  32936. /**
  32937. * Sets the stencil operation to use when stencil passes
  32938. * @param operation defines the stencil operation to use when stencil passes
  32939. */
  32940. setStencilOperationPass(operation: number): void;
  32941. /**
  32942. * Sets a boolean indicating if the dithering state is enabled or disabled
  32943. * @param value defines the dithering state
  32944. */
  32945. setDitheringState(value: boolean): void;
  32946. /**
  32947. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  32948. * @param value defines the rasterizer state
  32949. */
  32950. setRasterizerState(value: boolean): void;
  32951. /**
  32952. * Gets the current depth function
  32953. * @returns a number defining the depth function
  32954. */
  32955. getDepthFunction(): Nullable<number>;
  32956. /**
  32957. * Sets the current depth function
  32958. * @param depthFunc defines the function to use
  32959. */
  32960. setDepthFunction(depthFunc: number): void;
  32961. /**
  32962. * Sets the current depth function to GREATER
  32963. */
  32964. setDepthFunctionToGreater(): void;
  32965. /**
  32966. * Sets the current depth function to GEQUAL
  32967. */
  32968. setDepthFunctionToGreaterOrEqual(): void;
  32969. /**
  32970. * Sets the current depth function to LESS
  32971. */
  32972. setDepthFunctionToLess(): void;
  32973. /**
  32974. * Sets the current depth function to LEQUAL
  32975. */
  32976. setDepthFunctionToLessOrEqual(): void;
  32977. private _cachedStencilBuffer;
  32978. private _cachedStencilFunction;
  32979. private _cachedStencilMask;
  32980. private _cachedStencilOperationPass;
  32981. private _cachedStencilOperationFail;
  32982. private _cachedStencilOperationDepthFail;
  32983. private _cachedStencilReference;
  32984. /**
  32985. * Caches the the state of the stencil buffer
  32986. */
  32987. cacheStencilState(): void;
  32988. /**
  32989. * Restores the state of the stencil buffer
  32990. */
  32991. restoreStencilState(): void;
  32992. /**
  32993. * Directly set the WebGL Viewport
  32994. * @param x defines the x coordinate of the viewport (in screen space)
  32995. * @param y defines the y coordinate of the viewport (in screen space)
  32996. * @param width defines the width of the viewport (in screen space)
  32997. * @param height defines the height of the viewport (in screen space)
  32998. * @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
  32999. */
  33000. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  33001. /**
  33002. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  33003. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33004. * @param y defines the y-coordinate of the corner of the clear rectangle
  33005. * @param width defines the width of the clear rectangle
  33006. * @param height defines the height of the clear rectangle
  33007. * @param clearColor defines the clear color
  33008. */
  33009. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  33010. /**
  33011. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  33012. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33013. * @param y defines the y-coordinate of the corner of the clear rectangle
  33014. * @param width defines the width of the clear rectangle
  33015. * @param height defines the height of the clear rectangle
  33016. */
  33017. enableScissor(x: number, y: number, width: number, height: number): void;
  33018. /**
  33019. * Disable previously set scissor test rectangle
  33020. */
  33021. disableScissor(): void;
  33022. protected _reportDrawCall(): void;
  33023. /**
  33024. * Initializes a webVR display and starts listening to display change events
  33025. * The onVRDisplayChangedObservable will be notified upon these changes
  33026. * @returns The onVRDisplayChangedObservable
  33027. */
  33028. initWebVR(): Observable<IDisplayChangedEventArgs>;
  33029. /** @hidden */
  33030. _prepareVRComponent(): void;
  33031. /** @hidden */
  33032. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  33033. /** @hidden */
  33034. _submitVRFrame(): void;
  33035. /**
  33036. * Call this function to leave webVR mode
  33037. * Will do nothing if webVR is not supported or if there is no webVR device
  33038. * @see http://doc.babylonjs.com/how_to/webvr_camera
  33039. */
  33040. disableVR(): void;
  33041. /**
  33042. * Gets a boolean indicating that the system is in VR mode and is presenting
  33043. * @returns true if VR mode is engaged
  33044. */
  33045. isVRPresenting(): boolean;
  33046. /** @hidden */
  33047. _requestVRFrame(): void;
  33048. /** @hidden */
  33049. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33050. /**
  33051. * Gets the source code of the vertex shader associated with a specific webGL program
  33052. * @param program defines the program to use
  33053. * @returns a string containing the source code of the vertex shader associated with the program
  33054. */
  33055. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  33056. /**
  33057. * Gets the source code of the fragment shader associated with a specific webGL program
  33058. * @param program defines the program to use
  33059. * @returns a string containing the source code of the fragment shader associated with the program
  33060. */
  33061. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  33062. /**
  33063. * Reads pixels from the current frame buffer. Please note that this function can be slow
  33064. * @param x defines the x coordinate of the rectangle where pixels must be read
  33065. * @param y defines the y coordinate of the rectangle where pixels must be read
  33066. * @param width defines the width of the rectangle where pixels must be read
  33067. * @param height defines the height of the rectangle where pixels must be read
  33068. * @returns a Uint8Array containing RGBA colors
  33069. */
  33070. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  33071. /**
  33072. * Sets a depth stencil texture from a render target to the according uniform.
  33073. * @param channel The texture channel
  33074. * @param uniform The uniform to set
  33075. * @param texture The render target texture containing the depth stencil texture to apply
  33076. */
  33077. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  33078. /**
  33079. * Sets a texture to the webGL context from a postprocess
  33080. * @param channel defines the channel to use
  33081. * @param postProcess defines the source postprocess
  33082. */
  33083. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  33084. /**
  33085. * Binds the output of the passed in post process to the texture channel specified
  33086. * @param channel The channel the texture should be bound to
  33087. * @param postProcess The post process which's output should be bound
  33088. */
  33089. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  33090. /** @hidden */
  33091. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  33092. protected _rebuildBuffers(): void;
  33093. /** @hidden */
  33094. _renderFrame(): void;
  33095. _renderLoop(): void;
  33096. /** @hidden */
  33097. _renderViews(): boolean;
  33098. /**
  33099. * Toggle full screen mode
  33100. * @param requestPointerLock defines if a pointer lock should be requested from the user
  33101. */
  33102. switchFullscreen(requestPointerLock: boolean): void;
  33103. /**
  33104. * Enters full screen mode
  33105. * @param requestPointerLock defines if a pointer lock should be requested from the user
  33106. */
  33107. enterFullscreen(requestPointerLock: boolean): void;
  33108. /**
  33109. * Exits full screen mode
  33110. */
  33111. exitFullscreen(): void;
  33112. /**
  33113. * Enters Pointerlock mode
  33114. */
  33115. enterPointerlock(): void;
  33116. /**
  33117. * Exits Pointerlock mode
  33118. */
  33119. exitPointerlock(): void;
  33120. /**
  33121. * Begin a new frame
  33122. */
  33123. beginFrame(): void;
  33124. /**
  33125. * Enf the current frame
  33126. */
  33127. endFrame(): void;
  33128. resize(): void;
  33129. /**
  33130. * Set the compressed texture format to use, based on the formats you have, and the formats
  33131. * supported by the hardware / browser.
  33132. *
  33133. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  33134. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  33135. * to API arguments needed to compressed textures. This puts the burden on the container
  33136. * generator to house the arcane code for determining these for current & future formats.
  33137. *
  33138. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  33139. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  33140. *
  33141. * Note: The result of this call is not taken into account when a texture is base64.
  33142. *
  33143. * @param formatsAvailable defines the list of those format families you have created
  33144. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  33145. *
  33146. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  33147. * @returns The extension selected.
  33148. */
  33149. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  33150. /**
  33151. * Set the compressed texture extensions or file names to skip.
  33152. *
  33153. * @param skippedFiles defines the list of those texture files you want to skip
  33154. * Example: [".dds", ".env", "myfile.png"]
  33155. */
  33156. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  33157. /**
  33158. * Force a specific size of the canvas
  33159. * @param width defines the new canvas' width
  33160. * @param height defines the new canvas' height
  33161. */
  33162. setSize(width: number, height: number): void;
  33163. /**
  33164. * Updates a dynamic vertex buffer.
  33165. * @param vertexBuffer the vertex buffer to update
  33166. * @param data the data used to update the vertex buffer
  33167. * @param byteOffset the byte offset of the data
  33168. * @param byteLength the byte length of the data
  33169. */
  33170. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  33171. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  33172. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33173. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33174. _releaseTexture(texture: InternalTexture): void;
  33175. /**
  33176. * @hidden
  33177. * Rescales a texture
  33178. * @param source input texutre
  33179. * @param destination destination texture
  33180. * @param scene scene to use to render the resize
  33181. * @param internalFormat format to use when resizing
  33182. * @param onComplete callback to be called when resize has completed
  33183. */
  33184. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  33185. /**
  33186. * Gets the current framerate
  33187. * @returns a number representing the framerate
  33188. */
  33189. getFps(): number;
  33190. /**
  33191. * Gets the time spent between current and previous frame
  33192. * @returns a number representing the delta time in ms
  33193. */
  33194. getDeltaTime(): number;
  33195. private _measureFps;
  33196. /** @hidden */
  33197. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  33198. /**
  33199. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  33200. * @param renderTarget The render target to set the frame buffer for
  33201. */
  33202. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  33203. /**
  33204. * Update a dynamic index buffer
  33205. * @param indexBuffer defines the target index buffer
  33206. * @param indices defines the data to update
  33207. * @param offset defines the offset in the target index buffer where update should start
  33208. */
  33209. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  33210. /**
  33211. * Updates the sample count of a render target texture
  33212. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  33213. * @param texture defines the texture to update
  33214. * @param samples defines the sample count to set
  33215. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  33216. */
  33217. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  33218. /**
  33219. * Updates a depth texture Comparison Mode and Function.
  33220. * If the comparison Function is equal to 0, the mode will be set to none.
  33221. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  33222. * @param texture The texture to set the comparison function for
  33223. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  33224. */
  33225. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  33226. /**
  33227. * Creates a webGL buffer to use with instanciation
  33228. * @param capacity defines the size of the buffer
  33229. * @returns the webGL buffer
  33230. */
  33231. createInstancesBuffer(capacity: number): DataBuffer;
  33232. /**
  33233. * Delete a webGL buffer used with instanciation
  33234. * @param buffer defines the webGL buffer to delete
  33235. */
  33236. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  33237. /** @hidden */
  33238. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  33239. dispose(): void;
  33240. private _disableTouchAction;
  33241. /**
  33242. * Display the loading screen
  33243. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33244. */
  33245. displayLoadingUI(): void;
  33246. /**
  33247. * Hide the loading screen
  33248. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33249. */
  33250. hideLoadingUI(): void;
  33251. /**
  33252. * Gets the current loading screen object
  33253. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33254. */
  33255. /**
  33256. * Sets the current loading screen object
  33257. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33258. */
  33259. loadingScreen: ILoadingScreen;
  33260. /**
  33261. * Sets the current loading screen text
  33262. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33263. */
  33264. loadingUIText: string;
  33265. /**
  33266. * Sets the current loading screen background color
  33267. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33268. */
  33269. loadingUIBackgroundColor: string;
  33270. /** Pointerlock and fullscreen */
  33271. /**
  33272. * Ask the browser to promote the current element to pointerlock mode
  33273. * @param element defines the DOM element to promote
  33274. */
  33275. static _RequestPointerlock(element: HTMLElement): void;
  33276. /**
  33277. * Asks the browser to exit pointerlock mode
  33278. */
  33279. static _ExitPointerlock(): void;
  33280. /**
  33281. * Ask the browser to promote the current element to fullscreen rendering mode
  33282. * @param element defines the DOM element to promote
  33283. */
  33284. static _RequestFullscreen(element: HTMLElement): void;
  33285. /**
  33286. * Asks the browser to exit fullscreen mode
  33287. */
  33288. static _ExitFullscreen(): void;
  33289. }
  33290. }
  33291. declare module BABYLON {
  33292. /**
  33293. * The engine store class is responsible to hold all the instances of Engine and Scene created
  33294. * during the life time of the application.
  33295. */
  33296. export class EngineStore {
  33297. /** Gets the list of created engines */
  33298. static Instances: Engine[];
  33299. /** @hidden */
  33300. static _LastCreatedScene: Nullable<Scene>;
  33301. /**
  33302. * Gets the latest created engine
  33303. */
  33304. static readonly LastCreatedEngine: Nullable<Engine>;
  33305. /**
  33306. * Gets the latest created scene
  33307. */
  33308. static readonly LastCreatedScene: Nullable<Scene>;
  33309. /**
  33310. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  33311. * @ignorenaming
  33312. */
  33313. static UseFallbackTexture: boolean;
  33314. /**
  33315. * Texture content used if a texture cannot loaded
  33316. * @ignorenaming
  33317. */
  33318. static FallbackTexture: string;
  33319. }
  33320. }
  33321. declare module BABYLON {
  33322. /**
  33323. * Helper class that provides a small promise polyfill
  33324. */
  33325. export class PromisePolyfill {
  33326. /**
  33327. * Static function used to check if the polyfill is required
  33328. * If this is the case then the function will inject the polyfill to window.Promise
  33329. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  33330. */
  33331. static Apply(force?: boolean): void;
  33332. }
  33333. }
  33334. declare module BABYLON {
  33335. /**
  33336. * Interface for screenshot methods with describe argument called `size` as object with options
  33337. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  33338. */
  33339. export interface IScreenshotSize {
  33340. /**
  33341. * number in pixels for canvas height
  33342. */
  33343. height?: number;
  33344. /**
  33345. * multiplier allowing render at a higher or lower resolution
  33346. * If value is defined then height and width will be ignored and taken from camera
  33347. */
  33348. precision?: number;
  33349. /**
  33350. * number in pixels for canvas width
  33351. */
  33352. width?: number;
  33353. }
  33354. }
  33355. declare module BABYLON {
  33356. interface IColor4Like {
  33357. r: float;
  33358. g: float;
  33359. b: float;
  33360. a: float;
  33361. }
  33362. /**
  33363. * Class containing a set of static utilities functions
  33364. */
  33365. export class Tools {
  33366. /**
  33367. * Gets or sets the base URL to use to load assets
  33368. */
  33369. static BaseUrl: string;
  33370. /**
  33371. * Enable/Disable Custom HTTP Request Headers globally.
  33372. * default = false
  33373. * @see CustomRequestHeaders
  33374. */
  33375. static UseCustomRequestHeaders: boolean;
  33376. /**
  33377. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  33378. * i.e. when loading files, where the server/service expects an Authorization header
  33379. */
  33380. static CustomRequestHeaders: {
  33381. [key: string]: string;
  33382. };
  33383. /**
  33384. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  33385. */
  33386. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  33387. /**
  33388. * Default behaviour for cors in the application.
  33389. * It can be a string if the expected behavior is identical in the entire app.
  33390. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  33391. */
  33392. static CorsBehavior: string | ((url: string | string[]) => string);
  33393. /**
  33394. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  33395. * @ignorenaming
  33396. */
  33397. static UseFallbackTexture: boolean;
  33398. /**
  33399. * Use this object to register external classes like custom textures or material
  33400. * to allow the laoders to instantiate them
  33401. */
  33402. static RegisteredExternalClasses: {
  33403. [key: string]: Object;
  33404. };
  33405. /**
  33406. * Texture content used if a texture cannot loaded
  33407. * @ignorenaming
  33408. */
  33409. static fallbackTexture: string;
  33410. /**
  33411. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  33412. * @param u defines the coordinate on X axis
  33413. * @param v defines the coordinate on Y axis
  33414. * @param width defines the width of the source data
  33415. * @param height defines the height of the source data
  33416. * @param pixels defines the source byte array
  33417. * @param color defines the output color
  33418. */
  33419. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  33420. /**
  33421. * Interpolates between a and b via alpha
  33422. * @param a The lower value (returned when alpha = 0)
  33423. * @param b The upper value (returned when alpha = 1)
  33424. * @param alpha The interpolation-factor
  33425. * @return The mixed value
  33426. */
  33427. static Mix(a: number, b: number, alpha: number): number;
  33428. /**
  33429. * Tries to instantiate a new object from a given class name
  33430. * @param className defines the class name to instantiate
  33431. * @returns the new object or null if the system was not able to do the instantiation
  33432. */
  33433. static Instantiate(className: string): any;
  33434. /**
  33435. * Provides a slice function that will work even on IE
  33436. * @param data defines the array to slice
  33437. * @param start defines the start of the data (optional)
  33438. * @param end defines the end of the data (optional)
  33439. * @returns the new sliced array
  33440. */
  33441. static Slice<T>(data: T, start?: number, end?: number): T;
  33442. /**
  33443. * Polyfill for setImmediate
  33444. * @param action defines the action to execute after the current execution block
  33445. */
  33446. static SetImmediate(action: () => void): void;
  33447. /**
  33448. * Function indicating if a number is an exponent of 2
  33449. * @param value defines the value to test
  33450. * @returns true if the value is an exponent of 2
  33451. */
  33452. static IsExponentOfTwo(value: number): boolean;
  33453. private static _tmpFloatArray;
  33454. /**
  33455. * Returns the nearest 32-bit single precision float representation of a Number
  33456. * @param value A Number. If the parameter is of a different type, it will get converted
  33457. * to a number or to NaN if it cannot be converted
  33458. * @returns number
  33459. */
  33460. static FloatRound(value: number): number;
  33461. /**
  33462. * Extracts the filename from a path
  33463. * @param path defines the path to use
  33464. * @returns the filename
  33465. */
  33466. static GetFilename(path: string): string;
  33467. /**
  33468. * Extracts the "folder" part of a path (everything before the filename).
  33469. * @param uri The URI to extract the info from
  33470. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  33471. * @returns The "folder" part of the path
  33472. */
  33473. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  33474. /**
  33475. * Extracts text content from a DOM element hierarchy
  33476. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  33477. */
  33478. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  33479. /**
  33480. * Convert an angle in radians to degrees
  33481. * @param angle defines the angle to convert
  33482. * @returns the angle in degrees
  33483. */
  33484. static ToDegrees(angle: number): number;
  33485. /**
  33486. * Convert an angle in degrees to radians
  33487. * @param angle defines the angle to convert
  33488. * @returns the angle in radians
  33489. */
  33490. static ToRadians(angle: number): number;
  33491. /**
  33492. * Returns an array if obj is not an array
  33493. * @param obj defines the object to evaluate as an array
  33494. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  33495. * @returns either obj directly if obj is an array or a new array containing obj
  33496. */
  33497. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  33498. /**
  33499. * Gets the pointer prefix to use
  33500. * @returns "pointer" if touch is enabled. Else returns "mouse"
  33501. */
  33502. static GetPointerPrefix(): string;
  33503. /**
  33504. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  33505. * @param url define the url we are trying
  33506. * @param element define the dom element where to configure the cors policy
  33507. */
  33508. static SetCorsBehavior(url: string | string[], element: {
  33509. crossOrigin: string | null;
  33510. }): void;
  33511. /**
  33512. * Removes unwanted characters from an url
  33513. * @param url defines the url to clean
  33514. * @returns the cleaned url
  33515. */
  33516. static CleanUrl(url: string): string;
  33517. /**
  33518. * Gets or sets a function used to pre-process url before using them to load assets
  33519. */
  33520. static PreprocessUrl: (url: string) => string;
  33521. /**
  33522. * Loads an image as an HTMLImageElement.
  33523. * @param input url string, ArrayBuffer, or Blob to load
  33524. * @param onLoad callback called when the image successfully loads
  33525. * @param onError callback called when the image fails to load
  33526. * @param offlineProvider offline provider for caching
  33527. * @param mimeType optional mime type
  33528. * @returns the HTMLImageElement of the loaded image
  33529. */
  33530. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  33531. /**
  33532. * Loads a file from a url
  33533. * @param url url string, ArrayBuffer, or Blob to load
  33534. * @param onSuccess callback called when the file successfully loads
  33535. * @param onProgress callback called while file is loading (if the server supports this mode)
  33536. * @param offlineProvider defines the offline provider for caching
  33537. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  33538. * @param onError callback called when the file fails to load
  33539. * @returns a file request object
  33540. */
  33541. 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;
  33542. /**
  33543. * Loads a file from a url
  33544. * @param url the file url to load
  33545. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  33546. */
  33547. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  33548. /**
  33549. * Load a script (identified by an url). When the url returns, the
  33550. * content of this file is added into a new script element, attached to the DOM (body element)
  33551. * @param scriptUrl defines the url of the script to laod
  33552. * @param onSuccess defines the callback called when the script is loaded
  33553. * @param onError defines the callback to call if an error occurs
  33554. * @param scriptId defines the id of the script element
  33555. */
  33556. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  33557. /**
  33558. * Load an asynchronous script (identified by an url). When the url returns, the
  33559. * content of this file is added into a new script element, attached to the DOM (body element)
  33560. * @param scriptUrl defines the url of the script to laod
  33561. * @param scriptId defines the id of the script element
  33562. * @returns a promise request object
  33563. */
  33564. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  33565. /**
  33566. * Loads a file from a blob
  33567. * @param fileToLoad defines the blob to use
  33568. * @param callback defines the callback to call when data is loaded
  33569. * @param progressCallback defines the callback to call during loading process
  33570. * @returns a file request object
  33571. */
  33572. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  33573. /**
  33574. * Reads a file from a File object
  33575. * @param file defines the file to load
  33576. * @param onSuccess defines the callback to call when data is loaded
  33577. * @param onProgress defines the callback to call during loading process
  33578. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  33579. * @param onError defines the callback to call when an error occurs
  33580. * @returns a file request object
  33581. */
  33582. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  33583. /**
  33584. * Creates a data url from a given string content
  33585. * @param content defines the content to convert
  33586. * @returns the new data url link
  33587. */
  33588. static FileAsURL(content: string): string;
  33589. /**
  33590. * Format the given number to a specific decimal format
  33591. * @param value defines the number to format
  33592. * @param decimals defines the number of decimals to use
  33593. * @returns the formatted string
  33594. */
  33595. static Format(value: number, decimals?: number): string;
  33596. /**
  33597. * Tries to copy an object by duplicating every property
  33598. * @param source defines the source object
  33599. * @param destination defines the target object
  33600. * @param doNotCopyList defines a list of properties to avoid
  33601. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  33602. */
  33603. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  33604. /**
  33605. * Gets a boolean indicating if the given object has no own property
  33606. * @param obj defines the object to test
  33607. * @returns true if object has no own property
  33608. */
  33609. static IsEmpty(obj: any): boolean;
  33610. /**
  33611. * Function used to register events at window level
  33612. * @param windowElement defines the Window object to use
  33613. * @param events defines the events to register
  33614. */
  33615. static RegisterTopRootEvents(windowElement: Window, events: {
  33616. name: string;
  33617. handler: Nullable<(e: FocusEvent) => any>;
  33618. }[]): void;
  33619. /**
  33620. * Function used to unregister events from window level
  33621. * @param windowElement defines the Window object to use
  33622. * @param events defines the events to unregister
  33623. */
  33624. static UnregisterTopRootEvents(windowElement: Window, events: {
  33625. name: string;
  33626. handler: Nullable<(e: FocusEvent) => any>;
  33627. }[]): void;
  33628. /**
  33629. * @ignore
  33630. */
  33631. static _ScreenshotCanvas: HTMLCanvasElement;
  33632. /**
  33633. * Dumps the current bound framebuffer
  33634. * @param width defines the rendering width
  33635. * @param height defines the rendering height
  33636. * @param engine defines the hosting engine
  33637. * @param successCallback defines the callback triggered once the data are available
  33638. * @param mimeType defines the mime type of the result
  33639. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  33640. */
  33641. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33642. /**
  33643. * Converts the canvas data to blob.
  33644. * This acts as a polyfill for browsers not supporting the to blob function.
  33645. * @param canvas Defines the canvas to extract the data from
  33646. * @param successCallback Defines the callback triggered once the data are available
  33647. * @param mimeType Defines the mime type of the result
  33648. */
  33649. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  33650. /**
  33651. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  33652. * @param successCallback defines the callback triggered once the data are available
  33653. * @param mimeType defines the mime type of the result
  33654. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  33655. */
  33656. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33657. /**
  33658. * Downloads a blob in the browser
  33659. * @param blob defines the blob to download
  33660. * @param fileName defines the name of the downloaded file
  33661. */
  33662. static Download(blob: Blob, fileName: string): void;
  33663. /**
  33664. * Captures a screenshot of the current rendering
  33665. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33666. * @param engine defines the rendering engine
  33667. * @param camera defines the source camera
  33668. * @param size This parameter can be set to a single number or to an object with the
  33669. * following (optional) properties: precision, width, height. If a single number is passed,
  33670. * it will be used for both width and height. If an object is passed, the screenshot size
  33671. * will be derived from the parameters. The precision property is a multiplier allowing
  33672. * rendering at a higher or lower resolution
  33673. * @param successCallback defines the callback receives a single parameter which contains the
  33674. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33675. * src parameter of an <img> to display it
  33676. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33677. * Check your browser for supported MIME types
  33678. */
  33679. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  33680. /**
  33681. * Captures a screenshot of the current rendering
  33682. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33683. * @param engine defines the rendering engine
  33684. * @param camera defines the source camera
  33685. * @param size This parameter can be set to a single number or to an object with the
  33686. * following (optional) properties: precision, width, height. If a single number is passed,
  33687. * it will be used for both width and height. If an object is passed, the screenshot size
  33688. * will be derived from the parameters. The precision property is a multiplier allowing
  33689. * rendering at a higher or lower resolution
  33690. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33691. * Check your browser for supported MIME types
  33692. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33693. * to the src parameter of an <img> to display it
  33694. */
  33695. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  33696. /**
  33697. * Generates an image screenshot from the specified camera.
  33698. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33699. * @param engine The engine to use for rendering
  33700. * @param camera The camera to use for rendering
  33701. * @param size This parameter can be set to a single number or to an object with the
  33702. * following (optional) properties: precision, width, height. If a single number is passed,
  33703. * it will be used for both width and height. If an object is passed, the screenshot size
  33704. * will be derived from the parameters. The precision property is a multiplier allowing
  33705. * rendering at a higher or lower resolution
  33706. * @param successCallback The callback receives a single parameter which contains the
  33707. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33708. * src parameter of an <img> to display it
  33709. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33710. * Check your browser for supported MIME types
  33711. * @param samples Texture samples (default: 1)
  33712. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33713. * @param fileName A name for for the downloaded file.
  33714. */
  33715. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  33716. /**
  33717. * Generates an image screenshot from the specified camera.
  33718. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33719. * @param engine The engine to use for rendering
  33720. * @param camera The camera to use for rendering
  33721. * @param size This parameter can be set to a single number or to an object with the
  33722. * following (optional) properties: precision, width, height. If a single number is passed,
  33723. * it will be used for both width and height. If an object is passed, the screenshot size
  33724. * will be derived from the parameters. The precision property is a multiplier allowing
  33725. * rendering at a higher or lower resolution
  33726. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33727. * Check your browser for supported MIME types
  33728. * @param samples Texture samples (default: 1)
  33729. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33730. * @param fileName A name for for the downloaded file.
  33731. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33732. * to the src parameter of an <img> to display it
  33733. */
  33734. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  33735. /**
  33736. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  33737. * Be aware Math.random() could cause collisions, but:
  33738. * "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"
  33739. * @returns a pseudo random id
  33740. */
  33741. static RandomId(): string;
  33742. /**
  33743. * Test if the given uri is a base64 string
  33744. * @param uri The uri to test
  33745. * @return True if the uri is a base64 string or false otherwise
  33746. */
  33747. static IsBase64(uri: string): boolean;
  33748. /**
  33749. * Decode the given base64 uri.
  33750. * @param uri The uri to decode
  33751. * @return The decoded base64 data.
  33752. */
  33753. static DecodeBase64(uri: string): ArrayBuffer;
  33754. /**
  33755. * Gets the absolute url.
  33756. * @param url the input url
  33757. * @return the absolute url
  33758. */
  33759. static GetAbsoluteUrl(url: string): string;
  33760. /**
  33761. * No log
  33762. */
  33763. static readonly NoneLogLevel: number;
  33764. /**
  33765. * Only message logs
  33766. */
  33767. static readonly MessageLogLevel: number;
  33768. /**
  33769. * Only warning logs
  33770. */
  33771. static readonly WarningLogLevel: number;
  33772. /**
  33773. * Only error logs
  33774. */
  33775. static readonly ErrorLogLevel: number;
  33776. /**
  33777. * All logs
  33778. */
  33779. static readonly AllLogLevel: number;
  33780. /**
  33781. * Gets a value indicating the number of loading errors
  33782. * @ignorenaming
  33783. */
  33784. static readonly errorsCount: number;
  33785. /**
  33786. * Callback called when a new log is added
  33787. */
  33788. static OnNewCacheEntry: (entry: string) => void;
  33789. /**
  33790. * Log a message to the console
  33791. * @param message defines the message to log
  33792. */
  33793. static Log(message: string): void;
  33794. /**
  33795. * Write a warning message to the console
  33796. * @param message defines the message to log
  33797. */
  33798. static Warn(message: string): void;
  33799. /**
  33800. * Write an error message to the console
  33801. * @param message defines the message to log
  33802. */
  33803. static Error(message: string): void;
  33804. /**
  33805. * Gets current log cache (list of logs)
  33806. */
  33807. static readonly LogCache: string;
  33808. /**
  33809. * Clears the log cache
  33810. */
  33811. static ClearLogCache(): void;
  33812. /**
  33813. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  33814. */
  33815. static LogLevels: number;
  33816. /**
  33817. * Checks if the window object exists
  33818. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  33819. */
  33820. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  33821. /**
  33822. * No performance log
  33823. */
  33824. static readonly PerformanceNoneLogLevel: number;
  33825. /**
  33826. * Use user marks to log performance
  33827. */
  33828. static readonly PerformanceUserMarkLogLevel: number;
  33829. /**
  33830. * Log performance to the console
  33831. */
  33832. static readonly PerformanceConsoleLogLevel: number;
  33833. private static _performance;
  33834. /**
  33835. * Sets the current performance log level
  33836. */
  33837. static PerformanceLogLevel: number;
  33838. private static _StartPerformanceCounterDisabled;
  33839. private static _EndPerformanceCounterDisabled;
  33840. private static _StartUserMark;
  33841. private static _EndUserMark;
  33842. private static _StartPerformanceConsole;
  33843. private static _EndPerformanceConsole;
  33844. /**
  33845. * Starts a performance counter
  33846. */
  33847. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33848. /**
  33849. * Ends a specific performance coutner
  33850. */
  33851. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33852. /**
  33853. * Gets either window.performance.now() if supported or Date.now() else
  33854. */
  33855. static readonly Now: number;
  33856. /**
  33857. * This method will return the name of the class used to create the instance of the given object.
  33858. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  33859. * @param object the object to get the class name from
  33860. * @param isType defines if the object is actually a type
  33861. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  33862. */
  33863. static GetClassName(object: any, isType?: boolean): string;
  33864. /**
  33865. * Gets the first element of an array satisfying a given predicate
  33866. * @param array defines the array to browse
  33867. * @param predicate defines the predicate to use
  33868. * @returns null if not found or the element
  33869. */
  33870. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  33871. /**
  33872. * This method will return the name of the full name of the class, including its owning module (if any).
  33873. * 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).
  33874. * @param object the object to get the class name from
  33875. * @param isType defines if the object is actually a type
  33876. * @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.
  33877. * @ignorenaming
  33878. */
  33879. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  33880. /**
  33881. * Returns a promise that resolves after the given amount of time.
  33882. * @param delay Number of milliseconds to delay
  33883. * @returns Promise that resolves after the given amount of time
  33884. */
  33885. static DelayAsync(delay: number): Promise<void>;
  33886. }
  33887. /**
  33888. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  33889. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  33890. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  33891. * @param name The name of the class, case should be preserved
  33892. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  33893. */
  33894. export function className(name: string, module?: string): (target: Object) => void;
  33895. /**
  33896. * An implementation of a loop for asynchronous functions.
  33897. */
  33898. export class AsyncLoop {
  33899. /**
  33900. * Defines the number of iterations for the loop
  33901. */
  33902. iterations: number;
  33903. /**
  33904. * Defines the current index of the loop.
  33905. */
  33906. index: number;
  33907. private _done;
  33908. private _fn;
  33909. private _successCallback;
  33910. /**
  33911. * Constructor.
  33912. * @param iterations the number of iterations.
  33913. * @param func the function to run each iteration
  33914. * @param successCallback the callback that will be called upon succesful execution
  33915. * @param offset starting offset.
  33916. */
  33917. constructor(
  33918. /**
  33919. * Defines the number of iterations for the loop
  33920. */
  33921. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  33922. /**
  33923. * Execute the next iteration. Must be called after the last iteration was finished.
  33924. */
  33925. executeNext(): void;
  33926. /**
  33927. * Break the loop and run the success callback.
  33928. */
  33929. breakLoop(): void;
  33930. /**
  33931. * Create and run an async loop.
  33932. * @param iterations the number of iterations.
  33933. * @param fn the function to run each iteration
  33934. * @param successCallback the callback that will be called upon succesful execution
  33935. * @param offset starting offset.
  33936. * @returns the created async loop object
  33937. */
  33938. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  33939. /**
  33940. * A for-loop that will run a given number of iterations synchronous and the rest async.
  33941. * @param iterations total number of iterations
  33942. * @param syncedIterations number of synchronous iterations in each async iteration.
  33943. * @param fn the function to call each iteration.
  33944. * @param callback a success call back that will be called when iterating stops.
  33945. * @param breakFunction a break condition (optional)
  33946. * @param timeout timeout settings for the setTimeout function. default - 0.
  33947. * @returns the created async loop object
  33948. */
  33949. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  33950. }
  33951. }
  33952. declare module BABYLON {
  33953. /**
  33954. * This class implement a typical dictionary using a string as key and the generic type T as value.
  33955. * The underlying implementation relies on an associative array to ensure the best performances.
  33956. * The value can be anything including 'null' but except 'undefined'
  33957. */
  33958. export class StringDictionary<T> {
  33959. /**
  33960. * This will clear this dictionary and copy the content from the 'source' one.
  33961. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  33962. * @param source the dictionary to take the content from and copy to this dictionary
  33963. */
  33964. copyFrom(source: StringDictionary<T>): void;
  33965. /**
  33966. * Get a value based from its key
  33967. * @param key the given key to get the matching value from
  33968. * @return the value if found, otherwise undefined is returned
  33969. */
  33970. get(key: string): T | undefined;
  33971. /**
  33972. * Get a value from its key or add it if it doesn't exist.
  33973. * This method will ensure you that a given key/data will be present in the dictionary.
  33974. * @param key the given key to get the matching value from
  33975. * @param factory the factory that will create the value if the key is not present in the dictionary.
  33976. * The factory will only be invoked if there's no data for the given key.
  33977. * @return the value corresponding to the key.
  33978. */
  33979. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  33980. /**
  33981. * Get a value from its key if present in the dictionary otherwise add it
  33982. * @param key the key to get the value from
  33983. * @param val if there's no such key/value pair in the dictionary add it with this value
  33984. * @return the value corresponding to the key
  33985. */
  33986. getOrAdd(key: string, val: T): T;
  33987. /**
  33988. * Check if there's a given key in the dictionary
  33989. * @param key the key to check for
  33990. * @return true if the key is present, false otherwise
  33991. */
  33992. contains(key: string): boolean;
  33993. /**
  33994. * Add a new key and its corresponding value
  33995. * @param key the key to add
  33996. * @param value the value corresponding to the key
  33997. * @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
  33998. */
  33999. add(key: string, value: T): boolean;
  34000. /**
  34001. * Update a specific value associated to a key
  34002. * @param key defines the key to use
  34003. * @param value defines the value to store
  34004. * @returns true if the value was updated (or false if the key was not found)
  34005. */
  34006. set(key: string, value: T): boolean;
  34007. /**
  34008. * Get the element of the given key and remove it from the dictionary
  34009. * @param key defines the key to search
  34010. * @returns the value associated with the key or null if not found
  34011. */
  34012. getAndRemove(key: string): Nullable<T>;
  34013. /**
  34014. * Remove a key/value from the dictionary.
  34015. * @param key the key to remove
  34016. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  34017. */
  34018. remove(key: string): boolean;
  34019. /**
  34020. * Clear the whole content of the dictionary
  34021. */
  34022. clear(): void;
  34023. /**
  34024. * Gets the current count
  34025. */
  34026. readonly count: number;
  34027. /**
  34028. * Execute a callback on each key/val of the dictionary.
  34029. * Note that you can remove any element in this dictionary in the callback implementation
  34030. * @param callback the callback to execute on a given key/value pair
  34031. */
  34032. forEach(callback: (key: string, val: T) => void): void;
  34033. /**
  34034. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  34035. * If the callback returns null or undefined the method will iterate to the next key/value pair
  34036. * Note that you can remove any element in this dictionary in the callback implementation
  34037. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  34038. * @returns the first item
  34039. */
  34040. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  34041. private _count;
  34042. private _data;
  34043. }
  34044. }
  34045. declare module BABYLON {
  34046. /** @hidden */
  34047. export interface ICollisionCoordinator {
  34048. createCollider(): Collider;
  34049. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  34050. init(scene: Scene): void;
  34051. }
  34052. /** @hidden */
  34053. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  34054. private _scene;
  34055. private _scaledPosition;
  34056. private _scaledVelocity;
  34057. private _finalPosition;
  34058. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  34059. createCollider(): Collider;
  34060. init(scene: Scene): void;
  34061. private _collideWithWorld;
  34062. }
  34063. }
  34064. declare module BABYLON {
  34065. /**
  34066. * Class used to manage all inputs for the scene.
  34067. */
  34068. export class InputManager {
  34069. /** The distance in pixel that you have to move to prevent some events */
  34070. static DragMovementThreshold: number;
  34071. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  34072. static LongPressDelay: number;
  34073. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  34074. static DoubleClickDelay: number;
  34075. /** If you need to check double click without raising a single click at first click, enable this flag */
  34076. static ExclusiveDoubleClickMode: boolean;
  34077. private _wheelEventName;
  34078. private _onPointerMove;
  34079. private _onPointerDown;
  34080. private _onPointerUp;
  34081. private _initClickEvent;
  34082. private _initActionManager;
  34083. private _delayedSimpleClick;
  34084. private _delayedSimpleClickTimeout;
  34085. private _previousDelayedSimpleClickTimeout;
  34086. private _meshPickProceed;
  34087. private _previousButtonPressed;
  34088. private _currentPickResult;
  34089. private _previousPickResult;
  34090. private _totalPointersPressed;
  34091. private _doubleClickOccured;
  34092. private _pointerOverMesh;
  34093. private _pickedDownMesh;
  34094. private _pickedUpMesh;
  34095. private _pointerX;
  34096. private _pointerY;
  34097. private _unTranslatedPointerX;
  34098. private _unTranslatedPointerY;
  34099. private _startingPointerPosition;
  34100. private _previousStartingPointerPosition;
  34101. private _startingPointerTime;
  34102. private _previousStartingPointerTime;
  34103. private _pointerCaptures;
  34104. private _onKeyDown;
  34105. private _onKeyUp;
  34106. private _onCanvasFocusObserver;
  34107. private _onCanvasBlurObserver;
  34108. private _scene;
  34109. /**
  34110. * Creates a new InputManager
  34111. * @param scene defines the hosting scene
  34112. */
  34113. constructor(scene: Scene);
  34114. /**
  34115. * Gets the mesh that is currently under the pointer
  34116. */
  34117. readonly meshUnderPointer: Nullable<AbstractMesh>;
  34118. /**
  34119. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  34120. */
  34121. readonly unTranslatedPointer: Vector2;
  34122. /**
  34123. * Gets or sets the current on-screen X position of the pointer
  34124. */
  34125. pointerX: number;
  34126. /**
  34127. * Gets or sets the current on-screen Y position of the pointer
  34128. */
  34129. pointerY: number;
  34130. private _updatePointerPosition;
  34131. private _processPointerMove;
  34132. private _setRayOnPointerInfo;
  34133. private _checkPrePointerObservable;
  34134. /**
  34135. * Use this method to simulate a pointer move on a mesh
  34136. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34137. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34138. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34139. */
  34140. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  34141. /**
  34142. * Use this method to simulate a pointer down on a mesh
  34143. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34144. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34145. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34146. */
  34147. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  34148. private _processPointerDown;
  34149. /** @hidden */
  34150. _isPointerSwiping(): boolean;
  34151. /**
  34152. * Use this method to simulate a pointer up on a mesh
  34153. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34154. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34155. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34156. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34157. */
  34158. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  34159. private _processPointerUp;
  34160. /**
  34161. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34162. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34163. * @returns true if the pointer was captured
  34164. */
  34165. isPointerCaptured(pointerId?: number): boolean;
  34166. /**
  34167. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34168. * @param attachUp defines if you want to attach events to pointerup
  34169. * @param attachDown defines if you want to attach events to pointerdown
  34170. * @param attachMove defines if you want to attach events to pointermove
  34171. */
  34172. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34173. /**
  34174. * Detaches all event handlers
  34175. */
  34176. detachControl(): void;
  34177. /**
  34178. * Force the value of meshUnderPointer
  34179. * @param mesh defines the mesh to use
  34180. */
  34181. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34182. /**
  34183. * Gets the mesh under the pointer
  34184. * @returns a Mesh or null if no mesh is under the pointer
  34185. */
  34186. getPointerOverMesh(): Nullable<AbstractMesh>;
  34187. }
  34188. }
  34189. declare module BABYLON {
  34190. /**
  34191. * Helper class used to generate session unique ID
  34192. */
  34193. export class UniqueIdGenerator {
  34194. private static _UniqueIdCounter;
  34195. /**
  34196. * Gets an unique (relatively to the current scene) Id
  34197. */
  34198. static readonly UniqueId: number;
  34199. }
  34200. }
  34201. declare module BABYLON {
  34202. /**
  34203. * This class defines the direct association between an animation and a target
  34204. */
  34205. export class TargetedAnimation {
  34206. /**
  34207. * Animation to perform
  34208. */
  34209. animation: Animation;
  34210. /**
  34211. * Target to animate
  34212. */
  34213. target: any;
  34214. /**
  34215. * Serialize the object
  34216. * @returns the JSON object representing the current entity
  34217. */
  34218. serialize(): any;
  34219. }
  34220. /**
  34221. * Use this class to create coordinated animations on multiple targets
  34222. */
  34223. export class AnimationGroup implements IDisposable {
  34224. /** The name of the animation group */
  34225. name: string;
  34226. private _scene;
  34227. private _targetedAnimations;
  34228. private _animatables;
  34229. private _from;
  34230. private _to;
  34231. private _isStarted;
  34232. private _isPaused;
  34233. private _speedRatio;
  34234. private _loopAnimation;
  34235. /**
  34236. * Gets or sets the unique id of the node
  34237. */
  34238. uniqueId: number;
  34239. /**
  34240. * This observable will notify when one animation have ended
  34241. */
  34242. onAnimationEndObservable: Observable<TargetedAnimation>;
  34243. /**
  34244. * Observer raised when one animation loops
  34245. */
  34246. onAnimationLoopObservable: Observable<TargetedAnimation>;
  34247. /**
  34248. * Observer raised when all animations have looped
  34249. */
  34250. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  34251. /**
  34252. * This observable will notify when all animations have ended.
  34253. */
  34254. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  34255. /**
  34256. * This observable will notify when all animations have paused.
  34257. */
  34258. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  34259. /**
  34260. * This observable will notify when all animations are playing.
  34261. */
  34262. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  34263. /**
  34264. * Gets the first frame
  34265. */
  34266. readonly from: number;
  34267. /**
  34268. * Gets the last frame
  34269. */
  34270. readonly to: number;
  34271. /**
  34272. * Define if the animations are started
  34273. */
  34274. readonly isStarted: boolean;
  34275. /**
  34276. * Gets a value indicating that the current group is playing
  34277. */
  34278. readonly isPlaying: boolean;
  34279. /**
  34280. * Gets or sets the speed ratio to use for all animations
  34281. */
  34282. /**
  34283. * Gets or sets the speed ratio to use for all animations
  34284. */
  34285. speedRatio: number;
  34286. /**
  34287. * Gets or sets if all animations should loop or not
  34288. */
  34289. loopAnimation: boolean;
  34290. /**
  34291. * Gets the targeted animations for this animation group
  34292. */
  34293. readonly targetedAnimations: Array<TargetedAnimation>;
  34294. /**
  34295. * returning the list of animatables controlled by this animation group.
  34296. */
  34297. readonly animatables: Array<Animatable>;
  34298. /**
  34299. * Instantiates a new Animation Group.
  34300. * This helps managing several animations at once.
  34301. * @see http://doc.babylonjs.com/how_to/group
  34302. * @param name Defines the name of the group
  34303. * @param scene Defines the scene the group belongs to
  34304. */
  34305. constructor(
  34306. /** The name of the animation group */
  34307. name: string, scene?: Nullable<Scene>);
  34308. /**
  34309. * Add an animation (with its target) in the group
  34310. * @param animation defines the animation we want to add
  34311. * @param target defines the target of the animation
  34312. * @returns the TargetedAnimation object
  34313. */
  34314. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  34315. /**
  34316. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  34317. * It can add constant keys at begin or end
  34318. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  34319. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  34320. * @returns the animation group
  34321. */
  34322. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  34323. private _animationLoopCount;
  34324. private _animationLoopFlags;
  34325. private _processLoop;
  34326. /**
  34327. * Start all animations on given targets
  34328. * @param loop defines if animations must loop
  34329. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  34330. * @param from defines the from key (optional)
  34331. * @param to defines the to key (optional)
  34332. * @returns the current animation group
  34333. */
  34334. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  34335. /**
  34336. * Pause all animations
  34337. * @returns the animation group
  34338. */
  34339. pause(): AnimationGroup;
  34340. /**
  34341. * Play all animations to initial state
  34342. * This function will start() the animations if they were not started or will restart() them if they were paused
  34343. * @param loop defines if animations must loop
  34344. * @returns the animation group
  34345. */
  34346. play(loop?: boolean): AnimationGroup;
  34347. /**
  34348. * Reset all animations to initial state
  34349. * @returns the animation group
  34350. */
  34351. reset(): AnimationGroup;
  34352. /**
  34353. * Restart animations from key 0
  34354. * @returns the animation group
  34355. */
  34356. restart(): AnimationGroup;
  34357. /**
  34358. * Stop all animations
  34359. * @returns the animation group
  34360. */
  34361. stop(): AnimationGroup;
  34362. /**
  34363. * Set animation weight for all animatables
  34364. * @param weight defines the weight to use
  34365. * @return the animationGroup
  34366. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  34367. */
  34368. setWeightForAllAnimatables(weight: number): AnimationGroup;
  34369. /**
  34370. * Synchronize and normalize all animatables with a source animatable
  34371. * @param root defines the root animatable to synchronize with
  34372. * @return the animationGroup
  34373. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  34374. */
  34375. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  34376. /**
  34377. * Goes to a specific frame in this animation group
  34378. * @param frame the frame number to go to
  34379. * @return the animationGroup
  34380. */
  34381. goToFrame(frame: number): AnimationGroup;
  34382. /**
  34383. * Dispose all associated resources
  34384. */
  34385. dispose(): void;
  34386. private _checkAnimationGroupEnded;
  34387. /**
  34388. * Clone the current animation group and returns a copy
  34389. * @param newName defines the name of the new group
  34390. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  34391. * @returns the new aniamtion group
  34392. */
  34393. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  34394. /**
  34395. * Serializes the animationGroup to an object
  34396. * @returns Serialized object
  34397. */
  34398. serialize(): any;
  34399. /**
  34400. * Returns a new AnimationGroup object parsed from the source provided.
  34401. * @param parsedAnimationGroup defines the source
  34402. * @param scene defines the scene that will receive the animationGroup
  34403. * @returns a new AnimationGroup
  34404. */
  34405. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  34406. /**
  34407. * Returns the string "AnimationGroup"
  34408. * @returns "AnimationGroup"
  34409. */
  34410. getClassName(): string;
  34411. /**
  34412. * Creates a detailled string about the object
  34413. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  34414. * @returns a string representing the object
  34415. */
  34416. toString(fullDetails?: boolean): string;
  34417. }
  34418. }
  34419. declare module BABYLON {
  34420. /**
  34421. * Define an interface for all classes that will hold resources
  34422. */
  34423. export interface IDisposable {
  34424. /**
  34425. * Releases all held resources
  34426. */
  34427. dispose(): void;
  34428. }
  34429. /** Interface defining initialization parameters for Scene class */
  34430. export interface SceneOptions {
  34431. /**
  34432. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  34433. * It will improve performance when the number of geometries becomes important.
  34434. */
  34435. useGeometryUniqueIdsMap?: boolean;
  34436. /**
  34437. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  34438. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  34439. */
  34440. useMaterialMeshMap?: boolean;
  34441. /**
  34442. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  34443. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  34444. */
  34445. useClonedMeshhMap?: boolean;
  34446. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  34447. virtual?: boolean;
  34448. }
  34449. /**
  34450. * Represents a scene to be rendered by the engine.
  34451. * @see http://doc.babylonjs.com/features/scene
  34452. */
  34453. export class Scene extends AbstractScene implements IAnimatable {
  34454. /** The fog is deactivated */
  34455. static readonly FOGMODE_NONE: number;
  34456. /** The fog density is following an exponential function */
  34457. static readonly FOGMODE_EXP: number;
  34458. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  34459. static readonly FOGMODE_EXP2: number;
  34460. /** The fog density is following a linear function. */
  34461. static readonly FOGMODE_LINEAR: number;
  34462. /**
  34463. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  34464. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34465. */
  34466. static MinDeltaTime: number;
  34467. /**
  34468. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  34469. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34470. */
  34471. static MaxDeltaTime: number;
  34472. /**
  34473. * Factory used to create the default material.
  34474. * @param name The name of the material to create
  34475. * @param scene The scene to create the material for
  34476. * @returns The default material
  34477. */
  34478. static DefaultMaterialFactory(scene: Scene): Material;
  34479. /**
  34480. * Factory used to create the a collision coordinator.
  34481. * @returns The collision coordinator
  34482. */
  34483. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  34484. /** @hidden */
  34485. _inputManager: InputManager;
  34486. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  34487. cameraToUseForPointers: Nullable<Camera>;
  34488. /** @hidden */
  34489. readonly _isScene: boolean;
  34490. /**
  34491. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  34492. */
  34493. autoClear: boolean;
  34494. /**
  34495. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  34496. */
  34497. autoClearDepthAndStencil: boolean;
  34498. /**
  34499. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  34500. */
  34501. clearColor: Color4;
  34502. /**
  34503. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  34504. */
  34505. ambientColor: Color3;
  34506. /**
  34507. * This is use to store the default BRDF lookup for PBR materials in your scene.
  34508. * It should only be one of the following (if not the default embedded one):
  34509. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  34510. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  34511. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  34512. * The material properties need to be setup according to the type of texture in use.
  34513. */
  34514. environmentBRDFTexture: BaseTexture;
  34515. /** @hidden */
  34516. protected _environmentTexture: Nullable<BaseTexture>;
  34517. /**
  34518. * Texture used in all pbr material as the reflection texture.
  34519. * As in the majority of the scene they are the same (exception for multi room and so on),
  34520. * this is easier to reference from here than from all the materials.
  34521. */
  34522. /**
  34523. * Texture used in all pbr material as the reflection texture.
  34524. * As in the majority of the scene they are the same (exception for multi room and so on),
  34525. * this is easier to set here than in all the materials.
  34526. */
  34527. environmentTexture: Nullable<BaseTexture>;
  34528. /** @hidden */
  34529. protected _environmentIntensity: number;
  34530. /**
  34531. * Intensity of the environment in all pbr material.
  34532. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34533. * As in the majority of the scene they are the same (exception for multi room and so on),
  34534. * this is easier to reference from here than from all the materials.
  34535. */
  34536. /**
  34537. * Intensity of the environment in all pbr material.
  34538. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34539. * As in the majority of the scene they are the same (exception for multi room and so on),
  34540. * this is easier to set here than in all the materials.
  34541. */
  34542. environmentIntensity: number;
  34543. /** @hidden */
  34544. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  34545. /**
  34546. * Default image processing configuration used either in the rendering
  34547. * Forward main pass or through the imageProcessingPostProcess if present.
  34548. * As in the majority of the scene they are the same (exception for multi camera),
  34549. * this is easier to reference from here than from all the materials and post process.
  34550. *
  34551. * No setter as we it is a shared configuration, you can set the values instead.
  34552. */
  34553. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  34554. private _forceWireframe;
  34555. /**
  34556. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  34557. */
  34558. forceWireframe: boolean;
  34559. private _forcePointsCloud;
  34560. /**
  34561. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  34562. */
  34563. forcePointsCloud: boolean;
  34564. /**
  34565. * Gets or sets the active clipplane 1
  34566. */
  34567. clipPlane: Nullable<Plane>;
  34568. /**
  34569. * Gets or sets the active clipplane 2
  34570. */
  34571. clipPlane2: Nullable<Plane>;
  34572. /**
  34573. * Gets or sets the active clipplane 3
  34574. */
  34575. clipPlane3: Nullable<Plane>;
  34576. /**
  34577. * Gets or sets the active clipplane 4
  34578. */
  34579. clipPlane4: Nullable<Plane>;
  34580. /**
  34581. * Gets or sets a boolean indicating if animations are enabled
  34582. */
  34583. animationsEnabled: boolean;
  34584. private _animationPropertiesOverride;
  34585. /**
  34586. * Gets or sets the animation properties override
  34587. */
  34588. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  34589. /**
  34590. * Gets or sets a boolean indicating if a constant deltatime has to be used
  34591. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  34592. */
  34593. useConstantAnimationDeltaTime: boolean;
  34594. /**
  34595. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  34596. * Please note that it requires to run a ray cast through the scene on every frame
  34597. */
  34598. constantlyUpdateMeshUnderPointer: boolean;
  34599. /**
  34600. * Defines the HTML cursor to use when hovering over interactive elements
  34601. */
  34602. hoverCursor: string;
  34603. /**
  34604. * Defines the HTML default cursor to use (empty by default)
  34605. */
  34606. defaultCursor: string;
  34607. /**
  34608. * Defines wether cursors are handled by the scene.
  34609. */
  34610. doNotHandleCursors: boolean;
  34611. /**
  34612. * This is used to call preventDefault() on pointer down
  34613. * in order to block unwanted artifacts like system double clicks
  34614. */
  34615. preventDefaultOnPointerDown: boolean;
  34616. /**
  34617. * This is used to call preventDefault() on pointer up
  34618. * in order to block unwanted artifacts like system double clicks
  34619. */
  34620. preventDefaultOnPointerUp: boolean;
  34621. /**
  34622. * Gets or sets user defined metadata
  34623. */
  34624. metadata: any;
  34625. /**
  34626. * For internal use only. Please do not use.
  34627. */
  34628. reservedDataStore: any;
  34629. /**
  34630. * Gets the name of the plugin used to load this scene (null by default)
  34631. */
  34632. loadingPluginName: string;
  34633. /**
  34634. * Use this array to add regular expressions used to disable offline support for specific urls
  34635. */
  34636. disableOfflineSupportExceptionRules: RegExp[];
  34637. /**
  34638. * An event triggered when the scene is disposed.
  34639. */
  34640. onDisposeObservable: Observable<Scene>;
  34641. private _onDisposeObserver;
  34642. /** Sets a function to be executed when this scene is disposed. */
  34643. onDispose: () => void;
  34644. /**
  34645. * An event triggered before rendering the scene (right after animations and physics)
  34646. */
  34647. onBeforeRenderObservable: Observable<Scene>;
  34648. private _onBeforeRenderObserver;
  34649. /** Sets a function to be executed before rendering this scene */
  34650. beforeRender: Nullable<() => void>;
  34651. /**
  34652. * An event triggered after rendering the scene
  34653. */
  34654. onAfterRenderObservable: Observable<Scene>;
  34655. /**
  34656. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  34657. */
  34658. onAfterRenderCameraObservable: Observable<Camera>;
  34659. private _onAfterRenderObserver;
  34660. /** Sets a function to be executed after rendering this scene */
  34661. afterRender: Nullable<() => void>;
  34662. /**
  34663. * An event triggered before animating the scene
  34664. */
  34665. onBeforeAnimationsObservable: Observable<Scene>;
  34666. /**
  34667. * An event triggered after animations processing
  34668. */
  34669. onAfterAnimationsObservable: Observable<Scene>;
  34670. /**
  34671. * An event triggered before draw calls are ready to be sent
  34672. */
  34673. onBeforeDrawPhaseObservable: Observable<Scene>;
  34674. /**
  34675. * An event triggered after draw calls have been sent
  34676. */
  34677. onAfterDrawPhaseObservable: Observable<Scene>;
  34678. /**
  34679. * An event triggered when the scene is ready
  34680. */
  34681. onReadyObservable: Observable<Scene>;
  34682. /**
  34683. * An event triggered before rendering a camera
  34684. */
  34685. onBeforeCameraRenderObservable: Observable<Camera>;
  34686. private _onBeforeCameraRenderObserver;
  34687. /** Sets a function to be executed before rendering a camera*/
  34688. beforeCameraRender: () => void;
  34689. /**
  34690. * An event triggered after rendering a camera
  34691. */
  34692. onAfterCameraRenderObservable: Observable<Camera>;
  34693. private _onAfterCameraRenderObserver;
  34694. /** Sets a function to be executed after rendering a camera*/
  34695. afterCameraRender: () => void;
  34696. /**
  34697. * An event triggered when active meshes evaluation is about to start
  34698. */
  34699. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  34700. /**
  34701. * An event triggered when active meshes evaluation is done
  34702. */
  34703. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  34704. /**
  34705. * An event triggered when particles rendering is about to start
  34706. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34707. */
  34708. onBeforeParticlesRenderingObservable: Observable<Scene>;
  34709. /**
  34710. * An event triggered when particles rendering is done
  34711. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34712. */
  34713. onAfterParticlesRenderingObservable: Observable<Scene>;
  34714. /**
  34715. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  34716. */
  34717. onDataLoadedObservable: Observable<Scene>;
  34718. /**
  34719. * An event triggered when a camera is created
  34720. */
  34721. onNewCameraAddedObservable: Observable<Camera>;
  34722. /**
  34723. * An event triggered when a camera is removed
  34724. */
  34725. onCameraRemovedObservable: Observable<Camera>;
  34726. /**
  34727. * An event triggered when a light is created
  34728. */
  34729. onNewLightAddedObservable: Observable<Light>;
  34730. /**
  34731. * An event triggered when a light is removed
  34732. */
  34733. onLightRemovedObservable: Observable<Light>;
  34734. /**
  34735. * An event triggered when a geometry is created
  34736. */
  34737. onNewGeometryAddedObservable: Observable<Geometry>;
  34738. /**
  34739. * An event triggered when a geometry is removed
  34740. */
  34741. onGeometryRemovedObservable: Observable<Geometry>;
  34742. /**
  34743. * An event triggered when a transform node is created
  34744. */
  34745. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  34746. /**
  34747. * An event triggered when a transform node is removed
  34748. */
  34749. onTransformNodeRemovedObservable: Observable<TransformNode>;
  34750. /**
  34751. * An event triggered when a mesh is created
  34752. */
  34753. onNewMeshAddedObservable: Observable<AbstractMesh>;
  34754. /**
  34755. * An event triggered when a mesh is removed
  34756. */
  34757. onMeshRemovedObservable: Observable<AbstractMesh>;
  34758. /**
  34759. * An event triggered when a skeleton is created
  34760. */
  34761. onNewSkeletonAddedObservable: Observable<Skeleton>;
  34762. /**
  34763. * An event triggered when a skeleton is removed
  34764. */
  34765. onSkeletonRemovedObservable: Observable<Skeleton>;
  34766. /**
  34767. * An event triggered when a material is created
  34768. */
  34769. onNewMaterialAddedObservable: Observable<Material>;
  34770. /**
  34771. * An event triggered when a material is removed
  34772. */
  34773. onMaterialRemovedObservable: Observable<Material>;
  34774. /**
  34775. * An event triggered when a texture is created
  34776. */
  34777. onNewTextureAddedObservable: Observable<BaseTexture>;
  34778. /**
  34779. * An event triggered when a texture is removed
  34780. */
  34781. onTextureRemovedObservable: Observable<BaseTexture>;
  34782. /**
  34783. * An event triggered when render targets are about to be rendered
  34784. * Can happen multiple times per frame.
  34785. */
  34786. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  34787. /**
  34788. * An event triggered when render targets were rendered.
  34789. * Can happen multiple times per frame.
  34790. */
  34791. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  34792. /**
  34793. * An event triggered before calculating deterministic simulation step
  34794. */
  34795. onBeforeStepObservable: Observable<Scene>;
  34796. /**
  34797. * An event triggered after calculating deterministic simulation step
  34798. */
  34799. onAfterStepObservable: Observable<Scene>;
  34800. /**
  34801. * An event triggered when the activeCamera property is updated
  34802. */
  34803. onActiveCameraChanged: Observable<Scene>;
  34804. /**
  34805. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  34806. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34807. * 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)
  34808. */
  34809. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34810. /**
  34811. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  34812. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34813. * 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)
  34814. */
  34815. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34816. /**
  34817. * This Observable will when a mesh has been imported into the scene.
  34818. */
  34819. onMeshImportedObservable: Observable<AbstractMesh>;
  34820. /**
  34821. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  34822. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  34823. */
  34824. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  34825. /** @hidden */
  34826. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  34827. /**
  34828. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  34829. */
  34830. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  34831. /**
  34832. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  34833. */
  34834. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  34835. /**
  34836. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  34837. */
  34838. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  34839. /** Callback called when a pointer move is detected */
  34840. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34841. /** Callback called when a pointer down is detected */
  34842. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34843. /** Callback called when a pointer up is detected */
  34844. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  34845. /** Callback called when a pointer pick is detected */
  34846. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  34847. /**
  34848. * 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).
  34849. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  34850. */
  34851. onPrePointerObservable: Observable<PointerInfoPre>;
  34852. /**
  34853. * Observable event triggered each time an input event is received from the rendering canvas
  34854. */
  34855. onPointerObservable: Observable<PointerInfo>;
  34856. /**
  34857. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  34858. */
  34859. readonly unTranslatedPointer: Vector2;
  34860. /**
  34861. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  34862. */
  34863. static DragMovementThreshold: number;
  34864. /**
  34865. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  34866. */
  34867. static LongPressDelay: number;
  34868. /**
  34869. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  34870. */
  34871. static DoubleClickDelay: number;
  34872. /** If you need to check double click without raising a single click at first click, enable this flag */
  34873. static ExclusiveDoubleClickMode: boolean;
  34874. /** @hidden */
  34875. _mirroredCameraPosition: Nullable<Vector3>;
  34876. /**
  34877. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  34878. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  34879. */
  34880. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  34881. /**
  34882. * Observable event triggered each time an keyboard event is received from the hosting window
  34883. */
  34884. onKeyboardObservable: Observable<KeyboardInfo>;
  34885. private _useRightHandedSystem;
  34886. /**
  34887. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  34888. */
  34889. useRightHandedSystem: boolean;
  34890. private _timeAccumulator;
  34891. private _currentStepId;
  34892. private _currentInternalStep;
  34893. /**
  34894. * Sets the step Id used by deterministic lock step
  34895. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34896. * @param newStepId defines the step Id
  34897. */
  34898. setStepId(newStepId: number): void;
  34899. /**
  34900. * Gets the step Id used by deterministic lock step
  34901. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34902. * @returns the step Id
  34903. */
  34904. getStepId(): number;
  34905. /**
  34906. * Gets the internal step used by deterministic lock step
  34907. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34908. * @returns the internal step
  34909. */
  34910. getInternalStep(): number;
  34911. private _fogEnabled;
  34912. /**
  34913. * Gets or sets a boolean indicating if fog is enabled on this scene
  34914. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34915. * (Default is true)
  34916. */
  34917. fogEnabled: boolean;
  34918. private _fogMode;
  34919. /**
  34920. * Gets or sets the fog mode to use
  34921. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34922. * | mode | value |
  34923. * | --- | --- |
  34924. * | FOGMODE_NONE | 0 |
  34925. * | FOGMODE_EXP | 1 |
  34926. * | FOGMODE_EXP2 | 2 |
  34927. * | FOGMODE_LINEAR | 3 |
  34928. */
  34929. fogMode: number;
  34930. /**
  34931. * Gets or sets the fog color to use
  34932. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34933. * (Default is Color3(0.2, 0.2, 0.3))
  34934. */
  34935. fogColor: Color3;
  34936. /**
  34937. * Gets or sets the fog density to use
  34938. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34939. * (Default is 0.1)
  34940. */
  34941. fogDensity: number;
  34942. /**
  34943. * Gets or sets the fog start distance to use
  34944. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34945. * (Default is 0)
  34946. */
  34947. fogStart: number;
  34948. /**
  34949. * Gets or sets the fog end distance to use
  34950. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34951. * (Default is 1000)
  34952. */
  34953. fogEnd: number;
  34954. private _shadowsEnabled;
  34955. /**
  34956. * Gets or sets a boolean indicating if shadows are enabled on this scene
  34957. */
  34958. shadowsEnabled: boolean;
  34959. private _lightsEnabled;
  34960. /**
  34961. * Gets or sets a boolean indicating if lights are enabled on this scene
  34962. */
  34963. lightsEnabled: boolean;
  34964. /** All of the active cameras added to this scene. */
  34965. activeCameras: Camera[];
  34966. /** @hidden */
  34967. _activeCamera: Nullable<Camera>;
  34968. /** Gets or sets the current active camera */
  34969. activeCamera: Nullable<Camera>;
  34970. private _defaultMaterial;
  34971. /** The default material used on meshes when no material is affected */
  34972. /** The default material used on meshes when no material is affected */
  34973. defaultMaterial: Material;
  34974. private _texturesEnabled;
  34975. /**
  34976. * Gets or sets a boolean indicating if textures are enabled on this scene
  34977. */
  34978. texturesEnabled: boolean;
  34979. /**
  34980. * Gets or sets a boolean indicating if particles are enabled on this scene
  34981. */
  34982. particlesEnabled: boolean;
  34983. /**
  34984. * Gets or sets a boolean indicating if sprites are enabled on this scene
  34985. */
  34986. spritesEnabled: boolean;
  34987. private _skeletonsEnabled;
  34988. /**
  34989. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  34990. */
  34991. skeletonsEnabled: boolean;
  34992. /**
  34993. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  34994. */
  34995. lensFlaresEnabled: boolean;
  34996. /**
  34997. * Gets or sets a boolean indicating if collisions are enabled on this scene
  34998. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34999. */
  35000. collisionsEnabled: boolean;
  35001. private _collisionCoordinator;
  35002. /** @hidden */
  35003. readonly collisionCoordinator: ICollisionCoordinator;
  35004. /**
  35005. * Defines the gravity applied to this scene (used only for collisions)
  35006. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35007. */
  35008. gravity: Vector3;
  35009. /**
  35010. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  35011. */
  35012. postProcessesEnabled: boolean;
  35013. /**
  35014. * The list of postprocesses added to the scene
  35015. */
  35016. postProcesses: PostProcess[];
  35017. /**
  35018. * Gets the current postprocess manager
  35019. */
  35020. postProcessManager: PostProcessManager;
  35021. /**
  35022. * Gets or sets a boolean indicating if render targets are enabled on this scene
  35023. */
  35024. renderTargetsEnabled: boolean;
  35025. /**
  35026. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  35027. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  35028. */
  35029. dumpNextRenderTargets: boolean;
  35030. /**
  35031. * The list of user defined render targets added to the scene
  35032. */
  35033. customRenderTargets: RenderTargetTexture[];
  35034. /**
  35035. * Defines if texture loading must be delayed
  35036. * If true, textures will only be loaded when they need to be rendered
  35037. */
  35038. useDelayedTextureLoading: boolean;
  35039. /**
  35040. * Gets the list of meshes imported to the scene through SceneLoader
  35041. */
  35042. importedMeshesFiles: String[];
  35043. /**
  35044. * Gets or sets a boolean indicating if probes are enabled on this scene
  35045. */
  35046. probesEnabled: boolean;
  35047. /**
  35048. * Gets or sets the current offline provider to use to store scene data
  35049. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  35050. */
  35051. offlineProvider: IOfflineProvider;
  35052. /**
  35053. * Gets or sets the action manager associated with the scene
  35054. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35055. */
  35056. actionManager: AbstractActionManager;
  35057. private _meshesForIntersections;
  35058. /**
  35059. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  35060. */
  35061. proceduralTexturesEnabled: boolean;
  35062. private _engine;
  35063. private _totalVertices;
  35064. /** @hidden */
  35065. _activeIndices: PerfCounter;
  35066. /** @hidden */
  35067. _activeParticles: PerfCounter;
  35068. /** @hidden */
  35069. _activeBones: PerfCounter;
  35070. private _animationRatio;
  35071. /** @hidden */
  35072. _animationTimeLast: number;
  35073. /** @hidden */
  35074. _animationTime: number;
  35075. /**
  35076. * Gets or sets a general scale for animation speed
  35077. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  35078. */
  35079. animationTimeScale: number;
  35080. /** @hidden */
  35081. _cachedMaterial: Nullable<Material>;
  35082. /** @hidden */
  35083. _cachedEffect: Nullable<Effect>;
  35084. /** @hidden */
  35085. _cachedVisibility: Nullable<number>;
  35086. private _renderId;
  35087. private _frameId;
  35088. private _executeWhenReadyTimeoutId;
  35089. private _intermediateRendering;
  35090. private _viewUpdateFlag;
  35091. private _projectionUpdateFlag;
  35092. /** @hidden */
  35093. _toBeDisposed: Nullable<IDisposable>[];
  35094. private _activeRequests;
  35095. /** @hidden */
  35096. _pendingData: any[];
  35097. private _isDisposed;
  35098. /**
  35099. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  35100. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  35101. */
  35102. dispatchAllSubMeshesOfActiveMeshes: boolean;
  35103. private _activeMeshes;
  35104. private _processedMaterials;
  35105. private _renderTargets;
  35106. /** @hidden */
  35107. _activeParticleSystems: SmartArray<IParticleSystem>;
  35108. private _activeSkeletons;
  35109. private _softwareSkinnedMeshes;
  35110. private _renderingManager;
  35111. /** @hidden */
  35112. _activeAnimatables: Animatable[];
  35113. private _transformMatrix;
  35114. private _sceneUbo;
  35115. /** @hidden */
  35116. _viewMatrix: Matrix;
  35117. private _projectionMatrix;
  35118. /** @hidden */
  35119. _forcedViewPosition: Nullable<Vector3>;
  35120. /** @hidden */
  35121. _frustumPlanes: Plane[];
  35122. /**
  35123. * Gets the list of frustum planes (built from the active camera)
  35124. */
  35125. readonly frustumPlanes: Plane[];
  35126. /**
  35127. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  35128. * This is useful if there are more lights that the maximum simulteanous authorized
  35129. */
  35130. requireLightSorting: boolean;
  35131. /** @hidden */
  35132. readonly useMaterialMeshMap: boolean;
  35133. /** @hidden */
  35134. readonly useClonedMeshhMap: boolean;
  35135. private _externalData;
  35136. private _uid;
  35137. /**
  35138. * @hidden
  35139. * Backing store of defined scene components.
  35140. */
  35141. _components: ISceneComponent[];
  35142. /**
  35143. * @hidden
  35144. * Backing store of defined scene components.
  35145. */
  35146. _serializableComponents: ISceneSerializableComponent[];
  35147. /**
  35148. * List of components to register on the next registration step.
  35149. */
  35150. private _transientComponents;
  35151. /**
  35152. * Registers the transient components if needed.
  35153. */
  35154. private _registerTransientComponents;
  35155. /**
  35156. * @hidden
  35157. * Add a component to the scene.
  35158. * Note that the ccomponent could be registered on th next frame if this is called after
  35159. * the register component stage.
  35160. * @param component Defines the component to add to the scene
  35161. */
  35162. _addComponent(component: ISceneComponent): void;
  35163. /**
  35164. * @hidden
  35165. * Gets a component from the scene.
  35166. * @param name defines the name of the component to retrieve
  35167. * @returns the component or null if not present
  35168. */
  35169. _getComponent(name: string): Nullable<ISceneComponent>;
  35170. /**
  35171. * @hidden
  35172. * Defines the actions happening before camera updates.
  35173. */
  35174. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  35175. /**
  35176. * @hidden
  35177. * Defines the actions happening before clear the canvas.
  35178. */
  35179. _beforeClearStage: Stage<SimpleStageAction>;
  35180. /**
  35181. * @hidden
  35182. * Defines the actions when collecting render targets for the frame.
  35183. */
  35184. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35185. /**
  35186. * @hidden
  35187. * Defines the actions happening for one camera in the frame.
  35188. */
  35189. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35190. /**
  35191. * @hidden
  35192. * Defines the actions happening during the per mesh ready checks.
  35193. */
  35194. _isReadyForMeshStage: Stage<MeshStageAction>;
  35195. /**
  35196. * @hidden
  35197. * Defines the actions happening before evaluate active mesh checks.
  35198. */
  35199. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  35200. /**
  35201. * @hidden
  35202. * Defines the actions happening during the evaluate sub mesh checks.
  35203. */
  35204. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  35205. /**
  35206. * @hidden
  35207. * Defines the actions happening during the active mesh stage.
  35208. */
  35209. _activeMeshStage: Stage<ActiveMeshStageAction>;
  35210. /**
  35211. * @hidden
  35212. * Defines the actions happening during the per camera render target step.
  35213. */
  35214. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  35215. /**
  35216. * @hidden
  35217. * Defines the actions happening just before the active camera is drawing.
  35218. */
  35219. _beforeCameraDrawStage: Stage<CameraStageAction>;
  35220. /**
  35221. * @hidden
  35222. * Defines the actions happening just before a render target is drawing.
  35223. */
  35224. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35225. /**
  35226. * @hidden
  35227. * Defines the actions happening just before a rendering group is drawing.
  35228. */
  35229. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35230. /**
  35231. * @hidden
  35232. * Defines the actions happening just before a mesh is drawing.
  35233. */
  35234. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35235. /**
  35236. * @hidden
  35237. * Defines the actions happening just after a mesh has been drawn.
  35238. */
  35239. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35240. /**
  35241. * @hidden
  35242. * Defines the actions happening just after a rendering group has been drawn.
  35243. */
  35244. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35245. /**
  35246. * @hidden
  35247. * Defines the actions happening just after the active camera has been drawn.
  35248. */
  35249. _afterCameraDrawStage: Stage<CameraStageAction>;
  35250. /**
  35251. * @hidden
  35252. * Defines the actions happening just after a render target has been drawn.
  35253. */
  35254. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35255. /**
  35256. * @hidden
  35257. * Defines the actions happening just after rendering all cameras and computing intersections.
  35258. */
  35259. _afterRenderStage: Stage<SimpleStageAction>;
  35260. /**
  35261. * @hidden
  35262. * Defines the actions happening when a pointer move event happens.
  35263. */
  35264. _pointerMoveStage: Stage<PointerMoveStageAction>;
  35265. /**
  35266. * @hidden
  35267. * Defines the actions happening when a pointer down event happens.
  35268. */
  35269. _pointerDownStage: Stage<PointerUpDownStageAction>;
  35270. /**
  35271. * @hidden
  35272. * Defines the actions happening when a pointer up event happens.
  35273. */
  35274. _pointerUpStage: Stage<PointerUpDownStageAction>;
  35275. /**
  35276. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  35277. */
  35278. private geometriesByUniqueId;
  35279. /**
  35280. * Creates a new Scene
  35281. * @param engine defines the engine to use to render this scene
  35282. * @param options defines the scene options
  35283. */
  35284. constructor(engine: Engine, options?: SceneOptions);
  35285. /**
  35286. * Gets a string idenfifying the name of the class
  35287. * @returns "Scene" string
  35288. */
  35289. getClassName(): string;
  35290. private _defaultMeshCandidates;
  35291. /**
  35292. * @hidden
  35293. */
  35294. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  35295. private _defaultSubMeshCandidates;
  35296. /**
  35297. * @hidden
  35298. */
  35299. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  35300. /**
  35301. * Sets the default candidate providers for the scene.
  35302. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  35303. * and getCollidingSubMeshCandidates to their default function
  35304. */
  35305. setDefaultCandidateProviders(): void;
  35306. /**
  35307. * Gets the mesh that is currently under the pointer
  35308. */
  35309. readonly meshUnderPointer: Nullable<AbstractMesh>;
  35310. /**
  35311. * Gets or sets the current on-screen X position of the pointer
  35312. */
  35313. pointerX: number;
  35314. /**
  35315. * Gets or sets the current on-screen Y position of the pointer
  35316. */
  35317. pointerY: number;
  35318. /**
  35319. * Gets the cached material (ie. the latest rendered one)
  35320. * @returns the cached material
  35321. */
  35322. getCachedMaterial(): Nullable<Material>;
  35323. /**
  35324. * Gets the cached effect (ie. the latest rendered one)
  35325. * @returns the cached effect
  35326. */
  35327. getCachedEffect(): Nullable<Effect>;
  35328. /**
  35329. * Gets the cached visibility state (ie. the latest rendered one)
  35330. * @returns the cached visibility state
  35331. */
  35332. getCachedVisibility(): Nullable<number>;
  35333. /**
  35334. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  35335. * @param material defines the current material
  35336. * @param effect defines the current effect
  35337. * @param visibility defines the current visibility state
  35338. * @returns true if one parameter is not cached
  35339. */
  35340. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  35341. /**
  35342. * Gets the engine associated with the scene
  35343. * @returns an Engine
  35344. */
  35345. getEngine(): Engine;
  35346. /**
  35347. * Gets the total number of vertices rendered per frame
  35348. * @returns the total number of vertices rendered per frame
  35349. */
  35350. getTotalVertices(): number;
  35351. /**
  35352. * Gets the performance counter for total vertices
  35353. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35354. */
  35355. readonly totalVerticesPerfCounter: PerfCounter;
  35356. /**
  35357. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  35358. * @returns the total number of active indices rendered per frame
  35359. */
  35360. getActiveIndices(): number;
  35361. /**
  35362. * Gets the performance counter for active indices
  35363. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35364. */
  35365. readonly totalActiveIndicesPerfCounter: PerfCounter;
  35366. /**
  35367. * Gets the total number of active particles rendered per frame
  35368. * @returns the total number of active particles rendered per frame
  35369. */
  35370. getActiveParticles(): number;
  35371. /**
  35372. * Gets the performance counter for active particles
  35373. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35374. */
  35375. readonly activeParticlesPerfCounter: PerfCounter;
  35376. /**
  35377. * Gets the total number of active bones rendered per frame
  35378. * @returns the total number of active bones rendered per frame
  35379. */
  35380. getActiveBones(): number;
  35381. /**
  35382. * Gets the performance counter for active bones
  35383. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35384. */
  35385. readonly activeBonesPerfCounter: PerfCounter;
  35386. /**
  35387. * Gets the array of active meshes
  35388. * @returns an array of AbstractMesh
  35389. */
  35390. getActiveMeshes(): SmartArray<AbstractMesh>;
  35391. /**
  35392. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  35393. * @returns a number
  35394. */
  35395. getAnimationRatio(): number;
  35396. /**
  35397. * Gets an unique Id for the current render phase
  35398. * @returns a number
  35399. */
  35400. getRenderId(): number;
  35401. /**
  35402. * Gets an unique Id for the current frame
  35403. * @returns a number
  35404. */
  35405. getFrameId(): number;
  35406. /** Call this function if you want to manually increment the render Id*/
  35407. incrementRenderId(): void;
  35408. private _createUbo;
  35409. /**
  35410. * Use this method to simulate a pointer move on a mesh
  35411. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35412. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35413. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35414. * @returns the current scene
  35415. */
  35416. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  35417. /**
  35418. * Use this method to simulate a pointer down on a mesh
  35419. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35420. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35421. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35422. * @returns the current scene
  35423. */
  35424. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  35425. /**
  35426. * Use this method to simulate a pointer up on a mesh
  35427. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35428. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35429. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35430. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35431. * @returns the current scene
  35432. */
  35433. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  35434. /**
  35435. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35436. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35437. * @returns true if the pointer was captured
  35438. */
  35439. isPointerCaptured(pointerId?: number): boolean;
  35440. /**
  35441. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35442. * @param attachUp defines if you want to attach events to pointerup
  35443. * @param attachDown defines if you want to attach events to pointerdown
  35444. * @param attachMove defines if you want to attach events to pointermove
  35445. */
  35446. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  35447. /** Detaches all event handlers*/
  35448. detachControl(): void;
  35449. /**
  35450. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  35451. * Delay loaded resources are not taking in account
  35452. * @return true if all required resources are ready
  35453. */
  35454. isReady(): boolean;
  35455. /** Resets all cached information relative to material (including effect and visibility) */
  35456. resetCachedMaterial(): void;
  35457. /**
  35458. * Registers a function to be called before every frame render
  35459. * @param func defines the function to register
  35460. */
  35461. registerBeforeRender(func: () => void): void;
  35462. /**
  35463. * Unregisters a function called before every frame render
  35464. * @param func defines the function to unregister
  35465. */
  35466. unregisterBeforeRender(func: () => void): void;
  35467. /**
  35468. * Registers a function to be called after every frame render
  35469. * @param func defines the function to register
  35470. */
  35471. registerAfterRender(func: () => void): void;
  35472. /**
  35473. * Unregisters a function called after every frame render
  35474. * @param func defines the function to unregister
  35475. */
  35476. unregisterAfterRender(func: () => void): void;
  35477. private _executeOnceBeforeRender;
  35478. /**
  35479. * The provided function will run before render once and will be disposed afterwards.
  35480. * A timeout delay can be provided so that the function will be executed in N ms.
  35481. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  35482. * @param func The function to be executed.
  35483. * @param timeout optional delay in ms
  35484. */
  35485. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  35486. /** @hidden */
  35487. _addPendingData(data: any): void;
  35488. /** @hidden */
  35489. _removePendingData(data: any): void;
  35490. /**
  35491. * Returns the number of items waiting to be loaded
  35492. * @returns the number of items waiting to be loaded
  35493. */
  35494. getWaitingItemsCount(): number;
  35495. /**
  35496. * Returns a boolean indicating if the scene is still loading data
  35497. */
  35498. readonly isLoading: boolean;
  35499. /**
  35500. * Registers a function to be executed when the scene is ready
  35501. * @param {Function} func - the function to be executed
  35502. */
  35503. executeWhenReady(func: () => void): void;
  35504. /**
  35505. * Returns a promise that resolves when the scene is ready
  35506. * @returns A promise that resolves when the scene is ready
  35507. */
  35508. whenReadyAsync(): Promise<void>;
  35509. /** @hidden */
  35510. _checkIsReady(): void;
  35511. /**
  35512. * Gets all animatable attached to the scene
  35513. */
  35514. readonly animatables: Animatable[];
  35515. /**
  35516. * Resets the last animation time frame.
  35517. * Useful to override when animations start running when loading a scene for the first time.
  35518. */
  35519. resetLastAnimationTimeFrame(): void;
  35520. /**
  35521. * Gets the current view matrix
  35522. * @returns a Matrix
  35523. */
  35524. getViewMatrix(): Matrix;
  35525. /**
  35526. * Gets the current projection matrix
  35527. * @returns a Matrix
  35528. */
  35529. getProjectionMatrix(): Matrix;
  35530. /**
  35531. * Gets the current transform matrix
  35532. * @returns a Matrix made of View * Projection
  35533. */
  35534. getTransformMatrix(): Matrix;
  35535. /**
  35536. * Sets the current transform matrix
  35537. * @param viewL defines the View matrix to use
  35538. * @param projectionL defines the Projection matrix to use
  35539. * @param viewR defines the right View matrix to use (if provided)
  35540. * @param projectionR defines the right Projection matrix to use (if provided)
  35541. */
  35542. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  35543. /**
  35544. * Gets the uniform buffer used to store scene data
  35545. * @returns a UniformBuffer
  35546. */
  35547. getSceneUniformBuffer(): UniformBuffer;
  35548. /**
  35549. * Gets an unique (relatively to the current scene) Id
  35550. * @returns an unique number for the scene
  35551. */
  35552. getUniqueId(): number;
  35553. /**
  35554. * Add a mesh to the list of scene's meshes
  35555. * @param newMesh defines the mesh to add
  35556. * @param recursive if all child meshes should also be added to the scene
  35557. */
  35558. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  35559. /**
  35560. * Remove a mesh for the list of scene's meshes
  35561. * @param toRemove defines the mesh to remove
  35562. * @param recursive if all child meshes should also be removed from the scene
  35563. * @returns the index where the mesh was in the mesh list
  35564. */
  35565. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  35566. /**
  35567. * Add a transform node to the list of scene's transform nodes
  35568. * @param newTransformNode defines the transform node to add
  35569. */
  35570. addTransformNode(newTransformNode: TransformNode): void;
  35571. /**
  35572. * Remove a transform node for the list of scene's transform nodes
  35573. * @param toRemove defines the transform node to remove
  35574. * @returns the index where the transform node was in the transform node list
  35575. */
  35576. removeTransformNode(toRemove: TransformNode): number;
  35577. /**
  35578. * Remove a skeleton for the list of scene's skeletons
  35579. * @param toRemove defines the skeleton to remove
  35580. * @returns the index where the skeleton was in the skeleton list
  35581. */
  35582. removeSkeleton(toRemove: Skeleton): number;
  35583. /**
  35584. * Remove a morph target for the list of scene's morph targets
  35585. * @param toRemove defines the morph target to remove
  35586. * @returns the index where the morph target was in the morph target list
  35587. */
  35588. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  35589. /**
  35590. * Remove a light for the list of scene's lights
  35591. * @param toRemove defines the light to remove
  35592. * @returns the index where the light was in the light list
  35593. */
  35594. removeLight(toRemove: Light): number;
  35595. /**
  35596. * Remove a camera for the list of scene's cameras
  35597. * @param toRemove defines the camera to remove
  35598. * @returns the index where the camera was in the camera list
  35599. */
  35600. removeCamera(toRemove: Camera): number;
  35601. /**
  35602. * Remove a particle system for the list of scene's particle systems
  35603. * @param toRemove defines the particle system to remove
  35604. * @returns the index where the particle system was in the particle system list
  35605. */
  35606. removeParticleSystem(toRemove: IParticleSystem): number;
  35607. /**
  35608. * Remove a animation for the list of scene's animations
  35609. * @param toRemove defines the animation to remove
  35610. * @returns the index where the animation was in the animation list
  35611. */
  35612. removeAnimation(toRemove: Animation): number;
  35613. /**
  35614. * Will stop the animation of the given target
  35615. * @param target - the target
  35616. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  35617. * @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)
  35618. */
  35619. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  35620. /**
  35621. * Removes the given animation group from this scene.
  35622. * @param toRemove The animation group to remove
  35623. * @returns The index of the removed animation group
  35624. */
  35625. removeAnimationGroup(toRemove: AnimationGroup): number;
  35626. /**
  35627. * Removes the given multi-material from this scene.
  35628. * @param toRemove The multi-material to remove
  35629. * @returns The index of the removed multi-material
  35630. */
  35631. removeMultiMaterial(toRemove: MultiMaterial): number;
  35632. /**
  35633. * Removes the given material from this scene.
  35634. * @param toRemove The material to remove
  35635. * @returns The index of the removed material
  35636. */
  35637. removeMaterial(toRemove: Material): number;
  35638. /**
  35639. * Removes the given action manager from this scene.
  35640. * @param toRemove The action manager to remove
  35641. * @returns The index of the removed action manager
  35642. */
  35643. removeActionManager(toRemove: AbstractActionManager): number;
  35644. /**
  35645. * Removes the given texture from this scene.
  35646. * @param toRemove The texture to remove
  35647. * @returns The index of the removed texture
  35648. */
  35649. removeTexture(toRemove: BaseTexture): number;
  35650. /**
  35651. * Adds the given light to this scene
  35652. * @param newLight The light to add
  35653. */
  35654. addLight(newLight: Light): void;
  35655. /**
  35656. * Sorts the list list based on light priorities
  35657. */
  35658. sortLightsByPriority(): void;
  35659. /**
  35660. * Adds the given camera to this scene
  35661. * @param newCamera The camera to add
  35662. */
  35663. addCamera(newCamera: Camera): void;
  35664. /**
  35665. * Adds the given skeleton to this scene
  35666. * @param newSkeleton The skeleton to add
  35667. */
  35668. addSkeleton(newSkeleton: Skeleton): void;
  35669. /**
  35670. * Adds the given particle system to this scene
  35671. * @param newParticleSystem The particle system to add
  35672. */
  35673. addParticleSystem(newParticleSystem: IParticleSystem): void;
  35674. /**
  35675. * Adds the given animation to this scene
  35676. * @param newAnimation The animation to add
  35677. */
  35678. addAnimation(newAnimation: Animation): void;
  35679. /**
  35680. * Adds the given animation group to this scene.
  35681. * @param newAnimationGroup The animation group to add
  35682. */
  35683. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  35684. /**
  35685. * Adds the given multi-material to this scene
  35686. * @param newMultiMaterial The multi-material to add
  35687. */
  35688. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  35689. /**
  35690. * Adds the given material to this scene
  35691. * @param newMaterial The material to add
  35692. */
  35693. addMaterial(newMaterial: Material): void;
  35694. /**
  35695. * Adds the given morph target to this scene
  35696. * @param newMorphTargetManager The morph target to add
  35697. */
  35698. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  35699. /**
  35700. * Adds the given geometry to this scene
  35701. * @param newGeometry The geometry to add
  35702. */
  35703. addGeometry(newGeometry: Geometry): void;
  35704. /**
  35705. * Adds the given action manager to this scene
  35706. * @param newActionManager The action manager to add
  35707. */
  35708. addActionManager(newActionManager: AbstractActionManager): void;
  35709. /**
  35710. * Adds the given texture to this scene.
  35711. * @param newTexture The texture to add
  35712. */
  35713. addTexture(newTexture: BaseTexture): void;
  35714. /**
  35715. * Switch active camera
  35716. * @param newCamera defines the new active camera
  35717. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  35718. */
  35719. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  35720. /**
  35721. * sets the active camera of the scene using its ID
  35722. * @param id defines the camera's ID
  35723. * @return the new active camera or null if none found.
  35724. */
  35725. setActiveCameraByID(id: string): Nullable<Camera>;
  35726. /**
  35727. * sets the active camera of the scene using its name
  35728. * @param name defines the camera's name
  35729. * @returns the new active camera or null if none found.
  35730. */
  35731. setActiveCameraByName(name: string): Nullable<Camera>;
  35732. /**
  35733. * get an animation group using its name
  35734. * @param name defines the material's name
  35735. * @return the animation group or null if none found.
  35736. */
  35737. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  35738. /**
  35739. * Get a material using its unique id
  35740. * @param uniqueId defines the material's unique id
  35741. * @return the material or null if none found.
  35742. */
  35743. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  35744. /**
  35745. * get a material using its id
  35746. * @param id defines the material's ID
  35747. * @return the material or null if none found.
  35748. */
  35749. getMaterialByID(id: string): Nullable<Material>;
  35750. /**
  35751. * Gets a the last added material using a given id
  35752. * @param id defines the material's ID
  35753. * @return the last material with the given id or null if none found.
  35754. */
  35755. getLastMaterialByID(id: string): Nullable<Material>;
  35756. /**
  35757. * Gets a material using its name
  35758. * @param name defines the material's name
  35759. * @return the material or null if none found.
  35760. */
  35761. getMaterialByName(name: string): Nullable<Material>;
  35762. /**
  35763. * Get a texture using its unique id
  35764. * @param uniqueId defines the texture's unique id
  35765. * @return the texture or null if none found.
  35766. */
  35767. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  35768. /**
  35769. * Gets a camera using its id
  35770. * @param id defines the id to look for
  35771. * @returns the camera or null if not found
  35772. */
  35773. getCameraByID(id: string): Nullable<Camera>;
  35774. /**
  35775. * Gets a camera using its unique id
  35776. * @param uniqueId defines the unique id to look for
  35777. * @returns the camera or null if not found
  35778. */
  35779. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  35780. /**
  35781. * Gets a camera using its name
  35782. * @param name defines the camera's name
  35783. * @return the camera or null if none found.
  35784. */
  35785. getCameraByName(name: string): Nullable<Camera>;
  35786. /**
  35787. * Gets a bone using its id
  35788. * @param id defines the bone's id
  35789. * @return the bone or null if not found
  35790. */
  35791. getBoneByID(id: string): Nullable<Bone>;
  35792. /**
  35793. * Gets a bone using its id
  35794. * @param name defines the bone's name
  35795. * @return the bone or null if not found
  35796. */
  35797. getBoneByName(name: string): Nullable<Bone>;
  35798. /**
  35799. * Gets a light node using its name
  35800. * @param name defines the the light's name
  35801. * @return the light or null if none found.
  35802. */
  35803. getLightByName(name: string): Nullable<Light>;
  35804. /**
  35805. * Gets a light node using its id
  35806. * @param id defines the light's id
  35807. * @return the light or null if none found.
  35808. */
  35809. getLightByID(id: string): Nullable<Light>;
  35810. /**
  35811. * Gets a light node using its scene-generated unique ID
  35812. * @param uniqueId defines the light's unique id
  35813. * @return the light or null if none found.
  35814. */
  35815. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  35816. /**
  35817. * Gets a particle system by id
  35818. * @param id defines the particle system id
  35819. * @return the corresponding system or null if none found
  35820. */
  35821. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  35822. /**
  35823. * Gets a geometry using its ID
  35824. * @param id defines the geometry's id
  35825. * @return the geometry or null if none found.
  35826. */
  35827. getGeometryByID(id: string): Nullable<Geometry>;
  35828. private _getGeometryByUniqueID;
  35829. /**
  35830. * Add a new geometry to this scene
  35831. * @param geometry defines the geometry to be added to the scene.
  35832. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  35833. * @return a boolean defining if the geometry was added or not
  35834. */
  35835. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  35836. /**
  35837. * Removes an existing geometry
  35838. * @param geometry defines the geometry to be removed from the scene
  35839. * @return a boolean defining if the geometry was removed or not
  35840. */
  35841. removeGeometry(geometry: Geometry): boolean;
  35842. /**
  35843. * Gets the list of geometries attached to the scene
  35844. * @returns an array of Geometry
  35845. */
  35846. getGeometries(): Geometry[];
  35847. /**
  35848. * Gets the first added mesh found of a given ID
  35849. * @param id defines the id to search for
  35850. * @return the mesh found or null if not found at all
  35851. */
  35852. getMeshByID(id: string): Nullable<AbstractMesh>;
  35853. /**
  35854. * Gets a list of meshes using their id
  35855. * @param id defines the id to search for
  35856. * @returns a list of meshes
  35857. */
  35858. getMeshesByID(id: string): Array<AbstractMesh>;
  35859. /**
  35860. * Gets the first added transform node found of a given ID
  35861. * @param id defines the id to search for
  35862. * @return the found transform node or null if not found at all.
  35863. */
  35864. getTransformNodeByID(id: string): Nullable<TransformNode>;
  35865. /**
  35866. * Gets a transform node with its auto-generated unique id
  35867. * @param uniqueId efines the unique id to search for
  35868. * @return the found transform node or null if not found at all.
  35869. */
  35870. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  35871. /**
  35872. * Gets a list of transform nodes using their id
  35873. * @param id defines the id to search for
  35874. * @returns a list of transform nodes
  35875. */
  35876. getTransformNodesByID(id: string): Array<TransformNode>;
  35877. /**
  35878. * Gets a mesh with its auto-generated unique id
  35879. * @param uniqueId defines the unique id to search for
  35880. * @return the found mesh or null if not found at all.
  35881. */
  35882. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  35883. /**
  35884. * Gets a the last added mesh using a given id
  35885. * @param id defines the id to search for
  35886. * @return the found mesh or null if not found at all.
  35887. */
  35888. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  35889. /**
  35890. * Gets a the last added node (Mesh, Camera, Light) using a given id
  35891. * @param id defines the id to search for
  35892. * @return the found node or null if not found at all
  35893. */
  35894. getLastEntryByID(id: string): Nullable<Node>;
  35895. /**
  35896. * Gets a node (Mesh, Camera, Light) using a given id
  35897. * @param id defines the id to search for
  35898. * @return the found node or null if not found at all
  35899. */
  35900. getNodeByID(id: string): Nullable<Node>;
  35901. /**
  35902. * Gets a node (Mesh, Camera, Light) using a given name
  35903. * @param name defines the name to search for
  35904. * @return the found node or null if not found at all.
  35905. */
  35906. getNodeByName(name: string): Nullable<Node>;
  35907. /**
  35908. * Gets a mesh using a given name
  35909. * @param name defines the name to search for
  35910. * @return the found mesh or null if not found at all.
  35911. */
  35912. getMeshByName(name: string): Nullable<AbstractMesh>;
  35913. /**
  35914. * Gets a transform node using a given name
  35915. * @param name defines the name to search for
  35916. * @return the found transform node or null if not found at all.
  35917. */
  35918. getTransformNodeByName(name: string): Nullable<TransformNode>;
  35919. /**
  35920. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  35921. * @param id defines the id to search for
  35922. * @return the found skeleton or null if not found at all.
  35923. */
  35924. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  35925. /**
  35926. * Gets a skeleton using a given auto generated unique id
  35927. * @param uniqueId defines the unique id to search for
  35928. * @return the found skeleton or null if not found at all.
  35929. */
  35930. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  35931. /**
  35932. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  35933. * @param id defines the id to search for
  35934. * @return the found skeleton or null if not found at all.
  35935. */
  35936. getSkeletonById(id: string): Nullable<Skeleton>;
  35937. /**
  35938. * Gets a skeleton using a given name
  35939. * @param name defines the name to search for
  35940. * @return the found skeleton or null if not found at all.
  35941. */
  35942. getSkeletonByName(name: string): Nullable<Skeleton>;
  35943. /**
  35944. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  35945. * @param id defines the id to search for
  35946. * @return the found morph target manager or null if not found at all.
  35947. */
  35948. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  35949. /**
  35950. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  35951. * @param id defines the id to search for
  35952. * @return the found morph target or null if not found at all.
  35953. */
  35954. getMorphTargetById(id: string): Nullable<MorphTarget>;
  35955. /**
  35956. * Gets a boolean indicating if the given mesh is active
  35957. * @param mesh defines the mesh to look for
  35958. * @returns true if the mesh is in the active list
  35959. */
  35960. isActiveMesh(mesh: AbstractMesh): boolean;
  35961. /**
  35962. * Return a unique id as a string which can serve as an identifier for the scene
  35963. */
  35964. readonly uid: string;
  35965. /**
  35966. * Add an externaly attached data from its key.
  35967. * This method call will fail and return false, if such key already exists.
  35968. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  35969. * @param key the unique key that identifies the data
  35970. * @param data the data object to associate to the key for this Engine instance
  35971. * @return true if no such key were already present and the data was added successfully, false otherwise
  35972. */
  35973. addExternalData<T>(key: string, data: T): boolean;
  35974. /**
  35975. * Get an externaly attached data from its key
  35976. * @param key the unique key that identifies the data
  35977. * @return the associated data, if present (can be null), or undefined if not present
  35978. */
  35979. getExternalData<T>(key: string): Nullable<T>;
  35980. /**
  35981. * Get an externaly attached data from its key, create it using a factory if it's not already present
  35982. * @param key the unique key that identifies the data
  35983. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  35984. * @return the associated data, can be null if the factory returned null.
  35985. */
  35986. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  35987. /**
  35988. * Remove an externaly attached data from the Engine instance
  35989. * @param key the unique key that identifies the data
  35990. * @return true if the data was successfully removed, false if it doesn't exist
  35991. */
  35992. removeExternalData(key: string): boolean;
  35993. private _evaluateSubMesh;
  35994. /**
  35995. * Clear the processed materials smart array preventing retention point in material dispose.
  35996. */
  35997. freeProcessedMaterials(): void;
  35998. private _preventFreeActiveMeshesAndRenderingGroups;
  35999. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  36000. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  36001. * when disposing several meshes in a row or a hierarchy of meshes.
  36002. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  36003. */
  36004. blockfreeActiveMeshesAndRenderingGroups: boolean;
  36005. /**
  36006. * Clear the active meshes smart array preventing retention point in mesh dispose.
  36007. */
  36008. freeActiveMeshes(): void;
  36009. /**
  36010. * Clear the info related to rendering groups preventing retention points during dispose.
  36011. */
  36012. freeRenderingGroups(): void;
  36013. /** @hidden */
  36014. _isInIntermediateRendering(): boolean;
  36015. /**
  36016. * Lambda returning the list of potentially active meshes.
  36017. */
  36018. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  36019. /**
  36020. * Lambda returning the list of potentially active sub meshes.
  36021. */
  36022. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  36023. /**
  36024. * Lambda returning the list of potentially intersecting sub meshes.
  36025. */
  36026. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  36027. /**
  36028. * Lambda returning the list of potentially colliding sub meshes.
  36029. */
  36030. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  36031. private _activeMeshesFrozen;
  36032. private _skipEvaluateActiveMeshesCompletely;
  36033. /**
  36034. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  36035. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  36036. * @returns the current scene
  36037. */
  36038. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  36039. /**
  36040. * Use this function to restart evaluating active meshes on every frame
  36041. * @returns the current scene
  36042. */
  36043. unfreezeActiveMeshes(): Scene;
  36044. private _evaluateActiveMeshes;
  36045. private _activeMesh;
  36046. /**
  36047. * Update the transform matrix to update from the current active camera
  36048. * @param force defines a boolean used to force the update even if cache is up to date
  36049. */
  36050. updateTransformMatrix(force?: boolean): void;
  36051. private _bindFrameBuffer;
  36052. /** @hidden */
  36053. _allowPostProcessClearColor: boolean;
  36054. /** @hidden */
  36055. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  36056. private _processSubCameras;
  36057. private _checkIntersections;
  36058. /** @hidden */
  36059. _advancePhysicsEngineStep(step: number): void;
  36060. /**
  36061. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  36062. */
  36063. getDeterministicFrameTime: () => number;
  36064. /** @hidden */
  36065. _animate(): void;
  36066. /** Execute all animations (for a frame) */
  36067. animate(): void;
  36068. /**
  36069. * Render the scene
  36070. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  36071. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  36072. */
  36073. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  36074. /**
  36075. * Freeze all materials
  36076. * A frozen material will not be updatable but should be faster to render
  36077. */
  36078. freezeMaterials(): void;
  36079. /**
  36080. * Unfreeze all materials
  36081. * A frozen material will not be updatable but should be faster to render
  36082. */
  36083. unfreezeMaterials(): void;
  36084. /**
  36085. * Releases all held ressources
  36086. */
  36087. dispose(): void;
  36088. /**
  36089. * Gets if the scene is already disposed
  36090. */
  36091. readonly isDisposed: boolean;
  36092. /**
  36093. * Call this function to reduce memory footprint of the scene.
  36094. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  36095. */
  36096. clearCachedVertexData(): void;
  36097. /**
  36098. * This function will remove the local cached buffer data from texture.
  36099. * It will save memory but will prevent the texture from being rebuilt
  36100. */
  36101. cleanCachedTextureBuffer(): void;
  36102. /**
  36103. * Get the world extend vectors with an optional filter
  36104. *
  36105. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  36106. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  36107. */
  36108. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  36109. min: Vector3;
  36110. max: Vector3;
  36111. };
  36112. /**
  36113. * Creates a ray that can be used to pick in the scene
  36114. * @param x defines the x coordinate of the origin (on-screen)
  36115. * @param y defines the y coordinate of the origin (on-screen)
  36116. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  36117. * @param camera defines the camera to use for the picking
  36118. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  36119. * @returns a Ray
  36120. */
  36121. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  36122. /**
  36123. * Creates a ray that can be used to pick in the scene
  36124. * @param x defines the x coordinate of the origin (on-screen)
  36125. * @param y defines the y coordinate of the origin (on-screen)
  36126. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  36127. * @param result defines the ray where to store the picking ray
  36128. * @param camera defines the camera to use for the picking
  36129. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  36130. * @returns the current scene
  36131. */
  36132. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  36133. /**
  36134. * Creates a ray that can be used to pick in the scene
  36135. * @param x defines the x coordinate of the origin (on-screen)
  36136. * @param y defines the y coordinate of the origin (on-screen)
  36137. * @param camera defines the camera to use for the picking
  36138. * @returns a Ray
  36139. */
  36140. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  36141. /**
  36142. * Creates a ray that can be used to pick in the scene
  36143. * @param x defines the x coordinate of the origin (on-screen)
  36144. * @param y defines the y coordinate of the origin (on-screen)
  36145. * @param result defines the ray where to store the picking ray
  36146. * @param camera defines the camera to use for the picking
  36147. * @returns the current scene
  36148. */
  36149. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  36150. /** Launch a ray to try to pick a mesh in the scene
  36151. * @param x position on screen
  36152. * @param y position on screen
  36153. * @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
  36154. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  36155. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36156. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36157. * @returns a PickingInfo
  36158. */
  36159. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  36160. /** Use the given ray to pick a mesh in the scene
  36161. * @param ray The ray to use to pick meshes
  36162. * @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
  36163. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  36164. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36165. * @returns a PickingInfo
  36166. */
  36167. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  36168. /**
  36169. * Launch a ray to try to pick a mesh in the scene
  36170. * @param x X position on screen
  36171. * @param y Y position on screen
  36172. * @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
  36173. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36174. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36175. * @returns an array of PickingInfo
  36176. */
  36177. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36178. /**
  36179. * Launch a ray to try to pick a mesh in the scene
  36180. * @param ray Ray to use
  36181. * @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
  36182. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36183. * @returns an array of PickingInfo
  36184. */
  36185. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36186. /**
  36187. * Force the value of meshUnderPointer
  36188. * @param mesh defines the mesh to use
  36189. */
  36190. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  36191. /**
  36192. * Gets the mesh under the pointer
  36193. * @returns a Mesh or null if no mesh is under the pointer
  36194. */
  36195. getPointerOverMesh(): Nullable<AbstractMesh>;
  36196. /** @hidden */
  36197. _rebuildGeometries(): void;
  36198. /** @hidden */
  36199. _rebuildTextures(): void;
  36200. private _getByTags;
  36201. /**
  36202. * Get a list of meshes by tags
  36203. * @param tagsQuery defines the tags query to use
  36204. * @param forEach defines a predicate used to filter results
  36205. * @returns an array of Mesh
  36206. */
  36207. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  36208. /**
  36209. * Get a list of cameras by tags
  36210. * @param tagsQuery defines the tags query to use
  36211. * @param forEach defines a predicate used to filter results
  36212. * @returns an array of Camera
  36213. */
  36214. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  36215. /**
  36216. * Get a list of lights by tags
  36217. * @param tagsQuery defines the tags query to use
  36218. * @param forEach defines a predicate used to filter results
  36219. * @returns an array of Light
  36220. */
  36221. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  36222. /**
  36223. * Get a list of materials by tags
  36224. * @param tagsQuery defines the tags query to use
  36225. * @param forEach defines a predicate used to filter results
  36226. * @returns an array of Material
  36227. */
  36228. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  36229. /**
  36230. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  36231. * This allowed control for front to back rendering or reversly depending of the special needs.
  36232. *
  36233. * @param renderingGroupId The rendering group id corresponding to its index
  36234. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  36235. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  36236. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  36237. */
  36238. 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;
  36239. /**
  36240. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  36241. *
  36242. * @param renderingGroupId The rendering group id corresponding to its index
  36243. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  36244. * @param depth Automatically clears depth between groups if true and autoClear is true.
  36245. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  36246. */
  36247. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  36248. /**
  36249. * Gets the current auto clear configuration for one rendering group of the rendering
  36250. * manager.
  36251. * @param index the rendering group index to get the information for
  36252. * @returns The auto clear setup for the requested rendering group
  36253. */
  36254. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  36255. private _blockMaterialDirtyMechanism;
  36256. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  36257. blockMaterialDirtyMechanism: boolean;
  36258. /**
  36259. * Will flag all materials as dirty to trigger new shader compilation
  36260. * @param flag defines the flag used to specify which material part must be marked as dirty
  36261. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  36262. */
  36263. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  36264. /** @hidden */
  36265. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  36266. /** @hidden */
  36267. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36268. /** @hidden */
  36269. _requestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  36270. /** @hidden */
  36271. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  36272. /** @hidden */
  36273. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  36274. /** @hidden */
  36275. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36276. }
  36277. }
  36278. declare module BABYLON {
  36279. /**
  36280. * Set of assets to keep when moving a scene into an asset container.
  36281. */
  36282. export class KeepAssets extends AbstractScene {
  36283. }
  36284. /**
  36285. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  36286. */
  36287. export class InstantiatedEntries {
  36288. /**
  36289. * List of new root nodes (eg. nodes with no parent)
  36290. */
  36291. rootNodes: TransformNode[];
  36292. /**
  36293. * List of new skeletons
  36294. */
  36295. skeletons: Skeleton[];
  36296. /**
  36297. * List of new animation groups
  36298. */
  36299. animationGroups: AnimationGroup[];
  36300. }
  36301. /**
  36302. * Container with a set of assets that can be added or removed from a scene.
  36303. */
  36304. export class AssetContainer extends AbstractScene {
  36305. /**
  36306. * The scene the AssetContainer belongs to.
  36307. */
  36308. scene: Scene;
  36309. /**
  36310. * Instantiates an AssetContainer.
  36311. * @param scene The scene the AssetContainer belongs to.
  36312. */
  36313. constructor(scene: Scene);
  36314. /**
  36315. * Instantiate or clone all meshes and add the new ones to the scene.
  36316. * Skeletons and animation groups will all be cloned
  36317. * @param nameFunction defines an optional function used to get new names for clones
  36318. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  36319. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  36320. */
  36321. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  36322. /**
  36323. * Adds all the assets from the container to the scene.
  36324. */
  36325. addAllToScene(): void;
  36326. /**
  36327. * Removes all the assets in the container from the scene
  36328. */
  36329. removeAllFromScene(): void;
  36330. /**
  36331. * Disposes all the assets in the container
  36332. */
  36333. dispose(): void;
  36334. private _moveAssets;
  36335. /**
  36336. * Removes all the assets contained in the scene and adds them to the container.
  36337. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  36338. */
  36339. moveAllFromScene(keepAssets?: KeepAssets): void;
  36340. /**
  36341. * 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.
  36342. * @returns the root mesh
  36343. */
  36344. createRootMesh(): Mesh;
  36345. }
  36346. }
  36347. declare module BABYLON {
  36348. /**
  36349. * Defines how the parser contract is defined.
  36350. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  36351. */
  36352. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  36353. /**
  36354. * Defines how the individual parser contract is defined.
  36355. * These parser can parse an individual asset
  36356. */
  36357. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  36358. /**
  36359. * Base class of the scene acting as a container for the different elements composing a scene.
  36360. * This class is dynamically extended by the different components of the scene increasing
  36361. * flexibility and reducing coupling
  36362. */
  36363. export abstract class AbstractScene {
  36364. /**
  36365. * Stores the list of available parsers in the application.
  36366. */
  36367. private static _BabylonFileParsers;
  36368. /**
  36369. * Stores the list of available individual parsers in the application.
  36370. */
  36371. private static _IndividualBabylonFileParsers;
  36372. /**
  36373. * Adds a parser in the list of available ones
  36374. * @param name Defines the name of the parser
  36375. * @param parser Defines the parser to add
  36376. */
  36377. static AddParser(name: string, parser: BabylonFileParser): void;
  36378. /**
  36379. * Gets a general parser from the list of avaialble ones
  36380. * @param name Defines the name of the parser
  36381. * @returns the requested parser or null
  36382. */
  36383. static GetParser(name: string): Nullable<BabylonFileParser>;
  36384. /**
  36385. * Adds n individual parser in the list of available ones
  36386. * @param name Defines the name of the parser
  36387. * @param parser Defines the parser to add
  36388. */
  36389. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  36390. /**
  36391. * Gets an individual parser from the list of avaialble ones
  36392. * @param name Defines the name of the parser
  36393. * @returns the requested parser or null
  36394. */
  36395. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  36396. /**
  36397. * Parser json data and populate both a scene and its associated container object
  36398. * @param jsonData Defines the data to parse
  36399. * @param scene Defines the scene to parse the data for
  36400. * @param container Defines the container attached to the parsing sequence
  36401. * @param rootUrl Defines the root url of the data
  36402. */
  36403. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  36404. /**
  36405. * Gets the list of root nodes (ie. nodes with no parent)
  36406. */
  36407. rootNodes: Node[];
  36408. /** All of the cameras added to this scene
  36409. * @see http://doc.babylonjs.com/babylon101/cameras
  36410. */
  36411. cameras: Camera[];
  36412. /**
  36413. * All of the lights added to this scene
  36414. * @see http://doc.babylonjs.com/babylon101/lights
  36415. */
  36416. lights: Light[];
  36417. /**
  36418. * All of the (abstract) meshes added to this scene
  36419. */
  36420. meshes: AbstractMesh[];
  36421. /**
  36422. * The list of skeletons added to the scene
  36423. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  36424. */
  36425. skeletons: Skeleton[];
  36426. /**
  36427. * All of the particle systems added to this scene
  36428. * @see http://doc.babylonjs.com/babylon101/particles
  36429. */
  36430. particleSystems: IParticleSystem[];
  36431. /**
  36432. * Gets a list of Animations associated with the scene
  36433. */
  36434. animations: Animation[];
  36435. /**
  36436. * All of the animation groups added to this scene
  36437. * @see http://doc.babylonjs.com/how_to/group
  36438. */
  36439. animationGroups: AnimationGroup[];
  36440. /**
  36441. * All of the multi-materials added to this scene
  36442. * @see http://doc.babylonjs.com/how_to/multi_materials
  36443. */
  36444. multiMaterials: MultiMaterial[];
  36445. /**
  36446. * All of the materials added to this scene
  36447. * In the context of a Scene, it is not supposed to be modified manually.
  36448. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  36449. * Note also that the order of the Material within the array is not significant and might change.
  36450. * @see http://doc.babylonjs.com/babylon101/materials
  36451. */
  36452. materials: Material[];
  36453. /**
  36454. * The list of morph target managers added to the scene
  36455. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  36456. */
  36457. morphTargetManagers: MorphTargetManager[];
  36458. /**
  36459. * The list of geometries used in the scene.
  36460. */
  36461. geometries: Geometry[];
  36462. /**
  36463. * All of the tranform nodes added to this scene
  36464. * In the context of a Scene, it is not supposed to be modified manually.
  36465. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  36466. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  36467. * @see http://doc.babylonjs.com/how_to/transformnode
  36468. */
  36469. transformNodes: TransformNode[];
  36470. /**
  36471. * ActionManagers available on the scene.
  36472. */
  36473. actionManagers: AbstractActionManager[];
  36474. /**
  36475. * Textures to keep.
  36476. */
  36477. textures: BaseTexture[];
  36478. /**
  36479. * Environment texture for the scene
  36480. */
  36481. environmentTexture: Nullable<BaseTexture>;
  36482. }
  36483. }
  36484. declare module BABYLON {
  36485. /**
  36486. * Interface used to define options for Sound class
  36487. */
  36488. export interface ISoundOptions {
  36489. /**
  36490. * Does the sound autoplay once loaded.
  36491. */
  36492. autoplay?: boolean;
  36493. /**
  36494. * Does the sound loop after it finishes playing once.
  36495. */
  36496. loop?: boolean;
  36497. /**
  36498. * Sound's volume
  36499. */
  36500. volume?: number;
  36501. /**
  36502. * Is it a spatial sound?
  36503. */
  36504. spatialSound?: boolean;
  36505. /**
  36506. * Maximum distance to hear that sound
  36507. */
  36508. maxDistance?: number;
  36509. /**
  36510. * Uses user defined attenuation function
  36511. */
  36512. useCustomAttenuation?: boolean;
  36513. /**
  36514. * Define the roll off factor of spatial sounds.
  36515. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36516. */
  36517. rolloffFactor?: number;
  36518. /**
  36519. * Define the reference distance the sound should be heard perfectly.
  36520. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36521. */
  36522. refDistance?: number;
  36523. /**
  36524. * Define the distance attenuation model the sound will follow.
  36525. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36526. */
  36527. distanceModel?: string;
  36528. /**
  36529. * Defines the playback speed (1 by default)
  36530. */
  36531. playbackRate?: number;
  36532. /**
  36533. * Defines if the sound is from a streaming source
  36534. */
  36535. streaming?: boolean;
  36536. /**
  36537. * Defines an optional length (in seconds) inside the sound file
  36538. */
  36539. length?: number;
  36540. /**
  36541. * Defines an optional offset (in seconds) inside the sound file
  36542. */
  36543. offset?: number;
  36544. /**
  36545. * If true, URLs will not be required to state the audio file codec to use.
  36546. */
  36547. skipCodecCheck?: boolean;
  36548. }
  36549. /**
  36550. * Defines a sound that can be played in the application.
  36551. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  36552. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36553. */
  36554. export class Sound {
  36555. /**
  36556. * The name of the sound in the scene.
  36557. */
  36558. name: string;
  36559. /**
  36560. * Does the sound autoplay once loaded.
  36561. */
  36562. autoplay: boolean;
  36563. /**
  36564. * Does the sound loop after it finishes playing once.
  36565. */
  36566. loop: boolean;
  36567. /**
  36568. * Does the sound use a custom attenuation curve to simulate the falloff
  36569. * happening when the source gets further away from the camera.
  36570. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36571. */
  36572. useCustomAttenuation: boolean;
  36573. /**
  36574. * The sound track id this sound belongs to.
  36575. */
  36576. soundTrackId: number;
  36577. /**
  36578. * Is this sound currently played.
  36579. */
  36580. isPlaying: boolean;
  36581. /**
  36582. * Is this sound currently paused.
  36583. */
  36584. isPaused: boolean;
  36585. /**
  36586. * Does this sound enables spatial sound.
  36587. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36588. */
  36589. spatialSound: boolean;
  36590. /**
  36591. * Define the reference distance the sound should be heard perfectly.
  36592. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36593. */
  36594. refDistance: number;
  36595. /**
  36596. * Define the roll off factor of spatial sounds.
  36597. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36598. */
  36599. rolloffFactor: number;
  36600. /**
  36601. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  36602. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36603. */
  36604. maxDistance: number;
  36605. /**
  36606. * Define the distance attenuation model the sound will follow.
  36607. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36608. */
  36609. distanceModel: string;
  36610. /**
  36611. * @hidden
  36612. * Back Compat
  36613. **/
  36614. onended: () => any;
  36615. /**
  36616. * Observable event when the current playing sound finishes.
  36617. */
  36618. onEndedObservable: Observable<Sound>;
  36619. private _panningModel;
  36620. private _playbackRate;
  36621. private _streaming;
  36622. private _startTime;
  36623. private _startOffset;
  36624. private _position;
  36625. /** @hidden */
  36626. _positionInEmitterSpace: boolean;
  36627. private _localDirection;
  36628. private _volume;
  36629. private _isReadyToPlay;
  36630. private _isDirectional;
  36631. private _readyToPlayCallback;
  36632. private _audioBuffer;
  36633. private _soundSource;
  36634. private _streamingSource;
  36635. private _soundPanner;
  36636. private _soundGain;
  36637. private _inputAudioNode;
  36638. private _outputAudioNode;
  36639. private _coneInnerAngle;
  36640. private _coneOuterAngle;
  36641. private _coneOuterGain;
  36642. private _scene;
  36643. private _connectedTransformNode;
  36644. private _customAttenuationFunction;
  36645. private _registerFunc;
  36646. private _isOutputConnected;
  36647. private _htmlAudioElement;
  36648. private _urlType;
  36649. private _length?;
  36650. private _offset?;
  36651. /** @hidden */
  36652. static _SceneComponentInitialization: (scene: Scene) => void;
  36653. /**
  36654. * Create a sound and attach it to a scene
  36655. * @param name Name of your sound
  36656. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  36657. * @param scene defines the scene the sound belongs to
  36658. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  36659. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  36660. */
  36661. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  36662. /**
  36663. * Release the sound and its associated resources
  36664. */
  36665. dispose(): void;
  36666. /**
  36667. * Gets if the sounds is ready to be played or not.
  36668. * @returns true if ready, otherwise false
  36669. */
  36670. isReady(): boolean;
  36671. private _soundLoaded;
  36672. /**
  36673. * Sets the data of the sound from an audiobuffer
  36674. * @param audioBuffer The audioBuffer containing the data
  36675. */
  36676. setAudioBuffer(audioBuffer: AudioBuffer): void;
  36677. /**
  36678. * Updates the current sounds options such as maxdistance, loop...
  36679. * @param options A JSON object containing values named as the object properties
  36680. */
  36681. updateOptions(options: ISoundOptions): void;
  36682. private _createSpatialParameters;
  36683. private _updateSpatialParameters;
  36684. /**
  36685. * Switch the panning model to HRTF:
  36686. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36687. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36688. */
  36689. switchPanningModelToHRTF(): void;
  36690. /**
  36691. * Switch the panning model to Equal Power:
  36692. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36693. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36694. */
  36695. switchPanningModelToEqualPower(): void;
  36696. private _switchPanningModel;
  36697. /**
  36698. * Connect this sound to a sound track audio node like gain...
  36699. * @param soundTrackAudioNode the sound track audio node to connect to
  36700. */
  36701. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  36702. /**
  36703. * Transform this sound into a directional source
  36704. * @param coneInnerAngle Size of the inner cone in degree
  36705. * @param coneOuterAngle Size of the outer cone in degree
  36706. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  36707. */
  36708. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  36709. /**
  36710. * Gets or sets the inner angle for the directional cone.
  36711. */
  36712. /**
  36713. * Gets or sets the inner angle for the directional cone.
  36714. */
  36715. directionalConeInnerAngle: number;
  36716. /**
  36717. * Gets or sets the outer angle for the directional cone.
  36718. */
  36719. /**
  36720. * Gets or sets the outer angle for the directional cone.
  36721. */
  36722. directionalConeOuterAngle: number;
  36723. /**
  36724. * Sets the position of the emitter if spatial sound is enabled
  36725. * @param newPosition Defines the new posisiton
  36726. */
  36727. setPosition(newPosition: Vector3): void;
  36728. /**
  36729. * Sets the local direction of the emitter if spatial sound is enabled
  36730. * @param newLocalDirection Defines the new local direction
  36731. */
  36732. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  36733. private _updateDirection;
  36734. /** @hidden */
  36735. updateDistanceFromListener(): void;
  36736. /**
  36737. * Sets a new custom attenuation function for the sound.
  36738. * @param callback Defines the function used for the attenuation
  36739. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36740. */
  36741. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  36742. /**
  36743. * Play the sound
  36744. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  36745. * @param offset (optional) Start the sound at a specific time in seconds
  36746. * @param length (optional) Sound duration (in seconds)
  36747. */
  36748. play(time?: number, offset?: number, length?: number): void;
  36749. private _onended;
  36750. /**
  36751. * Stop the sound
  36752. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  36753. */
  36754. stop(time?: number): void;
  36755. /**
  36756. * Put the sound in pause
  36757. */
  36758. pause(): void;
  36759. /**
  36760. * Sets a dedicated volume for this sounds
  36761. * @param newVolume Define the new volume of the sound
  36762. * @param time Define time for gradual change to new volume
  36763. */
  36764. setVolume(newVolume: number, time?: number): void;
  36765. /**
  36766. * Set the sound play back rate
  36767. * @param newPlaybackRate Define the playback rate the sound should be played at
  36768. */
  36769. setPlaybackRate(newPlaybackRate: number): void;
  36770. /**
  36771. * Gets the volume of the sound.
  36772. * @returns the volume of the sound
  36773. */
  36774. getVolume(): number;
  36775. /**
  36776. * Attach the sound to a dedicated mesh
  36777. * @param transformNode The transform node to connect the sound with
  36778. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36779. */
  36780. attachToMesh(transformNode: TransformNode): void;
  36781. /**
  36782. * Detach the sound from the previously attached mesh
  36783. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36784. */
  36785. detachFromMesh(): void;
  36786. private _onRegisterAfterWorldMatrixUpdate;
  36787. /**
  36788. * Clone the current sound in the scene.
  36789. * @returns the new sound clone
  36790. */
  36791. clone(): Nullable<Sound>;
  36792. /**
  36793. * Gets the current underlying audio buffer containing the data
  36794. * @returns the audio buffer
  36795. */
  36796. getAudioBuffer(): Nullable<AudioBuffer>;
  36797. /**
  36798. * Serializes the Sound in a JSON representation
  36799. * @returns the JSON representation of the sound
  36800. */
  36801. serialize(): any;
  36802. /**
  36803. * Parse a JSON representation of a sound to innstantiate in a given scene
  36804. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  36805. * @param scene Define the scene the new parsed sound should be created in
  36806. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  36807. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  36808. * @returns the newly parsed sound
  36809. */
  36810. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  36811. }
  36812. }
  36813. declare module BABYLON {
  36814. /**
  36815. * This defines an action helpful to play a defined sound on a triggered action.
  36816. */
  36817. export class PlaySoundAction extends Action {
  36818. private _sound;
  36819. /**
  36820. * Instantiate the action
  36821. * @param triggerOptions defines the trigger options
  36822. * @param sound defines the sound to play
  36823. * @param condition defines the trigger related conditions
  36824. */
  36825. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36826. /** @hidden */
  36827. _prepare(): void;
  36828. /**
  36829. * Execute the action and play the sound.
  36830. */
  36831. execute(): void;
  36832. /**
  36833. * Serializes the actions and its related information.
  36834. * @param parent defines the object to serialize in
  36835. * @returns the serialized object
  36836. */
  36837. serialize(parent: any): any;
  36838. }
  36839. /**
  36840. * This defines an action helpful to stop a defined sound on a triggered action.
  36841. */
  36842. export class StopSoundAction extends Action {
  36843. private _sound;
  36844. /**
  36845. * Instantiate the action
  36846. * @param triggerOptions defines the trigger options
  36847. * @param sound defines the sound to stop
  36848. * @param condition defines the trigger related conditions
  36849. */
  36850. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36851. /** @hidden */
  36852. _prepare(): void;
  36853. /**
  36854. * Execute the action and stop the sound.
  36855. */
  36856. execute(): void;
  36857. /**
  36858. * Serializes the actions and its related information.
  36859. * @param parent defines the object to serialize in
  36860. * @returns the serialized object
  36861. */
  36862. serialize(parent: any): any;
  36863. }
  36864. }
  36865. declare module BABYLON {
  36866. /**
  36867. * This defines an action responsible to change the value of a property
  36868. * by interpolating between its current value and the newly set one once triggered.
  36869. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36870. */
  36871. export class InterpolateValueAction extends Action {
  36872. /**
  36873. * Defines the path of the property where the value should be interpolated
  36874. */
  36875. propertyPath: string;
  36876. /**
  36877. * Defines the target value at the end of the interpolation.
  36878. */
  36879. value: any;
  36880. /**
  36881. * Defines the time it will take for the property to interpolate to the value.
  36882. */
  36883. duration: number;
  36884. /**
  36885. * Defines if the other scene animations should be stopped when the action has been triggered
  36886. */
  36887. stopOtherAnimations?: boolean;
  36888. /**
  36889. * Defines a callback raised once the interpolation animation has been done.
  36890. */
  36891. onInterpolationDone?: () => void;
  36892. /**
  36893. * Observable triggered once the interpolation animation has been done.
  36894. */
  36895. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  36896. private _target;
  36897. private _effectiveTarget;
  36898. private _property;
  36899. /**
  36900. * Instantiate the action
  36901. * @param triggerOptions defines the trigger options
  36902. * @param target defines the object containing the value to interpolate
  36903. * @param propertyPath defines the path to the property in the target object
  36904. * @param value defines the target value at the end of the interpolation
  36905. * @param duration deines the time it will take for the property to interpolate to the value.
  36906. * @param condition defines the trigger related conditions
  36907. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  36908. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  36909. */
  36910. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  36911. /** @hidden */
  36912. _prepare(): void;
  36913. /**
  36914. * Execute the action starts the value interpolation.
  36915. */
  36916. execute(): void;
  36917. /**
  36918. * Serializes the actions and its related information.
  36919. * @param parent defines the object to serialize in
  36920. * @returns the serialized object
  36921. */
  36922. serialize(parent: any): any;
  36923. }
  36924. }
  36925. declare module BABYLON {
  36926. /**
  36927. * Options allowed during the creation of a sound track.
  36928. */
  36929. export interface ISoundTrackOptions {
  36930. /**
  36931. * The volume the sound track should take during creation
  36932. */
  36933. volume?: number;
  36934. /**
  36935. * Define if the sound track is the main sound track of the scene
  36936. */
  36937. mainTrack?: boolean;
  36938. }
  36939. /**
  36940. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  36941. * It will be also used in a future release to apply effects on a specific track.
  36942. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36943. */
  36944. export class SoundTrack {
  36945. /**
  36946. * The unique identifier of the sound track in the scene.
  36947. */
  36948. id: number;
  36949. /**
  36950. * The list of sounds included in the sound track.
  36951. */
  36952. soundCollection: Array<Sound>;
  36953. private _outputAudioNode;
  36954. private _scene;
  36955. private _connectedAnalyser;
  36956. private _options;
  36957. private _isInitialized;
  36958. /**
  36959. * Creates a new sound track.
  36960. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36961. * @param scene Define the scene the sound track belongs to
  36962. * @param options
  36963. */
  36964. constructor(scene: Scene, options?: ISoundTrackOptions);
  36965. private _initializeSoundTrackAudioGraph;
  36966. /**
  36967. * Release the sound track and its associated resources
  36968. */
  36969. dispose(): void;
  36970. /**
  36971. * Adds a sound to this sound track
  36972. * @param sound define the cound to add
  36973. * @ignoreNaming
  36974. */
  36975. AddSound(sound: Sound): void;
  36976. /**
  36977. * Removes a sound to this sound track
  36978. * @param sound define the cound to remove
  36979. * @ignoreNaming
  36980. */
  36981. RemoveSound(sound: Sound): void;
  36982. /**
  36983. * Set a global volume for the full sound track.
  36984. * @param newVolume Define the new volume of the sound track
  36985. */
  36986. setVolume(newVolume: number): void;
  36987. /**
  36988. * Switch the panning model to HRTF:
  36989. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36990. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36991. */
  36992. switchPanningModelToHRTF(): void;
  36993. /**
  36994. * Switch the panning model to Equal Power:
  36995. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36996. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36997. */
  36998. switchPanningModelToEqualPower(): void;
  36999. /**
  37000. * Connect the sound track to an audio analyser allowing some amazing
  37001. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  37002. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  37003. * @param analyser The analyser to connect to the engine
  37004. */
  37005. connectToAnalyser(analyser: Analyser): void;
  37006. }
  37007. }
  37008. declare module BABYLON {
  37009. interface AbstractScene {
  37010. /**
  37011. * The list of sounds used in the scene.
  37012. */
  37013. sounds: Nullable<Array<Sound>>;
  37014. }
  37015. interface Scene {
  37016. /**
  37017. * @hidden
  37018. * Backing field
  37019. */
  37020. _mainSoundTrack: SoundTrack;
  37021. /**
  37022. * The main sound track played by the scene.
  37023. * It cotains your primary collection of sounds.
  37024. */
  37025. mainSoundTrack: SoundTrack;
  37026. /**
  37027. * The list of sound tracks added to the scene
  37028. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37029. */
  37030. soundTracks: Nullable<Array<SoundTrack>>;
  37031. /**
  37032. * Gets a sound using a given name
  37033. * @param name defines the name to search for
  37034. * @return the found sound or null if not found at all.
  37035. */
  37036. getSoundByName(name: string): Nullable<Sound>;
  37037. /**
  37038. * Gets or sets if audio support is enabled
  37039. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37040. */
  37041. audioEnabled: boolean;
  37042. /**
  37043. * Gets or sets if audio will be output to headphones
  37044. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37045. */
  37046. headphone: boolean;
  37047. /**
  37048. * Gets or sets custom audio listener position provider
  37049. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37050. */
  37051. audioListenerPositionProvider: Nullable<() => Vector3>;
  37052. /**
  37053. * Gets or sets a refresh rate when using 3D audio positioning
  37054. */
  37055. audioPositioningRefreshRate: number;
  37056. }
  37057. /**
  37058. * Defines the sound scene component responsible to manage any sounds
  37059. * in a given scene.
  37060. */
  37061. export class AudioSceneComponent implements ISceneSerializableComponent {
  37062. /**
  37063. * The component name helpfull to identify the component in the list of scene components.
  37064. */
  37065. readonly name: string;
  37066. /**
  37067. * The scene the component belongs to.
  37068. */
  37069. scene: Scene;
  37070. private _audioEnabled;
  37071. /**
  37072. * Gets whether audio is enabled or not.
  37073. * Please use related enable/disable method to switch state.
  37074. */
  37075. readonly audioEnabled: boolean;
  37076. private _headphone;
  37077. /**
  37078. * Gets whether audio is outputing to headphone or not.
  37079. * Please use the according Switch methods to change output.
  37080. */
  37081. readonly headphone: boolean;
  37082. /**
  37083. * Gets or sets a refresh rate when using 3D audio positioning
  37084. */
  37085. audioPositioningRefreshRate: number;
  37086. private _audioListenerPositionProvider;
  37087. /**
  37088. * Gets the current audio listener position provider
  37089. */
  37090. /**
  37091. * Sets a custom listener position for all sounds in the scene
  37092. * By default, this is the position of the first active camera
  37093. */
  37094. audioListenerPositionProvider: Nullable<() => Vector3>;
  37095. /**
  37096. * Creates a new instance of the component for the given scene
  37097. * @param scene Defines the scene to register the component in
  37098. */
  37099. constructor(scene: Scene);
  37100. /**
  37101. * Registers the component in a given scene
  37102. */
  37103. register(): void;
  37104. /**
  37105. * Rebuilds the elements related to this component in case of
  37106. * context lost for instance.
  37107. */
  37108. rebuild(): void;
  37109. /**
  37110. * Serializes the component data to the specified json object
  37111. * @param serializationObject The object to serialize to
  37112. */
  37113. serialize(serializationObject: any): void;
  37114. /**
  37115. * Adds all the elements from the container to the scene
  37116. * @param container the container holding the elements
  37117. */
  37118. addFromContainer(container: AbstractScene): void;
  37119. /**
  37120. * Removes all the elements in the container from the scene
  37121. * @param container contains the elements to remove
  37122. * @param dispose if the removed element should be disposed (default: false)
  37123. */
  37124. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  37125. /**
  37126. * Disposes the component and the associated ressources.
  37127. */
  37128. dispose(): void;
  37129. /**
  37130. * Disables audio in the associated scene.
  37131. */
  37132. disableAudio(): void;
  37133. /**
  37134. * Enables audio in the associated scene.
  37135. */
  37136. enableAudio(): void;
  37137. /**
  37138. * Switch audio to headphone output.
  37139. */
  37140. switchAudioModeForHeadphones(): void;
  37141. /**
  37142. * Switch audio to normal speakers.
  37143. */
  37144. switchAudioModeForNormalSpeakers(): void;
  37145. private _cachedCameraDirection;
  37146. private _cachedCameraPosition;
  37147. private _lastCheck;
  37148. private _afterRender;
  37149. }
  37150. }
  37151. declare module BABYLON {
  37152. /**
  37153. * Wraps one or more Sound objects and selects one with random weight for playback.
  37154. */
  37155. export class WeightedSound {
  37156. /** When true a Sound will be selected and played when the current playing Sound completes. */
  37157. loop: boolean;
  37158. private _coneInnerAngle;
  37159. private _coneOuterAngle;
  37160. private _volume;
  37161. /** A Sound is currently playing. */
  37162. isPlaying: boolean;
  37163. /** A Sound is currently paused. */
  37164. isPaused: boolean;
  37165. private _sounds;
  37166. private _weights;
  37167. private _currentIndex?;
  37168. /**
  37169. * Creates a new WeightedSound from the list of sounds given.
  37170. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  37171. * @param sounds Array of Sounds that will be selected from.
  37172. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  37173. */
  37174. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  37175. /**
  37176. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  37177. */
  37178. /**
  37179. * The size of cone in degress for a directional sound in which there will be no attenuation.
  37180. */
  37181. directionalConeInnerAngle: number;
  37182. /**
  37183. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  37184. * Listener angles between innerAngle and outerAngle will falloff linearly.
  37185. */
  37186. /**
  37187. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  37188. * Listener angles between innerAngle and outerAngle will falloff linearly.
  37189. */
  37190. directionalConeOuterAngle: number;
  37191. /**
  37192. * Playback volume.
  37193. */
  37194. /**
  37195. * Playback volume.
  37196. */
  37197. volume: number;
  37198. private _onended;
  37199. /**
  37200. * Suspend playback
  37201. */
  37202. pause(): void;
  37203. /**
  37204. * Stop playback
  37205. */
  37206. stop(): void;
  37207. /**
  37208. * Start playback.
  37209. * @param startOffset Position the clip head at a specific time in seconds.
  37210. */
  37211. play(startOffset?: number): void;
  37212. }
  37213. }
  37214. declare module BABYLON {
  37215. /**
  37216. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  37217. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37218. */
  37219. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  37220. /**
  37221. * Gets the name of the behavior.
  37222. */
  37223. readonly name: string;
  37224. /**
  37225. * The easing function used by animations
  37226. */
  37227. static EasingFunction: BackEase;
  37228. /**
  37229. * The easing mode used by animations
  37230. */
  37231. static EasingMode: number;
  37232. /**
  37233. * The duration of the animation, in milliseconds
  37234. */
  37235. transitionDuration: number;
  37236. /**
  37237. * Length of the distance animated by the transition when lower radius is reached
  37238. */
  37239. lowerRadiusTransitionRange: number;
  37240. /**
  37241. * Length of the distance animated by the transition when upper radius is reached
  37242. */
  37243. upperRadiusTransitionRange: number;
  37244. private _autoTransitionRange;
  37245. /**
  37246. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37247. */
  37248. /**
  37249. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37250. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  37251. */
  37252. autoTransitionRange: boolean;
  37253. private _attachedCamera;
  37254. private _onAfterCheckInputsObserver;
  37255. private _onMeshTargetChangedObserver;
  37256. /**
  37257. * Initializes the behavior.
  37258. */
  37259. init(): void;
  37260. /**
  37261. * Attaches the behavior to its arc rotate camera.
  37262. * @param camera Defines the camera to attach the behavior to
  37263. */
  37264. attach(camera: ArcRotateCamera): void;
  37265. /**
  37266. * Detaches the behavior from its current arc rotate camera.
  37267. */
  37268. detach(): void;
  37269. private _radiusIsAnimating;
  37270. private _radiusBounceTransition;
  37271. private _animatables;
  37272. private _cachedWheelPrecision;
  37273. /**
  37274. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  37275. * @param radiusLimit The limit to check against.
  37276. * @return Bool to indicate if at limit.
  37277. */
  37278. private _isRadiusAtLimit;
  37279. /**
  37280. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  37281. * @param radiusDelta The delta by which to animate to. Can be negative.
  37282. */
  37283. private _applyBoundRadiusAnimation;
  37284. /**
  37285. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  37286. */
  37287. protected _clearAnimationLocks(): void;
  37288. /**
  37289. * Stops and removes all animations that have been applied to the camera
  37290. */
  37291. stopAllAnimations(): void;
  37292. }
  37293. }
  37294. declare module BABYLON {
  37295. /**
  37296. * 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.
  37297. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37298. */
  37299. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  37300. /**
  37301. * Gets the name of the behavior.
  37302. */
  37303. readonly name: string;
  37304. private _mode;
  37305. private _radiusScale;
  37306. private _positionScale;
  37307. private _defaultElevation;
  37308. private _elevationReturnTime;
  37309. private _elevationReturnWaitTime;
  37310. private _zoomStopsAnimation;
  37311. private _framingTime;
  37312. /**
  37313. * The easing function used by animations
  37314. */
  37315. static EasingFunction: ExponentialEase;
  37316. /**
  37317. * The easing mode used by animations
  37318. */
  37319. static EasingMode: number;
  37320. /**
  37321. * Sets the current mode used by the behavior
  37322. */
  37323. /**
  37324. * Gets current mode used by the behavior.
  37325. */
  37326. mode: number;
  37327. /**
  37328. * Sets the scale applied to the radius (1 by default)
  37329. */
  37330. /**
  37331. * Gets the scale applied to the radius
  37332. */
  37333. radiusScale: number;
  37334. /**
  37335. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  37336. */
  37337. /**
  37338. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  37339. */
  37340. positionScale: number;
  37341. /**
  37342. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  37343. * behaviour is triggered, in radians.
  37344. */
  37345. /**
  37346. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  37347. * behaviour is triggered, in radians.
  37348. */
  37349. defaultElevation: number;
  37350. /**
  37351. * Sets the time (in milliseconds) taken to return to the default beta position.
  37352. * Negative value indicates camera should not return to default.
  37353. */
  37354. /**
  37355. * Gets the time (in milliseconds) taken to return to the default beta position.
  37356. * Negative value indicates camera should not return to default.
  37357. */
  37358. elevationReturnTime: number;
  37359. /**
  37360. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  37361. */
  37362. /**
  37363. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  37364. */
  37365. elevationReturnWaitTime: number;
  37366. /**
  37367. * Sets the flag that indicates if user zooming should stop animation.
  37368. */
  37369. /**
  37370. * Gets the flag that indicates if user zooming should stop animation.
  37371. */
  37372. zoomStopsAnimation: boolean;
  37373. /**
  37374. * Sets the transition time when framing the mesh, in milliseconds
  37375. */
  37376. /**
  37377. * Gets the transition time when framing the mesh, in milliseconds
  37378. */
  37379. framingTime: number;
  37380. /**
  37381. * Define if the behavior should automatically change the configured
  37382. * camera limits and sensibilities.
  37383. */
  37384. autoCorrectCameraLimitsAndSensibility: boolean;
  37385. private _onPrePointerObservableObserver;
  37386. private _onAfterCheckInputsObserver;
  37387. private _onMeshTargetChangedObserver;
  37388. private _attachedCamera;
  37389. private _isPointerDown;
  37390. private _lastInteractionTime;
  37391. /**
  37392. * Initializes the behavior.
  37393. */
  37394. init(): void;
  37395. /**
  37396. * Attaches the behavior to its arc rotate camera.
  37397. * @param camera Defines the camera to attach the behavior to
  37398. */
  37399. attach(camera: ArcRotateCamera): void;
  37400. /**
  37401. * Detaches the behavior from its current arc rotate camera.
  37402. */
  37403. detach(): void;
  37404. private _animatables;
  37405. private _betaIsAnimating;
  37406. private _betaTransition;
  37407. private _radiusTransition;
  37408. private _vectorTransition;
  37409. /**
  37410. * Targets the given mesh and updates zoom level accordingly.
  37411. * @param mesh The mesh to target.
  37412. * @param radius Optional. If a cached radius position already exists, overrides default.
  37413. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37414. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37415. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37416. */
  37417. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37418. /**
  37419. * Targets the given mesh with its children and updates zoom level accordingly.
  37420. * @param mesh The mesh to target.
  37421. * @param radius Optional. If a cached radius position already exists, overrides default.
  37422. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37423. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37424. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37425. */
  37426. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37427. /**
  37428. * Targets the given meshes with their children and updates zoom level accordingly.
  37429. * @param meshes The mesh to target.
  37430. * @param radius Optional. If a cached radius position already exists, overrides default.
  37431. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37432. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37433. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37434. */
  37435. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37436. /**
  37437. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  37438. * @param minimumWorld Determines the smaller position of the bounding box extend
  37439. * @param maximumWorld Determines the bigger position of the bounding box extend
  37440. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37441. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37442. */
  37443. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37444. /**
  37445. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  37446. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  37447. * frustum width.
  37448. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  37449. * to fully enclose the mesh in the viewing frustum.
  37450. */
  37451. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  37452. /**
  37453. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  37454. * is automatically returned to its default position (expected to be above ground plane).
  37455. */
  37456. private _maintainCameraAboveGround;
  37457. /**
  37458. * Returns the frustum slope based on the canvas ratio and camera FOV
  37459. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  37460. */
  37461. private _getFrustumSlope;
  37462. /**
  37463. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  37464. */
  37465. private _clearAnimationLocks;
  37466. /**
  37467. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37468. */
  37469. private _applyUserInteraction;
  37470. /**
  37471. * Stops and removes all animations that have been applied to the camera
  37472. */
  37473. stopAllAnimations(): void;
  37474. /**
  37475. * Gets a value indicating if the user is moving the camera
  37476. */
  37477. readonly isUserIsMoving: boolean;
  37478. /**
  37479. * The camera can move all the way towards the mesh.
  37480. */
  37481. static IgnoreBoundsSizeMode: number;
  37482. /**
  37483. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  37484. */
  37485. static FitFrustumSidesMode: number;
  37486. }
  37487. }
  37488. declare module BABYLON {
  37489. /**
  37490. * Base class for Camera Pointer Inputs.
  37491. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  37492. * for example usage.
  37493. */
  37494. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  37495. /**
  37496. * Defines the camera the input is attached to.
  37497. */
  37498. abstract camera: Camera;
  37499. /**
  37500. * Whether keyboard modifier keys are pressed at time of last mouse event.
  37501. */
  37502. protected _altKey: boolean;
  37503. protected _ctrlKey: boolean;
  37504. protected _metaKey: boolean;
  37505. protected _shiftKey: boolean;
  37506. /**
  37507. * Which mouse buttons were pressed at time of last mouse event.
  37508. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  37509. */
  37510. protected _buttonsPressed: number;
  37511. /**
  37512. * Defines the buttons associated with the input to handle camera move.
  37513. */
  37514. buttons: number[];
  37515. /**
  37516. * Attach the input controls to a specific dom element to get the input from.
  37517. * @param element Defines the element the controls should be listened from
  37518. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37519. */
  37520. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37521. /**
  37522. * Detach the current controls from the specified dom element.
  37523. * @param element Defines the element to stop listening the inputs from
  37524. */
  37525. detachControl(element: Nullable<HTMLElement>): void;
  37526. /**
  37527. * Gets the class name of the current input.
  37528. * @returns the class name
  37529. */
  37530. getClassName(): string;
  37531. /**
  37532. * Get the friendly name associated with the input class.
  37533. * @returns the input friendly name
  37534. */
  37535. getSimpleName(): string;
  37536. /**
  37537. * Called on pointer POINTERDOUBLETAP event.
  37538. * Override this method to provide functionality on POINTERDOUBLETAP event.
  37539. */
  37540. protected onDoubleTap(type: string): void;
  37541. /**
  37542. * Called on pointer POINTERMOVE event if only a single touch is active.
  37543. * Override this method to provide functionality.
  37544. */
  37545. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37546. /**
  37547. * Called on pointer POINTERMOVE event if multiple touches are active.
  37548. * Override this method to provide functionality.
  37549. */
  37550. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37551. /**
  37552. * Called on JS contextmenu event.
  37553. * Override this method to provide functionality.
  37554. */
  37555. protected onContextMenu(evt: PointerEvent): void;
  37556. /**
  37557. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37558. * press.
  37559. * Override this method to provide functionality.
  37560. */
  37561. protected onButtonDown(evt: PointerEvent): void;
  37562. /**
  37563. * Called each time a new POINTERUP event occurs. Ie, for each button
  37564. * release.
  37565. * Override this method to provide functionality.
  37566. */
  37567. protected onButtonUp(evt: PointerEvent): void;
  37568. /**
  37569. * Called when window becomes inactive.
  37570. * Override this method to provide functionality.
  37571. */
  37572. protected onLostFocus(): void;
  37573. private _pointerInput;
  37574. private _observer;
  37575. private _onLostFocus;
  37576. private pointA;
  37577. private pointB;
  37578. }
  37579. }
  37580. declare module BABYLON {
  37581. /**
  37582. * Manage the pointers inputs to control an arc rotate camera.
  37583. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37584. */
  37585. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  37586. /**
  37587. * Defines the camera the input is attached to.
  37588. */
  37589. camera: ArcRotateCamera;
  37590. /**
  37591. * Gets the class name of the current input.
  37592. * @returns the class name
  37593. */
  37594. getClassName(): string;
  37595. /**
  37596. * Defines the buttons associated with the input to handle camera move.
  37597. */
  37598. buttons: number[];
  37599. /**
  37600. * Defines the pointer angular sensibility along the X axis or how fast is
  37601. * the camera rotating.
  37602. */
  37603. angularSensibilityX: number;
  37604. /**
  37605. * Defines the pointer angular sensibility along the Y axis or how fast is
  37606. * the camera rotating.
  37607. */
  37608. angularSensibilityY: number;
  37609. /**
  37610. * Defines the pointer pinch precision or how fast is the camera zooming.
  37611. */
  37612. pinchPrecision: number;
  37613. /**
  37614. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37615. * from 0.
  37616. * It defines the percentage of current camera.radius to use as delta when
  37617. * pinch zoom is used.
  37618. */
  37619. pinchDeltaPercentage: number;
  37620. /**
  37621. * Defines the pointer panning sensibility or how fast is the camera moving.
  37622. */
  37623. panningSensibility: number;
  37624. /**
  37625. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  37626. */
  37627. multiTouchPanning: boolean;
  37628. /**
  37629. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  37630. * zoom (pinch) through multitouch.
  37631. */
  37632. multiTouchPanAndZoom: boolean;
  37633. /**
  37634. * Revers pinch action direction.
  37635. */
  37636. pinchInwards: boolean;
  37637. private _isPanClick;
  37638. private _twoFingerActivityCount;
  37639. private _isPinching;
  37640. /**
  37641. * Called on pointer POINTERMOVE event if only a single touch is active.
  37642. */
  37643. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37644. /**
  37645. * Called on pointer POINTERDOUBLETAP event.
  37646. */
  37647. protected onDoubleTap(type: string): void;
  37648. /**
  37649. * Called on pointer POINTERMOVE event if multiple touches are active.
  37650. */
  37651. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37652. /**
  37653. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37654. * press.
  37655. */
  37656. protected onButtonDown(evt: PointerEvent): void;
  37657. /**
  37658. * Called each time a new POINTERUP event occurs. Ie, for each button
  37659. * release.
  37660. */
  37661. protected onButtonUp(evt: PointerEvent): void;
  37662. /**
  37663. * Called when window becomes inactive.
  37664. */
  37665. protected onLostFocus(): void;
  37666. }
  37667. }
  37668. declare module BABYLON {
  37669. /**
  37670. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  37671. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37672. */
  37673. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  37674. /**
  37675. * Defines the camera the input is attached to.
  37676. */
  37677. camera: ArcRotateCamera;
  37678. /**
  37679. * Defines the list of key codes associated with the up action (increase alpha)
  37680. */
  37681. keysUp: number[];
  37682. /**
  37683. * Defines the list of key codes associated with the down action (decrease alpha)
  37684. */
  37685. keysDown: number[];
  37686. /**
  37687. * Defines the list of key codes associated with the left action (increase beta)
  37688. */
  37689. keysLeft: number[];
  37690. /**
  37691. * Defines the list of key codes associated with the right action (decrease beta)
  37692. */
  37693. keysRight: number[];
  37694. /**
  37695. * Defines the list of key codes associated with the reset action.
  37696. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  37697. */
  37698. keysReset: number[];
  37699. /**
  37700. * Defines the panning sensibility of the inputs.
  37701. * (How fast is the camera paning)
  37702. */
  37703. panningSensibility: number;
  37704. /**
  37705. * Defines the zooming sensibility of the inputs.
  37706. * (How fast is the camera zooming)
  37707. */
  37708. zoomingSensibility: number;
  37709. /**
  37710. * Defines wether maintaining the alt key down switch the movement mode from
  37711. * orientation to zoom.
  37712. */
  37713. useAltToZoom: boolean;
  37714. /**
  37715. * Rotation speed of the camera
  37716. */
  37717. angularSpeed: number;
  37718. private _keys;
  37719. private _ctrlPressed;
  37720. private _altPressed;
  37721. private _onCanvasBlurObserver;
  37722. private _onKeyboardObserver;
  37723. private _engine;
  37724. private _scene;
  37725. /**
  37726. * Attach the input controls to a specific dom element to get the input from.
  37727. * @param element Defines the element the controls should be listened from
  37728. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37729. */
  37730. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37731. /**
  37732. * Detach the current controls from the specified dom element.
  37733. * @param element Defines the element to stop listening the inputs from
  37734. */
  37735. detachControl(element: Nullable<HTMLElement>): void;
  37736. /**
  37737. * Update the current camera state depending on the inputs that have been used this frame.
  37738. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37739. */
  37740. checkInputs(): void;
  37741. /**
  37742. * Gets the class name of the current intput.
  37743. * @returns the class name
  37744. */
  37745. getClassName(): string;
  37746. /**
  37747. * Get the friendly name associated with the input class.
  37748. * @returns the input friendly name
  37749. */
  37750. getSimpleName(): string;
  37751. }
  37752. }
  37753. declare module BABYLON {
  37754. /**
  37755. * Manage the mouse wheel inputs to control an arc rotate camera.
  37756. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37757. */
  37758. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  37759. /**
  37760. * Defines the camera the input is attached to.
  37761. */
  37762. camera: ArcRotateCamera;
  37763. /**
  37764. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37765. */
  37766. wheelPrecision: number;
  37767. /**
  37768. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37769. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37770. */
  37771. wheelDeltaPercentage: number;
  37772. private _wheel;
  37773. private _observer;
  37774. private computeDeltaFromMouseWheelLegacyEvent;
  37775. /**
  37776. * Attach the input controls to a specific dom element to get the input from.
  37777. * @param element Defines the element the controls should be listened from
  37778. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37779. */
  37780. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37781. /**
  37782. * Detach the current controls from the specified dom element.
  37783. * @param element Defines the element to stop listening the inputs from
  37784. */
  37785. detachControl(element: Nullable<HTMLElement>): void;
  37786. /**
  37787. * Gets the class name of the current intput.
  37788. * @returns the class name
  37789. */
  37790. getClassName(): string;
  37791. /**
  37792. * Get the friendly name associated with the input class.
  37793. * @returns the input friendly name
  37794. */
  37795. getSimpleName(): string;
  37796. }
  37797. }
  37798. declare module BABYLON {
  37799. /**
  37800. * Default Inputs manager for the ArcRotateCamera.
  37801. * It groups all the default supported inputs for ease of use.
  37802. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37803. */
  37804. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  37805. /**
  37806. * Instantiates a new ArcRotateCameraInputsManager.
  37807. * @param camera Defines the camera the inputs belong to
  37808. */
  37809. constructor(camera: ArcRotateCamera);
  37810. /**
  37811. * Add mouse wheel input support to the input manager.
  37812. * @returns the current input manager
  37813. */
  37814. addMouseWheel(): ArcRotateCameraInputsManager;
  37815. /**
  37816. * Add pointers input support to the input manager.
  37817. * @returns the current input manager
  37818. */
  37819. addPointers(): ArcRotateCameraInputsManager;
  37820. /**
  37821. * Add keyboard input support to the input manager.
  37822. * @returns the current input manager
  37823. */
  37824. addKeyboard(): ArcRotateCameraInputsManager;
  37825. }
  37826. }
  37827. declare module BABYLON {
  37828. /**
  37829. * This represents an orbital type of camera.
  37830. *
  37831. * 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.
  37832. * 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.
  37833. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  37834. */
  37835. export class ArcRotateCamera extends TargetCamera {
  37836. /**
  37837. * Defines the rotation angle of the camera along the longitudinal axis.
  37838. */
  37839. alpha: number;
  37840. /**
  37841. * Defines the rotation angle of the camera along the latitudinal axis.
  37842. */
  37843. beta: number;
  37844. /**
  37845. * Defines the radius of the camera from it s target point.
  37846. */
  37847. radius: number;
  37848. protected _target: Vector3;
  37849. protected _targetHost: Nullable<AbstractMesh>;
  37850. /**
  37851. * Defines the target point of the camera.
  37852. * The camera looks towards it form the radius distance.
  37853. */
  37854. target: Vector3;
  37855. /**
  37856. * Define the current local position of the camera in the scene
  37857. */
  37858. position: Vector3;
  37859. protected _upVector: Vector3;
  37860. protected _upToYMatrix: Matrix;
  37861. protected _YToUpMatrix: Matrix;
  37862. /**
  37863. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  37864. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  37865. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  37866. */
  37867. upVector: Vector3;
  37868. /**
  37869. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  37870. */
  37871. setMatUp(): void;
  37872. /**
  37873. * Current inertia value on the longitudinal axis.
  37874. * The bigger this number the longer it will take for the camera to stop.
  37875. */
  37876. inertialAlphaOffset: number;
  37877. /**
  37878. * Current inertia value on the latitudinal axis.
  37879. * The bigger this number the longer it will take for the camera to stop.
  37880. */
  37881. inertialBetaOffset: number;
  37882. /**
  37883. * Current inertia value on the radius axis.
  37884. * The bigger this number the longer it will take for the camera to stop.
  37885. */
  37886. inertialRadiusOffset: number;
  37887. /**
  37888. * Minimum allowed angle on the longitudinal axis.
  37889. * This can help limiting how the Camera is able to move in the scene.
  37890. */
  37891. lowerAlphaLimit: Nullable<number>;
  37892. /**
  37893. * Maximum allowed angle on the longitudinal axis.
  37894. * This can help limiting how the Camera is able to move in the scene.
  37895. */
  37896. upperAlphaLimit: Nullable<number>;
  37897. /**
  37898. * Minimum allowed angle on the latitudinal axis.
  37899. * This can help limiting how the Camera is able to move in the scene.
  37900. */
  37901. lowerBetaLimit: number;
  37902. /**
  37903. * Maximum allowed angle on the latitudinal axis.
  37904. * This can help limiting how the Camera is able to move in the scene.
  37905. */
  37906. upperBetaLimit: number;
  37907. /**
  37908. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  37909. * This can help limiting how the Camera is able to move in the scene.
  37910. */
  37911. lowerRadiusLimit: Nullable<number>;
  37912. /**
  37913. * Maximum allowed distance of the camera to the target (The camera can not get further).
  37914. * This can help limiting how the Camera is able to move in the scene.
  37915. */
  37916. upperRadiusLimit: Nullable<number>;
  37917. /**
  37918. * Defines the current inertia value used during panning of the camera along the X axis.
  37919. */
  37920. inertialPanningX: number;
  37921. /**
  37922. * Defines the current inertia value used during panning of the camera along the Y axis.
  37923. */
  37924. inertialPanningY: number;
  37925. /**
  37926. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  37927. * Basically if your fingers moves away from more than this distance you will be considered
  37928. * in pinch mode.
  37929. */
  37930. pinchToPanMaxDistance: number;
  37931. /**
  37932. * Defines the maximum distance the camera can pan.
  37933. * This could help keeping the cammera always in your scene.
  37934. */
  37935. panningDistanceLimit: Nullable<number>;
  37936. /**
  37937. * Defines the target of the camera before paning.
  37938. */
  37939. panningOriginTarget: Vector3;
  37940. /**
  37941. * Defines the value of the inertia used during panning.
  37942. * 0 would mean stop inertia and one would mean no decelleration at all.
  37943. */
  37944. panningInertia: number;
  37945. /**
  37946. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  37947. */
  37948. angularSensibilityX: number;
  37949. /**
  37950. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  37951. */
  37952. angularSensibilityY: number;
  37953. /**
  37954. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  37955. */
  37956. pinchPrecision: number;
  37957. /**
  37958. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  37959. * It will be used instead of pinchDeltaPrecision if different from 0.
  37960. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37961. */
  37962. pinchDeltaPercentage: number;
  37963. /**
  37964. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  37965. */
  37966. panningSensibility: number;
  37967. /**
  37968. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  37969. */
  37970. keysUp: number[];
  37971. /**
  37972. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  37973. */
  37974. keysDown: number[];
  37975. /**
  37976. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  37977. */
  37978. keysLeft: number[];
  37979. /**
  37980. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  37981. */
  37982. keysRight: number[];
  37983. /**
  37984. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37985. */
  37986. wheelPrecision: number;
  37987. /**
  37988. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  37989. * It will be used instead of pinchDeltaPrecision if different from 0.
  37990. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37991. */
  37992. wheelDeltaPercentage: number;
  37993. /**
  37994. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  37995. */
  37996. zoomOnFactor: number;
  37997. /**
  37998. * Defines a screen offset for the camera position.
  37999. */
  38000. targetScreenOffset: Vector2;
  38001. /**
  38002. * Allows the camera to be completely reversed.
  38003. * If false the camera can not arrive upside down.
  38004. */
  38005. allowUpsideDown: boolean;
  38006. /**
  38007. * Define if double tap/click is used to restore the previously saved state of the camera.
  38008. */
  38009. useInputToRestoreState: boolean;
  38010. /** @hidden */
  38011. _viewMatrix: Matrix;
  38012. /** @hidden */
  38013. _useCtrlForPanning: boolean;
  38014. /** @hidden */
  38015. _panningMouseButton: number;
  38016. /**
  38017. * Defines the input associated to the camera.
  38018. */
  38019. inputs: ArcRotateCameraInputsManager;
  38020. /** @hidden */
  38021. _reset: () => void;
  38022. /**
  38023. * Defines the allowed panning axis.
  38024. */
  38025. panningAxis: Vector3;
  38026. protected _localDirection: Vector3;
  38027. protected _transformedDirection: Vector3;
  38028. private _bouncingBehavior;
  38029. /**
  38030. * Gets the bouncing behavior of the camera if it has been enabled.
  38031. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38032. */
  38033. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  38034. /**
  38035. * Defines if the bouncing behavior of the camera is enabled on the camera.
  38036. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38037. */
  38038. useBouncingBehavior: boolean;
  38039. private _framingBehavior;
  38040. /**
  38041. * Gets the framing behavior of the camera if it has been enabled.
  38042. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38043. */
  38044. readonly framingBehavior: Nullable<FramingBehavior>;
  38045. /**
  38046. * Defines if the framing behavior of the camera is enabled on the camera.
  38047. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38048. */
  38049. useFramingBehavior: boolean;
  38050. private _autoRotationBehavior;
  38051. /**
  38052. * Gets the auto rotation behavior of the camera if it has been enabled.
  38053. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38054. */
  38055. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  38056. /**
  38057. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  38058. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38059. */
  38060. useAutoRotationBehavior: boolean;
  38061. /**
  38062. * Observable triggered when the mesh target has been changed on the camera.
  38063. */
  38064. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  38065. /**
  38066. * Event raised when the camera is colliding with a mesh.
  38067. */
  38068. onCollide: (collidedMesh: AbstractMesh) => void;
  38069. /**
  38070. * Defines whether the camera should check collision with the objects oh the scene.
  38071. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  38072. */
  38073. checkCollisions: boolean;
  38074. /**
  38075. * Defines the collision radius of the camera.
  38076. * This simulates a sphere around the camera.
  38077. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38078. */
  38079. collisionRadius: Vector3;
  38080. protected _collider: Collider;
  38081. protected _previousPosition: Vector3;
  38082. protected _collisionVelocity: Vector3;
  38083. protected _newPosition: Vector3;
  38084. protected _previousAlpha: number;
  38085. protected _previousBeta: number;
  38086. protected _previousRadius: number;
  38087. protected _collisionTriggered: boolean;
  38088. protected _targetBoundingCenter: Nullable<Vector3>;
  38089. private _computationVector;
  38090. /**
  38091. * Instantiates a new ArcRotateCamera in a given scene
  38092. * @param name Defines the name of the camera
  38093. * @param alpha Defines the camera rotation along the logitudinal axis
  38094. * @param beta Defines the camera rotation along the latitudinal axis
  38095. * @param radius Defines the camera distance from its target
  38096. * @param target Defines the camera target
  38097. * @param scene Defines the scene the camera belongs to
  38098. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  38099. */
  38100. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38101. /** @hidden */
  38102. _initCache(): void;
  38103. /** @hidden */
  38104. _updateCache(ignoreParentClass?: boolean): void;
  38105. protected _getTargetPosition(): Vector3;
  38106. private _storedAlpha;
  38107. private _storedBeta;
  38108. private _storedRadius;
  38109. private _storedTarget;
  38110. private _storedTargetScreenOffset;
  38111. /**
  38112. * Stores the current state of the camera (alpha, beta, radius and target)
  38113. * @returns the camera itself
  38114. */
  38115. storeState(): Camera;
  38116. /**
  38117. * @hidden
  38118. * Restored camera state. You must call storeState() first
  38119. */
  38120. _restoreStateValues(): boolean;
  38121. /** @hidden */
  38122. _isSynchronizedViewMatrix(): boolean;
  38123. /**
  38124. * Attached controls to the current camera.
  38125. * @param element Defines the element the controls should be listened from
  38126. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38127. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  38128. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  38129. */
  38130. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  38131. /**
  38132. * Detach the current controls from the camera.
  38133. * The camera will stop reacting to inputs.
  38134. * @param element Defines the element to stop listening the inputs from
  38135. */
  38136. detachControl(element: HTMLElement): void;
  38137. /** @hidden */
  38138. _checkInputs(): void;
  38139. protected _checkLimits(): void;
  38140. /**
  38141. * Rebuilds angles (alpha, beta) and radius from the give position and target
  38142. */
  38143. rebuildAnglesAndRadius(): void;
  38144. /**
  38145. * Use a position to define the current camera related information like alpha, beta and radius
  38146. * @param position Defines the position to set the camera at
  38147. */
  38148. setPosition(position: Vector3): void;
  38149. /**
  38150. * Defines the target the camera should look at.
  38151. * This will automatically adapt alpha beta and radius to fit within the new target.
  38152. * @param target Defines the new target as a Vector or a mesh
  38153. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  38154. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  38155. */
  38156. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  38157. /** @hidden */
  38158. _getViewMatrix(): Matrix;
  38159. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  38160. /**
  38161. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  38162. * @param meshes Defines the mesh to zoom on
  38163. * @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)
  38164. */
  38165. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  38166. /**
  38167. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  38168. * The target will be changed but the radius
  38169. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  38170. * @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)
  38171. */
  38172. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  38173. min: Vector3;
  38174. max: Vector3;
  38175. distance: number;
  38176. }, doNotUpdateMaxZ?: boolean): void;
  38177. /**
  38178. * @override
  38179. * Override Camera.createRigCamera
  38180. */
  38181. createRigCamera(name: string, cameraIndex: number): Camera;
  38182. /**
  38183. * @hidden
  38184. * @override
  38185. * Override Camera._updateRigCameras
  38186. */
  38187. _updateRigCameras(): void;
  38188. /**
  38189. * Destroy the camera and release the current resources hold by it.
  38190. */
  38191. dispose(): void;
  38192. /**
  38193. * Gets the current object class name.
  38194. * @return the class name
  38195. */
  38196. getClassName(): string;
  38197. }
  38198. }
  38199. declare module BABYLON {
  38200. /**
  38201. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  38202. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38203. */
  38204. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  38205. /**
  38206. * Gets the name of the behavior.
  38207. */
  38208. readonly name: string;
  38209. private _zoomStopsAnimation;
  38210. private _idleRotationSpeed;
  38211. private _idleRotationWaitTime;
  38212. private _idleRotationSpinupTime;
  38213. /**
  38214. * Sets the flag that indicates if user zooming should stop animation.
  38215. */
  38216. /**
  38217. * Gets the flag that indicates if user zooming should stop animation.
  38218. */
  38219. zoomStopsAnimation: boolean;
  38220. /**
  38221. * Sets the default speed at which the camera rotates around the model.
  38222. */
  38223. /**
  38224. * Gets the default speed at which the camera rotates around the model.
  38225. */
  38226. idleRotationSpeed: number;
  38227. /**
  38228. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  38229. */
  38230. /**
  38231. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  38232. */
  38233. idleRotationWaitTime: number;
  38234. /**
  38235. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38236. */
  38237. /**
  38238. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38239. */
  38240. idleRotationSpinupTime: number;
  38241. /**
  38242. * Gets a value indicating if the camera is currently rotating because of this behavior
  38243. */
  38244. readonly rotationInProgress: boolean;
  38245. private _onPrePointerObservableObserver;
  38246. private _onAfterCheckInputsObserver;
  38247. private _attachedCamera;
  38248. private _isPointerDown;
  38249. private _lastFrameTime;
  38250. private _lastInteractionTime;
  38251. private _cameraRotationSpeed;
  38252. /**
  38253. * Initializes the behavior.
  38254. */
  38255. init(): void;
  38256. /**
  38257. * Attaches the behavior to its arc rotate camera.
  38258. * @param camera Defines the camera to attach the behavior to
  38259. */
  38260. attach(camera: ArcRotateCamera): void;
  38261. /**
  38262. * Detaches the behavior from its current arc rotate camera.
  38263. */
  38264. detach(): void;
  38265. /**
  38266. * Returns true if user is scrolling.
  38267. * @return true if user is scrolling.
  38268. */
  38269. private _userIsZooming;
  38270. private _lastFrameRadius;
  38271. private _shouldAnimationStopForInteraction;
  38272. /**
  38273. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38274. */
  38275. private _applyUserInteraction;
  38276. private _userIsMoving;
  38277. }
  38278. }
  38279. declare module BABYLON {
  38280. /**
  38281. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  38282. */
  38283. export class AttachToBoxBehavior implements Behavior<Mesh> {
  38284. private ui;
  38285. /**
  38286. * The name of the behavior
  38287. */
  38288. name: string;
  38289. /**
  38290. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  38291. */
  38292. distanceAwayFromFace: number;
  38293. /**
  38294. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  38295. */
  38296. distanceAwayFromBottomOfFace: number;
  38297. private _faceVectors;
  38298. private _target;
  38299. private _scene;
  38300. private _onRenderObserver;
  38301. private _tmpMatrix;
  38302. private _tmpVector;
  38303. /**
  38304. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  38305. * @param ui The transform node that should be attched to the mesh
  38306. */
  38307. constructor(ui: TransformNode);
  38308. /**
  38309. * Initializes the behavior
  38310. */
  38311. init(): void;
  38312. private _closestFace;
  38313. private _zeroVector;
  38314. private _lookAtTmpMatrix;
  38315. private _lookAtToRef;
  38316. /**
  38317. * Attaches the AttachToBoxBehavior to the passed in mesh
  38318. * @param target The mesh that the specified node will be attached to
  38319. */
  38320. attach(target: Mesh): void;
  38321. /**
  38322. * Detaches the behavior from the mesh
  38323. */
  38324. detach(): void;
  38325. }
  38326. }
  38327. declare module BABYLON {
  38328. /**
  38329. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  38330. */
  38331. export class FadeInOutBehavior implements Behavior<Mesh> {
  38332. /**
  38333. * Time in milliseconds to delay before fading in (Default: 0)
  38334. */
  38335. delay: number;
  38336. /**
  38337. * Time in milliseconds for the mesh to fade in (Default: 300)
  38338. */
  38339. fadeInTime: number;
  38340. private _millisecondsPerFrame;
  38341. private _hovered;
  38342. private _hoverValue;
  38343. private _ownerNode;
  38344. /**
  38345. * Instatiates the FadeInOutBehavior
  38346. */
  38347. constructor();
  38348. /**
  38349. * The name of the behavior
  38350. */
  38351. readonly name: string;
  38352. /**
  38353. * Initializes the behavior
  38354. */
  38355. init(): void;
  38356. /**
  38357. * Attaches the fade behavior on the passed in mesh
  38358. * @param ownerNode The mesh that will be faded in/out once attached
  38359. */
  38360. attach(ownerNode: Mesh): void;
  38361. /**
  38362. * Detaches the behavior from the mesh
  38363. */
  38364. detach(): void;
  38365. /**
  38366. * Triggers the mesh to begin fading in or out
  38367. * @param value if the object should fade in or out (true to fade in)
  38368. */
  38369. fadeIn(value: boolean): void;
  38370. private _update;
  38371. private _setAllVisibility;
  38372. }
  38373. }
  38374. declare module BABYLON {
  38375. /**
  38376. * Class containing a set of static utilities functions for managing Pivots
  38377. * @hidden
  38378. */
  38379. export class PivotTools {
  38380. private static _PivotCached;
  38381. private static _OldPivotPoint;
  38382. private static _PivotTranslation;
  38383. private static _PivotTmpVector;
  38384. /** @hidden */
  38385. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  38386. /** @hidden */
  38387. static _RestorePivotPoint(mesh: AbstractMesh): void;
  38388. }
  38389. }
  38390. declare module BABYLON {
  38391. /**
  38392. * Class containing static functions to help procedurally build meshes
  38393. */
  38394. export class PlaneBuilder {
  38395. /**
  38396. * Creates a plane mesh
  38397. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  38398. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  38399. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  38400. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  38401. * * 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
  38402. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  38403. * @param name defines the name of the mesh
  38404. * @param options defines the options used to create the mesh
  38405. * @param scene defines the hosting scene
  38406. * @returns the plane mesh
  38407. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  38408. */
  38409. static CreatePlane(name: string, options: {
  38410. size?: number;
  38411. width?: number;
  38412. height?: number;
  38413. sideOrientation?: number;
  38414. frontUVs?: Vector4;
  38415. backUVs?: Vector4;
  38416. updatable?: boolean;
  38417. sourcePlane?: Plane;
  38418. }, scene?: Nullable<Scene>): Mesh;
  38419. }
  38420. }
  38421. declare module BABYLON {
  38422. /**
  38423. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  38424. */
  38425. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  38426. private static _AnyMouseID;
  38427. /**
  38428. * Abstract mesh the behavior is set on
  38429. */
  38430. attachedNode: AbstractMesh;
  38431. private _dragPlane;
  38432. private _scene;
  38433. private _pointerObserver;
  38434. private _beforeRenderObserver;
  38435. private static _planeScene;
  38436. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  38437. /**
  38438. * 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)
  38439. */
  38440. maxDragAngle: number;
  38441. /**
  38442. * @hidden
  38443. */
  38444. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  38445. /**
  38446. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38447. */
  38448. currentDraggingPointerID: number;
  38449. /**
  38450. * The last position where the pointer hit the drag plane in world space
  38451. */
  38452. lastDragPosition: Vector3;
  38453. /**
  38454. * If the behavior is currently in a dragging state
  38455. */
  38456. dragging: boolean;
  38457. /**
  38458. * 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)
  38459. */
  38460. dragDeltaRatio: number;
  38461. /**
  38462. * If the drag plane orientation should be updated during the dragging (Default: true)
  38463. */
  38464. updateDragPlane: boolean;
  38465. private _debugMode;
  38466. private _moving;
  38467. /**
  38468. * Fires each time the attached mesh is dragged with the pointer
  38469. * * delta between last drag position and current drag position in world space
  38470. * * dragDistance along the drag axis
  38471. * * dragPlaneNormal normal of the current drag plane used during the drag
  38472. * * dragPlanePoint in world space where the drag intersects the drag plane
  38473. */
  38474. onDragObservable: Observable<{
  38475. delta: Vector3;
  38476. dragPlanePoint: Vector3;
  38477. dragPlaneNormal: Vector3;
  38478. dragDistance: number;
  38479. pointerId: number;
  38480. }>;
  38481. /**
  38482. * Fires each time a drag begins (eg. mouse down on mesh)
  38483. */
  38484. onDragStartObservable: Observable<{
  38485. dragPlanePoint: Vector3;
  38486. pointerId: number;
  38487. }>;
  38488. /**
  38489. * Fires each time a drag ends (eg. mouse release after drag)
  38490. */
  38491. onDragEndObservable: Observable<{
  38492. dragPlanePoint: Vector3;
  38493. pointerId: number;
  38494. }>;
  38495. /**
  38496. * If the attached mesh should be moved when dragged
  38497. */
  38498. moveAttached: boolean;
  38499. /**
  38500. * If the drag behavior will react to drag events (Default: true)
  38501. */
  38502. enabled: boolean;
  38503. /**
  38504. * If pointer events should start and release the drag (Default: true)
  38505. */
  38506. startAndReleaseDragOnPointerEvents: boolean;
  38507. /**
  38508. * If camera controls should be detached during the drag
  38509. */
  38510. detachCameraControls: boolean;
  38511. /**
  38512. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  38513. */
  38514. useObjectOrienationForDragging: boolean;
  38515. private _options;
  38516. /**
  38517. * Gets the options used by the behavior
  38518. */
  38519. /**
  38520. * Sets the options used by the behavior
  38521. */
  38522. options: {
  38523. dragAxis?: Vector3;
  38524. dragPlaneNormal?: Vector3;
  38525. };
  38526. /**
  38527. * Creates a pointer drag behavior that can be attached to a mesh
  38528. * @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)
  38529. */
  38530. constructor(options?: {
  38531. dragAxis?: Vector3;
  38532. dragPlaneNormal?: Vector3;
  38533. });
  38534. /**
  38535. * Predicate to determine if it is valid to move the object to a new position when it is moved
  38536. */
  38537. validateDrag: (targetPosition: Vector3) => boolean;
  38538. /**
  38539. * The name of the behavior
  38540. */
  38541. readonly name: string;
  38542. /**
  38543. * Initializes the behavior
  38544. */
  38545. init(): void;
  38546. private _tmpVector;
  38547. private _alternatePickedPoint;
  38548. private _worldDragAxis;
  38549. private _targetPosition;
  38550. private _attachedElement;
  38551. /**
  38552. * Attaches the drag behavior the passed in mesh
  38553. * @param ownerNode The mesh that will be dragged around once attached
  38554. * @param predicate Predicate to use for pick filtering
  38555. */
  38556. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  38557. /**
  38558. * Force relase the drag action by code.
  38559. */
  38560. releaseDrag(): void;
  38561. private _startDragRay;
  38562. private _lastPointerRay;
  38563. /**
  38564. * Simulates the start of a pointer drag event on the behavior
  38565. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  38566. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  38567. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  38568. */
  38569. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  38570. private _startDrag;
  38571. private _dragDelta;
  38572. private _moveDrag;
  38573. private _pickWithRayOnDragPlane;
  38574. private _pointA;
  38575. private _pointB;
  38576. private _pointC;
  38577. private _lineA;
  38578. private _lineB;
  38579. private _localAxis;
  38580. private _lookAt;
  38581. private _updateDragPlanePosition;
  38582. /**
  38583. * Detaches the behavior from the mesh
  38584. */
  38585. detach(): void;
  38586. }
  38587. }
  38588. declare module BABYLON {
  38589. /**
  38590. * A behavior that when attached to a mesh will allow the mesh to be scaled
  38591. */
  38592. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  38593. private _dragBehaviorA;
  38594. private _dragBehaviorB;
  38595. private _startDistance;
  38596. private _initialScale;
  38597. private _targetScale;
  38598. private _ownerNode;
  38599. private _sceneRenderObserver;
  38600. /**
  38601. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  38602. */
  38603. constructor();
  38604. /**
  38605. * The name of the behavior
  38606. */
  38607. readonly name: string;
  38608. /**
  38609. * Initializes the behavior
  38610. */
  38611. init(): void;
  38612. private _getCurrentDistance;
  38613. /**
  38614. * Attaches the scale behavior the passed in mesh
  38615. * @param ownerNode The mesh that will be scaled around once attached
  38616. */
  38617. attach(ownerNode: Mesh): void;
  38618. /**
  38619. * Detaches the behavior from the mesh
  38620. */
  38621. detach(): void;
  38622. }
  38623. }
  38624. declare module BABYLON {
  38625. /**
  38626. * 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
  38627. */
  38628. export class SixDofDragBehavior implements Behavior<Mesh> {
  38629. private static _virtualScene;
  38630. private _ownerNode;
  38631. private _sceneRenderObserver;
  38632. private _scene;
  38633. private _targetPosition;
  38634. private _virtualOriginMesh;
  38635. private _virtualDragMesh;
  38636. private _pointerObserver;
  38637. private _moving;
  38638. private _startingOrientation;
  38639. /**
  38640. * 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)
  38641. */
  38642. private zDragFactor;
  38643. /**
  38644. * If the object should rotate to face the drag origin
  38645. */
  38646. rotateDraggedObject: boolean;
  38647. /**
  38648. * If the behavior is currently in a dragging state
  38649. */
  38650. dragging: boolean;
  38651. /**
  38652. * 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)
  38653. */
  38654. dragDeltaRatio: number;
  38655. /**
  38656. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38657. */
  38658. currentDraggingPointerID: number;
  38659. /**
  38660. * If camera controls should be detached during the drag
  38661. */
  38662. detachCameraControls: boolean;
  38663. /**
  38664. * Fires each time a drag starts
  38665. */
  38666. onDragStartObservable: Observable<{}>;
  38667. /**
  38668. * Fires each time a drag ends (eg. mouse release after drag)
  38669. */
  38670. onDragEndObservable: Observable<{}>;
  38671. /**
  38672. * 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
  38673. */
  38674. constructor();
  38675. /**
  38676. * The name of the behavior
  38677. */
  38678. readonly name: string;
  38679. /**
  38680. * Initializes the behavior
  38681. */
  38682. init(): void;
  38683. /**
  38684. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  38685. */
  38686. private readonly _pointerCamera;
  38687. /**
  38688. * Attaches the scale behavior the passed in mesh
  38689. * @param ownerNode The mesh that will be scaled around once attached
  38690. */
  38691. attach(ownerNode: Mesh): void;
  38692. /**
  38693. * Detaches the behavior from the mesh
  38694. */
  38695. detach(): void;
  38696. }
  38697. }
  38698. declare module BABYLON {
  38699. /**
  38700. * Class used to apply inverse kinematics to bones
  38701. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  38702. */
  38703. export class BoneIKController {
  38704. private static _tmpVecs;
  38705. private static _tmpQuat;
  38706. private static _tmpMats;
  38707. /**
  38708. * Gets or sets the target mesh
  38709. */
  38710. targetMesh: AbstractMesh;
  38711. /** Gets or sets the mesh used as pole */
  38712. poleTargetMesh: AbstractMesh;
  38713. /**
  38714. * Gets or sets the bone used as pole
  38715. */
  38716. poleTargetBone: Nullable<Bone>;
  38717. /**
  38718. * Gets or sets the target position
  38719. */
  38720. targetPosition: Vector3;
  38721. /**
  38722. * Gets or sets the pole target position
  38723. */
  38724. poleTargetPosition: Vector3;
  38725. /**
  38726. * Gets or sets the pole target local offset
  38727. */
  38728. poleTargetLocalOffset: Vector3;
  38729. /**
  38730. * Gets or sets the pole angle
  38731. */
  38732. poleAngle: number;
  38733. /**
  38734. * Gets or sets the mesh associated with the controller
  38735. */
  38736. mesh: AbstractMesh;
  38737. /**
  38738. * 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)
  38739. */
  38740. slerpAmount: number;
  38741. private _bone1Quat;
  38742. private _bone1Mat;
  38743. private _bone2Ang;
  38744. private _bone1;
  38745. private _bone2;
  38746. private _bone1Length;
  38747. private _bone2Length;
  38748. private _maxAngle;
  38749. private _maxReach;
  38750. private _rightHandedSystem;
  38751. private _bendAxis;
  38752. private _slerping;
  38753. private _adjustRoll;
  38754. /**
  38755. * Gets or sets maximum allowed angle
  38756. */
  38757. maxAngle: number;
  38758. /**
  38759. * Creates a new BoneIKController
  38760. * @param mesh defines the mesh to control
  38761. * @param bone defines the bone to control
  38762. * @param options defines options to set up the controller
  38763. */
  38764. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  38765. targetMesh?: AbstractMesh;
  38766. poleTargetMesh?: AbstractMesh;
  38767. poleTargetBone?: Bone;
  38768. poleTargetLocalOffset?: Vector3;
  38769. poleAngle?: number;
  38770. bendAxis?: Vector3;
  38771. maxAngle?: number;
  38772. slerpAmount?: number;
  38773. });
  38774. private _setMaxAngle;
  38775. /**
  38776. * Force the controller to update the bones
  38777. */
  38778. update(): void;
  38779. }
  38780. }
  38781. declare module BABYLON {
  38782. /**
  38783. * Class used to make a bone look toward a point in space
  38784. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  38785. */
  38786. export class BoneLookController {
  38787. private static _tmpVecs;
  38788. private static _tmpQuat;
  38789. private static _tmpMats;
  38790. /**
  38791. * The target Vector3 that the bone will look at
  38792. */
  38793. target: Vector3;
  38794. /**
  38795. * The mesh that the bone is attached to
  38796. */
  38797. mesh: AbstractMesh;
  38798. /**
  38799. * The bone that will be looking to the target
  38800. */
  38801. bone: Bone;
  38802. /**
  38803. * The up axis of the coordinate system that is used when the bone is rotated
  38804. */
  38805. upAxis: Vector3;
  38806. /**
  38807. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  38808. */
  38809. upAxisSpace: Space;
  38810. /**
  38811. * Used to make an adjustment to the yaw of the bone
  38812. */
  38813. adjustYaw: number;
  38814. /**
  38815. * Used to make an adjustment to the pitch of the bone
  38816. */
  38817. adjustPitch: number;
  38818. /**
  38819. * Used to make an adjustment to the roll of the bone
  38820. */
  38821. adjustRoll: number;
  38822. /**
  38823. * 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)
  38824. */
  38825. slerpAmount: number;
  38826. private _minYaw;
  38827. private _maxYaw;
  38828. private _minPitch;
  38829. private _maxPitch;
  38830. private _minYawSin;
  38831. private _minYawCos;
  38832. private _maxYawSin;
  38833. private _maxYawCos;
  38834. private _midYawConstraint;
  38835. private _minPitchTan;
  38836. private _maxPitchTan;
  38837. private _boneQuat;
  38838. private _slerping;
  38839. private _transformYawPitch;
  38840. private _transformYawPitchInv;
  38841. private _firstFrameSkipped;
  38842. private _yawRange;
  38843. private _fowardAxis;
  38844. /**
  38845. * Gets or sets the minimum yaw angle that the bone can look to
  38846. */
  38847. minYaw: number;
  38848. /**
  38849. * Gets or sets the maximum yaw angle that the bone can look to
  38850. */
  38851. maxYaw: number;
  38852. /**
  38853. * Gets or sets the minimum pitch angle that the bone can look to
  38854. */
  38855. minPitch: number;
  38856. /**
  38857. * Gets or sets the maximum pitch angle that the bone can look to
  38858. */
  38859. maxPitch: number;
  38860. /**
  38861. * Create a BoneLookController
  38862. * @param mesh the mesh that the bone belongs to
  38863. * @param bone the bone that will be looking to the target
  38864. * @param target the target Vector3 to look at
  38865. * @param options optional settings:
  38866. * * maxYaw: the maximum angle the bone will yaw to
  38867. * * minYaw: the minimum angle the bone will yaw to
  38868. * * maxPitch: the maximum angle the bone will pitch to
  38869. * * minPitch: the minimum angle the bone will yaw to
  38870. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  38871. * * upAxis: the up axis of the coordinate system
  38872. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  38873. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  38874. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  38875. * * adjustYaw: used to make an adjustment to the yaw of the bone
  38876. * * adjustPitch: used to make an adjustment to the pitch of the bone
  38877. * * adjustRoll: used to make an adjustment to the roll of the bone
  38878. **/
  38879. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  38880. maxYaw?: number;
  38881. minYaw?: number;
  38882. maxPitch?: number;
  38883. minPitch?: number;
  38884. slerpAmount?: number;
  38885. upAxis?: Vector3;
  38886. upAxisSpace?: Space;
  38887. yawAxis?: Vector3;
  38888. pitchAxis?: Vector3;
  38889. adjustYaw?: number;
  38890. adjustPitch?: number;
  38891. adjustRoll?: number;
  38892. });
  38893. /**
  38894. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  38895. */
  38896. update(): void;
  38897. private _getAngleDiff;
  38898. private _getAngleBetween;
  38899. private _isAngleBetween;
  38900. }
  38901. }
  38902. declare module BABYLON {
  38903. /**
  38904. * Manage the gamepad inputs to control an arc rotate camera.
  38905. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38906. */
  38907. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  38908. /**
  38909. * Defines the camera the input is attached to.
  38910. */
  38911. camera: ArcRotateCamera;
  38912. /**
  38913. * Defines the gamepad the input is gathering event from.
  38914. */
  38915. gamepad: Nullable<Gamepad>;
  38916. /**
  38917. * Defines the gamepad rotation sensiblity.
  38918. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38919. */
  38920. gamepadRotationSensibility: number;
  38921. /**
  38922. * Defines the gamepad move sensiblity.
  38923. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38924. */
  38925. gamepadMoveSensibility: number;
  38926. private _yAxisScale;
  38927. /**
  38928. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  38929. */
  38930. invertYAxis: boolean;
  38931. private _onGamepadConnectedObserver;
  38932. private _onGamepadDisconnectedObserver;
  38933. /**
  38934. * Attach the input controls to a specific dom element to get the input from.
  38935. * @param element Defines the element the controls should be listened from
  38936. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38937. */
  38938. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38939. /**
  38940. * Detach the current controls from the specified dom element.
  38941. * @param element Defines the element to stop listening the inputs from
  38942. */
  38943. detachControl(element: Nullable<HTMLElement>): void;
  38944. /**
  38945. * Update the current camera state depending on the inputs that have been used this frame.
  38946. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38947. */
  38948. checkInputs(): void;
  38949. /**
  38950. * Gets the class name of the current intput.
  38951. * @returns the class name
  38952. */
  38953. getClassName(): string;
  38954. /**
  38955. * Get the friendly name associated with the input class.
  38956. * @returns the input friendly name
  38957. */
  38958. getSimpleName(): string;
  38959. }
  38960. }
  38961. declare module BABYLON {
  38962. interface ArcRotateCameraInputsManager {
  38963. /**
  38964. * Add orientation input support to the input manager.
  38965. * @returns the current input manager
  38966. */
  38967. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  38968. }
  38969. /**
  38970. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  38971. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38972. */
  38973. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  38974. /**
  38975. * Defines the camera the input is attached to.
  38976. */
  38977. camera: ArcRotateCamera;
  38978. /**
  38979. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  38980. */
  38981. alphaCorrection: number;
  38982. /**
  38983. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  38984. */
  38985. gammaCorrection: number;
  38986. private _alpha;
  38987. private _gamma;
  38988. private _dirty;
  38989. private _deviceOrientationHandler;
  38990. /**
  38991. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  38992. */
  38993. constructor();
  38994. /**
  38995. * Attach the input controls to a specific dom element to get the input from.
  38996. * @param element Defines the element the controls should be listened from
  38997. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38998. */
  38999. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39000. /** @hidden */
  39001. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  39002. /**
  39003. * Update the current camera state depending on the inputs that have been used this frame.
  39004. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39005. */
  39006. checkInputs(): void;
  39007. /**
  39008. * Detach the current controls from the specified dom element.
  39009. * @param element Defines the element to stop listening the inputs from
  39010. */
  39011. detachControl(element: Nullable<HTMLElement>): void;
  39012. /**
  39013. * Gets the class name of the current intput.
  39014. * @returns the class name
  39015. */
  39016. getClassName(): string;
  39017. /**
  39018. * Get the friendly name associated with the input class.
  39019. * @returns the input friendly name
  39020. */
  39021. getSimpleName(): string;
  39022. }
  39023. }
  39024. declare module BABYLON {
  39025. /**
  39026. * Listen to mouse events to control the camera.
  39027. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39028. */
  39029. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  39030. /**
  39031. * Defines the camera the input is attached to.
  39032. */
  39033. camera: FlyCamera;
  39034. /**
  39035. * Defines if touch is enabled. (Default is true.)
  39036. */
  39037. touchEnabled: boolean;
  39038. /**
  39039. * Defines the buttons associated with the input to handle camera rotation.
  39040. */
  39041. buttons: number[];
  39042. /**
  39043. * Assign buttons for Yaw control.
  39044. */
  39045. buttonsYaw: number[];
  39046. /**
  39047. * Assign buttons for Pitch control.
  39048. */
  39049. buttonsPitch: number[];
  39050. /**
  39051. * Assign buttons for Roll control.
  39052. */
  39053. buttonsRoll: number[];
  39054. /**
  39055. * Detect if any button is being pressed while mouse is moved.
  39056. * -1 = Mouse locked.
  39057. * 0 = Left button.
  39058. * 1 = Middle Button.
  39059. * 2 = Right Button.
  39060. */
  39061. activeButton: number;
  39062. /**
  39063. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  39064. * Higher values reduce its sensitivity.
  39065. */
  39066. angularSensibility: number;
  39067. private _mousemoveCallback;
  39068. private _observer;
  39069. private _rollObserver;
  39070. private previousPosition;
  39071. private noPreventDefault;
  39072. private element;
  39073. /**
  39074. * Listen to mouse events to control the camera.
  39075. * @param touchEnabled Define if touch is enabled. (Default is true.)
  39076. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39077. */
  39078. constructor(touchEnabled?: boolean);
  39079. /**
  39080. * Attach the mouse control to the HTML DOM element.
  39081. * @param element Defines the element that listens to the input events.
  39082. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  39083. */
  39084. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39085. /**
  39086. * Detach the current controls from the specified dom element.
  39087. * @param element Defines the element to stop listening the inputs from
  39088. */
  39089. detachControl(element: Nullable<HTMLElement>): void;
  39090. /**
  39091. * Gets the class name of the current input.
  39092. * @returns the class name.
  39093. */
  39094. getClassName(): string;
  39095. /**
  39096. * Get the friendly name associated with the input class.
  39097. * @returns the input's friendly name.
  39098. */
  39099. getSimpleName(): string;
  39100. private _pointerInput;
  39101. private _onMouseMove;
  39102. /**
  39103. * Rotate camera by mouse offset.
  39104. */
  39105. private rotateCamera;
  39106. }
  39107. }
  39108. declare module BABYLON {
  39109. /**
  39110. * Default Inputs manager for the FlyCamera.
  39111. * It groups all the default supported inputs for ease of use.
  39112. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39113. */
  39114. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  39115. /**
  39116. * Instantiates a new FlyCameraInputsManager.
  39117. * @param camera Defines the camera the inputs belong to.
  39118. */
  39119. constructor(camera: FlyCamera);
  39120. /**
  39121. * Add keyboard input support to the input manager.
  39122. * @returns the new FlyCameraKeyboardMoveInput().
  39123. */
  39124. addKeyboard(): FlyCameraInputsManager;
  39125. /**
  39126. * Add mouse input support to the input manager.
  39127. * @param touchEnabled Enable touch screen support.
  39128. * @returns the new FlyCameraMouseInput().
  39129. */
  39130. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  39131. }
  39132. }
  39133. declare module BABYLON {
  39134. /**
  39135. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39136. * such as in a 3D Space Shooter or a Flight Simulator.
  39137. */
  39138. export class FlyCamera extends TargetCamera {
  39139. /**
  39140. * Define the collision ellipsoid of the camera.
  39141. * This is helpful for simulating a camera body, like a player's body.
  39142. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39143. */
  39144. ellipsoid: Vector3;
  39145. /**
  39146. * Define an offset for the position of the ellipsoid around the camera.
  39147. * This can be helpful if the camera is attached away from the player's body center,
  39148. * such as at its head.
  39149. */
  39150. ellipsoidOffset: Vector3;
  39151. /**
  39152. * Enable or disable collisions of the camera with the rest of the scene objects.
  39153. */
  39154. checkCollisions: boolean;
  39155. /**
  39156. * Enable or disable gravity on the camera.
  39157. */
  39158. applyGravity: boolean;
  39159. /**
  39160. * Define the current direction the camera is moving to.
  39161. */
  39162. cameraDirection: Vector3;
  39163. /**
  39164. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  39165. * This overrides and empties cameraRotation.
  39166. */
  39167. rotationQuaternion: Quaternion;
  39168. /**
  39169. * Track Roll to maintain the wanted Rolling when looking around.
  39170. */
  39171. _trackRoll: number;
  39172. /**
  39173. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  39174. */
  39175. rollCorrect: number;
  39176. /**
  39177. * Mimic a banked turn, Rolling the camera when Yawing.
  39178. * It's recommended to use rollCorrect = 10 for faster banking correction.
  39179. */
  39180. bankedTurn: boolean;
  39181. /**
  39182. * Limit in radians for how much Roll banking will add. (Default: 90°)
  39183. */
  39184. bankedTurnLimit: number;
  39185. /**
  39186. * Value of 0 disables the banked Roll.
  39187. * Value of 1 is equal to the Yaw angle in radians.
  39188. */
  39189. bankedTurnMultiplier: number;
  39190. /**
  39191. * The inputs manager loads all the input sources, such as keyboard and mouse.
  39192. */
  39193. inputs: FlyCameraInputsManager;
  39194. /**
  39195. * Gets the input sensibility for mouse input.
  39196. * Higher values reduce sensitivity.
  39197. */
  39198. /**
  39199. * Sets the input sensibility for a mouse input.
  39200. * Higher values reduce sensitivity.
  39201. */
  39202. angularSensibility: number;
  39203. /**
  39204. * Get the keys for camera movement forward.
  39205. */
  39206. /**
  39207. * Set the keys for camera movement forward.
  39208. */
  39209. keysForward: number[];
  39210. /**
  39211. * Get the keys for camera movement backward.
  39212. */
  39213. keysBackward: number[];
  39214. /**
  39215. * Get the keys for camera movement up.
  39216. */
  39217. /**
  39218. * Set the keys for camera movement up.
  39219. */
  39220. keysUp: number[];
  39221. /**
  39222. * Get the keys for camera movement down.
  39223. */
  39224. /**
  39225. * Set the keys for camera movement down.
  39226. */
  39227. keysDown: number[];
  39228. /**
  39229. * Get the keys for camera movement left.
  39230. */
  39231. /**
  39232. * Set the keys for camera movement left.
  39233. */
  39234. keysLeft: number[];
  39235. /**
  39236. * Set the keys for camera movement right.
  39237. */
  39238. /**
  39239. * Set the keys for camera movement right.
  39240. */
  39241. keysRight: number[];
  39242. /**
  39243. * Event raised when the camera collides with a mesh in the scene.
  39244. */
  39245. onCollide: (collidedMesh: AbstractMesh) => void;
  39246. private _collider;
  39247. private _needMoveForGravity;
  39248. private _oldPosition;
  39249. private _diffPosition;
  39250. private _newPosition;
  39251. /** @hidden */
  39252. _localDirection: Vector3;
  39253. /** @hidden */
  39254. _transformedDirection: Vector3;
  39255. /**
  39256. * Instantiates a FlyCamera.
  39257. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39258. * such as in a 3D Space Shooter or a Flight Simulator.
  39259. * @param name Define the name of the camera in the scene.
  39260. * @param position Define the starting position of the camera in the scene.
  39261. * @param scene Define the scene the camera belongs to.
  39262. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  39263. */
  39264. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39265. /**
  39266. * Attach a control to the HTML DOM element.
  39267. * @param element Defines the element that listens to the input events.
  39268. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  39269. */
  39270. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39271. /**
  39272. * Detach a control from the HTML DOM element.
  39273. * The camera will stop reacting to that input.
  39274. * @param element Defines the element that listens to the input events.
  39275. */
  39276. detachControl(element: HTMLElement): void;
  39277. private _collisionMask;
  39278. /**
  39279. * Get the mask that the camera ignores in collision events.
  39280. */
  39281. /**
  39282. * Set the mask that the camera ignores in collision events.
  39283. */
  39284. collisionMask: number;
  39285. /** @hidden */
  39286. _collideWithWorld(displacement: Vector3): void;
  39287. /** @hidden */
  39288. private _onCollisionPositionChange;
  39289. /** @hidden */
  39290. _checkInputs(): void;
  39291. /** @hidden */
  39292. _decideIfNeedsToMove(): boolean;
  39293. /** @hidden */
  39294. _updatePosition(): void;
  39295. /**
  39296. * Restore the Roll to its target value at the rate specified.
  39297. * @param rate - Higher means slower restoring.
  39298. * @hidden
  39299. */
  39300. restoreRoll(rate: number): void;
  39301. /**
  39302. * Destroy the camera and release the current resources held by it.
  39303. */
  39304. dispose(): void;
  39305. /**
  39306. * Get the current object class name.
  39307. * @returns the class name.
  39308. */
  39309. getClassName(): string;
  39310. }
  39311. }
  39312. declare module BABYLON {
  39313. /**
  39314. * Listen to keyboard events to control the camera.
  39315. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39316. */
  39317. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  39318. /**
  39319. * Defines the camera the input is attached to.
  39320. */
  39321. camera: FlyCamera;
  39322. /**
  39323. * The list of keyboard keys used to control the forward move of the camera.
  39324. */
  39325. keysForward: number[];
  39326. /**
  39327. * The list of keyboard keys used to control the backward move of the camera.
  39328. */
  39329. keysBackward: number[];
  39330. /**
  39331. * The list of keyboard keys used to control the forward move of the camera.
  39332. */
  39333. keysUp: number[];
  39334. /**
  39335. * The list of keyboard keys used to control the backward move of the camera.
  39336. */
  39337. keysDown: number[];
  39338. /**
  39339. * The list of keyboard keys used to control the right strafe move of the camera.
  39340. */
  39341. keysRight: number[];
  39342. /**
  39343. * The list of keyboard keys used to control the left strafe move of the camera.
  39344. */
  39345. keysLeft: number[];
  39346. private _keys;
  39347. private _onCanvasBlurObserver;
  39348. private _onKeyboardObserver;
  39349. private _engine;
  39350. private _scene;
  39351. /**
  39352. * Attach the input controls to a specific dom element to get the input from.
  39353. * @param element Defines the element the controls should be listened from
  39354. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39355. */
  39356. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39357. /**
  39358. * Detach the current controls from the specified dom element.
  39359. * @param element Defines the element to stop listening the inputs from
  39360. */
  39361. detachControl(element: Nullable<HTMLElement>): void;
  39362. /**
  39363. * Gets the class name of the current intput.
  39364. * @returns the class name
  39365. */
  39366. getClassName(): string;
  39367. /** @hidden */
  39368. _onLostFocus(e: FocusEvent): void;
  39369. /**
  39370. * Get the friendly name associated with the input class.
  39371. * @returns the input friendly name
  39372. */
  39373. getSimpleName(): string;
  39374. /**
  39375. * Update the current camera state depending on the inputs that have been used this frame.
  39376. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39377. */
  39378. checkInputs(): void;
  39379. }
  39380. }
  39381. declare module BABYLON {
  39382. /**
  39383. * Manage the mouse wheel inputs to control a follow camera.
  39384. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39385. */
  39386. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  39387. /**
  39388. * Defines the camera the input is attached to.
  39389. */
  39390. camera: FollowCamera;
  39391. /**
  39392. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  39393. */
  39394. axisControlRadius: boolean;
  39395. /**
  39396. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  39397. */
  39398. axisControlHeight: boolean;
  39399. /**
  39400. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  39401. */
  39402. axisControlRotation: boolean;
  39403. /**
  39404. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  39405. * relation to mouseWheel events.
  39406. */
  39407. wheelPrecision: number;
  39408. /**
  39409. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39410. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39411. */
  39412. wheelDeltaPercentage: number;
  39413. private _wheel;
  39414. private _observer;
  39415. /**
  39416. * Attach the input controls to a specific dom element to get the input from.
  39417. * @param element Defines the element the controls should be listened from
  39418. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39419. */
  39420. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39421. /**
  39422. * Detach the current controls from the specified dom element.
  39423. * @param element Defines the element to stop listening the inputs from
  39424. */
  39425. detachControl(element: Nullable<HTMLElement>): void;
  39426. /**
  39427. * Gets the class name of the current intput.
  39428. * @returns the class name
  39429. */
  39430. getClassName(): string;
  39431. /**
  39432. * Get the friendly name associated with the input class.
  39433. * @returns the input friendly name
  39434. */
  39435. getSimpleName(): string;
  39436. }
  39437. }
  39438. declare module BABYLON {
  39439. /**
  39440. * Manage the pointers inputs to control an follow camera.
  39441. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39442. */
  39443. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  39444. /**
  39445. * Defines the camera the input is attached to.
  39446. */
  39447. camera: FollowCamera;
  39448. /**
  39449. * Gets the class name of the current input.
  39450. * @returns the class name
  39451. */
  39452. getClassName(): string;
  39453. /**
  39454. * Defines the pointer angular sensibility along the X axis or how fast is
  39455. * the camera rotating.
  39456. * A negative number will reverse the axis direction.
  39457. */
  39458. angularSensibilityX: number;
  39459. /**
  39460. * Defines the pointer angular sensibility along the Y axis or how fast is
  39461. * the camera rotating.
  39462. * A negative number will reverse the axis direction.
  39463. */
  39464. angularSensibilityY: number;
  39465. /**
  39466. * Defines the pointer pinch precision or how fast is the camera zooming.
  39467. * A negative number will reverse the axis direction.
  39468. */
  39469. pinchPrecision: number;
  39470. /**
  39471. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39472. * from 0.
  39473. * It defines the percentage of current camera.radius to use as delta when
  39474. * pinch zoom is used.
  39475. */
  39476. pinchDeltaPercentage: number;
  39477. /**
  39478. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  39479. */
  39480. axisXControlRadius: boolean;
  39481. /**
  39482. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  39483. */
  39484. axisXControlHeight: boolean;
  39485. /**
  39486. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  39487. */
  39488. axisXControlRotation: boolean;
  39489. /**
  39490. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  39491. */
  39492. axisYControlRadius: boolean;
  39493. /**
  39494. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  39495. */
  39496. axisYControlHeight: boolean;
  39497. /**
  39498. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  39499. */
  39500. axisYControlRotation: boolean;
  39501. /**
  39502. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  39503. */
  39504. axisPinchControlRadius: boolean;
  39505. /**
  39506. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  39507. */
  39508. axisPinchControlHeight: boolean;
  39509. /**
  39510. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  39511. */
  39512. axisPinchControlRotation: boolean;
  39513. /**
  39514. * Log error messages if basic misconfiguration has occurred.
  39515. */
  39516. warningEnable: boolean;
  39517. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39518. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39519. private _warningCounter;
  39520. private _warning;
  39521. }
  39522. }
  39523. declare module BABYLON {
  39524. /**
  39525. * Default Inputs manager for the FollowCamera.
  39526. * It groups all the default supported inputs for ease of use.
  39527. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39528. */
  39529. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  39530. /**
  39531. * Instantiates a new FollowCameraInputsManager.
  39532. * @param camera Defines the camera the inputs belong to
  39533. */
  39534. constructor(camera: FollowCamera);
  39535. /**
  39536. * Add keyboard input support to the input manager.
  39537. * @returns the current input manager
  39538. */
  39539. addKeyboard(): FollowCameraInputsManager;
  39540. /**
  39541. * Add mouse wheel input support to the input manager.
  39542. * @returns the current input manager
  39543. */
  39544. addMouseWheel(): FollowCameraInputsManager;
  39545. /**
  39546. * Add pointers input support to the input manager.
  39547. * @returns the current input manager
  39548. */
  39549. addPointers(): FollowCameraInputsManager;
  39550. /**
  39551. * Add orientation input support to the input manager.
  39552. * @returns the current input manager
  39553. */
  39554. addVRDeviceOrientation(): FollowCameraInputsManager;
  39555. }
  39556. }
  39557. declare module BABYLON {
  39558. /**
  39559. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  39560. * an arc rotate version arcFollowCamera are available.
  39561. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39562. */
  39563. export class FollowCamera extends TargetCamera {
  39564. /**
  39565. * Distance the follow camera should follow an object at
  39566. */
  39567. radius: number;
  39568. /**
  39569. * Minimum allowed distance of the camera to the axis of rotation
  39570. * (The camera can not get closer).
  39571. * This can help limiting how the Camera is able to move in the scene.
  39572. */
  39573. lowerRadiusLimit: Nullable<number>;
  39574. /**
  39575. * Maximum allowed distance of the camera to the axis of rotation
  39576. * (The camera can not get further).
  39577. * This can help limiting how the Camera is able to move in the scene.
  39578. */
  39579. upperRadiusLimit: Nullable<number>;
  39580. /**
  39581. * Define a rotation offset between the camera and the object it follows
  39582. */
  39583. rotationOffset: number;
  39584. /**
  39585. * Minimum allowed angle to camera position relative to target object.
  39586. * This can help limiting how the Camera is able to move in the scene.
  39587. */
  39588. lowerRotationOffsetLimit: Nullable<number>;
  39589. /**
  39590. * Maximum allowed angle to camera position relative to target object.
  39591. * This can help limiting how the Camera is able to move in the scene.
  39592. */
  39593. upperRotationOffsetLimit: Nullable<number>;
  39594. /**
  39595. * Define a height offset between the camera and the object it follows.
  39596. * It can help following an object from the top (like a car chaing a plane)
  39597. */
  39598. heightOffset: number;
  39599. /**
  39600. * Minimum allowed height of camera position relative to target object.
  39601. * This can help limiting how the Camera is able to move in the scene.
  39602. */
  39603. lowerHeightOffsetLimit: Nullable<number>;
  39604. /**
  39605. * Maximum allowed height of camera position relative to target object.
  39606. * This can help limiting how the Camera is able to move in the scene.
  39607. */
  39608. upperHeightOffsetLimit: Nullable<number>;
  39609. /**
  39610. * Define how fast the camera can accelerate to follow it s target.
  39611. */
  39612. cameraAcceleration: number;
  39613. /**
  39614. * Define the speed limit of the camera following an object.
  39615. */
  39616. maxCameraSpeed: number;
  39617. /**
  39618. * Define the target of the camera.
  39619. */
  39620. lockedTarget: Nullable<AbstractMesh>;
  39621. /**
  39622. * Defines the input associated with the camera.
  39623. */
  39624. inputs: FollowCameraInputsManager;
  39625. /**
  39626. * Instantiates the follow camera.
  39627. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39628. * @param name Define the name of the camera in the scene
  39629. * @param position Define the position of the camera
  39630. * @param scene Define the scene the camera belong to
  39631. * @param lockedTarget Define the target of the camera
  39632. */
  39633. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  39634. private _follow;
  39635. /**
  39636. * Attached controls to the current camera.
  39637. * @param element Defines the element the controls should be listened from
  39638. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39639. */
  39640. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39641. /**
  39642. * Detach the current controls from the camera.
  39643. * The camera will stop reacting to inputs.
  39644. * @param element Defines the element to stop listening the inputs from
  39645. */
  39646. detachControl(element: HTMLElement): void;
  39647. /** @hidden */
  39648. _checkInputs(): void;
  39649. private _checkLimits;
  39650. /**
  39651. * Gets the camera class name.
  39652. * @returns the class name
  39653. */
  39654. getClassName(): string;
  39655. }
  39656. /**
  39657. * Arc Rotate version of the follow camera.
  39658. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  39659. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39660. */
  39661. export class ArcFollowCamera extends TargetCamera {
  39662. /** The longitudinal angle of the camera */
  39663. alpha: number;
  39664. /** The latitudinal angle of the camera */
  39665. beta: number;
  39666. /** The radius of the camera from its target */
  39667. radius: number;
  39668. /** Define the camera target (the messh it should follow) */
  39669. target: Nullable<AbstractMesh>;
  39670. private _cartesianCoordinates;
  39671. /**
  39672. * Instantiates a new ArcFollowCamera
  39673. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39674. * @param name Define the name of the camera
  39675. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  39676. * @param beta Define the rotation angle of the camera around the elevation axis
  39677. * @param radius Define the radius of the camera from its target point
  39678. * @param target Define the target of the camera
  39679. * @param scene Define the scene the camera belongs to
  39680. */
  39681. constructor(name: string,
  39682. /** The longitudinal angle of the camera */
  39683. alpha: number,
  39684. /** The latitudinal angle of the camera */
  39685. beta: number,
  39686. /** The radius of the camera from its target */
  39687. radius: number,
  39688. /** Define the camera target (the messh it should follow) */
  39689. target: Nullable<AbstractMesh>, scene: Scene);
  39690. private _follow;
  39691. /** @hidden */
  39692. _checkInputs(): void;
  39693. /**
  39694. * Returns the class name of the object.
  39695. * It is mostly used internally for serialization purposes.
  39696. */
  39697. getClassName(): string;
  39698. }
  39699. }
  39700. declare module BABYLON {
  39701. /**
  39702. * Manage the keyboard inputs to control the movement of a follow camera.
  39703. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39704. */
  39705. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  39706. /**
  39707. * Defines the camera the input is attached to.
  39708. */
  39709. camera: FollowCamera;
  39710. /**
  39711. * Defines the list of key codes associated with the up action (increase heightOffset)
  39712. */
  39713. keysHeightOffsetIncr: number[];
  39714. /**
  39715. * Defines the list of key codes associated with the down action (decrease heightOffset)
  39716. */
  39717. keysHeightOffsetDecr: number[];
  39718. /**
  39719. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  39720. */
  39721. keysHeightOffsetModifierAlt: boolean;
  39722. /**
  39723. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  39724. */
  39725. keysHeightOffsetModifierCtrl: boolean;
  39726. /**
  39727. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  39728. */
  39729. keysHeightOffsetModifierShift: boolean;
  39730. /**
  39731. * Defines the list of key codes associated with the left action (increase rotationOffset)
  39732. */
  39733. keysRotationOffsetIncr: number[];
  39734. /**
  39735. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  39736. */
  39737. keysRotationOffsetDecr: number[];
  39738. /**
  39739. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  39740. */
  39741. keysRotationOffsetModifierAlt: boolean;
  39742. /**
  39743. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  39744. */
  39745. keysRotationOffsetModifierCtrl: boolean;
  39746. /**
  39747. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  39748. */
  39749. keysRotationOffsetModifierShift: boolean;
  39750. /**
  39751. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  39752. */
  39753. keysRadiusIncr: number[];
  39754. /**
  39755. * Defines the list of key codes associated with the zoom-out action (increase radius)
  39756. */
  39757. keysRadiusDecr: number[];
  39758. /**
  39759. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  39760. */
  39761. keysRadiusModifierAlt: boolean;
  39762. /**
  39763. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  39764. */
  39765. keysRadiusModifierCtrl: boolean;
  39766. /**
  39767. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  39768. */
  39769. keysRadiusModifierShift: boolean;
  39770. /**
  39771. * Defines the rate of change of heightOffset.
  39772. */
  39773. heightSensibility: number;
  39774. /**
  39775. * Defines the rate of change of rotationOffset.
  39776. */
  39777. rotationSensibility: number;
  39778. /**
  39779. * Defines the rate of change of radius.
  39780. */
  39781. radiusSensibility: number;
  39782. private _keys;
  39783. private _ctrlPressed;
  39784. private _altPressed;
  39785. private _shiftPressed;
  39786. private _onCanvasBlurObserver;
  39787. private _onKeyboardObserver;
  39788. private _engine;
  39789. private _scene;
  39790. /**
  39791. * Attach the input controls to a specific dom element to get the input from.
  39792. * @param element Defines the element the controls should be listened from
  39793. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39794. */
  39795. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39796. /**
  39797. * Detach the current controls from the specified dom element.
  39798. * @param element Defines the element to stop listening the inputs from
  39799. */
  39800. detachControl(element: Nullable<HTMLElement>): void;
  39801. /**
  39802. * Update the current camera state depending on the inputs that have been used this frame.
  39803. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39804. */
  39805. checkInputs(): void;
  39806. /**
  39807. * Gets the class name of the current input.
  39808. * @returns the class name
  39809. */
  39810. getClassName(): string;
  39811. /**
  39812. * Get the friendly name associated with the input class.
  39813. * @returns the input friendly name
  39814. */
  39815. getSimpleName(): string;
  39816. /**
  39817. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39818. * allow modification of the heightOffset value.
  39819. */
  39820. private _modifierHeightOffset;
  39821. /**
  39822. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39823. * allow modification of the rotationOffset value.
  39824. */
  39825. private _modifierRotationOffset;
  39826. /**
  39827. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39828. * allow modification of the radius value.
  39829. */
  39830. private _modifierRadius;
  39831. }
  39832. }
  39833. declare module BABYLON {
  39834. interface FreeCameraInputsManager {
  39835. /**
  39836. * @hidden
  39837. */
  39838. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  39839. /**
  39840. * Add orientation input support to the input manager.
  39841. * @returns the current input manager
  39842. */
  39843. addDeviceOrientation(): FreeCameraInputsManager;
  39844. }
  39845. /**
  39846. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  39847. * Screen rotation is taken into account.
  39848. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39849. */
  39850. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  39851. private _camera;
  39852. private _screenOrientationAngle;
  39853. private _constantTranform;
  39854. private _screenQuaternion;
  39855. private _alpha;
  39856. private _beta;
  39857. private _gamma;
  39858. /**
  39859. * Can be used to detect if a device orientation sensor is available on a device
  39860. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  39861. * @returns a promise that will resolve on orientation change
  39862. */
  39863. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  39864. /**
  39865. * @hidden
  39866. */
  39867. _onDeviceOrientationChangedObservable: Observable<void>;
  39868. /**
  39869. * Instantiates a new input
  39870. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39871. */
  39872. constructor();
  39873. /**
  39874. * Define the camera controlled by the input.
  39875. */
  39876. camera: FreeCamera;
  39877. /**
  39878. * Attach the input controls to a specific dom element to get the input from.
  39879. * @param element Defines the element the controls should be listened from
  39880. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39881. */
  39882. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39883. private _orientationChanged;
  39884. private _deviceOrientation;
  39885. /**
  39886. * Detach the current controls from the specified dom element.
  39887. * @param element Defines the element to stop listening the inputs from
  39888. */
  39889. detachControl(element: Nullable<HTMLElement>): void;
  39890. /**
  39891. * Update the current camera state depending on the inputs that have been used this frame.
  39892. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39893. */
  39894. checkInputs(): void;
  39895. /**
  39896. * Gets the class name of the current intput.
  39897. * @returns the class name
  39898. */
  39899. getClassName(): string;
  39900. /**
  39901. * Get the friendly name associated with the input class.
  39902. * @returns the input friendly name
  39903. */
  39904. getSimpleName(): string;
  39905. }
  39906. }
  39907. declare module BABYLON {
  39908. /**
  39909. * Manage the gamepad inputs to control a free camera.
  39910. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39911. */
  39912. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  39913. /**
  39914. * Define the camera the input is attached to.
  39915. */
  39916. camera: FreeCamera;
  39917. /**
  39918. * Define the Gamepad controlling the input
  39919. */
  39920. gamepad: Nullable<Gamepad>;
  39921. /**
  39922. * Defines the gamepad rotation sensiblity.
  39923. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39924. */
  39925. gamepadAngularSensibility: number;
  39926. /**
  39927. * Defines the gamepad move sensiblity.
  39928. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39929. */
  39930. gamepadMoveSensibility: number;
  39931. private _yAxisScale;
  39932. /**
  39933. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  39934. */
  39935. invertYAxis: boolean;
  39936. private _onGamepadConnectedObserver;
  39937. private _onGamepadDisconnectedObserver;
  39938. private _cameraTransform;
  39939. private _deltaTransform;
  39940. private _vector3;
  39941. private _vector2;
  39942. /**
  39943. * Attach the input controls to a specific dom element to get the input from.
  39944. * @param element Defines the element the controls should be listened from
  39945. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39946. */
  39947. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39948. /**
  39949. * Detach the current controls from the specified dom element.
  39950. * @param element Defines the element to stop listening the inputs from
  39951. */
  39952. detachControl(element: Nullable<HTMLElement>): void;
  39953. /**
  39954. * Update the current camera state depending on the inputs that have been used this frame.
  39955. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39956. */
  39957. checkInputs(): void;
  39958. /**
  39959. * Gets the class name of the current intput.
  39960. * @returns the class name
  39961. */
  39962. getClassName(): string;
  39963. /**
  39964. * Get the friendly name associated with the input class.
  39965. * @returns the input friendly name
  39966. */
  39967. getSimpleName(): string;
  39968. }
  39969. }
  39970. declare module BABYLON {
  39971. /**
  39972. * Defines the potential axis of a Joystick
  39973. */
  39974. export enum JoystickAxis {
  39975. /** X axis */
  39976. X = 0,
  39977. /** Y axis */
  39978. Y = 1,
  39979. /** Z axis */
  39980. Z = 2
  39981. }
  39982. /**
  39983. * Class used to define virtual joystick (used in touch mode)
  39984. */
  39985. export class VirtualJoystick {
  39986. /**
  39987. * Gets or sets a boolean indicating that left and right values must be inverted
  39988. */
  39989. reverseLeftRight: boolean;
  39990. /**
  39991. * Gets or sets a boolean indicating that up and down values must be inverted
  39992. */
  39993. reverseUpDown: boolean;
  39994. /**
  39995. * Gets the offset value for the position (ie. the change of the position value)
  39996. */
  39997. deltaPosition: Vector3;
  39998. /**
  39999. * Gets a boolean indicating if the virtual joystick was pressed
  40000. */
  40001. pressed: boolean;
  40002. /**
  40003. * Canvas the virtual joystick will render onto, default z-index of this is 5
  40004. */
  40005. static Canvas: Nullable<HTMLCanvasElement>;
  40006. private static _globalJoystickIndex;
  40007. private static vjCanvasContext;
  40008. private static vjCanvasWidth;
  40009. private static vjCanvasHeight;
  40010. private static halfWidth;
  40011. private _action;
  40012. private _axisTargetedByLeftAndRight;
  40013. private _axisTargetedByUpAndDown;
  40014. private _joystickSensibility;
  40015. private _inversedSensibility;
  40016. private _joystickPointerID;
  40017. private _joystickColor;
  40018. private _joystickPointerPos;
  40019. private _joystickPreviousPointerPos;
  40020. private _joystickPointerStartPos;
  40021. private _deltaJoystickVector;
  40022. private _leftJoystick;
  40023. private _touches;
  40024. private _onPointerDownHandlerRef;
  40025. private _onPointerMoveHandlerRef;
  40026. private _onPointerUpHandlerRef;
  40027. private _onResize;
  40028. /**
  40029. * Creates a new virtual joystick
  40030. * @param leftJoystick defines that the joystick is for left hand (false by default)
  40031. */
  40032. constructor(leftJoystick?: boolean);
  40033. /**
  40034. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  40035. * @param newJoystickSensibility defines the new sensibility
  40036. */
  40037. setJoystickSensibility(newJoystickSensibility: number): void;
  40038. private _onPointerDown;
  40039. private _onPointerMove;
  40040. private _onPointerUp;
  40041. /**
  40042. * Change the color of the virtual joystick
  40043. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  40044. */
  40045. setJoystickColor(newColor: string): void;
  40046. /**
  40047. * Defines a callback to call when the joystick is touched
  40048. * @param action defines the callback
  40049. */
  40050. setActionOnTouch(action: () => any): void;
  40051. /**
  40052. * Defines which axis you'd like to control for left & right
  40053. * @param axis defines the axis to use
  40054. */
  40055. setAxisForLeftRight(axis: JoystickAxis): void;
  40056. /**
  40057. * Defines which axis you'd like to control for up & down
  40058. * @param axis defines the axis to use
  40059. */
  40060. setAxisForUpDown(axis: JoystickAxis): void;
  40061. private _drawVirtualJoystick;
  40062. /**
  40063. * Release internal HTML canvas
  40064. */
  40065. releaseCanvas(): void;
  40066. }
  40067. }
  40068. declare module BABYLON {
  40069. interface FreeCameraInputsManager {
  40070. /**
  40071. * Add virtual joystick input support to the input manager.
  40072. * @returns the current input manager
  40073. */
  40074. addVirtualJoystick(): FreeCameraInputsManager;
  40075. }
  40076. /**
  40077. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  40078. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40079. */
  40080. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  40081. /**
  40082. * Defines the camera the input is attached to.
  40083. */
  40084. camera: FreeCamera;
  40085. private _leftjoystick;
  40086. private _rightjoystick;
  40087. /**
  40088. * Gets the left stick of the virtual joystick.
  40089. * @returns The virtual Joystick
  40090. */
  40091. getLeftJoystick(): VirtualJoystick;
  40092. /**
  40093. * Gets the right stick of the virtual joystick.
  40094. * @returns The virtual Joystick
  40095. */
  40096. getRightJoystick(): VirtualJoystick;
  40097. /**
  40098. * Update the current camera state depending on the inputs that have been used this frame.
  40099. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40100. */
  40101. checkInputs(): void;
  40102. /**
  40103. * Attach the input controls to a specific dom element to get the input from.
  40104. * @param element Defines the element the controls should be listened from
  40105. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40106. */
  40107. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40108. /**
  40109. * Detach the current controls from the specified dom element.
  40110. * @param element Defines the element to stop listening the inputs from
  40111. */
  40112. detachControl(element: Nullable<HTMLElement>): void;
  40113. /**
  40114. * Gets the class name of the current intput.
  40115. * @returns the class name
  40116. */
  40117. getClassName(): string;
  40118. /**
  40119. * Get the friendly name associated with the input class.
  40120. * @returns the input friendly name
  40121. */
  40122. getSimpleName(): string;
  40123. }
  40124. }
  40125. declare module BABYLON {
  40126. /**
  40127. * This represents a FPS type of camera controlled by touch.
  40128. * This is like a universal camera minus the Gamepad controls.
  40129. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40130. */
  40131. export class TouchCamera extends FreeCamera {
  40132. /**
  40133. * Defines the touch sensibility for rotation.
  40134. * The higher the faster.
  40135. */
  40136. touchAngularSensibility: number;
  40137. /**
  40138. * Defines the touch sensibility for move.
  40139. * The higher the faster.
  40140. */
  40141. touchMoveSensibility: number;
  40142. /**
  40143. * Instantiates a new touch camera.
  40144. * This represents a FPS type of camera controlled by touch.
  40145. * This is like a universal camera minus the Gamepad controls.
  40146. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40147. * @param name Define the name of the camera in the scene
  40148. * @param position Define the start position of the camera in the scene
  40149. * @param scene Define the scene the camera belongs to
  40150. */
  40151. constructor(name: string, position: Vector3, scene: Scene);
  40152. /**
  40153. * Gets the current object class name.
  40154. * @return the class name
  40155. */
  40156. getClassName(): string;
  40157. /** @hidden */
  40158. _setupInputs(): void;
  40159. }
  40160. }
  40161. declare module BABYLON {
  40162. /**
  40163. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  40164. * being tilted forward or back and left or right.
  40165. */
  40166. export class DeviceOrientationCamera extends FreeCamera {
  40167. private _initialQuaternion;
  40168. private _quaternionCache;
  40169. private _tmpDragQuaternion;
  40170. private _disablePointerInputWhenUsingDeviceOrientation;
  40171. /**
  40172. * Creates a new device orientation camera
  40173. * @param name The name of the camera
  40174. * @param position The start position camera
  40175. * @param scene The scene the camera belongs to
  40176. */
  40177. constructor(name: string, position: Vector3, scene: Scene);
  40178. /**
  40179. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  40180. */
  40181. disablePointerInputWhenUsingDeviceOrientation: boolean;
  40182. private _dragFactor;
  40183. /**
  40184. * Enabled turning on the y axis when the orientation sensor is active
  40185. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  40186. */
  40187. enableHorizontalDragging(dragFactor?: number): void;
  40188. /**
  40189. * Gets the current instance class name ("DeviceOrientationCamera").
  40190. * This helps avoiding instanceof at run time.
  40191. * @returns the class name
  40192. */
  40193. getClassName(): string;
  40194. /**
  40195. * @hidden
  40196. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  40197. */
  40198. _checkInputs(): void;
  40199. /**
  40200. * Reset the camera to its default orientation on the specified axis only.
  40201. * @param axis The axis to reset
  40202. */
  40203. resetToCurrentRotation(axis?: Axis): void;
  40204. }
  40205. }
  40206. declare module BABYLON {
  40207. /**
  40208. * Defines supported buttons for XBox360 compatible gamepads
  40209. */
  40210. export enum Xbox360Button {
  40211. /** A */
  40212. A = 0,
  40213. /** B */
  40214. B = 1,
  40215. /** X */
  40216. X = 2,
  40217. /** Y */
  40218. Y = 3,
  40219. /** Start */
  40220. Start = 4,
  40221. /** Back */
  40222. Back = 5,
  40223. /** Left button */
  40224. LB = 6,
  40225. /** Right button */
  40226. RB = 7,
  40227. /** Left stick */
  40228. LeftStick = 8,
  40229. /** Right stick */
  40230. RightStick = 9
  40231. }
  40232. /** Defines values for XBox360 DPad */
  40233. export enum Xbox360Dpad {
  40234. /** Up */
  40235. Up = 0,
  40236. /** Down */
  40237. Down = 1,
  40238. /** Left */
  40239. Left = 2,
  40240. /** Right */
  40241. Right = 3
  40242. }
  40243. /**
  40244. * Defines a XBox360 gamepad
  40245. */
  40246. export class Xbox360Pad extends Gamepad {
  40247. private _leftTrigger;
  40248. private _rightTrigger;
  40249. private _onlefttriggerchanged;
  40250. private _onrighttriggerchanged;
  40251. private _onbuttondown;
  40252. private _onbuttonup;
  40253. private _ondpaddown;
  40254. private _ondpadup;
  40255. /** Observable raised when a button is pressed */
  40256. onButtonDownObservable: Observable<Xbox360Button>;
  40257. /** Observable raised when a button is released */
  40258. onButtonUpObservable: Observable<Xbox360Button>;
  40259. /** Observable raised when a pad is pressed */
  40260. onPadDownObservable: Observable<Xbox360Dpad>;
  40261. /** Observable raised when a pad is released */
  40262. onPadUpObservable: Observable<Xbox360Dpad>;
  40263. private _buttonA;
  40264. private _buttonB;
  40265. private _buttonX;
  40266. private _buttonY;
  40267. private _buttonBack;
  40268. private _buttonStart;
  40269. private _buttonLB;
  40270. private _buttonRB;
  40271. private _buttonLeftStick;
  40272. private _buttonRightStick;
  40273. private _dPadUp;
  40274. private _dPadDown;
  40275. private _dPadLeft;
  40276. private _dPadRight;
  40277. private _isXboxOnePad;
  40278. /**
  40279. * Creates a new XBox360 gamepad object
  40280. * @param id defines the id of this gamepad
  40281. * @param index defines its index
  40282. * @param gamepad defines the internal HTML gamepad object
  40283. * @param xboxOne defines if it is a XBox One gamepad
  40284. */
  40285. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  40286. /**
  40287. * Defines the callback to call when left trigger is pressed
  40288. * @param callback defines the callback to use
  40289. */
  40290. onlefttriggerchanged(callback: (value: number) => void): void;
  40291. /**
  40292. * Defines the callback to call when right trigger is pressed
  40293. * @param callback defines the callback to use
  40294. */
  40295. onrighttriggerchanged(callback: (value: number) => void): void;
  40296. /**
  40297. * Gets the left trigger value
  40298. */
  40299. /**
  40300. * Sets the left trigger value
  40301. */
  40302. leftTrigger: number;
  40303. /**
  40304. * Gets the right trigger value
  40305. */
  40306. /**
  40307. * Sets the right trigger value
  40308. */
  40309. rightTrigger: number;
  40310. /**
  40311. * Defines the callback to call when a button is pressed
  40312. * @param callback defines the callback to use
  40313. */
  40314. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  40315. /**
  40316. * Defines the callback to call when a button is released
  40317. * @param callback defines the callback to use
  40318. */
  40319. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  40320. /**
  40321. * Defines the callback to call when a pad is pressed
  40322. * @param callback defines the callback to use
  40323. */
  40324. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  40325. /**
  40326. * Defines the callback to call when a pad is released
  40327. * @param callback defines the callback to use
  40328. */
  40329. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  40330. private _setButtonValue;
  40331. private _setDPadValue;
  40332. /**
  40333. * Gets the value of the `A` button
  40334. */
  40335. /**
  40336. * Sets the value of the `A` button
  40337. */
  40338. buttonA: number;
  40339. /**
  40340. * Gets the value of the `B` button
  40341. */
  40342. /**
  40343. * Sets the value of the `B` button
  40344. */
  40345. buttonB: number;
  40346. /**
  40347. * Gets the value of the `X` button
  40348. */
  40349. /**
  40350. * Sets the value of the `X` button
  40351. */
  40352. buttonX: number;
  40353. /**
  40354. * Gets the value of the `Y` button
  40355. */
  40356. /**
  40357. * Sets the value of the `Y` button
  40358. */
  40359. buttonY: number;
  40360. /**
  40361. * Gets the value of the `Start` button
  40362. */
  40363. /**
  40364. * Sets the value of the `Start` button
  40365. */
  40366. buttonStart: number;
  40367. /**
  40368. * Gets the value of the `Back` button
  40369. */
  40370. /**
  40371. * Sets the value of the `Back` button
  40372. */
  40373. buttonBack: number;
  40374. /**
  40375. * Gets the value of the `Left` button
  40376. */
  40377. /**
  40378. * Sets the value of the `Left` button
  40379. */
  40380. buttonLB: number;
  40381. /**
  40382. * Gets the value of the `Right` button
  40383. */
  40384. /**
  40385. * Sets the value of the `Right` button
  40386. */
  40387. buttonRB: number;
  40388. /**
  40389. * Gets the value of the Left joystick
  40390. */
  40391. /**
  40392. * Sets the value of the Left joystick
  40393. */
  40394. buttonLeftStick: number;
  40395. /**
  40396. * Gets the value of the Right joystick
  40397. */
  40398. /**
  40399. * Sets the value of the Right joystick
  40400. */
  40401. buttonRightStick: number;
  40402. /**
  40403. * Gets the value of D-pad up
  40404. */
  40405. /**
  40406. * Sets the value of D-pad up
  40407. */
  40408. dPadUp: number;
  40409. /**
  40410. * Gets the value of D-pad down
  40411. */
  40412. /**
  40413. * Sets the value of D-pad down
  40414. */
  40415. dPadDown: number;
  40416. /**
  40417. * Gets the value of D-pad left
  40418. */
  40419. /**
  40420. * Sets the value of D-pad left
  40421. */
  40422. dPadLeft: number;
  40423. /**
  40424. * Gets the value of D-pad right
  40425. */
  40426. /**
  40427. * Sets the value of D-pad right
  40428. */
  40429. dPadRight: number;
  40430. /**
  40431. * Force the gamepad to synchronize with device values
  40432. */
  40433. update(): void;
  40434. /**
  40435. * Disposes the gamepad
  40436. */
  40437. dispose(): void;
  40438. }
  40439. }
  40440. declare module BABYLON {
  40441. /**
  40442. * Defines supported buttons for DualShock compatible gamepads
  40443. */
  40444. export enum DualShockButton {
  40445. /** Cross */
  40446. Cross = 0,
  40447. /** Circle */
  40448. Circle = 1,
  40449. /** Square */
  40450. Square = 2,
  40451. /** Triangle */
  40452. Triangle = 3,
  40453. /** Options */
  40454. Options = 4,
  40455. /** Share */
  40456. Share = 5,
  40457. /** L1 */
  40458. L1 = 6,
  40459. /** R1 */
  40460. R1 = 7,
  40461. /** Left stick */
  40462. LeftStick = 8,
  40463. /** Right stick */
  40464. RightStick = 9
  40465. }
  40466. /** Defines values for DualShock DPad */
  40467. export enum DualShockDpad {
  40468. /** Up */
  40469. Up = 0,
  40470. /** Down */
  40471. Down = 1,
  40472. /** Left */
  40473. Left = 2,
  40474. /** Right */
  40475. Right = 3
  40476. }
  40477. /**
  40478. * Defines a DualShock gamepad
  40479. */
  40480. export class DualShockPad extends Gamepad {
  40481. private _leftTrigger;
  40482. private _rightTrigger;
  40483. private _onlefttriggerchanged;
  40484. private _onrighttriggerchanged;
  40485. private _onbuttondown;
  40486. private _onbuttonup;
  40487. private _ondpaddown;
  40488. private _ondpadup;
  40489. /** Observable raised when a button is pressed */
  40490. onButtonDownObservable: Observable<DualShockButton>;
  40491. /** Observable raised when a button is released */
  40492. onButtonUpObservable: Observable<DualShockButton>;
  40493. /** Observable raised when a pad is pressed */
  40494. onPadDownObservable: Observable<DualShockDpad>;
  40495. /** Observable raised when a pad is released */
  40496. onPadUpObservable: Observable<DualShockDpad>;
  40497. private _buttonCross;
  40498. private _buttonCircle;
  40499. private _buttonSquare;
  40500. private _buttonTriangle;
  40501. private _buttonShare;
  40502. private _buttonOptions;
  40503. private _buttonL1;
  40504. private _buttonR1;
  40505. private _buttonLeftStick;
  40506. private _buttonRightStick;
  40507. private _dPadUp;
  40508. private _dPadDown;
  40509. private _dPadLeft;
  40510. private _dPadRight;
  40511. /**
  40512. * Creates a new DualShock gamepad object
  40513. * @param id defines the id of this gamepad
  40514. * @param index defines its index
  40515. * @param gamepad defines the internal HTML gamepad object
  40516. */
  40517. constructor(id: string, index: number, gamepad: any);
  40518. /**
  40519. * Defines the callback to call when left trigger is pressed
  40520. * @param callback defines the callback to use
  40521. */
  40522. onlefttriggerchanged(callback: (value: number) => void): void;
  40523. /**
  40524. * Defines the callback to call when right trigger is pressed
  40525. * @param callback defines the callback to use
  40526. */
  40527. onrighttriggerchanged(callback: (value: number) => void): void;
  40528. /**
  40529. * Gets the left trigger value
  40530. */
  40531. /**
  40532. * Sets the left trigger value
  40533. */
  40534. leftTrigger: number;
  40535. /**
  40536. * Gets the right trigger value
  40537. */
  40538. /**
  40539. * Sets the right trigger value
  40540. */
  40541. rightTrigger: number;
  40542. /**
  40543. * Defines the callback to call when a button is pressed
  40544. * @param callback defines the callback to use
  40545. */
  40546. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  40547. /**
  40548. * Defines the callback to call when a button is released
  40549. * @param callback defines the callback to use
  40550. */
  40551. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  40552. /**
  40553. * Defines the callback to call when a pad is pressed
  40554. * @param callback defines the callback to use
  40555. */
  40556. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  40557. /**
  40558. * Defines the callback to call when a pad is released
  40559. * @param callback defines the callback to use
  40560. */
  40561. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  40562. private _setButtonValue;
  40563. private _setDPadValue;
  40564. /**
  40565. * Gets the value of the `Cross` button
  40566. */
  40567. /**
  40568. * Sets the value of the `Cross` button
  40569. */
  40570. buttonCross: number;
  40571. /**
  40572. * Gets the value of the `Circle` button
  40573. */
  40574. /**
  40575. * Sets the value of the `Circle` button
  40576. */
  40577. buttonCircle: number;
  40578. /**
  40579. * Gets the value of the `Square` button
  40580. */
  40581. /**
  40582. * Sets the value of the `Square` button
  40583. */
  40584. buttonSquare: number;
  40585. /**
  40586. * Gets the value of the `Triangle` button
  40587. */
  40588. /**
  40589. * Sets the value of the `Triangle` button
  40590. */
  40591. buttonTriangle: number;
  40592. /**
  40593. * Gets the value of the `Options` button
  40594. */
  40595. /**
  40596. * Sets the value of the `Options` button
  40597. */
  40598. buttonOptions: number;
  40599. /**
  40600. * Gets the value of the `Share` button
  40601. */
  40602. /**
  40603. * Sets the value of the `Share` button
  40604. */
  40605. buttonShare: number;
  40606. /**
  40607. * Gets the value of the `L1` button
  40608. */
  40609. /**
  40610. * Sets the value of the `L1` button
  40611. */
  40612. buttonL1: number;
  40613. /**
  40614. * Gets the value of the `R1` button
  40615. */
  40616. /**
  40617. * Sets the value of the `R1` button
  40618. */
  40619. buttonR1: number;
  40620. /**
  40621. * Gets the value of the Left joystick
  40622. */
  40623. /**
  40624. * Sets the value of the Left joystick
  40625. */
  40626. buttonLeftStick: number;
  40627. /**
  40628. * Gets the value of the Right joystick
  40629. */
  40630. /**
  40631. * Sets the value of the Right joystick
  40632. */
  40633. buttonRightStick: number;
  40634. /**
  40635. * Gets the value of D-pad up
  40636. */
  40637. /**
  40638. * Sets the value of D-pad up
  40639. */
  40640. dPadUp: number;
  40641. /**
  40642. * Gets the value of D-pad down
  40643. */
  40644. /**
  40645. * Sets the value of D-pad down
  40646. */
  40647. dPadDown: number;
  40648. /**
  40649. * Gets the value of D-pad left
  40650. */
  40651. /**
  40652. * Sets the value of D-pad left
  40653. */
  40654. dPadLeft: number;
  40655. /**
  40656. * Gets the value of D-pad right
  40657. */
  40658. /**
  40659. * Sets the value of D-pad right
  40660. */
  40661. dPadRight: number;
  40662. /**
  40663. * Force the gamepad to synchronize with device values
  40664. */
  40665. update(): void;
  40666. /**
  40667. * Disposes the gamepad
  40668. */
  40669. dispose(): void;
  40670. }
  40671. }
  40672. declare module BABYLON {
  40673. /**
  40674. * Manager for handling gamepads
  40675. */
  40676. export class GamepadManager {
  40677. private _scene?;
  40678. private _babylonGamepads;
  40679. private _oneGamepadConnected;
  40680. /** @hidden */
  40681. _isMonitoring: boolean;
  40682. private _gamepadEventSupported;
  40683. private _gamepadSupport;
  40684. /**
  40685. * observable to be triggered when the gamepad controller has been connected
  40686. */
  40687. onGamepadConnectedObservable: Observable<Gamepad>;
  40688. /**
  40689. * observable to be triggered when the gamepad controller has been disconnected
  40690. */
  40691. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40692. private _onGamepadConnectedEvent;
  40693. private _onGamepadDisconnectedEvent;
  40694. /**
  40695. * Initializes the gamepad manager
  40696. * @param _scene BabylonJS scene
  40697. */
  40698. constructor(_scene?: Scene | undefined);
  40699. /**
  40700. * The gamepads in the game pad manager
  40701. */
  40702. readonly gamepads: Gamepad[];
  40703. /**
  40704. * Get the gamepad controllers based on type
  40705. * @param type The type of gamepad controller
  40706. * @returns Nullable gamepad
  40707. */
  40708. getGamepadByType(type?: number): Nullable<Gamepad>;
  40709. /**
  40710. * Disposes the gamepad manager
  40711. */
  40712. dispose(): void;
  40713. private _addNewGamepad;
  40714. private _startMonitoringGamepads;
  40715. private _stopMonitoringGamepads;
  40716. /** @hidden */
  40717. _checkGamepadsStatus(): void;
  40718. private _updateGamepadObjects;
  40719. }
  40720. }
  40721. declare module BABYLON {
  40722. interface Scene {
  40723. /** @hidden */
  40724. _gamepadManager: Nullable<GamepadManager>;
  40725. /**
  40726. * Gets the gamepad manager associated with the scene
  40727. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40728. */
  40729. gamepadManager: GamepadManager;
  40730. }
  40731. /**
  40732. * Interface representing a free camera inputs manager
  40733. */
  40734. interface FreeCameraInputsManager {
  40735. /**
  40736. * Adds gamepad input support to the FreeCameraInputsManager.
  40737. * @returns the FreeCameraInputsManager
  40738. */
  40739. addGamepad(): FreeCameraInputsManager;
  40740. }
  40741. /**
  40742. * Interface representing an arc rotate camera inputs manager
  40743. */
  40744. interface ArcRotateCameraInputsManager {
  40745. /**
  40746. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40747. * @returns the camera inputs manager
  40748. */
  40749. addGamepad(): ArcRotateCameraInputsManager;
  40750. }
  40751. /**
  40752. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40753. */
  40754. export class GamepadSystemSceneComponent implements ISceneComponent {
  40755. /**
  40756. * The component name helpfull to identify the component in the list of scene components.
  40757. */
  40758. readonly name: string;
  40759. /**
  40760. * The scene the component belongs to.
  40761. */
  40762. scene: Scene;
  40763. /**
  40764. * Creates a new instance of the component for the given scene
  40765. * @param scene Defines the scene to register the component in
  40766. */
  40767. constructor(scene: Scene);
  40768. /**
  40769. * Registers the component in a given scene
  40770. */
  40771. register(): void;
  40772. /**
  40773. * Rebuilds the elements related to this component in case of
  40774. * context lost for instance.
  40775. */
  40776. rebuild(): void;
  40777. /**
  40778. * Disposes the component and the associated ressources
  40779. */
  40780. dispose(): void;
  40781. private _beforeCameraUpdate;
  40782. }
  40783. }
  40784. declare module BABYLON {
  40785. /**
  40786. * 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,
  40787. * which still works and will still be found in many Playgrounds.
  40788. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40789. */
  40790. export class UniversalCamera extends TouchCamera {
  40791. /**
  40792. * Defines the gamepad rotation sensiblity.
  40793. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40794. */
  40795. gamepadAngularSensibility: number;
  40796. /**
  40797. * Defines the gamepad move sensiblity.
  40798. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40799. */
  40800. gamepadMoveSensibility: number;
  40801. /**
  40802. * 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,
  40803. * which still works and will still be found in many Playgrounds.
  40804. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40805. * @param name Define the name of the camera in the scene
  40806. * @param position Define the start position of the camera in the scene
  40807. * @param scene Define the scene the camera belongs to
  40808. */
  40809. constructor(name: string, position: Vector3, scene: Scene);
  40810. /**
  40811. * Gets the current object class name.
  40812. * @return the class name
  40813. */
  40814. getClassName(): string;
  40815. }
  40816. }
  40817. declare module BABYLON {
  40818. /**
  40819. * This represents a FPS type of camera. This is only here for back compat purpose.
  40820. * Please use the UniversalCamera instead as both are identical.
  40821. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40822. */
  40823. export class GamepadCamera extends UniversalCamera {
  40824. /**
  40825. * Instantiates a new Gamepad Camera
  40826. * This represents a FPS type of camera. This is only here for back compat purpose.
  40827. * Please use the UniversalCamera instead as both are identical.
  40828. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40829. * @param name Define the name of the camera in the scene
  40830. * @param position Define the start position of the camera in the scene
  40831. * @param scene Define the scene the camera belongs to
  40832. */
  40833. constructor(name: string, position: Vector3, scene: Scene);
  40834. /**
  40835. * Gets the current object class name.
  40836. * @return the class name
  40837. */
  40838. getClassName(): string;
  40839. }
  40840. }
  40841. declare module BABYLON {
  40842. /** @hidden */
  40843. export var passPixelShader: {
  40844. name: string;
  40845. shader: string;
  40846. };
  40847. }
  40848. declare module BABYLON {
  40849. /** @hidden */
  40850. export var passCubePixelShader: {
  40851. name: string;
  40852. shader: string;
  40853. };
  40854. }
  40855. declare module BABYLON {
  40856. /**
  40857. * PassPostProcess which produces an output the same as it's input
  40858. */
  40859. export class PassPostProcess extends PostProcess {
  40860. /**
  40861. * Creates the PassPostProcess
  40862. * @param name The name of the effect.
  40863. * @param options The required width/height ratio to downsize to before computing the render pass.
  40864. * @param camera The camera to apply the render pass to.
  40865. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40866. * @param engine The engine which the post process will be applied. (default: current engine)
  40867. * @param reusable If the post process can be reused on the same frame. (default: false)
  40868. * @param textureType The type of texture to be used when performing the post processing.
  40869. * @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)
  40870. */
  40871. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40872. }
  40873. /**
  40874. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  40875. */
  40876. export class PassCubePostProcess extends PostProcess {
  40877. private _face;
  40878. /**
  40879. * Gets or sets the cube face to display.
  40880. * * 0 is +X
  40881. * * 1 is -X
  40882. * * 2 is +Y
  40883. * * 3 is -Y
  40884. * * 4 is +Z
  40885. * * 5 is -Z
  40886. */
  40887. face: number;
  40888. /**
  40889. * Creates the PassCubePostProcess
  40890. * @param name The name of the effect.
  40891. * @param options The required width/height ratio to downsize to before computing the render pass.
  40892. * @param camera The camera to apply the render pass to.
  40893. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40894. * @param engine The engine which the post process will be applied. (default: current engine)
  40895. * @param reusable If the post process can be reused on the same frame. (default: false)
  40896. * @param textureType The type of texture to be used when performing the post processing.
  40897. * @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)
  40898. */
  40899. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40900. }
  40901. }
  40902. declare module BABYLON {
  40903. /** @hidden */
  40904. export var anaglyphPixelShader: {
  40905. name: string;
  40906. shader: string;
  40907. };
  40908. }
  40909. declare module BABYLON {
  40910. /**
  40911. * Postprocess used to generate anaglyphic rendering
  40912. */
  40913. export class AnaglyphPostProcess extends PostProcess {
  40914. private _passedProcess;
  40915. /**
  40916. * Creates a new AnaglyphPostProcess
  40917. * @param name defines postprocess name
  40918. * @param options defines creation options or target ratio scale
  40919. * @param rigCameras defines cameras using this postprocess
  40920. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  40921. * @param engine defines hosting engine
  40922. * @param reusable defines if the postprocess will be reused multiple times per frame
  40923. */
  40924. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  40925. }
  40926. }
  40927. declare module BABYLON {
  40928. /**
  40929. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  40930. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40931. */
  40932. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  40933. /**
  40934. * Creates a new AnaglyphArcRotateCamera
  40935. * @param name defines camera name
  40936. * @param alpha defines alpha angle (in radians)
  40937. * @param beta defines beta angle (in radians)
  40938. * @param radius defines radius
  40939. * @param target defines camera target
  40940. * @param interaxialDistance defines distance between each color axis
  40941. * @param scene defines the hosting scene
  40942. */
  40943. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  40944. /**
  40945. * Gets camera class name
  40946. * @returns AnaglyphArcRotateCamera
  40947. */
  40948. getClassName(): string;
  40949. }
  40950. }
  40951. declare module BABYLON {
  40952. /**
  40953. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  40954. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40955. */
  40956. export class AnaglyphFreeCamera extends FreeCamera {
  40957. /**
  40958. * Creates a new AnaglyphFreeCamera
  40959. * @param name defines camera name
  40960. * @param position defines initial position
  40961. * @param interaxialDistance defines distance between each color axis
  40962. * @param scene defines the hosting scene
  40963. */
  40964. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40965. /**
  40966. * Gets camera class name
  40967. * @returns AnaglyphFreeCamera
  40968. */
  40969. getClassName(): string;
  40970. }
  40971. }
  40972. declare module BABYLON {
  40973. /**
  40974. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  40975. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40976. */
  40977. export class AnaglyphGamepadCamera extends GamepadCamera {
  40978. /**
  40979. * Creates a new AnaglyphGamepadCamera
  40980. * @param name defines camera name
  40981. * @param position defines initial position
  40982. * @param interaxialDistance defines distance between each color axis
  40983. * @param scene defines the hosting scene
  40984. */
  40985. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40986. /**
  40987. * Gets camera class name
  40988. * @returns AnaglyphGamepadCamera
  40989. */
  40990. getClassName(): string;
  40991. }
  40992. }
  40993. declare module BABYLON {
  40994. /**
  40995. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  40996. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40997. */
  40998. export class AnaglyphUniversalCamera extends UniversalCamera {
  40999. /**
  41000. * Creates a new AnaglyphUniversalCamera
  41001. * @param name defines camera name
  41002. * @param position defines initial position
  41003. * @param interaxialDistance defines distance between each color axis
  41004. * @param scene defines the hosting scene
  41005. */
  41006. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41007. /**
  41008. * Gets camera class name
  41009. * @returns AnaglyphUniversalCamera
  41010. */
  41011. getClassName(): string;
  41012. }
  41013. }
  41014. declare module BABYLON {
  41015. /** @hidden */
  41016. export var stereoscopicInterlacePixelShader: {
  41017. name: string;
  41018. shader: string;
  41019. };
  41020. }
  41021. declare module BABYLON {
  41022. /**
  41023. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  41024. */
  41025. export class StereoscopicInterlacePostProcess extends PostProcess {
  41026. private _stepSize;
  41027. private _passedProcess;
  41028. /**
  41029. * Initializes a StereoscopicInterlacePostProcess
  41030. * @param name The name of the effect.
  41031. * @param rigCameras The rig cameras to be appled to the post process
  41032. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  41033. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41034. * @param engine The engine which the post process will be applied. (default: current engine)
  41035. * @param reusable If the post process can be reused on the same frame. (default: false)
  41036. */
  41037. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  41038. }
  41039. }
  41040. declare module BABYLON {
  41041. /**
  41042. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  41043. * @see http://doc.babylonjs.com/features/cameras
  41044. */
  41045. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  41046. /**
  41047. * Creates a new StereoscopicArcRotateCamera
  41048. * @param name defines camera name
  41049. * @param alpha defines alpha angle (in radians)
  41050. * @param beta defines beta angle (in radians)
  41051. * @param radius defines radius
  41052. * @param target defines camera target
  41053. * @param interaxialDistance defines distance between each color axis
  41054. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41055. * @param scene defines the hosting scene
  41056. */
  41057. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41058. /**
  41059. * Gets camera class name
  41060. * @returns StereoscopicArcRotateCamera
  41061. */
  41062. getClassName(): string;
  41063. }
  41064. }
  41065. declare module BABYLON {
  41066. /**
  41067. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  41068. * @see http://doc.babylonjs.com/features/cameras
  41069. */
  41070. export class StereoscopicFreeCamera extends FreeCamera {
  41071. /**
  41072. * Creates a new StereoscopicFreeCamera
  41073. * @param name defines camera name
  41074. * @param position defines initial position
  41075. * @param interaxialDistance defines distance between each color axis
  41076. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41077. * @param scene defines the hosting scene
  41078. */
  41079. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41080. /**
  41081. * Gets camera class name
  41082. * @returns StereoscopicFreeCamera
  41083. */
  41084. getClassName(): string;
  41085. }
  41086. }
  41087. declare module BABYLON {
  41088. /**
  41089. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  41090. * @see http://doc.babylonjs.com/features/cameras
  41091. */
  41092. export class StereoscopicGamepadCamera extends GamepadCamera {
  41093. /**
  41094. * Creates a new StereoscopicGamepadCamera
  41095. * @param name defines camera name
  41096. * @param position defines initial position
  41097. * @param interaxialDistance defines distance between each color axis
  41098. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41099. * @param scene defines the hosting scene
  41100. */
  41101. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41102. /**
  41103. * Gets camera class name
  41104. * @returns StereoscopicGamepadCamera
  41105. */
  41106. getClassName(): string;
  41107. }
  41108. }
  41109. declare module BABYLON {
  41110. /**
  41111. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  41112. * @see http://doc.babylonjs.com/features/cameras
  41113. */
  41114. export class StereoscopicUniversalCamera extends UniversalCamera {
  41115. /**
  41116. * Creates a new StereoscopicUniversalCamera
  41117. * @param name defines camera name
  41118. * @param position defines initial position
  41119. * @param interaxialDistance defines distance between each color axis
  41120. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41121. * @param scene defines the hosting scene
  41122. */
  41123. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41124. /**
  41125. * Gets camera class name
  41126. * @returns StereoscopicUniversalCamera
  41127. */
  41128. getClassName(): string;
  41129. }
  41130. }
  41131. declare module BABYLON {
  41132. /**
  41133. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  41134. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41135. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41136. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41137. */
  41138. export class VirtualJoysticksCamera extends FreeCamera {
  41139. /**
  41140. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  41141. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41142. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41143. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41144. * @param name Define the name of the camera in the scene
  41145. * @param position Define the start position of the camera in the scene
  41146. * @param scene Define the scene the camera belongs to
  41147. */
  41148. constructor(name: string, position: Vector3, scene: Scene);
  41149. /**
  41150. * Gets the current object class name.
  41151. * @return the class name
  41152. */
  41153. getClassName(): string;
  41154. }
  41155. }
  41156. declare module BABYLON {
  41157. /**
  41158. * This represents all the required metrics to create a VR camera.
  41159. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  41160. */
  41161. export class VRCameraMetrics {
  41162. /**
  41163. * Define the horizontal resolution off the screen.
  41164. */
  41165. hResolution: number;
  41166. /**
  41167. * Define the vertical resolution off the screen.
  41168. */
  41169. vResolution: number;
  41170. /**
  41171. * Define the horizontal screen size.
  41172. */
  41173. hScreenSize: number;
  41174. /**
  41175. * Define the vertical screen size.
  41176. */
  41177. vScreenSize: number;
  41178. /**
  41179. * Define the vertical screen center position.
  41180. */
  41181. vScreenCenter: number;
  41182. /**
  41183. * Define the distance of the eyes to the screen.
  41184. */
  41185. eyeToScreenDistance: number;
  41186. /**
  41187. * Define the distance between both lenses
  41188. */
  41189. lensSeparationDistance: number;
  41190. /**
  41191. * Define the distance between both viewer's eyes.
  41192. */
  41193. interpupillaryDistance: number;
  41194. /**
  41195. * Define the distortion factor of the VR postprocess.
  41196. * Please, touch with care.
  41197. */
  41198. distortionK: number[];
  41199. /**
  41200. * Define the chromatic aberration correction factors for the VR post process.
  41201. */
  41202. chromaAbCorrection: number[];
  41203. /**
  41204. * Define the scale factor of the post process.
  41205. * The smaller the better but the slower.
  41206. */
  41207. postProcessScaleFactor: number;
  41208. /**
  41209. * Define an offset for the lens center.
  41210. */
  41211. lensCenterOffset: number;
  41212. /**
  41213. * Define if the current vr camera should compensate the distortion of the lense or not.
  41214. */
  41215. compensateDistortion: boolean;
  41216. /**
  41217. * Defines if multiview should be enabled when rendering (Default: false)
  41218. */
  41219. multiviewEnabled: boolean;
  41220. /**
  41221. * Gets the rendering aspect ratio based on the provided resolutions.
  41222. */
  41223. readonly aspectRatio: number;
  41224. /**
  41225. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  41226. */
  41227. readonly aspectRatioFov: number;
  41228. /**
  41229. * @hidden
  41230. */
  41231. readonly leftHMatrix: Matrix;
  41232. /**
  41233. * @hidden
  41234. */
  41235. readonly rightHMatrix: Matrix;
  41236. /**
  41237. * @hidden
  41238. */
  41239. readonly leftPreViewMatrix: Matrix;
  41240. /**
  41241. * @hidden
  41242. */
  41243. readonly rightPreViewMatrix: Matrix;
  41244. /**
  41245. * Get the default VRMetrics based on the most generic setup.
  41246. * @returns the default vr metrics
  41247. */
  41248. static GetDefault(): VRCameraMetrics;
  41249. }
  41250. }
  41251. declare module BABYLON {
  41252. /** @hidden */
  41253. export var vrDistortionCorrectionPixelShader: {
  41254. name: string;
  41255. shader: string;
  41256. };
  41257. }
  41258. declare module BABYLON {
  41259. /**
  41260. * VRDistortionCorrectionPostProcess used for mobile VR
  41261. */
  41262. export class VRDistortionCorrectionPostProcess extends PostProcess {
  41263. private _isRightEye;
  41264. private _distortionFactors;
  41265. private _postProcessScaleFactor;
  41266. private _lensCenterOffset;
  41267. private _scaleIn;
  41268. private _scaleFactor;
  41269. private _lensCenter;
  41270. /**
  41271. * Initializes the VRDistortionCorrectionPostProcess
  41272. * @param name The name of the effect.
  41273. * @param camera The camera to apply the render pass to.
  41274. * @param isRightEye If this is for the right eye distortion
  41275. * @param vrMetrics All the required metrics for the VR camera
  41276. */
  41277. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  41278. }
  41279. }
  41280. declare module BABYLON {
  41281. /**
  41282. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  41283. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41284. */
  41285. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  41286. /**
  41287. * Creates a new VRDeviceOrientationArcRotateCamera
  41288. * @param name defines camera name
  41289. * @param alpha defines the camera rotation along the logitudinal axis
  41290. * @param beta defines the camera rotation along the latitudinal axis
  41291. * @param radius defines the camera distance from its target
  41292. * @param target defines the camera target
  41293. * @param scene defines the scene the camera belongs to
  41294. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41295. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41296. */
  41297. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41298. /**
  41299. * Gets camera class name
  41300. * @returns VRDeviceOrientationArcRotateCamera
  41301. */
  41302. getClassName(): string;
  41303. }
  41304. }
  41305. declare module BABYLON {
  41306. /**
  41307. * Camera used to simulate VR rendering (based on FreeCamera)
  41308. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41309. */
  41310. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  41311. /**
  41312. * Creates a new VRDeviceOrientationFreeCamera
  41313. * @param name defines camera name
  41314. * @param position defines the start position of the camera
  41315. * @param scene defines the scene the camera belongs to
  41316. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41317. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41318. */
  41319. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41320. /**
  41321. * Gets camera class name
  41322. * @returns VRDeviceOrientationFreeCamera
  41323. */
  41324. getClassName(): string;
  41325. }
  41326. }
  41327. declare module BABYLON {
  41328. /**
  41329. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  41330. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41331. */
  41332. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  41333. /**
  41334. * Creates a new VRDeviceOrientationGamepadCamera
  41335. * @param name defines camera name
  41336. * @param position defines the start position of the camera
  41337. * @param scene defines the scene the camera belongs to
  41338. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41339. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41340. */
  41341. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41342. /**
  41343. * Gets camera class name
  41344. * @returns VRDeviceOrientationGamepadCamera
  41345. */
  41346. getClassName(): string;
  41347. }
  41348. }
  41349. declare module BABYLON {
  41350. /** @hidden */
  41351. export var imageProcessingPixelShader: {
  41352. name: string;
  41353. shader: string;
  41354. };
  41355. }
  41356. declare module BABYLON {
  41357. /**
  41358. * ImageProcessingPostProcess
  41359. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  41360. */
  41361. export class ImageProcessingPostProcess extends PostProcess {
  41362. /**
  41363. * Default configuration related to image processing available in the PBR Material.
  41364. */
  41365. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41366. /**
  41367. * Gets the image processing configuration used either in this material.
  41368. */
  41369. /**
  41370. * Sets the Default image processing configuration used either in the this material.
  41371. *
  41372. * If sets to null, the scene one is in use.
  41373. */
  41374. imageProcessingConfiguration: ImageProcessingConfiguration;
  41375. /**
  41376. * Keep track of the image processing observer to allow dispose and replace.
  41377. */
  41378. private _imageProcessingObserver;
  41379. /**
  41380. * Attaches a new image processing configuration to the PBR Material.
  41381. * @param configuration
  41382. */
  41383. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  41384. /**
  41385. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41386. */
  41387. /**
  41388. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41389. */
  41390. colorCurves: Nullable<ColorCurves>;
  41391. /**
  41392. * Gets wether the color curves effect is enabled.
  41393. */
  41394. /**
  41395. * Sets wether the color curves effect is enabled.
  41396. */
  41397. colorCurvesEnabled: boolean;
  41398. /**
  41399. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41400. */
  41401. /**
  41402. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41403. */
  41404. colorGradingTexture: Nullable<BaseTexture>;
  41405. /**
  41406. * Gets wether the color grading effect is enabled.
  41407. */
  41408. /**
  41409. * Gets wether the color grading effect is enabled.
  41410. */
  41411. colorGradingEnabled: boolean;
  41412. /**
  41413. * Gets exposure used in the effect.
  41414. */
  41415. /**
  41416. * Sets exposure used in the effect.
  41417. */
  41418. exposure: number;
  41419. /**
  41420. * Gets wether tonemapping is enabled or not.
  41421. */
  41422. /**
  41423. * Sets wether tonemapping is enabled or not
  41424. */
  41425. toneMappingEnabled: boolean;
  41426. /**
  41427. * Gets the type of tone mapping effect.
  41428. */
  41429. /**
  41430. * Sets the type of tone mapping effect.
  41431. */
  41432. toneMappingType: number;
  41433. /**
  41434. * Gets contrast used in the effect.
  41435. */
  41436. /**
  41437. * Sets contrast used in the effect.
  41438. */
  41439. contrast: number;
  41440. /**
  41441. * Gets Vignette stretch size.
  41442. */
  41443. /**
  41444. * Sets Vignette stretch size.
  41445. */
  41446. vignetteStretch: number;
  41447. /**
  41448. * Gets Vignette centre X Offset.
  41449. */
  41450. /**
  41451. * Sets Vignette centre X Offset.
  41452. */
  41453. vignetteCentreX: number;
  41454. /**
  41455. * Gets Vignette centre Y Offset.
  41456. */
  41457. /**
  41458. * Sets Vignette centre Y Offset.
  41459. */
  41460. vignetteCentreY: number;
  41461. /**
  41462. * Gets Vignette weight or intensity of the vignette effect.
  41463. */
  41464. /**
  41465. * Sets Vignette weight or intensity of the vignette effect.
  41466. */
  41467. vignetteWeight: number;
  41468. /**
  41469. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41470. * if vignetteEnabled is set to true.
  41471. */
  41472. /**
  41473. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41474. * if vignetteEnabled is set to true.
  41475. */
  41476. vignetteColor: Color4;
  41477. /**
  41478. * Gets Camera field of view used by the Vignette effect.
  41479. */
  41480. /**
  41481. * Sets Camera field of view used by the Vignette effect.
  41482. */
  41483. vignetteCameraFov: number;
  41484. /**
  41485. * Gets the vignette blend mode allowing different kind of effect.
  41486. */
  41487. /**
  41488. * Sets the vignette blend mode allowing different kind of effect.
  41489. */
  41490. vignetteBlendMode: number;
  41491. /**
  41492. * Gets wether the vignette effect is enabled.
  41493. */
  41494. /**
  41495. * Sets wether the vignette effect is enabled.
  41496. */
  41497. vignetteEnabled: boolean;
  41498. private _fromLinearSpace;
  41499. /**
  41500. * Gets wether the input of the processing is in Gamma or Linear Space.
  41501. */
  41502. /**
  41503. * Sets wether the input of the processing is in Gamma or Linear Space.
  41504. */
  41505. fromLinearSpace: boolean;
  41506. /**
  41507. * Defines cache preventing GC.
  41508. */
  41509. private _defines;
  41510. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  41511. /**
  41512. * "ImageProcessingPostProcess"
  41513. * @returns "ImageProcessingPostProcess"
  41514. */
  41515. getClassName(): string;
  41516. protected _updateParameters(): void;
  41517. dispose(camera?: Camera): void;
  41518. }
  41519. }
  41520. declare module BABYLON {
  41521. /**
  41522. * Class containing static functions to help procedurally build meshes
  41523. */
  41524. export class GroundBuilder {
  41525. /**
  41526. * Creates a ground mesh
  41527. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  41528. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  41529. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41530. * @param name defines the name of the mesh
  41531. * @param options defines the options used to create the mesh
  41532. * @param scene defines the hosting scene
  41533. * @returns the ground mesh
  41534. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  41535. */
  41536. static CreateGround(name: string, options: {
  41537. width?: number;
  41538. height?: number;
  41539. subdivisions?: number;
  41540. subdivisionsX?: number;
  41541. subdivisionsY?: number;
  41542. updatable?: boolean;
  41543. }, scene: any): Mesh;
  41544. /**
  41545. * Creates a tiled ground mesh
  41546. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  41547. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  41548. * * 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
  41549. * * 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
  41550. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41551. * @param name defines the name of the mesh
  41552. * @param options defines the options used to create the mesh
  41553. * @param scene defines the hosting scene
  41554. * @returns the tiled ground mesh
  41555. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  41556. */
  41557. static CreateTiledGround(name: string, options: {
  41558. xmin: number;
  41559. zmin: number;
  41560. xmax: number;
  41561. zmax: number;
  41562. subdivisions?: {
  41563. w: number;
  41564. h: number;
  41565. };
  41566. precision?: {
  41567. w: number;
  41568. h: number;
  41569. };
  41570. updatable?: boolean;
  41571. }, scene?: Nullable<Scene>): Mesh;
  41572. /**
  41573. * Creates a ground mesh from a height map
  41574. * * The parameter `url` sets the URL of the height map image resource.
  41575. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  41576. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  41577. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  41578. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  41579. * * 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.
  41580. * * 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).
  41581. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  41582. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41583. * @param name defines the name of the mesh
  41584. * @param url defines the url to the height map
  41585. * @param options defines the options used to create the mesh
  41586. * @param scene defines the hosting scene
  41587. * @returns the ground mesh
  41588. * @see https://doc.babylonjs.com/babylon101/height_map
  41589. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  41590. */
  41591. static CreateGroundFromHeightMap(name: string, url: string, options: {
  41592. width?: number;
  41593. height?: number;
  41594. subdivisions?: number;
  41595. minHeight?: number;
  41596. maxHeight?: number;
  41597. colorFilter?: Color3;
  41598. alphaFilter?: number;
  41599. updatable?: boolean;
  41600. onReady?: (mesh: GroundMesh) => void;
  41601. }, scene?: Nullable<Scene>): GroundMesh;
  41602. }
  41603. }
  41604. declare module BABYLON {
  41605. /**
  41606. * Class containing static functions to help procedurally build meshes
  41607. */
  41608. export class TorusBuilder {
  41609. /**
  41610. * Creates a torus mesh
  41611. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  41612. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  41613. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  41614. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41615. * * 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
  41616. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41617. * @param name defines the name of the mesh
  41618. * @param options defines the options used to create the mesh
  41619. * @param scene defines the hosting scene
  41620. * @returns the torus mesh
  41621. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  41622. */
  41623. static CreateTorus(name: string, options: {
  41624. diameter?: number;
  41625. thickness?: number;
  41626. tessellation?: number;
  41627. updatable?: boolean;
  41628. sideOrientation?: number;
  41629. frontUVs?: Vector4;
  41630. backUVs?: Vector4;
  41631. }, scene: any): Mesh;
  41632. }
  41633. }
  41634. declare module BABYLON {
  41635. /**
  41636. * Class containing static functions to help procedurally build meshes
  41637. */
  41638. export class CylinderBuilder {
  41639. /**
  41640. * Creates a cylinder or a cone mesh
  41641. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  41642. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  41643. * * 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.
  41644. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  41645. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  41646. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  41647. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  41648. * * 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).
  41649. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  41650. * * 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).
  41651. * * 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
  41652. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  41653. * * 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
  41654. * * 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.
  41655. * * If `enclose` is false, a ring surface is one element.
  41656. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  41657. * * 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
  41658. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41659. * * 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
  41660. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41661. * @param name defines the name of the mesh
  41662. * @param options defines the options used to create the mesh
  41663. * @param scene defines the hosting scene
  41664. * @returns the cylinder mesh
  41665. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  41666. */
  41667. static CreateCylinder(name: string, options: {
  41668. height?: number;
  41669. diameterTop?: number;
  41670. diameterBottom?: number;
  41671. diameter?: number;
  41672. tessellation?: number;
  41673. subdivisions?: number;
  41674. arc?: number;
  41675. faceColors?: Color4[];
  41676. faceUV?: Vector4[];
  41677. updatable?: boolean;
  41678. hasRings?: boolean;
  41679. enclose?: boolean;
  41680. cap?: number;
  41681. sideOrientation?: number;
  41682. frontUVs?: Vector4;
  41683. backUVs?: Vector4;
  41684. }, scene: any): Mesh;
  41685. }
  41686. }
  41687. declare module BABYLON {
  41688. /**
  41689. * States of the webXR experience
  41690. */
  41691. export enum WebXRState {
  41692. /**
  41693. * Transitioning to being in XR mode
  41694. */
  41695. ENTERING_XR = 0,
  41696. /**
  41697. * Transitioning to non XR mode
  41698. */
  41699. EXITING_XR = 1,
  41700. /**
  41701. * In XR mode and presenting
  41702. */
  41703. IN_XR = 2,
  41704. /**
  41705. * Not entered XR mode
  41706. */
  41707. NOT_IN_XR = 3
  41708. }
  41709. /**
  41710. * Abstraction of the XR render target
  41711. */
  41712. export interface WebXRRenderTarget extends IDisposable {
  41713. /**
  41714. * xrpresent context of the canvas which can be used to display/mirror xr content
  41715. */
  41716. canvasContext: WebGLRenderingContext;
  41717. /**
  41718. * xr layer for the canvas
  41719. */
  41720. xrLayer: Nullable<XRWebGLLayer>;
  41721. /**
  41722. * Initializes the xr layer for the session
  41723. * @param xrSession xr session
  41724. * @returns a promise that will resolve once the XR Layer has been created
  41725. */
  41726. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  41727. }
  41728. }
  41729. declare module BABYLON {
  41730. /**
  41731. * COnfiguration object for WebXR output canvas
  41732. */
  41733. export class WebXRManagedOutputCanvasOptions {
  41734. /**
  41735. * Options for this XR Layer output
  41736. */
  41737. canvasOptions: XRWebGLLayerOptions;
  41738. /**
  41739. * CSS styling for a newly created canvas (if not provided)
  41740. */
  41741. newCanvasCssStyle?: string;
  41742. /**
  41743. * Get the default values of the configuration object
  41744. * @returns default values of this configuration object
  41745. */
  41746. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  41747. }
  41748. /**
  41749. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41750. */
  41751. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  41752. private configuration;
  41753. private _engine;
  41754. private _canvas;
  41755. /**
  41756. * xrpresent context of the canvas which can be used to display/mirror xr content
  41757. */
  41758. canvasContext: WebGLRenderingContext;
  41759. /**
  41760. * xr layer for the canvas
  41761. */
  41762. xrLayer: Nullable<XRWebGLLayer>;
  41763. /**
  41764. * Initializes the xr layer for the session
  41765. * @param xrSession xr session
  41766. * @returns a promise that will resolve once the XR Layer has been created
  41767. */
  41768. initializeXRLayerAsync(xrSession: any): any;
  41769. /**
  41770. * Initializes the canvas to be added/removed upon entering/exiting xr
  41771. * @param engine the Babylon engine
  41772. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41773. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  41774. * @param configuration optional configuration for this canvas output. defaults will be used if not provided
  41775. */
  41776. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>, configuration?: WebXRManagedOutputCanvasOptions);
  41777. /**
  41778. * Disposes of the object
  41779. */
  41780. dispose(): void;
  41781. private _setManagedOutputCanvas;
  41782. private _addCanvas;
  41783. private _removeCanvas;
  41784. }
  41785. }
  41786. declare module BABYLON {
  41787. /**
  41788. * Manages an XRSession to work with Babylon's engine
  41789. * @see https://doc.babylonjs.com/how_to/webxr
  41790. */
  41791. export class WebXRSessionManager implements IDisposable {
  41792. private scene;
  41793. /**
  41794. * Fires every time a new xrFrame arrives which can be used to update the camera
  41795. */
  41796. onXRFrameObservable: Observable<any>;
  41797. /**
  41798. * Fires when the xr session is ended either by the device or manually done
  41799. */
  41800. onXRSessionEnded: Observable<any>;
  41801. /**
  41802. * Underlying xr session
  41803. */
  41804. session: XRSession;
  41805. /**
  41806. * Type of reference space used when creating the session
  41807. */
  41808. referenceSpace: XRReferenceSpace;
  41809. /**
  41810. * Current XR frame
  41811. */
  41812. currentFrame: Nullable<XRFrame>;
  41813. private _xrNavigator;
  41814. private baseLayer;
  41815. private _rttProvider;
  41816. private _sessionEnded;
  41817. /**
  41818. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  41819. * @param scene The scene which the session should be created for
  41820. */
  41821. constructor(scene: Scene);
  41822. /**
  41823. * Initializes the manager
  41824. * After initialization enterXR can be called to start an XR session
  41825. * @returns Promise which resolves after it is initialized
  41826. */
  41827. initializeAsync(): Promise<void>;
  41828. /**
  41829. * Initializes an xr session
  41830. * @param xrSessionMode mode to initialize
  41831. * @param optionalFeatures defines optional values to pass to the session builder
  41832. * @returns a promise which will resolve once the session has been initialized
  41833. */
  41834. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): Promise<XRSession>;
  41835. /**
  41836. * Sets the reference space on the xr session
  41837. * @param referenceSpace space to set
  41838. * @returns a promise that will resolve once the reference space has been set
  41839. */
  41840. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  41841. /**
  41842. * Updates the render state of the session
  41843. * @param state state to set
  41844. * @returns a promise that resolves once the render state has been updated
  41845. */
  41846. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  41847. /**
  41848. * Starts rendering to the xr layer
  41849. * @returns a promise that will resolve once rendering has started
  41850. */
  41851. startRenderingToXRAsync(): Promise<void>;
  41852. /**
  41853. * Gets the correct render target texture to be rendered this frame for this eye
  41854. * @param eye the eye for which to get the render target
  41855. * @returns the render target for the specified eye
  41856. */
  41857. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  41858. /**
  41859. * Stops the xrSession and restores the renderloop
  41860. * @returns Promise which resolves after it exits XR
  41861. */
  41862. exitXRAsync(): Promise<void>;
  41863. /**
  41864. * Checks if a session would be supported for the creation options specified
  41865. * @param sessionMode session mode to check if supported eg. immersive-vr
  41866. * @returns true if supported
  41867. */
  41868. supportsSessionAsync(sessionMode: XRSessionMode): Promise<boolean>;
  41869. /**
  41870. * Creates a WebXRRenderTarget object for the XR session
  41871. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  41872. * @param options optional options to provide when creating a new render target
  41873. * @returns a WebXR render target to which the session can render
  41874. */
  41875. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>, options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  41876. /**
  41877. * @hidden
  41878. * Converts the render layer of xrSession to a render target
  41879. * @param session session to create render target for
  41880. * @param scene scene the new render target should be created for
  41881. */
  41882. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  41883. /**
  41884. * Disposes of the session manager
  41885. */
  41886. dispose(): void;
  41887. /**
  41888. * Gets a promise returning true when fullfiled if the given session mode is supported
  41889. * @param sessionMode defines the session to test
  41890. * @returns a promise
  41891. */
  41892. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  41893. }
  41894. }
  41895. declare module BABYLON {
  41896. /**
  41897. * WebXR Camera which holds the views for the xrSession
  41898. * @see https://doc.babylonjs.com/how_to/webxr
  41899. */
  41900. export class WebXRCamera extends FreeCamera {
  41901. /**
  41902. * Is the camera in debug mode. Used when using an emulator
  41903. */
  41904. debugMode: boolean;
  41905. /**
  41906. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  41907. * @param name the name of the camera
  41908. * @param scene the scene to add the camera to
  41909. */
  41910. constructor(name: string, scene: Scene);
  41911. private _updateNumberOfRigCameras;
  41912. /** @hidden */
  41913. _updateForDualEyeDebugging(): void;
  41914. /**
  41915. * Updates the cameras position from the current pose information of the XR session
  41916. * @param xrSessionManager the session containing pose information
  41917. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  41918. */
  41919. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  41920. }
  41921. }
  41922. declare module BABYLON {
  41923. /**
  41924. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  41925. * @see https://doc.babylonjs.com/how_to/webxr
  41926. */
  41927. export class WebXRExperienceHelper implements IDisposable {
  41928. private scene;
  41929. /**
  41930. * 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
  41931. */
  41932. container: AbstractMesh;
  41933. /**
  41934. * Camera used to render xr content
  41935. */
  41936. camera: WebXRCamera;
  41937. /**
  41938. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  41939. */
  41940. state: WebXRState;
  41941. private _setState;
  41942. private static _TmpVector;
  41943. /**
  41944. * Fires when the state of the experience helper has changed
  41945. */
  41946. onStateChangedObservable: Observable<WebXRState>;
  41947. /** Session manager used to keep track of xr session */
  41948. sessionManager: WebXRSessionManager;
  41949. private _nonVRCamera;
  41950. private _originalSceneAutoClear;
  41951. private _supported;
  41952. /**
  41953. * Creates the experience helper
  41954. * @param scene the scene to attach the experience helper to
  41955. * @returns a promise for the experience helper
  41956. */
  41957. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  41958. /**
  41959. * Creates a WebXRExperienceHelper
  41960. * @param scene The scene the helper should be created in
  41961. */
  41962. private constructor();
  41963. /**
  41964. * Exits XR mode and returns the scene to its original state
  41965. * @returns promise that resolves after xr mode has exited
  41966. */
  41967. exitXRAsync(): Promise<void>;
  41968. /**
  41969. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  41970. * @param sessionMode options for the XR session
  41971. * @param referenceSpaceType frame of reference of the XR session
  41972. * @param renderTarget the output canvas that will be used to enter XR mode
  41973. * @returns promise that resolves after xr mode has entered
  41974. */
  41975. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): Promise<WebXRSessionManager>;
  41976. /**
  41977. * Updates the global position of the camera by moving the camera's container
  41978. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  41979. * @param position The desired global position of the camera
  41980. */
  41981. setPositionOfCameraUsingContainer(position: Vector3): void;
  41982. /**
  41983. * Rotates the xr camera by rotating the camera's container around the camera's position
  41984. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  41985. * @param rotation the desired quaternion rotation to apply to the camera
  41986. */
  41987. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  41988. /**
  41989. * Disposes of the experience helper
  41990. */
  41991. dispose(): void;
  41992. }
  41993. }
  41994. declare module BABYLON {
  41995. /**
  41996. * Represents an XR input
  41997. */
  41998. export class WebXRController {
  41999. private scene;
  42000. /** The underlying input source for the controller */
  42001. inputSource: XRInputSource;
  42002. private parentContainer;
  42003. /**
  42004. * 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
  42005. */
  42006. grip?: AbstractMesh;
  42007. /**
  42008. * Pointer which can be used to select objects or attach a visible laser to
  42009. */
  42010. pointer: AbstractMesh;
  42011. private _gamepadMode;
  42012. /**
  42013. * If available, this is the gamepad object related to this controller.
  42014. * Using this object it is possible to get click events and trackpad changes of the
  42015. * webxr controller that is currently being used.
  42016. */
  42017. gamepadController?: WebVRController;
  42018. /**
  42019. * Event that fires when the controller is removed/disposed
  42020. */
  42021. onDisposeObservable: Observable<{}>;
  42022. private _tmpQuaternion;
  42023. private _tmpVector;
  42024. /**
  42025. * Creates the controller
  42026. * @see https://doc.babylonjs.com/how_to/webxr
  42027. * @param scene the scene which the controller should be associated to
  42028. * @param inputSource the underlying input source for the controller
  42029. * @param parentContainer parent that the controller meshes should be children of
  42030. */
  42031. constructor(scene: Scene,
  42032. /** The underlying input source for the controller */
  42033. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  42034. /**
  42035. * Updates the controller pose based on the given XRFrame
  42036. * @param xrFrame xr frame to update the pose with
  42037. * @param referenceSpace reference space to use
  42038. */
  42039. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  42040. /**
  42041. * Gets a world space ray coming from the controller
  42042. * @param result the resulting ray
  42043. */
  42044. getWorldPointerRayToRef(result: Ray): void;
  42045. /**
  42046. * Get the scene associated with this controller
  42047. * @returns the scene object
  42048. */
  42049. getScene(): Scene;
  42050. /**
  42051. * Disposes of the object
  42052. */
  42053. dispose(): void;
  42054. }
  42055. }
  42056. declare module BABYLON {
  42057. /**
  42058. * XR input used to track XR inputs such as controllers/rays
  42059. */
  42060. export class WebXRInput implements IDisposable {
  42061. /**
  42062. * Base experience the input listens to
  42063. */
  42064. baseExperience: WebXRExperienceHelper;
  42065. /**
  42066. * XR controllers being tracked
  42067. */
  42068. controllers: Array<WebXRController>;
  42069. private _frameObserver;
  42070. private _stateObserver;
  42071. /**
  42072. * Event when a controller has been connected/added
  42073. */
  42074. onControllerAddedObservable: Observable<WebXRController>;
  42075. /**
  42076. * Event when a controller has been removed/disconnected
  42077. */
  42078. onControllerRemovedObservable: Observable<WebXRController>;
  42079. /**
  42080. * Initializes the WebXRInput
  42081. * @param baseExperience experience helper which the input should be created for
  42082. */
  42083. constructor(
  42084. /**
  42085. * Base experience the input listens to
  42086. */
  42087. baseExperience: WebXRExperienceHelper);
  42088. private _onInputSourcesChange;
  42089. private _addAndRemoveControllers;
  42090. /**
  42091. * Disposes of the object
  42092. */
  42093. dispose(): void;
  42094. }
  42095. }
  42096. declare module BABYLON {
  42097. /**
  42098. * Class used to represent data loading progression
  42099. */
  42100. export class SceneLoaderProgressEvent {
  42101. /** defines if data length to load can be evaluated */
  42102. readonly lengthComputable: boolean;
  42103. /** defines the loaded data length */
  42104. readonly loaded: number;
  42105. /** defines the data length to load */
  42106. readonly total: number;
  42107. /**
  42108. * Create a new progress event
  42109. * @param lengthComputable defines if data length to load can be evaluated
  42110. * @param loaded defines the loaded data length
  42111. * @param total defines the data length to load
  42112. */
  42113. constructor(
  42114. /** defines if data length to load can be evaluated */
  42115. lengthComputable: boolean,
  42116. /** defines the loaded data length */
  42117. loaded: number,
  42118. /** defines the data length to load */
  42119. total: number);
  42120. /**
  42121. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  42122. * @param event defines the source event
  42123. * @returns a new SceneLoaderProgressEvent
  42124. */
  42125. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  42126. }
  42127. /**
  42128. * Interface used by SceneLoader plugins to define supported file extensions
  42129. */
  42130. export interface ISceneLoaderPluginExtensions {
  42131. /**
  42132. * Defines the list of supported extensions
  42133. */
  42134. [extension: string]: {
  42135. isBinary: boolean;
  42136. };
  42137. }
  42138. /**
  42139. * Interface used by SceneLoader plugin factory
  42140. */
  42141. export interface ISceneLoaderPluginFactory {
  42142. /**
  42143. * Defines the name of the factory
  42144. */
  42145. name: string;
  42146. /**
  42147. * Function called to create a new plugin
  42148. * @return the new plugin
  42149. */
  42150. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  42151. /**
  42152. * The callback that returns true if the data can be directly loaded.
  42153. * @param data string containing the file data
  42154. * @returns if the data can be loaded directly
  42155. */
  42156. canDirectLoad?(data: string): boolean;
  42157. }
  42158. /**
  42159. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  42160. */
  42161. export interface ISceneLoaderPluginBase {
  42162. /**
  42163. * The friendly name of this plugin.
  42164. */
  42165. name: string;
  42166. /**
  42167. * The file extensions supported by this plugin.
  42168. */
  42169. extensions: string | ISceneLoaderPluginExtensions;
  42170. /**
  42171. * The callback called when loading from a url.
  42172. * @param scene scene loading this url
  42173. * @param url url to load
  42174. * @param onSuccess callback called when the file successfully loads
  42175. * @param onProgress callback called while file is loading (if the server supports this mode)
  42176. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  42177. * @param onError callback called when the file fails to load
  42178. * @returns a file request object
  42179. */
  42180. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  42181. /**
  42182. * The callback called when loading from a file object.
  42183. * @param scene scene loading this file
  42184. * @param file defines the file to load
  42185. * @param onSuccess defines the callback to call when data is loaded
  42186. * @param onProgress defines the callback to call during loading process
  42187. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  42188. * @param onError defines the callback to call when an error occurs
  42189. * @returns a file request object
  42190. */
  42191. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  42192. /**
  42193. * The callback that returns true if the data can be directly loaded.
  42194. * @param data string containing the file data
  42195. * @returns if the data can be loaded directly
  42196. */
  42197. canDirectLoad?(data: string): boolean;
  42198. /**
  42199. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  42200. * @param scene scene loading this data
  42201. * @param data string containing the data
  42202. * @returns data to pass to the plugin
  42203. */
  42204. directLoad?(scene: Scene, data: string): any;
  42205. /**
  42206. * The callback that allows custom handling of the root url based on the response url.
  42207. * @param rootUrl the original root url
  42208. * @param responseURL the response url if available
  42209. * @returns the new root url
  42210. */
  42211. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  42212. }
  42213. /**
  42214. * Interface used to define a SceneLoader plugin
  42215. */
  42216. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  42217. /**
  42218. * Import meshes into a scene.
  42219. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42220. * @param scene The scene to import into
  42221. * @param data The data to import
  42222. * @param rootUrl The root url for scene and resources
  42223. * @param meshes The meshes array to import into
  42224. * @param particleSystems The particle systems array to import into
  42225. * @param skeletons The skeletons array to import into
  42226. * @param onError The callback when import fails
  42227. * @returns True if successful or false otherwise
  42228. */
  42229. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  42230. /**
  42231. * Load into a scene.
  42232. * @param scene The scene to load into
  42233. * @param data The data to import
  42234. * @param rootUrl The root url for scene and resources
  42235. * @param onError The callback when import fails
  42236. * @returns True if successful or false otherwise
  42237. */
  42238. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  42239. /**
  42240. * Load into an asset container.
  42241. * @param scene The scene to load into
  42242. * @param data The data to import
  42243. * @param rootUrl The root url for scene and resources
  42244. * @param onError The callback when import fails
  42245. * @returns The loaded asset container
  42246. */
  42247. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  42248. }
  42249. /**
  42250. * Interface used to define an async SceneLoader plugin
  42251. */
  42252. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  42253. /**
  42254. * Import meshes into a scene.
  42255. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42256. * @param scene The scene to import into
  42257. * @param data The data to import
  42258. * @param rootUrl The root url for scene and resources
  42259. * @param onProgress The callback when the load progresses
  42260. * @param fileName Defines the name of the file to load
  42261. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  42262. */
  42263. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  42264. meshes: AbstractMesh[];
  42265. particleSystems: IParticleSystem[];
  42266. skeletons: Skeleton[];
  42267. animationGroups: AnimationGroup[];
  42268. }>;
  42269. /**
  42270. * Load into a scene.
  42271. * @param scene The scene to load into
  42272. * @param data The data to import
  42273. * @param rootUrl The root url for scene and resources
  42274. * @param onProgress The callback when the load progresses
  42275. * @param fileName Defines the name of the file to load
  42276. * @returns Nothing
  42277. */
  42278. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  42279. /**
  42280. * Load into an asset container.
  42281. * @param scene The scene to load into
  42282. * @param data The data to import
  42283. * @param rootUrl The root url for scene and resources
  42284. * @param onProgress The callback when the load progresses
  42285. * @param fileName Defines the name of the file to load
  42286. * @returns The loaded asset container
  42287. */
  42288. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  42289. }
  42290. /**
  42291. * Class used to load scene from various file formats using registered plugins
  42292. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  42293. */
  42294. export class SceneLoader {
  42295. /**
  42296. * No logging while loading
  42297. */
  42298. static readonly NO_LOGGING: number;
  42299. /**
  42300. * Minimal logging while loading
  42301. */
  42302. static readonly MINIMAL_LOGGING: number;
  42303. /**
  42304. * Summary logging while loading
  42305. */
  42306. static readonly SUMMARY_LOGGING: number;
  42307. /**
  42308. * Detailled logging while loading
  42309. */
  42310. static readonly DETAILED_LOGGING: number;
  42311. /**
  42312. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  42313. */
  42314. static ForceFullSceneLoadingForIncremental: boolean;
  42315. /**
  42316. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  42317. */
  42318. static ShowLoadingScreen: boolean;
  42319. /**
  42320. * Defines the current logging level (while loading the scene)
  42321. * @ignorenaming
  42322. */
  42323. static loggingLevel: number;
  42324. /**
  42325. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  42326. */
  42327. static CleanBoneMatrixWeights: boolean;
  42328. /**
  42329. * Event raised when a plugin is used to load a scene
  42330. */
  42331. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42332. private static _registeredPlugins;
  42333. private static _getDefaultPlugin;
  42334. private static _getPluginForExtension;
  42335. private static _getPluginForDirectLoad;
  42336. private static _getPluginForFilename;
  42337. private static _getDirectLoad;
  42338. private static _loadData;
  42339. private static _getFileInfo;
  42340. /**
  42341. * Gets a plugin that can load the given extension
  42342. * @param extension defines the extension to load
  42343. * @returns a plugin or null if none works
  42344. */
  42345. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  42346. /**
  42347. * Gets a boolean indicating that the given extension can be loaded
  42348. * @param extension defines the extension to load
  42349. * @returns true if the extension is supported
  42350. */
  42351. static IsPluginForExtensionAvailable(extension: string): boolean;
  42352. /**
  42353. * Adds a new plugin to the list of registered plugins
  42354. * @param plugin defines the plugin to add
  42355. */
  42356. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  42357. /**
  42358. * Import meshes into a scene
  42359. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42360. * @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)
  42361. * @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)
  42362. * @param scene the instance of BABYLON.Scene to append to
  42363. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  42364. * @param onProgress a callback with a progress event for each file being loaded
  42365. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42366. * @param pluginExtension the extension used to determine the plugin
  42367. * @returns The loaded plugin
  42368. */
  42369. 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>;
  42370. /**
  42371. * Import meshes into a scene
  42372. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42373. * @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)
  42374. * @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)
  42375. * @param scene the instance of BABYLON.Scene to append to
  42376. * @param onProgress a callback with a progress event for each file being loaded
  42377. * @param pluginExtension the extension used to determine the plugin
  42378. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  42379. */
  42380. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  42381. meshes: AbstractMesh[];
  42382. particleSystems: IParticleSystem[];
  42383. skeletons: Skeleton[];
  42384. animationGroups: AnimationGroup[];
  42385. }>;
  42386. /**
  42387. * Load a scene
  42388. * @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)
  42389. * @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)
  42390. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42391. * @param onSuccess a callback with the scene when import succeeds
  42392. * @param onProgress a callback with a progress event for each file being loaded
  42393. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42394. * @param pluginExtension the extension used to determine the plugin
  42395. * @returns The loaded plugin
  42396. */
  42397. 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>;
  42398. /**
  42399. * Load a scene
  42400. * @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)
  42401. * @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)
  42402. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42403. * @param onProgress a callback with a progress event for each file being loaded
  42404. * @param pluginExtension the extension used to determine the plugin
  42405. * @returns The loaded scene
  42406. */
  42407. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42408. /**
  42409. * Append a scene
  42410. * @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)
  42411. * @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)
  42412. * @param scene is the instance of BABYLON.Scene to append to
  42413. * @param onSuccess a callback with the scene when import succeeds
  42414. * @param onProgress a callback with a progress event for each file being loaded
  42415. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42416. * @param pluginExtension the extension used to determine the plugin
  42417. * @returns The loaded plugin
  42418. */
  42419. 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>;
  42420. /**
  42421. * Append a scene
  42422. * @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)
  42423. * @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)
  42424. * @param scene is the instance of BABYLON.Scene to append to
  42425. * @param onProgress a callback with a progress event for each file being loaded
  42426. * @param pluginExtension the extension used to determine the plugin
  42427. * @returns The given scene
  42428. */
  42429. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42430. /**
  42431. * Load a scene into an asset container
  42432. * @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)
  42433. * @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)
  42434. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42435. * @param onSuccess a callback with the scene when import succeeds
  42436. * @param onProgress a callback with a progress event for each file being loaded
  42437. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42438. * @param pluginExtension the extension used to determine the plugin
  42439. * @returns The loaded plugin
  42440. */
  42441. 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>;
  42442. /**
  42443. * Load a scene into an asset container
  42444. * @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)
  42445. * @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)
  42446. * @param scene is the instance of Scene to append to
  42447. * @param onProgress a callback with a progress event for each file being loaded
  42448. * @param pluginExtension the extension used to determine the plugin
  42449. * @returns The loaded asset container
  42450. */
  42451. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  42452. }
  42453. }
  42454. declare module BABYLON {
  42455. /**
  42456. * Generic Controller
  42457. */
  42458. export class GenericController extends WebVRController {
  42459. /**
  42460. * Base Url for the controller model.
  42461. */
  42462. static readonly MODEL_BASE_URL: string;
  42463. /**
  42464. * File name for the controller model.
  42465. */
  42466. static readonly MODEL_FILENAME: string;
  42467. /**
  42468. * Creates a new GenericController from a gamepad
  42469. * @param vrGamepad the gamepad that the controller should be created from
  42470. */
  42471. constructor(vrGamepad: any);
  42472. /**
  42473. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42474. * @param scene scene in which to add meshes
  42475. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42476. */
  42477. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42478. /**
  42479. * Called once for each button that changed state since the last frame
  42480. * @param buttonIdx Which button index changed
  42481. * @param state New state of the button
  42482. * @param changes Which properties on the state changed since last frame
  42483. */
  42484. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42485. }
  42486. }
  42487. declare module BABYLON {
  42488. /**
  42489. * Defines the WindowsMotionController object that the state of the windows motion controller
  42490. */
  42491. export class WindowsMotionController extends WebVRController {
  42492. /**
  42493. * The base url used to load the left and right controller models
  42494. */
  42495. static MODEL_BASE_URL: string;
  42496. /**
  42497. * The name of the left controller model file
  42498. */
  42499. static MODEL_LEFT_FILENAME: string;
  42500. /**
  42501. * The name of the right controller model file
  42502. */
  42503. static MODEL_RIGHT_FILENAME: string;
  42504. /**
  42505. * The controller name prefix for this controller type
  42506. */
  42507. static readonly GAMEPAD_ID_PREFIX: string;
  42508. /**
  42509. * The controller id pattern for this controller type
  42510. */
  42511. private static readonly GAMEPAD_ID_PATTERN;
  42512. private _loadedMeshInfo;
  42513. protected readonly _mapping: {
  42514. buttons: string[];
  42515. buttonMeshNames: {
  42516. 'trigger': string;
  42517. 'menu': string;
  42518. 'grip': string;
  42519. 'thumbstick': string;
  42520. 'trackpad': string;
  42521. };
  42522. buttonObservableNames: {
  42523. 'trigger': string;
  42524. 'menu': string;
  42525. 'grip': string;
  42526. 'thumbstick': string;
  42527. 'trackpad': string;
  42528. };
  42529. axisMeshNames: string[];
  42530. pointingPoseMeshName: string;
  42531. };
  42532. /**
  42533. * Fired when the trackpad on this controller is clicked
  42534. */
  42535. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42536. /**
  42537. * Fired when the trackpad on this controller is modified
  42538. */
  42539. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42540. /**
  42541. * The current x and y values of this controller's trackpad
  42542. */
  42543. trackpad: StickValues;
  42544. /**
  42545. * Creates a new WindowsMotionController from a gamepad
  42546. * @param vrGamepad the gamepad that the controller should be created from
  42547. */
  42548. constructor(vrGamepad: any);
  42549. /**
  42550. * Fired when the trigger on this controller is modified
  42551. */
  42552. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42553. /**
  42554. * Fired when the menu button on this controller is modified
  42555. */
  42556. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42557. /**
  42558. * Fired when the grip button on this controller is modified
  42559. */
  42560. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42561. /**
  42562. * Fired when the thumbstick button on this controller is modified
  42563. */
  42564. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42565. /**
  42566. * Fired when the touchpad button on this controller is modified
  42567. */
  42568. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42569. /**
  42570. * Fired when the touchpad values on this controller are modified
  42571. */
  42572. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42573. protected _updateTrackpad(): void;
  42574. /**
  42575. * Called once per frame by the engine.
  42576. */
  42577. update(): void;
  42578. /**
  42579. * Called once for each button that changed state since the last frame
  42580. * @param buttonIdx Which button index changed
  42581. * @param state New state of the button
  42582. * @param changes Which properties on the state changed since last frame
  42583. */
  42584. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42585. /**
  42586. * Moves the buttons on the controller mesh based on their current state
  42587. * @param buttonName the name of the button to move
  42588. * @param buttonValue the value of the button which determines the buttons new position
  42589. */
  42590. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42591. /**
  42592. * Moves the axis on the controller mesh based on its current state
  42593. * @param axis the index of the axis
  42594. * @param axisValue the value of the axis which determines the meshes new position
  42595. * @hidden
  42596. */
  42597. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42598. /**
  42599. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42600. * @param scene scene in which to add meshes
  42601. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42602. */
  42603. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42604. /**
  42605. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42606. * can be transformed by button presses and axes values, based on this._mapping.
  42607. *
  42608. * @param scene scene in which the meshes exist
  42609. * @param meshes list of meshes that make up the controller model to process
  42610. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  42611. */
  42612. private processModel;
  42613. private createMeshInfo;
  42614. /**
  42615. * Gets the ray of the controller in the direction the controller is pointing
  42616. * @param length the length the resulting ray should be
  42617. * @returns a ray in the direction the controller is pointing
  42618. */
  42619. getForwardRay(length?: number): Ray;
  42620. /**
  42621. * Disposes of the controller
  42622. */
  42623. dispose(): void;
  42624. }
  42625. /**
  42626. * This class represents a new windows motion controller in XR.
  42627. */
  42628. export class XRWindowsMotionController extends WindowsMotionController {
  42629. /**
  42630. * Changing the original WIndowsMotionController mapping to fir the new mapping
  42631. */
  42632. protected readonly _mapping: {
  42633. buttons: string[];
  42634. buttonMeshNames: {
  42635. 'trigger': string;
  42636. 'menu': string;
  42637. 'grip': string;
  42638. 'thumbstick': string;
  42639. 'trackpad': string;
  42640. };
  42641. buttonObservableNames: {
  42642. 'trigger': string;
  42643. 'menu': string;
  42644. 'grip': string;
  42645. 'thumbstick': string;
  42646. 'trackpad': string;
  42647. };
  42648. axisMeshNames: string[];
  42649. pointingPoseMeshName: string;
  42650. };
  42651. /**
  42652. * Construct a new XR-Based windows motion controller
  42653. *
  42654. * @param gamepadInfo the gamepad object from the browser
  42655. */
  42656. constructor(gamepadInfo: any);
  42657. /**
  42658. * holds the thumbstick values (X,Y)
  42659. */
  42660. thumbstickValues: StickValues;
  42661. /**
  42662. * Fired when the thumbstick on this controller is clicked
  42663. */
  42664. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  42665. /**
  42666. * Fired when the thumbstick on this controller is modified
  42667. */
  42668. onThumbstickValuesChangedObservable: Observable<StickValues>;
  42669. /**
  42670. * Fired when the touchpad button on this controller is modified
  42671. */
  42672. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42673. /**
  42674. * Fired when the touchpad values on this controller are modified
  42675. */
  42676. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42677. /**
  42678. * Fired when the thumbstick button on this controller is modified
  42679. * here to prevent breaking changes
  42680. */
  42681. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42682. /**
  42683. * updating the thumbstick(!) and not the trackpad.
  42684. * This is named this way due to the difference between WebVR and XR and to avoid
  42685. * changing the parent class.
  42686. */
  42687. protected _updateTrackpad(): void;
  42688. /**
  42689. * Disposes the class with joy
  42690. */
  42691. dispose(): void;
  42692. }
  42693. }
  42694. declare module BABYLON {
  42695. /**
  42696. * Oculus Touch Controller
  42697. */
  42698. export class OculusTouchController extends WebVRController {
  42699. /**
  42700. * Base Url for the controller model.
  42701. */
  42702. static MODEL_BASE_URL: string;
  42703. /**
  42704. * File name for the left controller model.
  42705. */
  42706. static MODEL_LEFT_FILENAME: string;
  42707. /**
  42708. * File name for the right controller model.
  42709. */
  42710. static MODEL_RIGHT_FILENAME: string;
  42711. /**
  42712. * Base Url for the Quest controller model.
  42713. */
  42714. static QUEST_MODEL_BASE_URL: string;
  42715. /**
  42716. * @hidden
  42717. * If the controllers are running on a device that needs the updated Quest controller models
  42718. */
  42719. static _IsQuest: boolean;
  42720. /**
  42721. * Fired when the secondary trigger on this controller is modified
  42722. */
  42723. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42724. /**
  42725. * Fired when the thumb rest on this controller is modified
  42726. */
  42727. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42728. /**
  42729. * Creates a new OculusTouchController from a gamepad
  42730. * @param vrGamepad the gamepad that the controller should be created from
  42731. */
  42732. constructor(vrGamepad: any);
  42733. /**
  42734. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42735. * @param scene scene in which to add meshes
  42736. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42737. */
  42738. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42739. /**
  42740. * Fired when the A button on this controller is modified
  42741. */
  42742. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42743. /**
  42744. * Fired when the B button on this controller is modified
  42745. */
  42746. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42747. /**
  42748. * Fired when the X button on this controller is modified
  42749. */
  42750. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42751. /**
  42752. * Fired when the Y button on this controller is modified
  42753. */
  42754. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42755. /**
  42756. * Called once for each button that changed state since the last frame
  42757. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42758. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42759. * 2) secondary trigger (same)
  42760. * 3) A (right) X (left), touch, pressed = value
  42761. * 4) B / Y
  42762. * 5) thumb rest
  42763. * @param buttonIdx Which button index changed
  42764. * @param state New state of the button
  42765. * @param changes Which properties on the state changed since last frame
  42766. */
  42767. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42768. }
  42769. }
  42770. declare module BABYLON {
  42771. /**
  42772. * Vive Controller
  42773. */
  42774. export class ViveController extends WebVRController {
  42775. /**
  42776. * Base Url for the controller model.
  42777. */
  42778. static MODEL_BASE_URL: string;
  42779. /**
  42780. * File name for the controller model.
  42781. */
  42782. static MODEL_FILENAME: string;
  42783. /**
  42784. * Creates a new ViveController from a gamepad
  42785. * @param vrGamepad the gamepad that the controller should be created from
  42786. */
  42787. constructor(vrGamepad: any);
  42788. /**
  42789. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42790. * @param scene scene in which to add meshes
  42791. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42792. */
  42793. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42794. /**
  42795. * Fired when the left button on this controller is modified
  42796. */
  42797. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42798. /**
  42799. * Fired when the right button on this controller is modified
  42800. */
  42801. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42802. /**
  42803. * Fired when the menu button on this controller is modified
  42804. */
  42805. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42806. /**
  42807. * Called once for each button that changed state since the last frame
  42808. * Vive mapping:
  42809. * 0: touchpad
  42810. * 1: trigger
  42811. * 2: left AND right buttons
  42812. * 3: menu button
  42813. * @param buttonIdx Which button index changed
  42814. * @param state New state of the button
  42815. * @param changes Which properties on the state changed since last frame
  42816. */
  42817. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42818. }
  42819. }
  42820. declare module BABYLON {
  42821. /**
  42822. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  42823. */
  42824. export class WebXRControllerModelLoader {
  42825. /**
  42826. * an observable that triggers when a new model (the mesh itself) was initialized.
  42827. * To know when the mesh was loaded use the controller's own modelLoaded() method
  42828. */
  42829. onControllerModelLoaded: Observable<WebXRController>;
  42830. /**
  42831. * Creates the WebXRControllerModelLoader
  42832. * @param input xr input that creates the controllers
  42833. */
  42834. constructor(input: WebXRInput);
  42835. }
  42836. }
  42837. declare module BABYLON {
  42838. /**
  42839. * Handles pointer input automatically for the pointer of XR controllers
  42840. */
  42841. export class WebXRControllerPointerSelection {
  42842. private static _idCounter;
  42843. private _tmpRay;
  42844. /**
  42845. * Creates a WebXRControllerPointerSelection
  42846. * @param input input manager to setup pointer selection
  42847. */
  42848. constructor(input: WebXRInput);
  42849. private _convertNormalToDirectionOfRay;
  42850. private _updatePointerDistance;
  42851. }
  42852. }
  42853. declare module BABYLON {
  42854. /**
  42855. * Enables teleportation
  42856. */
  42857. export class WebXRControllerTeleportation {
  42858. private _teleportationFillColor;
  42859. private _teleportationBorderColor;
  42860. private _tmpRay;
  42861. private _tmpVector;
  42862. /**
  42863. * Creates a WebXRControllerTeleportation
  42864. * @param input input manager to add teleportation to
  42865. * @param floorMeshes floormeshes which can be teleported to
  42866. */
  42867. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  42868. }
  42869. }
  42870. declare module BABYLON {
  42871. /**
  42872. * Button which can be used to enter a different mode of XR
  42873. */
  42874. export class WebXREnterExitUIButton {
  42875. /** button element */
  42876. element: HTMLElement;
  42877. /** XR initialization options for the button */
  42878. sessionMode: XRSessionMode;
  42879. /** Reference space type */
  42880. referenceSpaceType: XRReferenceSpaceType;
  42881. /**
  42882. * Creates a WebXREnterExitUIButton
  42883. * @param element button element
  42884. * @param sessionMode XR initialization session mode
  42885. * @param referenceSpaceType the type of reference space to be used
  42886. */
  42887. constructor(
  42888. /** button element */
  42889. element: HTMLElement,
  42890. /** XR initialization options for the button */
  42891. sessionMode: XRSessionMode,
  42892. /** Reference space type */
  42893. referenceSpaceType: XRReferenceSpaceType);
  42894. /**
  42895. * Overwritable function which can be used to update the button's visuals when the state changes
  42896. * @param activeButton the current active button in the UI
  42897. */
  42898. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  42899. }
  42900. /**
  42901. * Options to create the webXR UI
  42902. */
  42903. export class WebXREnterExitUIOptions {
  42904. /**
  42905. * Context to enter xr with
  42906. */
  42907. renderTarget?: Nullable<WebXRRenderTarget>;
  42908. /**
  42909. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  42910. */
  42911. customButtons?: Array<WebXREnterExitUIButton>;
  42912. /**
  42913. * A session mode to use when creating the default button.
  42914. * Default is immersive-vr
  42915. */
  42916. sessionMode?: XRSessionMode;
  42917. /**
  42918. * A reference space type to use when creating the default button.
  42919. * Default is local-floor
  42920. */
  42921. referenceSpaceType?: XRReferenceSpaceType;
  42922. }
  42923. /**
  42924. * UI to allow the user to enter/exit XR mode
  42925. */
  42926. export class WebXREnterExitUI implements IDisposable {
  42927. private scene;
  42928. private _overlay;
  42929. private _buttons;
  42930. private _activeButton;
  42931. /**
  42932. * Fired every time the active button is changed.
  42933. *
  42934. * When xr is entered via a button that launches xr that button will be the callback parameter
  42935. *
  42936. * When exiting xr the callback parameter will be null)
  42937. */
  42938. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  42939. /**
  42940. * Creates UI to allow the user to enter/exit XR mode
  42941. * @param scene the scene to add the ui to
  42942. * @param helper the xr experience helper to enter/exit xr with
  42943. * @param options options to configure the UI
  42944. * @returns the created ui
  42945. */
  42946. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  42947. private constructor();
  42948. private _updateButtons;
  42949. /**
  42950. * Disposes of the object
  42951. */
  42952. dispose(): void;
  42953. }
  42954. }
  42955. declare module BABYLON {
  42956. /**
  42957. * Options for the default xr helper
  42958. */
  42959. export class WebXRDefaultExperienceOptions {
  42960. /**
  42961. * Floor meshes that should be used for teleporting
  42962. */
  42963. floorMeshes: Array<AbstractMesh>;
  42964. /**
  42965. * Enable or disable default UI to enter XR
  42966. */
  42967. disableDefaultUI?: boolean;
  42968. /**
  42969. * optional configuration for the output canvas
  42970. */
  42971. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  42972. }
  42973. /**
  42974. * Default experience which provides a similar setup to the previous webVRExperience
  42975. */
  42976. export class WebXRDefaultExperience {
  42977. /**
  42978. * Base experience
  42979. */
  42980. baseExperience: WebXRExperienceHelper;
  42981. /**
  42982. * Input experience extension
  42983. */
  42984. input: WebXRInput;
  42985. /**
  42986. * Loads the controller models
  42987. */
  42988. controllerModelLoader: WebXRControllerModelLoader;
  42989. /**
  42990. * Enables laser pointer and selection
  42991. */
  42992. pointerSelection: WebXRControllerPointerSelection;
  42993. /**
  42994. * Enables teleportation
  42995. */
  42996. teleportation: WebXRControllerTeleportation;
  42997. /**
  42998. * Enables ui for enetering/exiting xr
  42999. */
  43000. enterExitUI: WebXREnterExitUI;
  43001. /**
  43002. * Default target xr should render to
  43003. */
  43004. renderTarget: WebXRRenderTarget;
  43005. /**
  43006. * Creates the default xr experience
  43007. * @param scene scene
  43008. * @param options options for basic configuration
  43009. * @returns resulting WebXRDefaultExperience
  43010. */
  43011. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  43012. private constructor();
  43013. /**
  43014. * DIsposes of the experience helper
  43015. */
  43016. dispose(): void;
  43017. }
  43018. }
  43019. declare module BABYLON {
  43020. /**
  43021. * Options to modify the vr teleportation behavior.
  43022. */
  43023. export interface VRTeleportationOptions {
  43024. /**
  43025. * The name of the mesh which should be used as the teleportation floor. (default: null)
  43026. */
  43027. floorMeshName?: string;
  43028. /**
  43029. * A list of meshes to be used as the teleportation floor. (default: empty)
  43030. */
  43031. floorMeshes?: Mesh[];
  43032. /**
  43033. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  43034. */
  43035. teleportationMode?: number;
  43036. /**
  43037. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  43038. */
  43039. teleportationTime?: number;
  43040. /**
  43041. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  43042. */
  43043. teleportationSpeed?: number;
  43044. /**
  43045. * The easing function used in the animation or null for Linear. (default CircleEase)
  43046. */
  43047. easingFunction?: EasingFunction;
  43048. }
  43049. /**
  43050. * Options to modify the vr experience helper's behavior.
  43051. */
  43052. export interface VRExperienceHelperOptions extends WebVROptions {
  43053. /**
  43054. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  43055. */
  43056. createDeviceOrientationCamera?: boolean;
  43057. /**
  43058. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  43059. */
  43060. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  43061. /**
  43062. * Uses the main button on the controller to toggle the laser casted. (default: true)
  43063. */
  43064. laserToggle?: boolean;
  43065. /**
  43066. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  43067. */
  43068. floorMeshes?: Mesh[];
  43069. /**
  43070. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  43071. */
  43072. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  43073. /**
  43074. * Defines if WebXR should be used instead of WebVR (if available)
  43075. */
  43076. useXR?: boolean;
  43077. }
  43078. /**
  43079. * Event containing information after VR has been entered
  43080. */
  43081. export class OnAfterEnteringVRObservableEvent {
  43082. /**
  43083. * If entering vr was successful
  43084. */
  43085. success: boolean;
  43086. }
  43087. /**
  43088. * Helps to quickly add VR support to an existing scene.
  43089. * See http://doc.babylonjs.com/how_to/webvr_helper
  43090. */
  43091. export class VRExperienceHelper {
  43092. /** Options to modify the vr experience helper's behavior. */
  43093. webVROptions: VRExperienceHelperOptions;
  43094. private _scene;
  43095. private _position;
  43096. private _btnVR;
  43097. private _btnVRDisplayed;
  43098. private _webVRsupported;
  43099. private _webVRready;
  43100. private _webVRrequesting;
  43101. private _webVRpresenting;
  43102. private _hasEnteredVR;
  43103. private _fullscreenVRpresenting;
  43104. private _inputElement;
  43105. private _webVRCamera;
  43106. private _vrDeviceOrientationCamera;
  43107. private _deviceOrientationCamera;
  43108. private _existingCamera;
  43109. private _onKeyDown;
  43110. private _onVrDisplayPresentChange;
  43111. private _onVRDisplayChanged;
  43112. private _onVRRequestPresentStart;
  43113. private _onVRRequestPresentComplete;
  43114. /**
  43115. * 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)
  43116. */
  43117. enableGazeEvenWhenNoPointerLock: boolean;
  43118. /**
  43119. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  43120. */
  43121. exitVROnDoubleTap: boolean;
  43122. /**
  43123. * Observable raised right before entering VR.
  43124. */
  43125. onEnteringVRObservable: Observable<VRExperienceHelper>;
  43126. /**
  43127. * Observable raised when entering VR has completed.
  43128. */
  43129. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  43130. /**
  43131. * Observable raised when exiting VR.
  43132. */
  43133. onExitingVRObservable: Observable<VRExperienceHelper>;
  43134. /**
  43135. * Observable raised when controller mesh is loaded.
  43136. */
  43137. onControllerMeshLoadedObservable: Observable<WebVRController>;
  43138. /** Return this.onEnteringVRObservable
  43139. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  43140. */
  43141. readonly onEnteringVR: Observable<VRExperienceHelper>;
  43142. /** Return this.onExitingVRObservable
  43143. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  43144. */
  43145. readonly onExitingVR: Observable<VRExperienceHelper>;
  43146. /** Return this.onControllerMeshLoadedObservable
  43147. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  43148. */
  43149. readonly onControllerMeshLoaded: Observable<WebVRController>;
  43150. private _rayLength;
  43151. private _useCustomVRButton;
  43152. private _teleportationRequested;
  43153. private _teleportActive;
  43154. private _floorMeshName;
  43155. private _floorMeshesCollection;
  43156. private _teleportationMode;
  43157. private _teleportationTime;
  43158. private _teleportationSpeed;
  43159. private _teleportationEasing;
  43160. private _rotationAllowed;
  43161. private _teleportBackwardsVector;
  43162. private _teleportationTarget;
  43163. private _isDefaultTeleportationTarget;
  43164. private _postProcessMove;
  43165. private _teleportationFillColor;
  43166. private _teleportationBorderColor;
  43167. private _rotationAngle;
  43168. private _haloCenter;
  43169. private _cameraGazer;
  43170. private _padSensibilityUp;
  43171. private _padSensibilityDown;
  43172. private _leftController;
  43173. private _rightController;
  43174. /**
  43175. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  43176. */
  43177. onNewMeshSelected: Observable<AbstractMesh>;
  43178. /**
  43179. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  43180. * This observable will provide the mesh and the controller used to select the mesh
  43181. */
  43182. onMeshSelectedWithController: Observable<{
  43183. mesh: AbstractMesh;
  43184. controller: WebVRController;
  43185. }>;
  43186. /**
  43187. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  43188. */
  43189. onNewMeshPicked: Observable<PickingInfo>;
  43190. private _circleEase;
  43191. /**
  43192. * Observable raised before camera teleportation
  43193. */
  43194. onBeforeCameraTeleport: Observable<Vector3>;
  43195. /**
  43196. * Observable raised after camera teleportation
  43197. */
  43198. onAfterCameraTeleport: Observable<Vector3>;
  43199. /**
  43200. * Observable raised when current selected mesh gets unselected
  43201. */
  43202. onSelectedMeshUnselected: Observable<AbstractMesh>;
  43203. private _raySelectionPredicate;
  43204. /**
  43205. * To be optionaly changed by user to define custom ray selection
  43206. */
  43207. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  43208. /**
  43209. * To be optionaly changed by user to define custom selection logic (after ray selection)
  43210. */
  43211. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  43212. /**
  43213. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  43214. */
  43215. teleportationEnabled: boolean;
  43216. private _defaultHeight;
  43217. private _teleportationInitialized;
  43218. private _interactionsEnabled;
  43219. private _interactionsRequested;
  43220. private _displayGaze;
  43221. private _displayLaserPointer;
  43222. /**
  43223. * The mesh used to display where the user is going to teleport.
  43224. */
  43225. /**
  43226. * Sets the mesh to be used to display where the user is going to teleport.
  43227. */
  43228. teleportationTarget: Mesh;
  43229. /**
  43230. * 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
  43231. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  43232. * See http://doc.babylonjs.com/resources/baking_transformations
  43233. */
  43234. gazeTrackerMesh: Mesh;
  43235. /**
  43236. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  43237. */
  43238. updateGazeTrackerScale: boolean;
  43239. /**
  43240. * If the gaze trackers color should be updated when selecting meshes
  43241. */
  43242. updateGazeTrackerColor: boolean;
  43243. /**
  43244. * If the controller laser color should be updated when selecting meshes
  43245. */
  43246. updateControllerLaserColor: boolean;
  43247. /**
  43248. * The gaze tracking mesh corresponding to the left controller
  43249. */
  43250. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  43251. /**
  43252. * The gaze tracking mesh corresponding to the right controller
  43253. */
  43254. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  43255. /**
  43256. * If the ray of the gaze should be displayed.
  43257. */
  43258. /**
  43259. * Sets if the ray of the gaze should be displayed.
  43260. */
  43261. displayGaze: boolean;
  43262. /**
  43263. * If the ray of the LaserPointer should be displayed.
  43264. */
  43265. /**
  43266. * Sets if the ray of the LaserPointer should be displayed.
  43267. */
  43268. displayLaserPointer: boolean;
  43269. /**
  43270. * The deviceOrientationCamera used as the camera when not in VR.
  43271. */
  43272. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  43273. /**
  43274. * Based on the current WebVR support, returns the current VR camera used.
  43275. */
  43276. readonly currentVRCamera: Nullable<Camera>;
  43277. /**
  43278. * The webVRCamera which is used when in VR.
  43279. */
  43280. readonly webVRCamera: WebVRFreeCamera;
  43281. /**
  43282. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  43283. */
  43284. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  43285. /**
  43286. * The html button that is used to trigger entering into VR.
  43287. */
  43288. readonly vrButton: Nullable<HTMLButtonElement>;
  43289. private readonly _teleportationRequestInitiated;
  43290. /**
  43291. * Defines wether or not Pointer lock should be requested when switching to
  43292. * full screen.
  43293. */
  43294. requestPointerLockOnFullScreen: boolean;
  43295. /**
  43296. * If asking to force XR, this will be populated with the default xr experience
  43297. */
  43298. xr: WebXRDefaultExperience;
  43299. /**
  43300. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  43301. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  43302. */
  43303. xrTestDone: boolean;
  43304. /**
  43305. * Instantiates a VRExperienceHelper.
  43306. * Helps to quickly add VR support to an existing scene.
  43307. * @param scene The scene the VRExperienceHelper belongs to.
  43308. * @param webVROptions Options to modify the vr experience helper's behavior.
  43309. */
  43310. constructor(scene: Scene,
  43311. /** Options to modify the vr experience helper's behavior. */
  43312. webVROptions?: VRExperienceHelperOptions);
  43313. private completeVRInit;
  43314. private _onDefaultMeshLoaded;
  43315. private _onResize;
  43316. private _onFullscreenChange;
  43317. /**
  43318. * Gets a value indicating if we are currently in VR mode.
  43319. */
  43320. readonly isInVRMode: boolean;
  43321. private onVrDisplayPresentChange;
  43322. private onVRDisplayChanged;
  43323. private moveButtonToBottomRight;
  43324. private displayVRButton;
  43325. private updateButtonVisibility;
  43326. private _cachedAngularSensibility;
  43327. /**
  43328. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  43329. * Otherwise, will use the fullscreen API.
  43330. */
  43331. enterVR(): void;
  43332. /**
  43333. * Attempt to exit VR, or fullscreen.
  43334. */
  43335. exitVR(): void;
  43336. /**
  43337. * The position of the vr experience helper.
  43338. */
  43339. /**
  43340. * Sets the position of the vr experience helper.
  43341. */
  43342. position: Vector3;
  43343. /**
  43344. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  43345. */
  43346. enableInteractions(): void;
  43347. private readonly _noControllerIsActive;
  43348. private beforeRender;
  43349. private _isTeleportationFloor;
  43350. /**
  43351. * Adds a floor mesh to be used for teleportation.
  43352. * @param floorMesh the mesh to be used for teleportation.
  43353. */
  43354. addFloorMesh(floorMesh: Mesh): void;
  43355. /**
  43356. * Removes a floor mesh from being used for teleportation.
  43357. * @param floorMesh the mesh to be removed.
  43358. */
  43359. removeFloorMesh(floorMesh: Mesh): void;
  43360. /**
  43361. * Enables interactions and teleportation using the VR controllers and gaze.
  43362. * @param vrTeleportationOptions options to modify teleportation behavior.
  43363. */
  43364. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  43365. private _onNewGamepadConnected;
  43366. private _tryEnableInteractionOnController;
  43367. private _onNewGamepadDisconnected;
  43368. private _enableInteractionOnController;
  43369. private _checkTeleportWithRay;
  43370. private _checkRotate;
  43371. private _checkTeleportBackwards;
  43372. private _enableTeleportationOnController;
  43373. private _createTeleportationCircles;
  43374. private _displayTeleportationTarget;
  43375. private _hideTeleportationTarget;
  43376. private _rotateCamera;
  43377. private _moveTeleportationSelectorTo;
  43378. private _workingVector;
  43379. private _workingQuaternion;
  43380. private _workingMatrix;
  43381. /**
  43382. * Time Constant Teleportation Mode
  43383. */
  43384. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  43385. /**
  43386. * Speed Constant Teleportation Mode
  43387. */
  43388. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  43389. /**
  43390. * Teleports the users feet to the desired location
  43391. * @param location The location where the user's feet should be placed
  43392. */
  43393. teleportCamera(location: Vector3): void;
  43394. private _convertNormalToDirectionOfRay;
  43395. private _castRayAndSelectObject;
  43396. private _notifySelectedMeshUnselected;
  43397. /**
  43398. * Sets the color of the laser ray from the vr controllers.
  43399. * @param color new color for the ray.
  43400. */
  43401. changeLaserColor(color: Color3): void;
  43402. /**
  43403. * Sets the color of the ray from the vr headsets gaze.
  43404. * @param color new color for the ray.
  43405. */
  43406. changeGazeColor(color: Color3): void;
  43407. /**
  43408. * Exits VR and disposes of the vr experience helper
  43409. */
  43410. dispose(): void;
  43411. /**
  43412. * Gets the name of the VRExperienceHelper class
  43413. * @returns "VRExperienceHelper"
  43414. */
  43415. getClassName(): string;
  43416. }
  43417. }
  43418. declare module BABYLON {
  43419. /**
  43420. * Contains an array of blocks representing the octree
  43421. */
  43422. export interface IOctreeContainer<T> {
  43423. /**
  43424. * Blocks within the octree
  43425. */
  43426. blocks: Array<OctreeBlock<T>>;
  43427. }
  43428. /**
  43429. * Class used to store a cell in an octree
  43430. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43431. */
  43432. export class OctreeBlock<T> {
  43433. /**
  43434. * Gets the content of the current block
  43435. */
  43436. entries: T[];
  43437. /**
  43438. * Gets the list of block children
  43439. */
  43440. blocks: Array<OctreeBlock<T>>;
  43441. private _depth;
  43442. private _maxDepth;
  43443. private _capacity;
  43444. private _minPoint;
  43445. private _maxPoint;
  43446. private _boundingVectors;
  43447. private _creationFunc;
  43448. /**
  43449. * Creates a new block
  43450. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  43451. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  43452. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43453. * @param depth defines the current depth of this block in the octree
  43454. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  43455. * @param creationFunc defines a callback to call when an element is added to the block
  43456. */
  43457. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  43458. /**
  43459. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43460. */
  43461. readonly capacity: number;
  43462. /**
  43463. * Gets the minimum vector (in world space) of the block's bounding box
  43464. */
  43465. readonly minPoint: Vector3;
  43466. /**
  43467. * Gets the maximum vector (in world space) of the block's bounding box
  43468. */
  43469. readonly maxPoint: Vector3;
  43470. /**
  43471. * Add a new element to this block
  43472. * @param entry defines the element to add
  43473. */
  43474. addEntry(entry: T): void;
  43475. /**
  43476. * Remove an element from this block
  43477. * @param entry defines the element to remove
  43478. */
  43479. removeEntry(entry: T): void;
  43480. /**
  43481. * Add an array of elements to this block
  43482. * @param entries defines the array of elements to add
  43483. */
  43484. addEntries(entries: T[]): void;
  43485. /**
  43486. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  43487. * @param frustumPlanes defines the frustum planes to test
  43488. * @param selection defines the array to store current content if selection is positive
  43489. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43490. */
  43491. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43492. /**
  43493. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  43494. * @param sphereCenter defines the bounding sphere center
  43495. * @param sphereRadius defines the bounding sphere radius
  43496. * @param selection defines the array to store current content if selection is positive
  43497. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43498. */
  43499. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43500. /**
  43501. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  43502. * @param ray defines the ray to test with
  43503. * @param selection defines the array to store current content if selection is positive
  43504. */
  43505. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  43506. /**
  43507. * Subdivide the content into child blocks (this block will then be empty)
  43508. */
  43509. createInnerBlocks(): void;
  43510. /**
  43511. * @hidden
  43512. */
  43513. 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;
  43514. }
  43515. }
  43516. declare module BABYLON {
  43517. /**
  43518. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  43519. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43520. */
  43521. export class Octree<T> {
  43522. /** 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.) */
  43523. maxDepth: number;
  43524. /**
  43525. * Blocks within the octree containing objects
  43526. */
  43527. blocks: Array<OctreeBlock<T>>;
  43528. /**
  43529. * Content stored in the octree
  43530. */
  43531. dynamicContent: T[];
  43532. private _maxBlockCapacity;
  43533. private _selectionContent;
  43534. private _creationFunc;
  43535. /**
  43536. * Creates a octree
  43537. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43538. * @param creationFunc function to be used to instatiate the octree
  43539. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  43540. * @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.)
  43541. */
  43542. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  43543. /** 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.) */
  43544. maxDepth?: number);
  43545. /**
  43546. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  43547. * @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);
  43548. * @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);
  43549. * @param entries meshes to be added to the octree blocks
  43550. */
  43551. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  43552. /**
  43553. * Adds a mesh to the octree
  43554. * @param entry Mesh to add to the octree
  43555. */
  43556. addMesh(entry: T): void;
  43557. /**
  43558. * Remove an element from the octree
  43559. * @param entry defines the element to remove
  43560. */
  43561. removeMesh(entry: T): void;
  43562. /**
  43563. * Selects an array of meshes within the frustum
  43564. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  43565. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  43566. * @returns array of meshes within the frustum
  43567. */
  43568. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  43569. /**
  43570. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  43571. * @param sphereCenter defines the bounding sphere center
  43572. * @param sphereRadius defines the bounding sphere radius
  43573. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43574. * @returns an array of objects that intersect the sphere
  43575. */
  43576. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  43577. /**
  43578. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  43579. * @param ray defines the ray to test with
  43580. * @returns array of intersected objects
  43581. */
  43582. intersectsRay(ray: Ray): SmartArray<T>;
  43583. /**
  43584. * Adds a mesh into the octree block if it intersects the block
  43585. */
  43586. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  43587. /**
  43588. * Adds a submesh into the octree block if it intersects the block
  43589. */
  43590. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  43591. }
  43592. }
  43593. declare module BABYLON {
  43594. interface Scene {
  43595. /**
  43596. * @hidden
  43597. * Backing Filed
  43598. */
  43599. _selectionOctree: Octree<AbstractMesh>;
  43600. /**
  43601. * Gets the octree used to boost mesh selection (picking)
  43602. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43603. */
  43604. selectionOctree: Octree<AbstractMesh>;
  43605. /**
  43606. * Creates or updates the octree used to boost selection (picking)
  43607. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43608. * @param maxCapacity defines the maximum capacity per leaf
  43609. * @param maxDepth defines the maximum depth of the octree
  43610. * @returns an octree of AbstractMesh
  43611. */
  43612. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  43613. }
  43614. interface AbstractMesh {
  43615. /**
  43616. * @hidden
  43617. * Backing Field
  43618. */
  43619. _submeshesOctree: Octree<SubMesh>;
  43620. /**
  43621. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  43622. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  43623. * @param maxCapacity defines the maximum size of each block (64 by default)
  43624. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  43625. * @returns the new octree
  43626. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  43627. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43628. */
  43629. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  43630. }
  43631. /**
  43632. * Defines the octree scene component responsible to manage any octrees
  43633. * in a given scene.
  43634. */
  43635. export class OctreeSceneComponent {
  43636. /**
  43637. * The component name help to identify the component in the list of scene components.
  43638. */
  43639. readonly name: string;
  43640. /**
  43641. * The scene the component belongs to.
  43642. */
  43643. scene: Scene;
  43644. /**
  43645. * Indicates if the meshes have been checked to make sure they are isEnabled()
  43646. */
  43647. readonly checksIsEnabled: boolean;
  43648. /**
  43649. * Creates a new instance of the component for the given scene
  43650. * @param scene Defines the scene to register the component in
  43651. */
  43652. constructor(scene: Scene);
  43653. /**
  43654. * Registers the component in a given scene
  43655. */
  43656. register(): void;
  43657. /**
  43658. * Return the list of active meshes
  43659. * @returns the list of active meshes
  43660. */
  43661. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  43662. /**
  43663. * Return the list of active sub meshes
  43664. * @param mesh The mesh to get the candidates sub meshes from
  43665. * @returns the list of active sub meshes
  43666. */
  43667. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  43668. private _tempRay;
  43669. /**
  43670. * Return the list of sub meshes intersecting with a given local ray
  43671. * @param mesh defines the mesh to find the submesh for
  43672. * @param localRay defines the ray in local space
  43673. * @returns the list of intersecting sub meshes
  43674. */
  43675. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  43676. /**
  43677. * Return the list of sub meshes colliding with a collider
  43678. * @param mesh defines the mesh to find the submesh for
  43679. * @param collider defines the collider to evaluate the collision against
  43680. * @returns the list of colliding sub meshes
  43681. */
  43682. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  43683. /**
  43684. * Rebuilds the elements related to this component in case of
  43685. * context lost for instance.
  43686. */
  43687. rebuild(): void;
  43688. /**
  43689. * Disposes the component and the associated ressources.
  43690. */
  43691. dispose(): void;
  43692. }
  43693. }
  43694. declare module BABYLON {
  43695. /**
  43696. * Renders a layer on top of an existing scene
  43697. */
  43698. export class UtilityLayerRenderer implements IDisposable {
  43699. /** the original scene that will be rendered on top of */
  43700. originalScene: Scene;
  43701. private _pointerCaptures;
  43702. private _lastPointerEvents;
  43703. private static _DefaultUtilityLayer;
  43704. private static _DefaultKeepDepthUtilityLayer;
  43705. private _sharedGizmoLight;
  43706. private _renderCamera;
  43707. /**
  43708. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  43709. * @returns the camera that is used when rendering the utility layer
  43710. */
  43711. getRenderCamera(): Nullable<Camera>;
  43712. /**
  43713. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  43714. * @param cam the camera that should be used when rendering the utility layer
  43715. */
  43716. setRenderCamera(cam: Nullable<Camera>): void;
  43717. /**
  43718. * @hidden
  43719. * Light which used by gizmos to get light shading
  43720. */
  43721. _getSharedGizmoLight(): HemisphericLight;
  43722. /**
  43723. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  43724. */
  43725. pickUtilitySceneFirst: boolean;
  43726. /**
  43727. * 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)
  43728. */
  43729. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  43730. /**
  43731. * 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)
  43732. */
  43733. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  43734. /**
  43735. * The scene that is rendered on top of the original scene
  43736. */
  43737. utilityLayerScene: Scene;
  43738. /**
  43739. * If the utility layer should automatically be rendered on top of existing scene
  43740. */
  43741. shouldRender: boolean;
  43742. /**
  43743. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  43744. */
  43745. onlyCheckPointerDownEvents: boolean;
  43746. /**
  43747. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  43748. */
  43749. processAllEvents: boolean;
  43750. /**
  43751. * Observable raised when the pointer move from the utility layer scene to the main scene
  43752. */
  43753. onPointerOutObservable: Observable<number>;
  43754. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  43755. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  43756. private _afterRenderObserver;
  43757. private _sceneDisposeObserver;
  43758. private _originalPointerObserver;
  43759. /**
  43760. * Instantiates a UtilityLayerRenderer
  43761. * @param originalScene the original scene that will be rendered on top of
  43762. * @param handleEvents boolean indicating if the utility layer should handle events
  43763. */
  43764. constructor(
  43765. /** the original scene that will be rendered on top of */
  43766. originalScene: Scene, handleEvents?: boolean);
  43767. private _notifyObservers;
  43768. /**
  43769. * Renders the utility layers scene on top of the original scene
  43770. */
  43771. render(): void;
  43772. /**
  43773. * Disposes of the renderer
  43774. */
  43775. dispose(): void;
  43776. private _updateCamera;
  43777. }
  43778. }
  43779. declare module BABYLON {
  43780. /**
  43781. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  43782. */
  43783. export class Gizmo implements IDisposable {
  43784. /** The utility layer the gizmo will be added to */
  43785. gizmoLayer: UtilityLayerRenderer;
  43786. /**
  43787. * The root mesh of the gizmo
  43788. */
  43789. _rootMesh: Mesh;
  43790. private _attachedMesh;
  43791. /**
  43792. * Ratio for the scale of the gizmo (Default: 1)
  43793. */
  43794. scaleRatio: number;
  43795. /**
  43796. * If a custom mesh has been set (Default: false)
  43797. */
  43798. protected _customMeshSet: boolean;
  43799. /**
  43800. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  43801. * * When set, interactions will be enabled
  43802. */
  43803. attachedMesh: Nullable<AbstractMesh>;
  43804. /**
  43805. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  43806. * @param mesh The mesh to replace the default mesh of the gizmo
  43807. */
  43808. setCustomMesh(mesh: Mesh): void;
  43809. /**
  43810. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  43811. */
  43812. updateGizmoRotationToMatchAttachedMesh: boolean;
  43813. /**
  43814. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  43815. */
  43816. updateGizmoPositionToMatchAttachedMesh: boolean;
  43817. /**
  43818. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  43819. */
  43820. updateScale: boolean;
  43821. protected _interactionsEnabled: boolean;
  43822. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43823. private _beforeRenderObserver;
  43824. private _tempVector;
  43825. /**
  43826. * Creates a gizmo
  43827. * @param gizmoLayer The utility layer the gizmo will be added to
  43828. */
  43829. constructor(
  43830. /** The utility layer the gizmo will be added to */
  43831. gizmoLayer?: UtilityLayerRenderer);
  43832. /**
  43833. * Updates the gizmo to match the attached mesh's position/rotation
  43834. */
  43835. protected _update(): void;
  43836. /**
  43837. * Disposes of the gizmo
  43838. */
  43839. dispose(): void;
  43840. }
  43841. }
  43842. declare module BABYLON {
  43843. /**
  43844. * Single plane drag gizmo
  43845. */
  43846. export class PlaneDragGizmo extends Gizmo {
  43847. /**
  43848. * Drag behavior responsible for the gizmos dragging interactions
  43849. */
  43850. dragBehavior: PointerDragBehavior;
  43851. private _pointerObserver;
  43852. /**
  43853. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43854. */
  43855. snapDistance: number;
  43856. /**
  43857. * Event that fires each time the gizmo snaps to a new location.
  43858. * * snapDistance is the the change in distance
  43859. */
  43860. onSnapObservable: Observable<{
  43861. snapDistance: number;
  43862. }>;
  43863. private _plane;
  43864. private _coloredMaterial;
  43865. private _hoverMaterial;
  43866. private _isEnabled;
  43867. private _parent;
  43868. /** @hidden */
  43869. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  43870. /** @hidden */
  43871. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  43872. /**
  43873. * Creates a PlaneDragGizmo
  43874. * @param gizmoLayer The utility layer the gizmo will be added to
  43875. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  43876. * @param color The color of the gizmo
  43877. */
  43878. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  43879. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43880. /**
  43881. * If the gizmo is enabled
  43882. */
  43883. isEnabled: boolean;
  43884. /**
  43885. * Disposes of the gizmo
  43886. */
  43887. dispose(): void;
  43888. }
  43889. }
  43890. declare module BABYLON {
  43891. /**
  43892. * Gizmo that enables dragging a mesh along 3 axis
  43893. */
  43894. export class PositionGizmo extends Gizmo {
  43895. /**
  43896. * Internal gizmo used for interactions on the x axis
  43897. */
  43898. xGizmo: AxisDragGizmo;
  43899. /**
  43900. * Internal gizmo used for interactions on the y axis
  43901. */
  43902. yGizmo: AxisDragGizmo;
  43903. /**
  43904. * Internal gizmo used for interactions on the z axis
  43905. */
  43906. zGizmo: AxisDragGizmo;
  43907. /**
  43908. * Internal gizmo used for interactions on the yz plane
  43909. */
  43910. xPlaneGizmo: PlaneDragGizmo;
  43911. /**
  43912. * Internal gizmo used for interactions on the xz plane
  43913. */
  43914. yPlaneGizmo: PlaneDragGizmo;
  43915. /**
  43916. * Internal gizmo used for interactions on the xy plane
  43917. */
  43918. zPlaneGizmo: PlaneDragGizmo;
  43919. /**
  43920. * private variables
  43921. */
  43922. private _meshAttached;
  43923. private _updateGizmoRotationToMatchAttachedMesh;
  43924. private _snapDistance;
  43925. private _scaleRatio;
  43926. /** Fires an event when any of it's sub gizmos are dragged */
  43927. onDragStartObservable: Observable<unknown>;
  43928. /** Fires an event when any of it's sub gizmos are released from dragging */
  43929. onDragEndObservable: Observable<unknown>;
  43930. /**
  43931. * If set to true, planar drag is enabled
  43932. */
  43933. private _planarGizmoEnabled;
  43934. attachedMesh: Nullable<AbstractMesh>;
  43935. /**
  43936. * Creates a PositionGizmo
  43937. * @param gizmoLayer The utility layer the gizmo will be added to
  43938. */
  43939. constructor(gizmoLayer?: UtilityLayerRenderer);
  43940. /**
  43941. * If the planar drag gizmo is enabled
  43942. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  43943. */
  43944. planarGizmoEnabled: boolean;
  43945. updateGizmoRotationToMatchAttachedMesh: boolean;
  43946. /**
  43947. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43948. */
  43949. snapDistance: number;
  43950. /**
  43951. * Ratio for the scale of the gizmo (Default: 1)
  43952. */
  43953. scaleRatio: number;
  43954. /**
  43955. * Disposes of the gizmo
  43956. */
  43957. dispose(): void;
  43958. /**
  43959. * CustomMeshes are not supported by this gizmo
  43960. * @param mesh The mesh to replace the default mesh of the gizmo
  43961. */
  43962. setCustomMesh(mesh: Mesh): void;
  43963. }
  43964. }
  43965. declare module BABYLON {
  43966. /**
  43967. * Single axis drag gizmo
  43968. */
  43969. export class AxisDragGizmo extends Gizmo {
  43970. /**
  43971. * Drag behavior responsible for the gizmos dragging interactions
  43972. */
  43973. dragBehavior: PointerDragBehavior;
  43974. private _pointerObserver;
  43975. /**
  43976. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43977. */
  43978. snapDistance: number;
  43979. /**
  43980. * Event that fires each time the gizmo snaps to a new location.
  43981. * * snapDistance is the the change in distance
  43982. */
  43983. onSnapObservable: Observable<{
  43984. snapDistance: number;
  43985. }>;
  43986. private _isEnabled;
  43987. private _parent;
  43988. private _arrow;
  43989. private _coloredMaterial;
  43990. private _hoverMaterial;
  43991. /** @hidden */
  43992. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  43993. /** @hidden */
  43994. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  43995. /**
  43996. * Creates an AxisDragGizmo
  43997. * @param gizmoLayer The utility layer the gizmo will be added to
  43998. * @param dragAxis The axis which the gizmo will be able to drag on
  43999. * @param color The color of the gizmo
  44000. */
  44001. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44002. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44003. /**
  44004. * If the gizmo is enabled
  44005. */
  44006. isEnabled: boolean;
  44007. /**
  44008. * Disposes of the gizmo
  44009. */
  44010. dispose(): void;
  44011. }
  44012. }
  44013. declare module BABYLON.Debug {
  44014. /**
  44015. * The Axes viewer will show 3 axes in a specific point in space
  44016. */
  44017. export class AxesViewer {
  44018. private _xAxis;
  44019. private _yAxis;
  44020. private _zAxis;
  44021. private _scaleLinesFactor;
  44022. private _instanced;
  44023. /**
  44024. * Gets the hosting scene
  44025. */
  44026. scene: Scene;
  44027. /**
  44028. * Gets or sets a number used to scale line length
  44029. */
  44030. scaleLines: number;
  44031. /** Gets the node hierarchy used to render x-axis */
  44032. readonly xAxis: TransformNode;
  44033. /** Gets the node hierarchy used to render y-axis */
  44034. readonly yAxis: TransformNode;
  44035. /** Gets the node hierarchy used to render z-axis */
  44036. readonly zAxis: TransformNode;
  44037. /**
  44038. * Creates a new AxesViewer
  44039. * @param scene defines the hosting scene
  44040. * @param scaleLines defines a number used to scale line length (1 by default)
  44041. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  44042. * @param xAxis defines the node hierarchy used to render the x-axis
  44043. * @param yAxis defines the node hierarchy used to render the y-axis
  44044. * @param zAxis defines the node hierarchy used to render the z-axis
  44045. */
  44046. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  44047. /**
  44048. * Force the viewer to update
  44049. * @param position defines the position of the viewer
  44050. * @param xaxis defines the x axis of the viewer
  44051. * @param yaxis defines the y axis of the viewer
  44052. * @param zaxis defines the z axis of the viewer
  44053. */
  44054. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  44055. /**
  44056. * Creates an instance of this axes viewer.
  44057. * @returns a new axes viewer with instanced meshes
  44058. */
  44059. createInstance(): AxesViewer;
  44060. /** Releases resources */
  44061. dispose(): void;
  44062. private static _SetRenderingGroupId;
  44063. }
  44064. }
  44065. declare module BABYLON.Debug {
  44066. /**
  44067. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  44068. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  44069. */
  44070. export class BoneAxesViewer extends AxesViewer {
  44071. /**
  44072. * Gets or sets the target mesh where to display the axes viewer
  44073. */
  44074. mesh: Nullable<Mesh>;
  44075. /**
  44076. * Gets or sets the target bone where to display the axes viewer
  44077. */
  44078. bone: Nullable<Bone>;
  44079. /** Gets current position */
  44080. pos: Vector3;
  44081. /** Gets direction of X axis */
  44082. xaxis: Vector3;
  44083. /** Gets direction of Y axis */
  44084. yaxis: Vector3;
  44085. /** Gets direction of Z axis */
  44086. zaxis: Vector3;
  44087. /**
  44088. * Creates a new BoneAxesViewer
  44089. * @param scene defines the hosting scene
  44090. * @param bone defines the target bone
  44091. * @param mesh defines the target mesh
  44092. * @param scaleLines defines a scaling factor for line length (1 by default)
  44093. */
  44094. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  44095. /**
  44096. * Force the viewer to update
  44097. */
  44098. update(): void;
  44099. /** Releases resources */
  44100. dispose(): void;
  44101. }
  44102. }
  44103. declare module BABYLON {
  44104. /**
  44105. * Interface used to define scene explorer extensibility option
  44106. */
  44107. export interface IExplorerExtensibilityOption {
  44108. /**
  44109. * Define the option label
  44110. */
  44111. label: string;
  44112. /**
  44113. * Defines the action to execute on click
  44114. */
  44115. action: (entity: any) => void;
  44116. }
  44117. /**
  44118. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  44119. */
  44120. export interface IExplorerExtensibilityGroup {
  44121. /**
  44122. * Defines a predicate to test if a given type mut be extended
  44123. */
  44124. predicate: (entity: any) => boolean;
  44125. /**
  44126. * Gets the list of options added to a type
  44127. */
  44128. entries: IExplorerExtensibilityOption[];
  44129. }
  44130. /**
  44131. * Interface used to define the options to use to create the Inspector
  44132. */
  44133. export interface IInspectorOptions {
  44134. /**
  44135. * Display in overlay mode (default: false)
  44136. */
  44137. overlay?: boolean;
  44138. /**
  44139. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  44140. */
  44141. globalRoot?: HTMLElement;
  44142. /**
  44143. * Display the Scene explorer
  44144. */
  44145. showExplorer?: boolean;
  44146. /**
  44147. * Display the property inspector
  44148. */
  44149. showInspector?: boolean;
  44150. /**
  44151. * Display in embed mode (both panes on the right)
  44152. */
  44153. embedMode?: boolean;
  44154. /**
  44155. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  44156. */
  44157. handleResize?: boolean;
  44158. /**
  44159. * Allow the panes to popup (default: true)
  44160. */
  44161. enablePopup?: boolean;
  44162. /**
  44163. * Allow the panes to be closed by users (default: true)
  44164. */
  44165. enableClose?: boolean;
  44166. /**
  44167. * Optional list of extensibility entries
  44168. */
  44169. explorerExtensibility?: IExplorerExtensibilityGroup[];
  44170. /**
  44171. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  44172. */
  44173. inspectorURL?: string;
  44174. }
  44175. interface Scene {
  44176. /**
  44177. * @hidden
  44178. * Backing field
  44179. */
  44180. _debugLayer: DebugLayer;
  44181. /**
  44182. * Gets the debug layer (aka Inspector) associated with the scene
  44183. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44184. */
  44185. debugLayer: DebugLayer;
  44186. }
  44187. /**
  44188. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44189. * what is happening in your scene
  44190. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44191. */
  44192. export class DebugLayer {
  44193. /**
  44194. * Define the url to get the inspector script from.
  44195. * By default it uses the babylonjs CDN.
  44196. * @ignoreNaming
  44197. */
  44198. static InspectorURL: string;
  44199. private _scene;
  44200. private BJSINSPECTOR;
  44201. private _onPropertyChangedObservable?;
  44202. /**
  44203. * Observable triggered when a property is changed through the inspector.
  44204. */
  44205. readonly onPropertyChangedObservable: any;
  44206. /**
  44207. * Instantiates a new debug layer.
  44208. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44209. * what is happening in your scene
  44210. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44211. * @param scene Defines the scene to inspect
  44212. */
  44213. constructor(scene: Scene);
  44214. /** Creates the inspector window. */
  44215. private _createInspector;
  44216. /**
  44217. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  44218. * @param entity defines the entity to select
  44219. * @param lineContainerTitle defines the specific block to highlight
  44220. */
  44221. select(entity: any, lineContainerTitle?: string): void;
  44222. /** Get the inspector from bundle or global */
  44223. private _getGlobalInspector;
  44224. /**
  44225. * Get if the inspector is visible or not.
  44226. * @returns true if visible otherwise, false
  44227. */
  44228. isVisible(): boolean;
  44229. /**
  44230. * Hide the inspector and close its window.
  44231. */
  44232. hide(): void;
  44233. /**
  44234. * Launch the debugLayer.
  44235. * @param config Define the configuration of the inspector
  44236. * @return a promise fulfilled when the debug layer is visible
  44237. */
  44238. show(config?: IInspectorOptions): Promise<DebugLayer>;
  44239. }
  44240. }
  44241. declare module BABYLON {
  44242. /**
  44243. * Class containing static functions to help procedurally build meshes
  44244. */
  44245. export class BoxBuilder {
  44246. /**
  44247. * Creates a box mesh
  44248. * * The parameter `size` sets the size (float) of each box side (default 1)
  44249. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  44250. * * 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)
  44251. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  44252. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44253. * * 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
  44254. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44255. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  44256. * @param name defines the name of the mesh
  44257. * @param options defines the options used to create the mesh
  44258. * @param scene defines the hosting scene
  44259. * @returns the box mesh
  44260. */
  44261. static CreateBox(name: string, options: {
  44262. size?: number;
  44263. width?: number;
  44264. height?: number;
  44265. depth?: number;
  44266. faceUV?: Vector4[];
  44267. faceColors?: Color4[];
  44268. sideOrientation?: number;
  44269. frontUVs?: Vector4;
  44270. backUVs?: Vector4;
  44271. wrap?: boolean;
  44272. topBaseAt?: number;
  44273. bottomBaseAt?: number;
  44274. updatable?: boolean;
  44275. }, scene?: Nullable<Scene>): Mesh;
  44276. }
  44277. }
  44278. declare module BABYLON {
  44279. /**
  44280. * Class containing static functions to help procedurally build meshes
  44281. */
  44282. export class SphereBuilder {
  44283. /**
  44284. * Creates a sphere mesh
  44285. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  44286. * * 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`)
  44287. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  44288. * * 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
  44289. * * 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)
  44290. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44291. * * 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
  44292. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44293. * @param name defines the name of the mesh
  44294. * @param options defines the options used to create the mesh
  44295. * @param scene defines the hosting scene
  44296. * @returns the sphere mesh
  44297. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  44298. */
  44299. static CreateSphere(name: string, options: {
  44300. segments?: number;
  44301. diameter?: number;
  44302. diameterX?: number;
  44303. diameterY?: number;
  44304. diameterZ?: number;
  44305. arc?: number;
  44306. slice?: number;
  44307. sideOrientation?: number;
  44308. frontUVs?: Vector4;
  44309. backUVs?: Vector4;
  44310. updatable?: boolean;
  44311. }, scene?: Nullable<Scene>): Mesh;
  44312. }
  44313. }
  44314. declare module BABYLON.Debug {
  44315. /**
  44316. * Used to show the physics impostor around the specific mesh
  44317. */
  44318. export class PhysicsViewer {
  44319. /** @hidden */
  44320. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  44321. /** @hidden */
  44322. protected _meshes: Array<Nullable<AbstractMesh>>;
  44323. /** @hidden */
  44324. protected _scene: Nullable<Scene>;
  44325. /** @hidden */
  44326. protected _numMeshes: number;
  44327. /** @hidden */
  44328. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  44329. private _renderFunction;
  44330. private _utilityLayer;
  44331. private _debugBoxMesh;
  44332. private _debugSphereMesh;
  44333. private _debugCylinderMesh;
  44334. private _debugMaterial;
  44335. private _debugMeshMeshes;
  44336. /**
  44337. * Creates a new PhysicsViewer
  44338. * @param scene defines the hosting scene
  44339. */
  44340. constructor(scene: Scene);
  44341. /** @hidden */
  44342. protected _updateDebugMeshes(): void;
  44343. /**
  44344. * Renders a specified physic impostor
  44345. * @param impostor defines the impostor to render
  44346. * @param targetMesh defines the mesh represented by the impostor
  44347. * @returns the new debug mesh used to render the impostor
  44348. */
  44349. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  44350. /**
  44351. * Hides a specified physic impostor
  44352. * @param impostor defines the impostor to hide
  44353. */
  44354. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  44355. private _getDebugMaterial;
  44356. private _getDebugBoxMesh;
  44357. private _getDebugSphereMesh;
  44358. private _getDebugCylinderMesh;
  44359. private _getDebugMeshMesh;
  44360. private _getDebugMesh;
  44361. /** Releases all resources */
  44362. dispose(): void;
  44363. }
  44364. }
  44365. declare module BABYLON {
  44366. /**
  44367. * Class containing static functions to help procedurally build meshes
  44368. */
  44369. export class LinesBuilder {
  44370. /**
  44371. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  44372. * * 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
  44373. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  44374. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  44375. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  44376. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  44377. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  44378. * * 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
  44379. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  44380. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44381. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  44382. * @param name defines the name of the new line system
  44383. * @param options defines the options used to create the line system
  44384. * @param scene defines the hosting scene
  44385. * @returns a new line system mesh
  44386. */
  44387. static CreateLineSystem(name: string, options: {
  44388. lines: Vector3[][];
  44389. updatable?: boolean;
  44390. instance?: Nullable<LinesMesh>;
  44391. colors?: Nullable<Color4[][]>;
  44392. useVertexAlpha?: boolean;
  44393. }, scene: Nullable<Scene>): LinesMesh;
  44394. /**
  44395. * Creates a line mesh
  44396. * 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
  44397. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44398. * * The parameter `points` is an array successive Vector3
  44399. * * 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
  44400. * * The optional parameter `colors` is an array of successive Color4, one per line point
  44401. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  44402. * * When updating an instance, remember that only point positions can change, not the number of points
  44403. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44404. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  44405. * @param name defines the name of the new line system
  44406. * @param options defines the options used to create the line system
  44407. * @param scene defines the hosting scene
  44408. * @returns a new line mesh
  44409. */
  44410. static CreateLines(name: string, options: {
  44411. points: Vector3[];
  44412. updatable?: boolean;
  44413. instance?: Nullable<LinesMesh>;
  44414. colors?: Color4[];
  44415. useVertexAlpha?: boolean;
  44416. }, scene?: Nullable<Scene>): LinesMesh;
  44417. /**
  44418. * Creates a dashed line mesh
  44419. * * 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
  44420. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44421. * * The parameter `points` is an array successive Vector3
  44422. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  44423. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  44424. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  44425. * * 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
  44426. * * When updating an instance, remember that only point positions can change, not the number of points
  44427. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44428. * @param name defines the name of the mesh
  44429. * @param options defines the options used to create the mesh
  44430. * @param scene defines the hosting scene
  44431. * @returns the dashed line mesh
  44432. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  44433. */
  44434. static CreateDashedLines(name: string, options: {
  44435. points: Vector3[];
  44436. dashSize?: number;
  44437. gapSize?: number;
  44438. dashNb?: number;
  44439. updatable?: boolean;
  44440. instance?: LinesMesh;
  44441. }, scene?: Nullable<Scene>): LinesMesh;
  44442. }
  44443. }
  44444. declare module BABYLON {
  44445. /**
  44446. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  44447. * in order to better appreciate the issue one might have.
  44448. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  44449. */
  44450. export class RayHelper {
  44451. /**
  44452. * Defines the ray we are currently tryin to visualize.
  44453. */
  44454. ray: Nullable<Ray>;
  44455. private _renderPoints;
  44456. private _renderLine;
  44457. private _renderFunction;
  44458. private _scene;
  44459. private _updateToMeshFunction;
  44460. private _attachedToMesh;
  44461. private _meshSpaceDirection;
  44462. private _meshSpaceOrigin;
  44463. /**
  44464. * Helper function to create a colored helper in a scene in one line.
  44465. * @param ray Defines the ray we are currently tryin to visualize
  44466. * @param scene Defines the scene the ray is used in
  44467. * @param color Defines the color we want to see the ray in
  44468. * @returns The newly created ray helper.
  44469. */
  44470. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  44471. /**
  44472. * Instantiate a new ray helper.
  44473. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  44474. * in order to better appreciate the issue one might have.
  44475. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  44476. * @param ray Defines the ray we are currently tryin to visualize
  44477. */
  44478. constructor(ray: Ray);
  44479. /**
  44480. * Shows the ray we are willing to debug.
  44481. * @param scene Defines the scene the ray needs to be rendered in
  44482. * @param color Defines the color the ray needs to be rendered in
  44483. */
  44484. show(scene: Scene, color?: Color3): void;
  44485. /**
  44486. * Hides the ray we are debugging.
  44487. */
  44488. hide(): void;
  44489. private _render;
  44490. /**
  44491. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  44492. * @param mesh Defines the mesh we want the helper attached to
  44493. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  44494. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  44495. * @param length Defines the length of the ray
  44496. */
  44497. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  44498. /**
  44499. * Detach the ray helper from the mesh it has previously been attached to.
  44500. */
  44501. detachFromMesh(): void;
  44502. private _updateToMesh;
  44503. /**
  44504. * Dispose the helper and release its associated resources.
  44505. */
  44506. dispose(): void;
  44507. }
  44508. }
  44509. declare module BABYLON.Debug {
  44510. /**
  44511. * Class used to render a debug view of a given skeleton
  44512. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  44513. */
  44514. export class SkeletonViewer {
  44515. /** defines the skeleton to render */
  44516. skeleton: Skeleton;
  44517. /** defines the mesh attached to the skeleton */
  44518. mesh: AbstractMesh;
  44519. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  44520. autoUpdateBonesMatrices: boolean;
  44521. /** defines the rendering group id to use with the viewer */
  44522. renderingGroupId: number;
  44523. /** Gets or sets the color used to render the skeleton */
  44524. color: Color3;
  44525. private _scene;
  44526. private _debugLines;
  44527. private _debugMesh;
  44528. private _isEnabled;
  44529. private _renderFunction;
  44530. private _utilityLayer;
  44531. /**
  44532. * Returns the mesh used to render the bones
  44533. */
  44534. readonly debugMesh: Nullable<LinesMesh>;
  44535. /**
  44536. * Creates a new SkeletonViewer
  44537. * @param skeleton defines the skeleton to render
  44538. * @param mesh defines the mesh attached to the skeleton
  44539. * @param scene defines the hosting scene
  44540. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  44541. * @param renderingGroupId defines the rendering group id to use with the viewer
  44542. */
  44543. constructor(
  44544. /** defines the skeleton to render */
  44545. skeleton: Skeleton,
  44546. /** defines the mesh attached to the skeleton */
  44547. mesh: AbstractMesh, scene: Scene,
  44548. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  44549. autoUpdateBonesMatrices?: boolean,
  44550. /** defines the rendering group id to use with the viewer */
  44551. renderingGroupId?: number);
  44552. /** Gets or sets a boolean indicating if the viewer is enabled */
  44553. isEnabled: boolean;
  44554. private _getBonePosition;
  44555. private _getLinesForBonesWithLength;
  44556. private _getLinesForBonesNoLength;
  44557. /** Update the viewer to sync with current skeleton state */
  44558. update(): void;
  44559. /** Release associated resources */
  44560. dispose(): void;
  44561. }
  44562. }
  44563. declare module BABYLON {
  44564. /**
  44565. * Options to create the null engine
  44566. */
  44567. export class NullEngineOptions {
  44568. /**
  44569. * Render width (Default: 512)
  44570. */
  44571. renderWidth: number;
  44572. /**
  44573. * Render height (Default: 256)
  44574. */
  44575. renderHeight: number;
  44576. /**
  44577. * Texture size (Default: 512)
  44578. */
  44579. textureSize: number;
  44580. /**
  44581. * If delta time between frames should be constant
  44582. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44583. */
  44584. deterministicLockstep: boolean;
  44585. /**
  44586. * Maximum about of steps between frames (Default: 4)
  44587. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44588. */
  44589. lockstepMaxSteps: number;
  44590. }
  44591. /**
  44592. * The null engine class provides support for headless version of babylon.js.
  44593. * This can be used in server side scenario or for testing purposes
  44594. */
  44595. export class NullEngine extends Engine {
  44596. private _options;
  44597. /**
  44598. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  44599. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44600. * @returns true if engine is in deterministic lock step mode
  44601. */
  44602. isDeterministicLockStep(): boolean;
  44603. /**
  44604. * Gets the max steps when engine is running in deterministic lock step
  44605. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44606. * @returns the max steps
  44607. */
  44608. getLockstepMaxSteps(): number;
  44609. /**
  44610. * Gets the current hardware scaling level.
  44611. * By default the hardware scaling level is computed from the window device ratio.
  44612. * 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.
  44613. * @returns a number indicating the current hardware scaling level
  44614. */
  44615. getHardwareScalingLevel(): number;
  44616. constructor(options?: NullEngineOptions);
  44617. /**
  44618. * Creates a vertex buffer
  44619. * @param vertices the data for the vertex buffer
  44620. * @returns the new WebGL static buffer
  44621. */
  44622. createVertexBuffer(vertices: FloatArray): DataBuffer;
  44623. /**
  44624. * Creates a new index buffer
  44625. * @param indices defines the content of the index buffer
  44626. * @param updatable defines if the index buffer must be updatable
  44627. * @returns a new webGL buffer
  44628. */
  44629. createIndexBuffer(indices: IndicesArray): DataBuffer;
  44630. /**
  44631. * Clear the current render buffer or the current render target (if any is set up)
  44632. * @param color defines the color to use
  44633. * @param backBuffer defines if the back buffer must be cleared
  44634. * @param depth defines if the depth buffer must be cleared
  44635. * @param stencil defines if the stencil buffer must be cleared
  44636. */
  44637. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  44638. /**
  44639. * Gets the current render width
  44640. * @param useScreen defines if screen size must be used (or the current render target if any)
  44641. * @returns a number defining the current render width
  44642. */
  44643. getRenderWidth(useScreen?: boolean): number;
  44644. /**
  44645. * Gets the current render height
  44646. * @param useScreen defines if screen size must be used (or the current render target if any)
  44647. * @returns a number defining the current render height
  44648. */
  44649. getRenderHeight(useScreen?: boolean): number;
  44650. /**
  44651. * Set the WebGL's viewport
  44652. * @param viewport defines the viewport element to be used
  44653. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  44654. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  44655. */
  44656. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  44657. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  44658. /**
  44659. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  44660. * @param pipelineContext defines the pipeline context to use
  44661. * @param uniformsNames defines the list of uniform names
  44662. * @returns an array of webGL uniform locations
  44663. */
  44664. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  44665. /**
  44666. * Gets the lsit of active attributes for a given webGL program
  44667. * @param pipelineContext defines the pipeline context to use
  44668. * @param attributesNames defines the list of attribute names to get
  44669. * @returns an array of indices indicating the offset of each attribute
  44670. */
  44671. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  44672. /**
  44673. * Binds an effect to the webGL context
  44674. * @param effect defines the effect to bind
  44675. */
  44676. bindSamplers(effect: Effect): void;
  44677. /**
  44678. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  44679. * @param effect defines the effect to activate
  44680. */
  44681. enableEffect(effect: Effect): void;
  44682. /**
  44683. * Set various states to the webGL context
  44684. * @param culling defines backface culling state
  44685. * @param zOffset defines the value to apply to zOffset (0 by default)
  44686. * @param force defines if states must be applied even if cache is up to date
  44687. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  44688. */
  44689. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  44690. /**
  44691. * Set the value of an uniform to an array of int32
  44692. * @param uniform defines the webGL uniform location where to store the value
  44693. * @param array defines the array of int32 to store
  44694. */
  44695. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  44696. /**
  44697. * Set the value of an uniform to an array of int32 (stored as vec2)
  44698. * @param uniform defines the webGL uniform location where to store the value
  44699. * @param array defines the array of int32 to store
  44700. */
  44701. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  44702. /**
  44703. * Set the value of an uniform to an array of int32 (stored as vec3)
  44704. * @param uniform defines the webGL uniform location where to store the value
  44705. * @param array defines the array of int32 to store
  44706. */
  44707. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  44708. /**
  44709. * Set the value of an uniform to an array of int32 (stored as vec4)
  44710. * @param uniform defines the webGL uniform location where to store the value
  44711. * @param array defines the array of int32 to store
  44712. */
  44713. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  44714. /**
  44715. * Set the value of an uniform to an array of float32
  44716. * @param uniform defines the webGL uniform location where to store the value
  44717. * @param array defines the array of float32 to store
  44718. */
  44719. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  44720. /**
  44721. * Set the value of an uniform to an array of float32 (stored as vec2)
  44722. * @param uniform defines the webGL uniform location where to store the value
  44723. * @param array defines the array of float32 to store
  44724. */
  44725. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  44726. /**
  44727. * Set the value of an uniform to an array of float32 (stored as vec3)
  44728. * @param uniform defines the webGL uniform location where to store the value
  44729. * @param array defines the array of float32 to store
  44730. */
  44731. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  44732. /**
  44733. * Set the value of an uniform to an array of float32 (stored as vec4)
  44734. * @param uniform defines the webGL uniform location where to store the value
  44735. * @param array defines the array of float32 to store
  44736. */
  44737. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  44738. /**
  44739. * Set the value of an uniform to an array of number
  44740. * @param uniform defines the webGL uniform location where to store the value
  44741. * @param array defines the array of number to store
  44742. */
  44743. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  44744. /**
  44745. * Set the value of an uniform to an array of number (stored as vec2)
  44746. * @param uniform defines the webGL uniform location where to store the value
  44747. * @param array defines the array of number to store
  44748. */
  44749. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  44750. /**
  44751. * Set the value of an uniform to an array of number (stored as vec3)
  44752. * @param uniform defines the webGL uniform location where to store the value
  44753. * @param array defines the array of number to store
  44754. */
  44755. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  44756. /**
  44757. * Set the value of an uniform to an array of number (stored as vec4)
  44758. * @param uniform defines the webGL uniform location where to store the value
  44759. * @param array defines the array of number to store
  44760. */
  44761. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  44762. /**
  44763. * Set the value of an uniform to an array of float32 (stored as matrices)
  44764. * @param uniform defines the webGL uniform location where to store the value
  44765. * @param matrices defines the array of float32 to store
  44766. */
  44767. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  44768. /**
  44769. * Set the value of an uniform to a matrix (3x3)
  44770. * @param uniform defines the webGL uniform location where to store the value
  44771. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  44772. */
  44773. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44774. /**
  44775. * Set the value of an uniform to a matrix (2x2)
  44776. * @param uniform defines the webGL uniform location where to store the value
  44777. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  44778. */
  44779. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44780. /**
  44781. * Set the value of an uniform to a number (float)
  44782. * @param uniform defines the webGL uniform location where to store the value
  44783. * @param value defines the float number to store
  44784. */
  44785. setFloat(uniform: WebGLUniformLocation, value: number): void;
  44786. /**
  44787. * Set the value of an uniform to a vec2
  44788. * @param uniform defines the webGL uniform location where to store the value
  44789. * @param x defines the 1st component of the value
  44790. * @param y defines the 2nd component of the value
  44791. */
  44792. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  44793. /**
  44794. * Set the value of an uniform to a vec3
  44795. * @param uniform defines the webGL uniform location where to store the value
  44796. * @param x defines the 1st component of the value
  44797. * @param y defines the 2nd component of the value
  44798. * @param z defines the 3rd component of the value
  44799. */
  44800. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  44801. /**
  44802. * Set the value of an uniform to a boolean
  44803. * @param uniform defines the webGL uniform location where to store the value
  44804. * @param bool defines the boolean to store
  44805. */
  44806. setBool(uniform: WebGLUniformLocation, bool: number): void;
  44807. /**
  44808. * Set the value of an uniform to a vec4
  44809. * @param uniform defines the webGL uniform location where to store the value
  44810. * @param x defines the 1st component of the value
  44811. * @param y defines the 2nd component of the value
  44812. * @param z defines the 3rd component of the value
  44813. * @param w defines the 4th component of the value
  44814. */
  44815. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  44816. /**
  44817. * Sets the current alpha mode
  44818. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  44819. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  44820. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  44821. */
  44822. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  44823. /**
  44824. * Bind webGl buffers directly to the webGL context
  44825. * @param vertexBuffers defines the vertex buffer to bind
  44826. * @param indexBuffer defines the index buffer to bind
  44827. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  44828. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  44829. * @param effect defines the effect associated with the vertex buffer
  44830. */
  44831. bindBuffers(vertexBuffers: {
  44832. [key: string]: VertexBuffer;
  44833. }, indexBuffer: DataBuffer, effect: Effect): void;
  44834. /**
  44835. * Force the entire cache to be cleared
  44836. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  44837. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  44838. */
  44839. wipeCaches(bruteForce?: boolean): void;
  44840. /**
  44841. * Send a draw order
  44842. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  44843. * @param indexStart defines the starting index
  44844. * @param indexCount defines the number of index to draw
  44845. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  44846. */
  44847. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  44848. /**
  44849. * Draw a list of indexed primitives
  44850. * @param fillMode defines the primitive to use
  44851. * @param indexStart defines the starting index
  44852. * @param indexCount defines the number of index to draw
  44853. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  44854. */
  44855. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  44856. /**
  44857. * Draw a list of unindexed primitives
  44858. * @param fillMode defines the primitive to use
  44859. * @param verticesStart defines the index of first vertex to draw
  44860. * @param verticesCount defines the count of vertices to draw
  44861. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  44862. */
  44863. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  44864. /** @hidden */
  44865. _createTexture(): WebGLTexture;
  44866. /** @hidden */
  44867. _releaseTexture(texture: InternalTexture): void;
  44868. /**
  44869. * Usually called from Texture.ts.
  44870. * Passed information to create a WebGLTexture
  44871. * @param urlArg defines a value which contains one of the following:
  44872. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  44873. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  44874. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  44875. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  44876. * @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)
  44877. * @param scene needed for loading to the correct scene
  44878. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  44879. * @param onLoad optional callback to be called upon successful completion
  44880. * @param onError optional callback to be called upon failure
  44881. * @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
  44882. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  44883. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  44884. * @param forcedExtension defines the extension to use to pick the right loader
  44885. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  44886. * @returns a InternalTexture for assignment back into BABYLON.Texture
  44887. */
  44888. 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;
  44889. /**
  44890. * Creates a new render target texture
  44891. * @param size defines the size of the texture
  44892. * @param options defines the options used to create the texture
  44893. * @returns a new render target texture stored in an InternalTexture
  44894. */
  44895. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  44896. /**
  44897. * Update the sampling mode of a given texture
  44898. * @param samplingMode defines the required sampling mode
  44899. * @param texture defines the texture to update
  44900. */
  44901. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  44902. /**
  44903. * Binds the frame buffer to the specified texture.
  44904. * @param texture The texture to render to or null for the default canvas
  44905. * @param faceIndex The face of the texture to render to in case of cube texture
  44906. * @param requiredWidth The width of the target to render to
  44907. * @param requiredHeight The height of the target to render to
  44908. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  44909. * @param depthStencilTexture The depth stencil texture to use to render
  44910. * @param lodLevel defines le lod level to bind to the frame buffer
  44911. */
  44912. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  44913. /**
  44914. * Unbind the current render target texture from the webGL context
  44915. * @param texture defines the render target texture to unbind
  44916. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  44917. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  44918. */
  44919. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  44920. /**
  44921. * Creates a dynamic vertex buffer
  44922. * @param vertices the data for the dynamic vertex buffer
  44923. * @returns the new WebGL dynamic buffer
  44924. */
  44925. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  44926. /**
  44927. * Update the content of a dynamic texture
  44928. * @param texture defines the texture to update
  44929. * @param canvas defines the canvas containing the source
  44930. * @param invertY defines if data must be stored with Y axis inverted
  44931. * @param premulAlpha defines if alpha is stored as premultiplied
  44932. * @param format defines the format of the data
  44933. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  44934. */
  44935. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  44936. /**
  44937. * Gets a boolean indicating if all created effects are ready
  44938. * @returns true if all effects are ready
  44939. */
  44940. areAllEffectsReady(): boolean;
  44941. /**
  44942. * @hidden
  44943. * Get the current error code of the webGL context
  44944. * @returns the error code
  44945. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  44946. */
  44947. getError(): number;
  44948. /** @hidden */
  44949. _getUnpackAlignement(): number;
  44950. /** @hidden */
  44951. _unpackFlipY(value: boolean): void;
  44952. /**
  44953. * Update a dynamic index buffer
  44954. * @param indexBuffer defines the target index buffer
  44955. * @param indices defines the data to update
  44956. * @param offset defines the offset in the target index buffer where update should start
  44957. */
  44958. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  44959. /**
  44960. * Updates a dynamic vertex buffer.
  44961. * @param vertexBuffer the vertex buffer to update
  44962. * @param vertices the data used to update the vertex buffer
  44963. * @param byteOffset the byte offset of the data (optional)
  44964. * @param byteLength the byte length of the data (optional)
  44965. */
  44966. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  44967. /** @hidden */
  44968. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  44969. /** @hidden */
  44970. _bindTexture(channel: number, texture: InternalTexture): void;
  44971. protected _deleteBuffer(buffer: WebGLBuffer): void;
  44972. /**
  44973. * 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
  44974. */
  44975. releaseEffects(): void;
  44976. displayLoadingUI(): void;
  44977. hideLoadingUI(): void;
  44978. /** @hidden */
  44979. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44980. /** @hidden */
  44981. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44982. /** @hidden */
  44983. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44984. /** @hidden */
  44985. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  44986. }
  44987. }
  44988. declare module BABYLON {
  44989. /** @hidden */
  44990. export class _OcclusionDataStorage {
  44991. /** @hidden */
  44992. occlusionInternalRetryCounter: number;
  44993. /** @hidden */
  44994. isOcclusionQueryInProgress: boolean;
  44995. /** @hidden */
  44996. isOccluded: boolean;
  44997. /** @hidden */
  44998. occlusionRetryCount: number;
  44999. /** @hidden */
  45000. occlusionType: number;
  45001. /** @hidden */
  45002. occlusionQueryAlgorithmType: number;
  45003. }
  45004. interface Engine {
  45005. /**
  45006. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  45007. * @return the new query
  45008. */
  45009. createQuery(): WebGLQuery;
  45010. /**
  45011. * Delete and release a webGL query
  45012. * @param query defines the query to delete
  45013. * @return the current engine
  45014. */
  45015. deleteQuery(query: WebGLQuery): Engine;
  45016. /**
  45017. * Check if a given query has resolved and got its value
  45018. * @param query defines the query to check
  45019. * @returns true if the query got its value
  45020. */
  45021. isQueryResultAvailable(query: WebGLQuery): boolean;
  45022. /**
  45023. * Gets the value of a given query
  45024. * @param query defines the query to check
  45025. * @returns the value of the query
  45026. */
  45027. getQueryResult(query: WebGLQuery): number;
  45028. /**
  45029. * Initiates an occlusion query
  45030. * @param algorithmType defines the algorithm to use
  45031. * @param query defines the query to use
  45032. * @returns the current engine
  45033. * @see http://doc.babylonjs.com/features/occlusionquery
  45034. */
  45035. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  45036. /**
  45037. * Ends an occlusion query
  45038. * @see http://doc.babylonjs.com/features/occlusionquery
  45039. * @param algorithmType defines the algorithm to use
  45040. * @returns the current engine
  45041. */
  45042. endOcclusionQuery(algorithmType: number): Engine;
  45043. /**
  45044. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  45045. * Please note that only one query can be issued at a time
  45046. * @returns a time token used to track the time span
  45047. */
  45048. startTimeQuery(): Nullable<_TimeToken>;
  45049. /**
  45050. * Ends a time query
  45051. * @param token defines the token used to measure the time span
  45052. * @returns the time spent (in ns)
  45053. */
  45054. endTimeQuery(token: _TimeToken): int;
  45055. /** @hidden */
  45056. _currentNonTimestampToken: Nullable<_TimeToken>;
  45057. /** @hidden */
  45058. _createTimeQuery(): WebGLQuery;
  45059. /** @hidden */
  45060. _deleteTimeQuery(query: WebGLQuery): void;
  45061. /** @hidden */
  45062. _getGlAlgorithmType(algorithmType: number): number;
  45063. /** @hidden */
  45064. _getTimeQueryResult(query: WebGLQuery): any;
  45065. /** @hidden */
  45066. _getTimeQueryAvailability(query: WebGLQuery): any;
  45067. }
  45068. interface AbstractMesh {
  45069. /**
  45070. * Backing filed
  45071. * @hidden
  45072. */
  45073. __occlusionDataStorage: _OcclusionDataStorage;
  45074. /**
  45075. * Access property
  45076. * @hidden
  45077. */
  45078. _occlusionDataStorage: _OcclusionDataStorage;
  45079. /**
  45080. * 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.
  45081. * The default value is -1 which means don't break the query and wait till the result
  45082. * @see http://doc.babylonjs.com/features/occlusionquery
  45083. */
  45084. occlusionRetryCount: number;
  45085. /**
  45086. * 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:
  45087. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  45088. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  45089. * * 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.
  45090. * @see http://doc.babylonjs.com/features/occlusionquery
  45091. */
  45092. occlusionType: number;
  45093. /**
  45094. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  45095. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  45096. * * 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.
  45097. * @see http://doc.babylonjs.com/features/occlusionquery
  45098. */
  45099. occlusionQueryAlgorithmType: number;
  45100. /**
  45101. * 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
  45102. * @see http://doc.babylonjs.com/features/occlusionquery
  45103. */
  45104. isOccluded: boolean;
  45105. /**
  45106. * Flag to check the progress status of the query
  45107. * @see http://doc.babylonjs.com/features/occlusionquery
  45108. */
  45109. isOcclusionQueryInProgress: boolean;
  45110. }
  45111. }
  45112. declare module BABYLON {
  45113. /** @hidden */
  45114. export var _forceTransformFeedbackToBundle: boolean;
  45115. interface Engine {
  45116. /**
  45117. * Creates a webGL transform feedback object
  45118. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  45119. * @returns the webGL transform feedback object
  45120. */
  45121. createTransformFeedback(): WebGLTransformFeedback;
  45122. /**
  45123. * Delete a webGL transform feedback object
  45124. * @param value defines the webGL transform feedback object to delete
  45125. */
  45126. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  45127. /**
  45128. * Bind a webGL transform feedback object to the webgl context
  45129. * @param value defines the webGL transform feedback object to bind
  45130. */
  45131. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  45132. /**
  45133. * Begins a transform feedback operation
  45134. * @param usePoints defines if points or triangles must be used
  45135. */
  45136. beginTransformFeedback(usePoints: boolean): void;
  45137. /**
  45138. * Ends a transform feedback operation
  45139. */
  45140. endTransformFeedback(): void;
  45141. /**
  45142. * Specify the varyings to use with transform feedback
  45143. * @param program defines the associated webGL program
  45144. * @param value defines the list of strings representing the varying names
  45145. */
  45146. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  45147. /**
  45148. * Bind a webGL buffer for a transform feedback operation
  45149. * @param value defines the webGL buffer to bind
  45150. */
  45151. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  45152. }
  45153. }
  45154. declare module BABYLON {
  45155. /**
  45156. * Creation options of the multi render target texture.
  45157. */
  45158. export interface IMultiRenderTargetOptions {
  45159. /**
  45160. * Define if the texture needs to create mip maps after render.
  45161. */
  45162. generateMipMaps?: boolean;
  45163. /**
  45164. * Define the types of all the draw buffers we want to create
  45165. */
  45166. types?: number[];
  45167. /**
  45168. * Define the sampling modes of all the draw buffers we want to create
  45169. */
  45170. samplingModes?: number[];
  45171. /**
  45172. * Define if a depth buffer is required
  45173. */
  45174. generateDepthBuffer?: boolean;
  45175. /**
  45176. * Define if a stencil buffer is required
  45177. */
  45178. generateStencilBuffer?: boolean;
  45179. /**
  45180. * Define if a depth texture is required instead of a depth buffer
  45181. */
  45182. generateDepthTexture?: boolean;
  45183. /**
  45184. * Define the number of desired draw buffers
  45185. */
  45186. textureCount?: number;
  45187. /**
  45188. * Define if aspect ratio should be adapted to the texture or stay the scene one
  45189. */
  45190. doNotChangeAspectRatio?: boolean;
  45191. /**
  45192. * Define the default type of the buffers we are creating
  45193. */
  45194. defaultType?: number;
  45195. }
  45196. /**
  45197. * A multi render target, like a render target provides the ability to render to a texture.
  45198. * Unlike the render target, it can render to several draw buffers in one draw.
  45199. * This is specially interesting in deferred rendering or for any effects requiring more than
  45200. * just one color from a single pass.
  45201. */
  45202. export class MultiRenderTarget extends RenderTargetTexture {
  45203. private _internalTextures;
  45204. private _textures;
  45205. private _multiRenderTargetOptions;
  45206. /**
  45207. * Get if draw buffers are currently supported by the used hardware and browser.
  45208. */
  45209. readonly isSupported: boolean;
  45210. /**
  45211. * Get the list of textures generated by the multi render target.
  45212. */
  45213. readonly textures: Texture[];
  45214. /**
  45215. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  45216. */
  45217. readonly depthTexture: Texture;
  45218. /**
  45219. * Set the wrapping mode on U of all the textures we are rendering to.
  45220. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45221. */
  45222. wrapU: number;
  45223. /**
  45224. * Set the wrapping mode on V of all the textures we are rendering to.
  45225. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45226. */
  45227. wrapV: number;
  45228. /**
  45229. * Instantiate a new multi render target texture.
  45230. * A multi render target, like a render target provides the ability to render to a texture.
  45231. * Unlike the render target, it can render to several draw buffers in one draw.
  45232. * This is specially interesting in deferred rendering or for any effects requiring more than
  45233. * just one color from a single pass.
  45234. * @param name Define the name of the texture
  45235. * @param size Define the size of the buffers to render to
  45236. * @param count Define the number of target we are rendering into
  45237. * @param scene Define the scene the texture belongs to
  45238. * @param options Define the options used to create the multi render target
  45239. */
  45240. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  45241. /** @hidden */
  45242. _rebuild(): void;
  45243. private _createInternalTextures;
  45244. private _createTextures;
  45245. /**
  45246. * Define the number of samples used if MSAA is enabled.
  45247. */
  45248. samples: number;
  45249. /**
  45250. * Resize all the textures in the multi render target.
  45251. * Be carrefull as it will recreate all the data in the new texture.
  45252. * @param size Define the new size
  45253. */
  45254. resize(size: any): void;
  45255. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  45256. /**
  45257. * Dispose the render targets and their associated resources
  45258. */
  45259. dispose(): void;
  45260. /**
  45261. * Release all the underlying texture used as draw buffers.
  45262. */
  45263. releaseInternalTextures(): void;
  45264. }
  45265. }
  45266. declare module BABYLON {
  45267. interface ThinEngine {
  45268. /**
  45269. * Unbind a list of render target textures from the webGL context
  45270. * This is used only when drawBuffer extension or webGL2 are active
  45271. * @param textures defines the render target textures to unbind
  45272. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45273. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45274. */
  45275. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  45276. /**
  45277. * Create a multi render target texture
  45278. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  45279. * @param size defines the size of the texture
  45280. * @param options defines the creation options
  45281. * @returns the cube texture as an InternalTexture
  45282. */
  45283. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  45284. /**
  45285. * Update the sample count for a given multiple render target texture
  45286. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  45287. * @param textures defines the textures to update
  45288. * @param samples defines the sample count to set
  45289. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  45290. */
  45291. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  45292. }
  45293. }
  45294. declare module BABYLON {
  45295. /**
  45296. * Class used to define an additional view for the engine
  45297. * @see https://doc.babylonjs.com/how_to/multi_canvases
  45298. */
  45299. export class EngineView {
  45300. /** Defines the canvas where to render the view */
  45301. target: HTMLCanvasElement;
  45302. /** Defines an optional camera used to render the view (will use active camera else) */
  45303. camera?: Camera;
  45304. }
  45305. interface Engine {
  45306. /**
  45307. * Gets or sets the HTML element to use for attaching events
  45308. */
  45309. inputElement: Nullable<HTMLElement>;
  45310. /**
  45311. * Gets the current engine view
  45312. * @see https://doc.babylonjs.com/how_to/multi_canvases
  45313. */
  45314. activeView: Nullable<EngineView>;
  45315. /** Gets or sets the list of views */
  45316. views: EngineView[];
  45317. /**
  45318. * Register a new child canvas
  45319. * @param canvas defines the canvas to register
  45320. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  45321. * @returns the associated view
  45322. */
  45323. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  45324. /**
  45325. * Remove a registered child canvas
  45326. * @param canvas defines the canvas to remove
  45327. * @returns the current engine
  45328. */
  45329. unRegisterView(canvas: HTMLCanvasElement): Engine;
  45330. }
  45331. }
  45332. declare module BABYLON {
  45333. /**
  45334. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  45335. */
  45336. export interface CubeMapInfo {
  45337. /**
  45338. * The pixel array for the front face.
  45339. * This is stored in format, left to right, up to down format.
  45340. */
  45341. front: Nullable<ArrayBufferView>;
  45342. /**
  45343. * The pixel array for the back face.
  45344. * This is stored in format, left to right, up to down format.
  45345. */
  45346. back: Nullable<ArrayBufferView>;
  45347. /**
  45348. * The pixel array for the left face.
  45349. * This is stored in format, left to right, up to down format.
  45350. */
  45351. left: Nullable<ArrayBufferView>;
  45352. /**
  45353. * The pixel array for the right face.
  45354. * This is stored in format, left to right, up to down format.
  45355. */
  45356. right: Nullable<ArrayBufferView>;
  45357. /**
  45358. * The pixel array for the up face.
  45359. * This is stored in format, left to right, up to down format.
  45360. */
  45361. up: Nullable<ArrayBufferView>;
  45362. /**
  45363. * The pixel array for the down face.
  45364. * This is stored in format, left to right, up to down format.
  45365. */
  45366. down: Nullable<ArrayBufferView>;
  45367. /**
  45368. * The size of the cubemap stored.
  45369. *
  45370. * Each faces will be size * size pixels.
  45371. */
  45372. size: number;
  45373. /**
  45374. * The format of the texture.
  45375. *
  45376. * RGBA, RGB.
  45377. */
  45378. format: number;
  45379. /**
  45380. * The type of the texture data.
  45381. *
  45382. * UNSIGNED_INT, FLOAT.
  45383. */
  45384. type: number;
  45385. /**
  45386. * Specifies whether the texture is in gamma space.
  45387. */
  45388. gammaSpace: boolean;
  45389. }
  45390. /**
  45391. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  45392. */
  45393. export class PanoramaToCubeMapTools {
  45394. private static FACE_FRONT;
  45395. private static FACE_BACK;
  45396. private static FACE_RIGHT;
  45397. private static FACE_LEFT;
  45398. private static FACE_DOWN;
  45399. private static FACE_UP;
  45400. /**
  45401. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  45402. *
  45403. * @param float32Array The source data.
  45404. * @param inputWidth The width of the input panorama.
  45405. * @param inputHeight The height of the input panorama.
  45406. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  45407. * @return The cubemap data
  45408. */
  45409. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  45410. private static CreateCubemapTexture;
  45411. private static CalcProjectionSpherical;
  45412. }
  45413. }
  45414. declare module BABYLON {
  45415. /**
  45416. * Helper class dealing with the extraction of spherical polynomial dataArray
  45417. * from a cube map.
  45418. */
  45419. export class CubeMapToSphericalPolynomialTools {
  45420. private static FileFaces;
  45421. /**
  45422. * Converts a texture to the according Spherical Polynomial data.
  45423. * This extracts the first 3 orders only as they are the only one used in the lighting.
  45424. *
  45425. * @param texture The texture to extract the information from.
  45426. * @return The Spherical Polynomial data.
  45427. */
  45428. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  45429. /**
  45430. * Converts a cubemap to the according Spherical Polynomial data.
  45431. * This extracts the first 3 orders only as they are the only one used in the lighting.
  45432. *
  45433. * @param cubeInfo The Cube map to extract the information from.
  45434. * @return The Spherical Polynomial data.
  45435. */
  45436. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  45437. }
  45438. }
  45439. declare module BABYLON {
  45440. interface BaseTexture {
  45441. /**
  45442. * Get the polynomial representation of the texture data.
  45443. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  45444. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  45445. */
  45446. sphericalPolynomial: Nullable<SphericalPolynomial>;
  45447. }
  45448. }
  45449. declare module BABYLON {
  45450. /** @hidden */
  45451. export var rgbdEncodePixelShader: {
  45452. name: string;
  45453. shader: string;
  45454. };
  45455. }
  45456. declare module BABYLON {
  45457. /** @hidden */
  45458. export var rgbdDecodePixelShader: {
  45459. name: string;
  45460. shader: string;
  45461. };
  45462. }
  45463. declare module BABYLON {
  45464. /**
  45465. * Raw texture data and descriptor sufficient for WebGL texture upload
  45466. */
  45467. export interface EnvironmentTextureInfo {
  45468. /**
  45469. * Version of the environment map
  45470. */
  45471. version: number;
  45472. /**
  45473. * Width of image
  45474. */
  45475. width: number;
  45476. /**
  45477. * Irradiance information stored in the file.
  45478. */
  45479. irradiance: any;
  45480. /**
  45481. * Specular information stored in the file.
  45482. */
  45483. specular: any;
  45484. }
  45485. /**
  45486. * Defines One Image in the file. It requires only the position in the file
  45487. * as well as the length.
  45488. */
  45489. interface BufferImageData {
  45490. /**
  45491. * Length of the image data.
  45492. */
  45493. length: number;
  45494. /**
  45495. * Position of the data from the null terminator delimiting the end of the JSON.
  45496. */
  45497. position: number;
  45498. }
  45499. /**
  45500. * Defines the specular data enclosed in the file.
  45501. * This corresponds to the version 1 of the data.
  45502. */
  45503. export interface EnvironmentTextureSpecularInfoV1 {
  45504. /**
  45505. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  45506. */
  45507. specularDataPosition?: number;
  45508. /**
  45509. * This contains all the images data needed to reconstruct the cubemap.
  45510. */
  45511. mipmaps: Array<BufferImageData>;
  45512. /**
  45513. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  45514. */
  45515. lodGenerationScale: number;
  45516. }
  45517. /**
  45518. * Sets of helpers addressing the serialization and deserialization of environment texture
  45519. * stored in a BabylonJS env file.
  45520. * Those files are usually stored as .env files.
  45521. */
  45522. export class EnvironmentTextureTools {
  45523. /**
  45524. * Magic number identifying the env file.
  45525. */
  45526. private static _MagicBytes;
  45527. /**
  45528. * Gets the environment info from an env file.
  45529. * @param data The array buffer containing the .env bytes.
  45530. * @returns the environment file info (the json header) if successfully parsed.
  45531. */
  45532. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  45533. /**
  45534. * Creates an environment texture from a loaded cube texture.
  45535. * @param texture defines the cube texture to convert in env file
  45536. * @return a promise containing the environment data if succesfull.
  45537. */
  45538. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  45539. /**
  45540. * Creates a JSON representation of the spherical data.
  45541. * @param texture defines the texture containing the polynomials
  45542. * @return the JSON representation of the spherical info
  45543. */
  45544. private static _CreateEnvTextureIrradiance;
  45545. /**
  45546. * Creates the ArrayBufferViews used for initializing environment texture image data.
  45547. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  45548. * @param info parameters that determine what views will be created for accessing the underlying buffer
  45549. * @return the views described by info providing access to the underlying buffer
  45550. */
  45551. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  45552. /**
  45553. * Uploads the texture info contained in the env file to the GPU.
  45554. * @param texture defines the internal texture to upload to
  45555. * @param arrayBuffer defines the buffer cotaining the data to load
  45556. * @param info defines the texture info retrieved through the GetEnvInfo method
  45557. * @returns a promise
  45558. */
  45559. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  45560. private static _OnImageReadyAsync;
  45561. /**
  45562. * Uploads the levels of image data to the GPU.
  45563. * @param texture defines the internal texture to upload to
  45564. * @param imageData defines the array buffer views of image data [mipmap][face]
  45565. * @returns a promise
  45566. */
  45567. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  45568. /**
  45569. * Uploads spherical polynomials information to the texture.
  45570. * @param texture defines the texture we are trying to upload the information to
  45571. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  45572. */
  45573. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  45574. /** @hidden */
  45575. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  45576. }
  45577. }
  45578. declare module BABYLON {
  45579. /**
  45580. * Contains position and normal vectors for a vertex
  45581. */
  45582. export class PositionNormalVertex {
  45583. /** the position of the vertex (defaut: 0,0,0) */
  45584. position: Vector3;
  45585. /** the normal of the vertex (defaut: 0,1,0) */
  45586. normal: Vector3;
  45587. /**
  45588. * Creates a PositionNormalVertex
  45589. * @param position the position of the vertex (defaut: 0,0,0)
  45590. * @param normal the normal of the vertex (defaut: 0,1,0)
  45591. */
  45592. constructor(
  45593. /** the position of the vertex (defaut: 0,0,0) */
  45594. position?: Vector3,
  45595. /** the normal of the vertex (defaut: 0,1,0) */
  45596. normal?: Vector3);
  45597. /**
  45598. * Clones the PositionNormalVertex
  45599. * @returns the cloned PositionNormalVertex
  45600. */
  45601. clone(): PositionNormalVertex;
  45602. }
  45603. /**
  45604. * Contains position, normal and uv vectors for a vertex
  45605. */
  45606. export class PositionNormalTextureVertex {
  45607. /** the position of the vertex (defaut: 0,0,0) */
  45608. position: Vector3;
  45609. /** the normal of the vertex (defaut: 0,1,0) */
  45610. normal: Vector3;
  45611. /** the uv of the vertex (default: 0,0) */
  45612. uv: Vector2;
  45613. /**
  45614. * Creates a PositionNormalTextureVertex
  45615. * @param position the position of the vertex (defaut: 0,0,0)
  45616. * @param normal the normal of the vertex (defaut: 0,1,0)
  45617. * @param uv the uv of the vertex (default: 0,0)
  45618. */
  45619. constructor(
  45620. /** the position of the vertex (defaut: 0,0,0) */
  45621. position?: Vector3,
  45622. /** the normal of the vertex (defaut: 0,1,0) */
  45623. normal?: Vector3,
  45624. /** the uv of the vertex (default: 0,0) */
  45625. uv?: Vector2);
  45626. /**
  45627. * Clones the PositionNormalTextureVertex
  45628. * @returns the cloned PositionNormalTextureVertex
  45629. */
  45630. clone(): PositionNormalTextureVertex;
  45631. }
  45632. }
  45633. declare module BABYLON {
  45634. /** @hidden */
  45635. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  45636. private _genericAttributeLocation;
  45637. private _varyingLocationCount;
  45638. private _varyingLocationMap;
  45639. private _replacements;
  45640. private _textureCount;
  45641. private _uniforms;
  45642. lineProcessor(line: string): string;
  45643. attributeProcessor(attribute: string): string;
  45644. varyingProcessor(varying: string, isFragment: boolean): string;
  45645. uniformProcessor(uniform: string): string;
  45646. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  45647. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  45648. }
  45649. }
  45650. declare module BABYLON {
  45651. /**
  45652. * Container for accessors for natively-stored mesh data buffers.
  45653. */
  45654. class NativeDataBuffer extends DataBuffer {
  45655. /**
  45656. * Accessor value used to identify/retrieve a natively-stored index buffer.
  45657. */
  45658. nativeIndexBuffer?: any;
  45659. /**
  45660. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  45661. */
  45662. nativeVertexBuffer?: any;
  45663. }
  45664. /** @hidden */
  45665. class NativeTexture extends InternalTexture {
  45666. getInternalTexture(): InternalTexture;
  45667. getViewCount(): number;
  45668. }
  45669. /** @hidden */
  45670. export class NativeEngine extends Engine {
  45671. private readonly _native;
  45672. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  45673. private readonly INVALID_HANDLE;
  45674. getHardwareScalingLevel(): number;
  45675. constructor();
  45676. /**
  45677. * Can be used to override the current requestAnimationFrame requester.
  45678. * @hidden
  45679. */
  45680. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  45681. /**
  45682. * Override default engine behavior.
  45683. * @param color
  45684. * @param backBuffer
  45685. * @param depth
  45686. * @param stencil
  45687. */
  45688. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  45689. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45690. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  45691. createVertexBuffer(data: DataArray): NativeDataBuffer;
  45692. recordVertexArrayObject(vertexBuffers: {
  45693. [key: string]: VertexBuffer;
  45694. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  45695. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  45696. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  45697. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45698. /**
  45699. * Draw a list of indexed primitives
  45700. * @param fillMode defines the primitive to use
  45701. * @param indexStart defines the starting index
  45702. * @param indexCount defines the number of index to draw
  45703. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45704. */
  45705. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  45706. /**
  45707. * Draw a list of unindexed primitives
  45708. * @param fillMode defines the primitive to use
  45709. * @param verticesStart defines the index of first vertex to draw
  45710. * @param verticesCount defines the count of vertices to draw
  45711. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45712. */
  45713. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  45714. createPipelineContext(): IPipelineContext;
  45715. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  45716. /** @hidden */
  45717. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  45718. /** @hidden */
  45719. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  45720. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  45721. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  45722. protected _setProgram(program: WebGLProgram): void;
  45723. _releaseEffect(effect: Effect): void;
  45724. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  45725. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  45726. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  45727. bindSamplers(effect: Effect): void;
  45728. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  45729. getRenderWidth(useScreen?: boolean): number;
  45730. getRenderHeight(useScreen?: boolean): number;
  45731. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  45732. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45733. /**
  45734. * Set the z offset to apply to current rendering
  45735. * @param value defines the offset to apply
  45736. */
  45737. setZOffset(value: number): void;
  45738. /**
  45739. * Gets the current value of the zOffset
  45740. * @returns the current zOffset state
  45741. */
  45742. getZOffset(): number;
  45743. /**
  45744. * Enable or disable depth buffering
  45745. * @param enable defines the state to set
  45746. */
  45747. setDepthBuffer(enable: boolean): void;
  45748. /**
  45749. * Gets a boolean indicating if depth writing is enabled
  45750. * @returns the current depth writing state
  45751. */
  45752. getDepthWrite(): boolean;
  45753. /**
  45754. * Enable or disable depth writing
  45755. * @param enable defines the state to set
  45756. */
  45757. setDepthWrite(enable: boolean): void;
  45758. /**
  45759. * Enable or disable color writing
  45760. * @param enable defines the state to set
  45761. */
  45762. setColorWrite(enable: boolean): void;
  45763. /**
  45764. * Gets a boolean indicating if color writing is enabled
  45765. * @returns the current color writing state
  45766. */
  45767. getColorWrite(): boolean;
  45768. /**
  45769. * Sets alpha constants used by some alpha blending modes
  45770. * @param r defines the red component
  45771. * @param g defines the green component
  45772. * @param b defines the blue component
  45773. * @param a defines the alpha component
  45774. */
  45775. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  45776. /**
  45777. * Sets the current alpha mode
  45778. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  45779. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  45780. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45781. */
  45782. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45783. /**
  45784. * Gets the current alpha mode
  45785. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45786. * @returns the current alpha mode
  45787. */
  45788. getAlphaMode(): number;
  45789. setInt(uniform: WebGLUniformLocation, int: number): void;
  45790. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  45791. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  45792. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  45793. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  45794. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  45795. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  45796. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  45797. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  45798. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  45799. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  45800. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  45801. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  45802. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  45803. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45804. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45805. setFloat(uniform: WebGLUniformLocation, value: number): void;
  45806. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  45807. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  45808. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  45809. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  45810. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  45811. wipeCaches(bruteForce?: boolean): void;
  45812. _createTexture(): WebGLTexture;
  45813. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  45814. /**
  45815. * Usually called from BABYLON.Texture.ts.
  45816. * Passed information to create a WebGLTexture
  45817. * @param urlArg defines a value which contains one of the following:
  45818. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  45819. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  45820. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  45821. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  45822. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  45823. * @param scene needed for loading to the correct scene
  45824. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  45825. * @param onLoad optional callback to be called upon successful completion
  45826. * @param onError optional callback to be called upon failure
  45827. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  45828. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  45829. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  45830. * @param forcedExtension defines the extension to use to pick the right loader
  45831. * @returns a InternalTexture for assignment back into BABYLON.Texture
  45832. */
  45833. 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;
  45834. /**
  45835. * Creates a cube texture
  45836. * @param rootUrl defines the url where the files to load is located
  45837. * @param scene defines the current scene
  45838. * @param files defines the list of files to load (1 per face)
  45839. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  45840. * @param onLoad defines an optional callback raised when the texture is loaded
  45841. * @param onError defines an optional callback raised if there is an issue to load the texture
  45842. * @param format defines the format of the data
  45843. * @param forcedExtension defines the extension to use to pick the right loader
  45844. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  45845. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  45846. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  45847. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  45848. * @returns the cube texture as an InternalTexture
  45849. */
  45850. 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;
  45851. private _getSamplingFilter;
  45852. private static _GetNativeTextureFormat;
  45853. createRenderTargetTexture(size: number | {
  45854. width: number;
  45855. height: number;
  45856. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  45857. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  45858. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  45859. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45860. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  45861. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  45862. /**
  45863. * Updates a dynamic vertex buffer.
  45864. * @param vertexBuffer the vertex buffer to update
  45865. * @param data the data used to update the vertex buffer
  45866. * @param byteOffset the byte offset of the data (optional)
  45867. * @param byteLength the byte length of the data (optional)
  45868. */
  45869. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  45870. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  45871. private _updateAnisotropicLevel;
  45872. private _getAddressMode;
  45873. /** @hidden */
  45874. _bindTexture(channel: number, texture: InternalTexture): void;
  45875. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  45876. releaseEffects(): void;
  45877. /** @hidden */
  45878. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45879. /** @hidden */
  45880. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45881. /** @hidden */
  45882. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45883. /** @hidden */
  45884. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  45885. }
  45886. }
  45887. declare module BABYLON {
  45888. /**
  45889. * Gather the list of clipboard event types as constants.
  45890. */
  45891. export class ClipboardEventTypes {
  45892. /**
  45893. * The clipboard event is fired when a copy command is active (pressed).
  45894. */
  45895. static readonly COPY: number;
  45896. /**
  45897. * The clipboard event is fired when a cut command is active (pressed).
  45898. */
  45899. static readonly CUT: number;
  45900. /**
  45901. * The clipboard event is fired when a paste command is active (pressed).
  45902. */
  45903. static readonly PASTE: number;
  45904. }
  45905. /**
  45906. * This class is used to store clipboard related info for the onClipboardObservable event.
  45907. */
  45908. export class ClipboardInfo {
  45909. /**
  45910. * Defines the type of event (BABYLON.ClipboardEventTypes)
  45911. */
  45912. type: number;
  45913. /**
  45914. * Defines the related dom event
  45915. */
  45916. event: ClipboardEvent;
  45917. /**
  45918. *Creates an instance of ClipboardInfo.
  45919. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  45920. * @param event Defines the related dom event
  45921. */
  45922. constructor(
  45923. /**
  45924. * Defines the type of event (BABYLON.ClipboardEventTypes)
  45925. */
  45926. type: number,
  45927. /**
  45928. * Defines the related dom event
  45929. */
  45930. event: ClipboardEvent);
  45931. /**
  45932. * Get the clipboard event's type from the keycode.
  45933. * @param keyCode Defines the keyCode for the current keyboard event.
  45934. * @return {number}
  45935. */
  45936. static GetTypeFromCharacter(keyCode: number): number;
  45937. }
  45938. }
  45939. declare module BABYLON {
  45940. /**
  45941. * Google Daydream controller
  45942. */
  45943. export class DaydreamController extends WebVRController {
  45944. /**
  45945. * Base Url for the controller model.
  45946. */
  45947. static MODEL_BASE_URL: string;
  45948. /**
  45949. * File name for the controller model.
  45950. */
  45951. static MODEL_FILENAME: string;
  45952. /**
  45953. * Gamepad Id prefix used to identify Daydream Controller.
  45954. */
  45955. static readonly GAMEPAD_ID_PREFIX: string;
  45956. /**
  45957. * Creates a new DaydreamController from a gamepad
  45958. * @param vrGamepad the gamepad that the controller should be created from
  45959. */
  45960. constructor(vrGamepad: any);
  45961. /**
  45962. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  45963. * @param scene scene in which to add meshes
  45964. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  45965. */
  45966. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  45967. /**
  45968. * Called once for each button that changed state since the last frame
  45969. * @param buttonIdx Which button index changed
  45970. * @param state New state of the button
  45971. * @param changes Which properties on the state changed since last frame
  45972. */
  45973. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  45974. }
  45975. }
  45976. declare module BABYLON {
  45977. /**
  45978. * Gear VR Controller
  45979. */
  45980. export class GearVRController extends WebVRController {
  45981. /**
  45982. * Base Url for the controller model.
  45983. */
  45984. static MODEL_BASE_URL: string;
  45985. /**
  45986. * File name for the controller model.
  45987. */
  45988. static MODEL_FILENAME: string;
  45989. /**
  45990. * Gamepad Id prefix used to identify this controller.
  45991. */
  45992. static readonly GAMEPAD_ID_PREFIX: string;
  45993. private readonly _buttonIndexToObservableNameMap;
  45994. /**
  45995. * Creates a new GearVRController from a gamepad
  45996. * @param vrGamepad the gamepad that the controller should be created from
  45997. */
  45998. constructor(vrGamepad: any);
  45999. /**
  46000. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  46001. * @param scene scene in which to add meshes
  46002. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  46003. */
  46004. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  46005. /**
  46006. * Called once for each button that changed state since the last frame
  46007. * @param buttonIdx Which button index changed
  46008. * @param state New state of the button
  46009. * @param changes Which properties on the state changed since last frame
  46010. */
  46011. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  46012. }
  46013. }
  46014. declare module BABYLON {
  46015. /**
  46016. * Class containing static functions to help procedurally build meshes
  46017. */
  46018. export class PolyhedronBuilder {
  46019. /**
  46020. * Creates a polyhedron mesh
  46021. * * 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
  46022. * * The parameter `size` (positive float, default 1) sets the polygon size
  46023. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  46024. * * 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`
  46025. * * 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
  46026. * * 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)`)
  46027. * * 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
  46028. * * 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
  46029. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46030. * * 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
  46031. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46032. * @param name defines the name of the mesh
  46033. * @param options defines the options used to create the mesh
  46034. * @param scene defines the hosting scene
  46035. * @returns the polyhedron mesh
  46036. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  46037. */
  46038. static CreatePolyhedron(name: string, options: {
  46039. type?: number;
  46040. size?: number;
  46041. sizeX?: number;
  46042. sizeY?: number;
  46043. sizeZ?: number;
  46044. custom?: any;
  46045. faceUV?: Vector4[];
  46046. faceColors?: Color4[];
  46047. flat?: boolean;
  46048. updatable?: boolean;
  46049. sideOrientation?: number;
  46050. frontUVs?: Vector4;
  46051. backUVs?: Vector4;
  46052. }, scene?: Nullable<Scene>): Mesh;
  46053. }
  46054. }
  46055. declare module BABYLON {
  46056. /**
  46057. * Gizmo that enables scaling a mesh along 3 axis
  46058. */
  46059. export class ScaleGizmo extends Gizmo {
  46060. /**
  46061. * Internal gizmo used for interactions on the x axis
  46062. */
  46063. xGizmo: AxisScaleGizmo;
  46064. /**
  46065. * Internal gizmo used for interactions on the y axis
  46066. */
  46067. yGizmo: AxisScaleGizmo;
  46068. /**
  46069. * Internal gizmo used for interactions on the z axis
  46070. */
  46071. zGizmo: AxisScaleGizmo;
  46072. /**
  46073. * Internal gizmo used to scale all axis equally
  46074. */
  46075. uniformScaleGizmo: AxisScaleGizmo;
  46076. private _meshAttached;
  46077. private _updateGizmoRotationToMatchAttachedMesh;
  46078. private _snapDistance;
  46079. private _scaleRatio;
  46080. private _uniformScalingMesh;
  46081. private _octahedron;
  46082. private _sensitivity;
  46083. /** Fires an event when any of it's sub gizmos are dragged */
  46084. onDragStartObservable: Observable<unknown>;
  46085. /** Fires an event when any of it's sub gizmos are released from dragging */
  46086. onDragEndObservable: Observable<unknown>;
  46087. attachedMesh: Nullable<AbstractMesh>;
  46088. /**
  46089. * Creates a ScaleGizmo
  46090. * @param gizmoLayer The utility layer the gizmo will be added to
  46091. */
  46092. constructor(gizmoLayer?: UtilityLayerRenderer);
  46093. updateGizmoRotationToMatchAttachedMesh: boolean;
  46094. /**
  46095. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46096. */
  46097. snapDistance: number;
  46098. /**
  46099. * Ratio for the scale of the gizmo (Default: 1)
  46100. */
  46101. scaleRatio: number;
  46102. /**
  46103. * Sensitivity factor for dragging (Default: 1)
  46104. */
  46105. sensitivity: number;
  46106. /**
  46107. * Disposes of the gizmo
  46108. */
  46109. dispose(): void;
  46110. }
  46111. }
  46112. declare module BABYLON {
  46113. /**
  46114. * Single axis scale gizmo
  46115. */
  46116. export class AxisScaleGizmo extends Gizmo {
  46117. /**
  46118. * Drag behavior responsible for the gizmos dragging interactions
  46119. */
  46120. dragBehavior: PointerDragBehavior;
  46121. private _pointerObserver;
  46122. /**
  46123. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46124. */
  46125. snapDistance: number;
  46126. /**
  46127. * Event that fires each time the gizmo snaps to a new location.
  46128. * * snapDistance is the the change in distance
  46129. */
  46130. onSnapObservable: Observable<{
  46131. snapDistance: number;
  46132. }>;
  46133. /**
  46134. * If the scaling operation should be done on all axis (default: false)
  46135. */
  46136. uniformScaling: boolean;
  46137. /**
  46138. * Custom sensitivity value for the drag strength
  46139. */
  46140. sensitivity: number;
  46141. private _isEnabled;
  46142. private _parent;
  46143. private _arrow;
  46144. private _coloredMaterial;
  46145. private _hoverMaterial;
  46146. /**
  46147. * Creates an AxisScaleGizmo
  46148. * @param gizmoLayer The utility layer the gizmo will be added to
  46149. * @param dragAxis The axis which the gizmo will be able to scale on
  46150. * @param color The color of the gizmo
  46151. */
  46152. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  46153. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46154. /**
  46155. * If the gizmo is enabled
  46156. */
  46157. isEnabled: boolean;
  46158. /**
  46159. * Disposes of the gizmo
  46160. */
  46161. dispose(): void;
  46162. /**
  46163. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  46164. * @param mesh The mesh to replace the default mesh of the gizmo
  46165. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  46166. */
  46167. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  46168. }
  46169. }
  46170. declare module BABYLON {
  46171. /**
  46172. * Bounding box gizmo
  46173. */
  46174. export class BoundingBoxGizmo extends Gizmo {
  46175. private _lineBoundingBox;
  46176. private _rotateSpheresParent;
  46177. private _scaleBoxesParent;
  46178. private _boundingDimensions;
  46179. private _renderObserver;
  46180. private _pointerObserver;
  46181. private _scaleDragSpeed;
  46182. private _tmpQuaternion;
  46183. private _tmpVector;
  46184. private _tmpRotationMatrix;
  46185. /**
  46186. * 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)
  46187. */
  46188. ignoreChildren: boolean;
  46189. /**
  46190. * 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)
  46191. */
  46192. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  46193. /**
  46194. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  46195. */
  46196. rotationSphereSize: number;
  46197. /**
  46198. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  46199. */
  46200. scaleBoxSize: number;
  46201. /**
  46202. * 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)
  46203. */
  46204. fixedDragMeshScreenSize: boolean;
  46205. /**
  46206. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  46207. */
  46208. fixedDragMeshScreenSizeDistanceFactor: number;
  46209. /**
  46210. * Fired when a rotation sphere or scale box is dragged
  46211. */
  46212. onDragStartObservable: Observable<{}>;
  46213. /**
  46214. * Fired when a scale box is dragged
  46215. */
  46216. onScaleBoxDragObservable: Observable<{}>;
  46217. /**
  46218. * Fired when a scale box drag is ended
  46219. */
  46220. onScaleBoxDragEndObservable: Observable<{}>;
  46221. /**
  46222. * Fired when a rotation sphere is dragged
  46223. */
  46224. onRotationSphereDragObservable: Observable<{}>;
  46225. /**
  46226. * Fired when a rotation sphere drag is ended
  46227. */
  46228. onRotationSphereDragEndObservable: Observable<{}>;
  46229. /**
  46230. * 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)
  46231. */
  46232. scalePivot: Nullable<Vector3>;
  46233. /**
  46234. * Mesh used as a pivot to rotate the attached mesh
  46235. */
  46236. private _anchorMesh;
  46237. private _existingMeshScale;
  46238. private _dragMesh;
  46239. private pointerDragBehavior;
  46240. private coloredMaterial;
  46241. private hoverColoredMaterial;
  46242. /**
  46243. * Sets the color of the bounding box gizmo
  46244. * @param color the color to set
  46245. */
  46246. setColor(color: Color3): void;
  46247. /**
  46248. * Creates an BoundingBoxGizmo
  46249. * @param gizmoLayer The utility layer the gizmo will be added to
  46250. * @param color The color of the gizmo
  46251. */
  46252. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  46253. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46254. private _selectNode;
  46255. /**
  46256. * Updates the bounding box information for the Gizmo
  46257. */
  46258. updateBoundingBox(): void;
  46259. private _updateRotationSpheres;
  46260. private _updateScaleBoxes;
  46261. /**
  46262. * Enables rotation on the specified axis and disables rotation on the others
  46263. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  46264. */
  46265. setEnabledRotationAxis(axis: string): void;
  46266. /**
  46267. * Enables/disables scaling
  46268. * @param enable if scaling should be enabled
  46269. */
  46270. setEnabledScaling(enable: boolean): void;
  46271. private _updateDummy;
  46272. /**
  46273. * Enables a pointer drag behavior on the bounding box of the gizmo
  46274. */
  46275. enableDragBehavior(): void;
  46276. /**
  46277. * Disposes of the gizmo
  46278. */
  46279. dispose(): void;
  46280. /**
  46281. * 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)
  46282. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  46283. * @returns the bounding box mesh with the passed in mesh as a child
  46284. */
  46285. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  46286. /**
  46287. * CustomMeshes are not supported by this gizmo
  46288. * @param mesh The mesh to replace the default mesh of the gizmo
  46289. */
  46290. setCustomMesh(mesh: Mesh): void;
  46291. }
  46292. }
  46293. declare module BABYLON {
  46294. /**
  46295. * Single plane rotation gizmo
  46296. */
  46297. export class PlaneRotationGizmo extends Gizmo {
  46298. /**
  46299. * Drag behavior responsible for the gizmos dragging interactions
  46300. */
  46301. dragBehavior: PointerDragBehavior;
  46302. private _pointerObserver;
  46303. /**
  46304. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  46305. */
  46306. snapDistance: number;
  46307. /**
  46308. * Event that fires each time the gizmo snaps to a new location.
  46309. * * snapDistance is the the change in distance
  46310. */
  46311. onSnapObservable: Observable<{
  46312. snapDistance: number;
  46313. }>;
  46314. private _isEnabled;
  46315. private _parent;
  46316. /**
  46317. * Creates a PlaneRotationGizmo
  46318. * @param gizmoLayer The utility layer the gizmo will be added to
  46319. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  46320. * @param color The color of the gizmo
  46321. * @param tessellation Amount of tessellation to be used when creating rotation circles
  46322. * @param useEulerRotation Use and update Euler angle instead of quaternion
  46323. */
  46324. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  46325. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46326. /**
  46327. * If the gizmo is enabled
  46328. */
  46329. isEnabled: boolean;
  46330. /**
  46331. * Disposes of the gizmo
  46332. */
  46333. dispose(): void;
  46334. }
  46335. }
  46336. declare module BABYLON {
  46337. /**
  46338. * Gizmo that enables rotating a mesh along 3 axis
  46339. */
  46340. export class RotationGizmo extends Gizmo {
  46341. /**
  46342. * Internal gizmo used for interactions on the x axis
  46343. */
  46344. xGizmo: PlaneRotationGizmo;
  46345. /**
  46346. * Internal gizmo used for interactions on the y axis
  46347. */
  46348. yGizmo: PlaneRotationGizmo;
  46349. /**
  46350. * Internal gizmo used for interactions on the z axis
  46351. */
  46352. zGizmo: PlaneRotationGizmo;
  46353. /** Fires an event when any of it's sub gizmos are dragged */
  46354. onDragStartObservable: Observable<unknown>;
  46355. /** Fires an event when any of it's sub gizmos are released from dragging */
  46356. onDragEndObservable: Observable<unknown>;
  46357. private _meshAttached;
  46358. attachedMesh: Nullable<AbstractMesh>;
  46359. /**
  46360. * Creates a RotationGizmo
  46361. * @param gizmoLayer The utility layer the gizmo will be added to
  46362. * @param tessellation Amount of tessellation to be used when creating rotation circles
  46363. * @param useEulerRotation Use and update Euler angle instead of quaternion
  46364. */
  46365. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  46366. updateGizmoRotationToMatchAttachedMesh: boolean;
  46367. /**
  46368. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46369. */
  46370. snapDistance: number;
  46371. /**
  46372. * Ratio for the scale of the gizmo (Default: 1)
  46373. */
  46374. scaleRatio: number;
  46375. /**
  46376. * Disposes of the gizmo
  46377. */
  46378. dispose(): void;
  46379. /**
  46380. * CustomMeshes are not supported by this gizmo
  46381. * @param mesh The mesh to replace the default mesh of the gizmo
  46382. */
  46383. setCustomMesh(mesh: Mesh): void;
  46384. }
  46385. }
  46386. declare module BABYLON {
  46387. /**
  46388. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  46389. */
  46390. export class GizmoManager implements IDisposable {
  46391. private scene;
  46392. /**
  46393. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  46394. */
  46395. gizmos: {
  46396. positionGizmo: Nullable<PositionGizmo>;
  46397. rotationGizmo: Nullable<RotationGizmo>;
  46398. scaleGizmo: Nullable<ScaleGizmo>;
  46399. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  46400. };
  46401. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  46402. clearGizmoOnEmptyPointerEvent: boolean;
  46403. /** Fires an event when the manager is attached to a mesh */
  46404. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  46405. private _gizmosEnabled;
  46406. private _pointerObserver;
  46407. private _attachedMesh;
  46408. private _boundingBoxColor;
  46409. private _defaultUtilityLayer;
  46410. private _defaultKeepDepthUtilityLayer;
  46411. /**
  46412. * When bounding box gizmo is enabled, this can be used to track drag/end events
  46413. */
  46414. boundingBoxDragBehavior: SixDofDragBehavior;
  46415. /**
  46416. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  46417. */
  46418. attachableMeshes: Nullable<Array<AbstractMesh>>;
  46419. /**
  46420. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  46421. */
  46422. usePointerToAttachGizmos: boolean;
  46423. /**
  46424. * Utility layer that the bounding box gizmo belongs to
  46425. */
  46426. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  46427. /**
  46428. * Utility layer that all gizmos besides bounding box belong to
  46429. */
  46430. readonly utilityLayer: UtilityLayerRenderer;
  46431. /**
  46432. * Instatiates a gizmo manager
  46433. * @param scene the scene to overlay the gizmos on top of
  46434. */
  46435. constructor(scene: Scene);
  46436. /**
  46437. * Attaches a set of gizmos to the specified mesh
  46438. * @param mesh The mesh the gizmo's should be attached to
  46439. */
  46440. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  46441. /**
  46442. * If the position gizmo is enabled
  46443. */
  46444. positionGizmoEnabled: boolean;
  46445. /**
  46446. * If the rotation gizmo is enabled
  46447. */
  46448. rotationGizmoEnabled: boolean;
  46449. /**
  46450. * If the scale gizmo is enabled
  46451. */
  46452. scaleGizmoEnabled: boolean;
  46453. /**
  46454. * If the boundingBox gizmo is enabled
  46455. */
  46456. boundingBoxGizmoEnabled: boolean;
  46457. /**
  46458. * Disposes of the gizmo manager
  46459. */
  46460. dispose(): void;
  46461. }
  46462. }
  46463. declare module BABYLON {
  46464. /**
  46465. * A directional light is defined by a direction (what a surprise!).
  46466. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  46467. * 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.
  46468. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46469. */
  46470. export class DirectionalLight extends ShadowLight {
  46471. private _shadowFrustumSize;
  46472. /**
  46473. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  46474. */
  46475. /**
  46476. * Specifies a fix frustum size for the shadow generation.
  46477. */
  46478. shadowFrustumSize: number;
  46479. private _shadowOrthoScale;
  46480. /**
  46481. * Gets the shadow projection scale against the optimal computed one.
  46482. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46483. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46484. */
  46485. /**
  46486. * Sets the shadow projection scale against the optimal computed one.
  46487. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46488. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46489. */
  46490. shadowOrthoScale: number;
  46491. /**
  46492. * Automatically compute the projection matrix to best fit (including all the casters)
  46493. * on each frame.
  46494. */
  46495. autoUpdateExtends: boolean;
  46496. private _orthoLeft;
  46497. private _orthoRight;
  46498. private _orthoTop;
  46499. private _orthoBottom;
  46500. /**
  46501. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  46502. * The directional light is emitted from everywhere in the given direction.
  46503. * It can cast shadows.
  46504. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46505. * @param name The friendly name of the light
  46506. * @param direction The direction of the light
  46507. * @param scene The scene the light belongs to
  46508. */
  46509. constructor(name: string, direction: Vector3, scene: Scene);
  46510. /**
  46511. * Returns the string "DirectionalLight".
  46512. * @return The class name
  46513. */
  46514. getClassName(): string;
  46515. /**
  46516. * Returns the integer 1.
  46517. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46518. */
  46519. getTypeID(): number;
  46520. /**
  46521. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  46522. * Returns the DirectionalLight Shadow projection matrix.
  46523. */
  46524. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46525. /**
  46526. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  46527. * Returns the DirectionalLight Shadow projection matrix.
  46528. */
  46529. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  46530. /**
  46531. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  46532. * Returns the DirectionalLight Shadow projection matrix.
  46533. */
  46534. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46535. protected _buildUniformLayout(): void;
  46536. /**
  46537. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  46538. * @param effect The effect to update
  46539. * @param lightIndex The index of the light in the effect to update
  46540. * @returns The directional light
  46541. */
  46542. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  46543. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  46544. /**
  46545. * Gets the minZ used for shadow according to both the scene and the light.
  46546. *
  46547. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46548. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46549. * @param activeCamera The camera we are returning the min for
  46550. * @returns the depth min z
  46551. */
  46552. getDepthMinZ(activeCamera: Camera): number;
  46553. /**
  46554. * Gets the maxZ used for shadow according to both the scene and the light.
  46555. *
  46556. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46557. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46558. * @param activeCamera The camera we are returning the max for
  46559. * @returns the depth max z
  46560. */
  46561. getDepthMaxZ(activeCamera: Camera): number;
  46562. /**
  46563. * Prepares the list of defines specific to the light type.
  46564. * @param defines the list of defines
  46565. * @param lightIndex defines the index of the light for the effect
  46566. */
  46567. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46568. }
  46569. }
  46570. declare module BABYLON {
  46571. /**
  46572. * Class containing static functions to help procedurally build meshes
  46573. */
  46574. export class HemisphereBuilder {
  46575. /**
  46576. * Creates a hemisphere mesh
  46577. * @param name defines the name of the mesh
  46578. * @param options defines the options used to create the mesh
  46579. * @param scene defines the hosting scene
  46580. * @returns the hemisphere mesh
  46581. */
  46582. static CreateHemisphere(name: string, options: {
  46583. segments?: number;
  46584. diameter?: number;
  46585. sideOrientation?: number;
  46586. }, scene: any): Mesh;
  46587. }
  46588. }
  46589. declare module BABYLON {
  46590. /**
  46591. * A spot light is defined by a position, a direction, an angle, and an exponent.
  46592. * These values define a cone of light starting from the position, emitting toward the direction.
  46593. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  46594. * and the exponent defines the speed of the decay of the light with distance (reach).
  46595. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46596. */
  46597. export class SpotLight extends ShadowLight {
  46598. private _angle;
  46599. private _innerAngle;
  46600. private _cosHalfAngle;
  46601. private _lightAngleScale;
  46602. private _lightAngleOffset;
  46603. /**
  46604. * Gets the cone angle of the spot light in Radians.
  46605. */
  46606. /**
  46607. * Sets the cone angle of the spot light in Radians.
  46608. */
  46609. angle: number;
  46610. /**
  46611. * Only used in gltf falloff mode, this defines the angle where
  46612. * the directional falloff will start before cutting at angle which could be seen
  46613. * as outer angle.
  46614. */
  46615. /**
  46616. * Only used in gltf falloff mode, this defines the angle where
  46617. * the directional falloff will start before cutting at angle which could be seen
  46618. * as outer angle.
  46619. */
  46620. innerAngle: number;
  46621. private _shadowAngleScale;
  46622. /**
  46623. * Allows scaling the angle of the light for shadow generation only.
  46624. */
  46625. /**
  46626. * Allows scaling the angle of the light for shadow generation only.
  46627. */
  46628. shadowAngleScale: number;
  46629. /**
  46630. * The light decay speed with the distance from the emission spot.
  46631. */
  46632. exponent: number;
  46633. private _projectionTextureMatrix;
  46634. /**
  46635. * Allows reading the projecton texture
  46636. */
  46637. readonly projectionTextureMatrix: Matrix;
  46638. protected _projectionTextureLightNear: number;
  46639. /**
  46640. * Gets the near clip of the Spotlight for texture projection.
  46641. */
  46642. /**
  46643. * Sets the near clip of the Spotlight for texture projection.
  46644. */
  46645. projectionTextureLightNear: number;
  46646. protected _projectionTextureLightFar: number;
  46647. /**
  46648. * Gets the far clip of the Spotlight for texture projection.
  46649. */
  46650. /**
  46651. * Sets the far clip of the Spotlight for texture projection.
  46652. */
  46653. projectionTextureLightFar: number;
  46654. protected _projectionTextureUpDirection: Vector3;
  46655. /**
  46656. * Gets the Up vector of the Spotlight for texture projection.
  46657. */
  46658. /**
  46659. * Sets the Up vector of the Spotlight for texture projection.
  46660. */
  46661. projectionTextureUpDirection: Vector3;
  46662. private _projectionTexture;
  46663. /**
  46664. * Gets the projection texture of the light.
  46665. */
  46666. /**
  46667. * Sets the projection texture of the light.
  46668. */
  46669. projectionTexture: Nullable<BaseTexture>;
  46670. private _projectionTextureViewLightDirty;
  46671. private _projectionTextureProjectionLightDirty;
  46672. private _projectionTextureDirty;
  46673. private _projectionTextureViewTargetVector;
  46674. private _projectionTextureViewLightMatrix;
  46675. private _projectionTextureProjectionLightMatrix;
  46676. private _projectionTextureScalingMatrix;
  46677. /**
  46678. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  46679. * It can cast shadows.
  46680. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46681. * @param name The light friendly name
  46682. * @param position The position of the spot light in the scene
  46683. * @param direction The direction of the light in the scene
  46684. * @param angle The cone angle of the light in Radians
  46685. * @param exponent The light decay speed with the distance from the emission spot
  46686. * @param scene The scene the lights belongs to
  46687. */
  46688. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  46689. /**
  46690. * Returns the string "SpotLight".
  46691. * @returns the class name
  46692. */
  46693. getClassName(): string;
  46694. /**
  46695. * Returns the integer 2.
  46696. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46697. */
  46698. getTypeID(): number;
  46699. /**
  46700. * Overrides the direction setter to recompute the projection texture view light Matrix.
  46701. */
  46702. protected _setDirection(value: Vector3): void;
  46703. /**
  46704. * Overrides the position setter to recompute the projection texture view light Matrix.
  46705. */
  46706. protected _setPosition(value: Vector3): void;
  46707. /**
  46708. * 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.
  46709. * Returns the SpotLight.
  46710. */
  46711. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46712. protected _computeProjectionTextureViewLightMatrix(): void;
  46713. protected _computeProjectionTextureProjectionLightMatrix(): void;
  46714. /**
  46715. * Main function for light texture projection matrix computing.
  46716. */
  46717. protected _computeProjectionTextureMatrix(): void;
  46718. protected _buildUniformLayout(): void;
  46719. private _computeAngleValues;
  46720. /**
  46721. * Sets the passed Effect "effect" with the Light textures.
  46722. * @param effect The effect to update
  46723. * @param lightIndex The index of the light in the effect to update
  46724. * @returns The light
  46725. */
  46726. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  46727. /**
  46728. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  46729. * @param effect The effect to update
  46730. * @param lightIndex The index of the light in the effect to update
  46731. * @returns The spot light
  46732. */
  46733. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  46734. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  46735. /**
  46736. * Disposes the light and the associated resources.
  46737. */
  46738. dispose(): void;
  46739. /**
  46740. * Prepares the list of defines specific to the light type.
  46741. * @param defines the list of defines
  46742. * @param lightIndex defines the index of the light for the effect
  46743. */
  46744. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46745. }
  46746. }
  46747. declare module BABYLON {
  46748. /**
  46749. * Gizmo that enables viewing a light
  46750. */
  46751. export class LightGizmo extends Gizmo {
  46752. private _lightMesh;
  46753. private _material;
  46754. private _cachedPosition;
  46755. private _cachedForward;
  46756. private _attachedMeshParent;
  46757. /**
  46758. * Creates a LightGizmo
  46759. * @param gizmoLayer The utility layer the gizmo will be added to
  46760. */
  46761. constructor(gizmoLayer?: UtilityLayerRenderer);
  46762. private _light;
  46763. /**
  46764. * The light that the gizmo is attached to
  46765. */
  46766. light: Nullable<Light>;
  46767. /**
  46768. * Gets the material used to render the light gizmo
  46769. */
  46770. readonly material: StandardMaterial;
  46771. /**
  46772. * @hidden
  46773. * Updates the gizmo to match the attached mesh's position/rotation
  46774. */
  46775. protected _update(): void;
  46776. private static _Scale;
  46777. /**
  46778. * Creates the lines for a light mesh
  46779. */
  46780. private static _CreateLightLines;
  46781. /**
  46782. * Disposes of the light gizmo
  46783. */
  46784. dispose(): void;
  46785. private static _CreateHemisphericLightMesh;
  46786. private static _CreatePointLightMesh;
  46787. private static _CreateSpotLightMesh;
  46788. private static _CreateDirectionalLightMesh;
  46789. }
  46790. }
  46791. declare module BABYLON {
  46792. /** @hidden */
  46793. export var backgroundFragmentDeclaration: {
  46794. name: string;
  46795. shader: string;
  46796. };
  46797. }
  46798. declare module BABYLON {
  46799. /** @hidden */
  46800. export var backgroundUboDeclaration: {
  46801. name: string;
  46802. shader: string;
  46803. };
  46804. }
  46805. declare module BABYLON {
  46806. /** @hidden */
  46807. export var backgroundPixelShader: {
  46808. name: string;
  46809. shader: string;
  46810. };
  46811. }
  46812. declare module BABYLON {
  46813. /** @hidden */
  46814. export var backgroundVertexDeclaration: {
  46815. name: string;
  46816. shader: string;
  46817. };
  46818. }
  46819. declare module BABYLON {
  46820. /** @hidden */
  46821. export var backgroundVertexShader: {
  46822. name: string;
  46823. shader: string;
  46824. };
  46825. }
  46826. declare module BABYLON {
  46827. /**
  46828. * Background material used to create an efficient environement around your scene.
  46829. */
  46830. export class BackgroundMaterial extends PushMaterial {
  46831. /**
  46832. * Standard reflectance value at parallel view angle.
  46833. */
  46834. static StandardReflectance0: number;
  46835. /**
  46836. * Standard reflectance value at grazing angle.
  46837. */
  46838. static StandardReflectance90: number;
  46839. protected _primaryColor: Color3;
  46840. /**
  46841. * Key light Color (multiply against the environement texture)
  46842. */
  46843. primaryColor: Color3;
  46844. protected __perceptualColor: Nullable<Color3>;
  46845. /**
  46846. * Experimental Internal Use Only.
  46847. *
  46848. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  46849. * This acts as a helper to set the primary color to a more "human friendly" value.
  46850. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  46851. * output color as close as possible from the chosen value.
  46852. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  46853. * part of lighting setup.)
  46854. */
  46855. _perceptualColor: Nullable<Color3>;
  46856. protected _primaryColorShadowLevel: float;
  46857. /**
  46858. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  46859. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  46860. */
  46861. primaryColorShadowLevel: float;
  46862. protected _primaryColorHighlightLevel: float;
  46863. /**
  46864. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  46865. * The primary color is used at the level chosen to define what the white area would look.
  46866. */
  46867. primaryColorHighlightLevel: float;
  46868. protected _reflectionTexture: Nullable<BaseTexture>;
  46869. /**
  46870. * Reflection Texture used in the material.
  46871. * Should be author in a specific way for the best result (refer to the documentation).
  46872. */
  46873. reflectionTexture: Nullable<BaseTexture>;
  46874. protected _reflectionBlur: float;
  46875. /**
  46876. * Reflection Texture level of blur.
  46877. *
  46878. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  46879. * texture twice.
  46880. */
  46881. reflectionBlur: float;
  46882. protected _diffuseTexture: Nullable<BaseTexture>;
  46883. /**
  46884. * Diffuse Texture used in the material.
  46885. * Should be author in a specific way for the best result (refer to the documentation).
  46886. */
  46887. diffuseTexture: Nullable<BaseTexture>;
  46888. protected _shadowLights: Nullable<IShadowLight[]>;
  46889. /**
  46890. * Specify the list of lights casting shadow on the material.
  46891. * All scene shadow lights will be included if null.
  46892. */
  46893. shadowLights: Nullable<IShadowLight[]>;
  46894. protected _shadowLevel: float;
  46895. /**
  46896. * Helps adjusting the shadow to a softer level if required.
  46897. * 0 means black shadows and 1 means no shadows.
  46898. */
  46899. shadowLevel: float;
  46900. protected _sceneCenter: Vector3;
  46901. /**
  46902. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  46903. * It is usually zero but might be interesting to modify according to your setup.
  46904. */
  46905. sceneCenter: Vector3;
  46906. protected _opacityFresnel: boolean;
  46907. /**
  46908. * This helps specifying that the material is falling off to the sky box at grazing angle.
  46909. * This helps ensuring a nice transition when the camera goes under the ground.
  46910. */
  46911. opacityFresnel: boolean;
  46912. protected _reflectionFresnel: boolean;
  46913. /**
  46914. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  46915. * This helps adding a mirror texture on the ground.
  46916. */
  46917. reflectionFresnel: boolean;
  46918. protected _reflectionFalloffDistance: number;
  46919. /**
  46920. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  46921. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  46922. */
  46923. reflectionFalloffDistance: number;
  46924. protected _reflectionAmount: number;
  46925. /**
  46926. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  46927. */
  46928. reflectionAmount: number;
  46929. protected _reflectionReflectance0: number;
  46930. /**
  46931. * This specifies the weight of the reflection at grazing angle.
  46932. */
  46933. reflectionReflectance0: number;
  46934. protected _reflectionReflectance90: number;
  46935. /**
  46936. * This specifies the weight of the reflection at a perpendicular point of view.
  46937. */
  46938. reflectionReflectance90: number;
  46939. /**
  46940. * Sets the reflection reflectance fresnel values according to the default standard
  46941. * empirically know to work well :-)
  46942. */
  46943. reflectionStandardFresnelWeight: number;
  46944. protected _useRGBColor: boolean;
  46945. /**
  46946. * Helps to directly use the maps channels instead of their level.
  46947. */
  46948. useRGBColor: boolean;
  46949. protected _enableNoise: boolean;
  46950. /**
  46951. * This helps reducing the banding effect that could occur on the background.
  46952. */
  46953. enableNoise: boolean;
  46954. /**
  46955. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46956. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  46957. * Recommended to be keep at 1.0 except for special cases.
  46958. */
  46959. fovMultiplier: number;
  46960. private _fovMultiplier;
  46961. /**
  46962. * Enable the FOV adjustment feature controlled by fovMultiplier.
  46963. */
  46964. useEquirectangularFOV: boolean;
  46965. private _maxSimultaneousLights;
  46966. /**
  46967. * Number of Simultaneous lights allowed on the material.
  46968. */
  46969. maxSimultaneousLights: int;
  46970. /**
  46971. * Default configuration related to image processing available in the Background Material.
  46972. */
  46973. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  46974. /**
  46975. * Keep track of the image processing observer to allow dispose and replace.
  46976. */
  46977. private _imageProcessingObserver;
  46978. /**
  46979. * Attaches a new image processing configuration to the PBR Material.
  46980. * @param configuration (if null the scene configuration will be use)
  46981. */
  46982. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  46983. /**
  46984. * Gets the image processing configuration used either in this material.
  46985. */
  46986. /**
  46987. * Sets the Default image processing configuration used either in the this material.
  46988. *
  46989. * If sets to null, the scene one is in use.
  46990. */
  46991. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  46992. /**
  46993. * Gets wether the color curves effect is enabled.
  46994. */
  46995. /**
  46996. * Sets wether the color curves effect is enabled.
  46997. */
  46998. cameraColorCurvesEnabled: boolean;
  46999. /**
  47000. * Gets wether the color grading effect is enabled.
  47001. */
  47002. /**
  47003. * Gets wether the color grading effect is enabled.
  47004. */
  47005. cameraColorGradingEnabled: boolean;
  47006. /**
  47007. * Gets wether tonemapping is enabled or not.
  47008. */
  47009. /**
  47010. * Sets wether tonemapping is enabled or not
  47011. */
  47012. cameraToneMappingEnabled: boolean;
  47013. /**
  47014. * The camera exposure used on this material.
  47015. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47016. * This corresponds to a photographic exposure.
  47017. */
  47018. /**
  47019. * The camera exposure used on this material.
  47020. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47021. * This corresponds to a photographic exposure.
  47022. */
  47023. cameraExposure: float;
  47024. /**
  47025. * Gets The camera contrast used on this material.
  47026. */
  47027. /**
  47028. * Sets The camera contrast used on this material.
  47029. */
  47030. cameraContrast: float;
  47031. /**
  47032. * Gets the Color Grading 2D Lookup Texture.
  47033. */
  47034. /**
  47035. * Sets the Color Grading 2D Lookup Texture.
  47036. */
  47037. cameraColorGradingTexture: Nullable<BaseTexture>;
  47038. /**
  47039. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47040. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47041. * 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;
  47042. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47043. */
  47044. /**
  47045. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47046. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47047. * 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;
  47048. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47049. */
  47050. cameraColorCurves: Nullable<ColorCurves>;
  47051. /**
  47052. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  47053. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  47054. */
  47055. switchToBGR: boolean;
  47056. private _renderTargets;
  47057. private _reflectionControls;
  47058. private _white;
  47059. private _primaryShadowColor;
  47060. private _primaryHighlightColor;
  47061. /**
  47062. * Instantiates a Background Material in the given scene
  47063. * @param name The friendly name of the material
  47064. * @param scene The scene to add the material to
  47065. */
  47066. constructor(name: string, scene: Scene);
  47067. /**
  47068. * Gets a boolean indicating that current material needs to register RTT
  47069. */
  47070. readonly hasRenderTargetTextures: boolean;
  47071. /**
  47072. * The entire material has been created in order to prevent overdraw.
  47073. * @returns false
  47074. */
  47075. needAlphaTesting(): boolean;
  47076. /**
  47077. * The entire material has been created in order to prevent overdraw.
  47078. * @returns true if blending is enable
  47079. */
  47080. needAlphaBlending(): boolean;
  47081. /**
  47082. * Checks wether the material is ready to be rendered for a given mesh.
  47083. * @param mesh The mesh to render
  47084. * @param subMesh The submesh to check against
  47085. * @param useInstances Specify wether or not the material is used with instances
  47086. * @returns true if all the dependencies are ready (Textures, Effects...)
  47087. */
  47088. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  47089. /**
  47090. * Compute the primary color according to the chosen perceptual color.
  47091. */
  47092. private _computePrimaryColorFromPerceptualColor;
  47093. /**
  47094. * Compute the highlights and shadow colors according to their chosen levels.
  47095. */
  47096. private _computePrimaryColors;
  47097. /**
  47098. * Build the uniform buffer used in the material.
  47099. */
  47100. buildUniformLayout(): void;
  47101. /**
  47102. * Unbind the material.
  47103. */
  47104. unbind(): void;
  47105. /**
  47106. * Bind only the world matrix to the material.
  47107. * @param world The world matrix to bind.
  47108. */
  47109. bindOnlyWorldMatrix(world: Matrix): void;
  47110. /**
  47111. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  47112. * @param world The world matrix to bind.
  47113. * @param subMesh The submesh to bind for.
  47114. */
  47115. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  47116. /**
  47117. * Checks to see if a texture is used in the material.
  47118. * @param texture - Base texture to use.
  47119. * @returns - Boolean specifying if a texture is used in the material.
  47120. */
  47121. hasTexture(texture: BaseTexture): boolean;
  47122. /**
  47123. * Dispose the material.
  47124. * @param forceDisposeEffect Force disposal of the associated effect.
  47125. * @param forceDisposeTextures Force disposal of the associated textures.
  47126. */
  47127. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  47128. /**
  47129. * Clones the material.
  47130. * @param name The cloned name.
  47131. * @returns The cloned material.
  47132. */
  47133. clone(name: string): BackgroundMaterial;
  47134. /**
  47135. * Serializes the current material to its JSON representation.
  47136. * @returns The JSON representation.
  47137. */
  47138. serialize(): any;
  47139. /**
  47140. * Gets the class name of the material
  47141. * @returns "BackgroundMaterial"
  47142. */
  47143. getClassName(): string;
  47144. /**
  47145. * Parse a JSON input to create back a background material.
  47146. * @param source The JSON data to parse
  47147. * @param scene The scene to create the parsed material in
  47148. * @param rootUrl The root url of the assets the material depends upon
  47149. * @returns the instantiated BackgroundMaterial.
  47150. */
  47151. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  47152. }
  47153. }
  47154. declare module BABYLON {
  47155. /**
  47156. * Represents the different options available during the creation of
  47157. * a Environment helper.
  47158. *
  47159. * This can control the default ground, skybox and image processing setup of your scene.
  47160. */
  47161. export interface IEnvironmentHelperOptions {
  47162. /**
  47163. * Specifies wether or not to create a ground.
  47164. * True by default.
  47165. */
  47166. createGround: boolean;
  47167. /**
  47168. * Specifies the ground size.
  47169. * 15 by default.
  47170. */
  47171. groundSize: number;
  47172. /**
  47173. * The texture used on the ground for the main color.
  47174. * Comes from the BabylonJS CDN by default.
  47175. *
  47176. * Remarks: Can be either a texture or a url.
  47177. */
  47178. groundTexture: string | BaseTexture;
  47179. /**
  47180. * The color mixed in the ground texture by default.
  47181. * BabylonJS clearColor by default.
  47182. */
  47183. groundColor: Color3;
  47184. /**
  47185. * Specifies the ground opacity.
  47186. * 1 by default.
  47187. */
  47188. groundOpacity: number;
  47189. /**
  47190. * Enables the ground to receive shadows.
  47191. * True by default.
  47192. */
  47193. enableGroundShadow: boolean;
  47194. /**
  47195. * Helps preventing the shadow to be fully black on the ground.
  47196. * 0.5 by default.
  47197. */
  47198. groundShadowLevel: number;
  47199. /**
  47200. * Creates a mirror texture attach to the ground.
  47201. * false by default.
  47202. */
  47203. enableGroundMirror: boolean;
  47204. /**
  47205. * Specifies the ground mirror size ratio.
  47206. * 0.3 by default as the default kernel is 64.
  47207. */
  47208. groundMirrorSizeRatio: number;
  47209. /**
  47210. * Specifies the ground mirror blur kernel size.
  47211. * 64 by default.
  47212. */
  47213. groundMirrorBlurKernel: number;
  47214. /**
  47215. * Specifies the ground mirror visibility amount.
  47216. * 1 by default
  47217. */
  47218. groundMirrorAmount: number;
  47219. /**
  47220. * Specifies the ground mirror reflectance weight.
  47221. * This uses the standard weight of the background material to setup the fresnel effect
  47222. * of the mirror.
  47223. * 1 by default.
  47224. */
  47225. groundMirrorFresnelWeight: number;
  47226. /**
  47227. * Specifies the ground mirror Falloff distance.
  47228. * This can helps reducing the size of the reflection.
  47229. * 0 by Default.
  47230. */
  47231. groundMirrorFallOffDistance: number;
  47232. /**
  47233. * Specifies the ground mirror texture type.
  47234. * Unsigned Int by Default.
  47235. */
  47236. groundMirrorTextureType: number;
  47237. /**
  47238. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  47239. * the shown objects.
  47240. */
  47241. groundYBias: number;
  47242. /**
  47243. * Specifies wether or not to create a skybox.
  47244. * True by default.
  47245. */
  47246. createSkybox: boolean;
  47247. /**
  47248. * Specifies the skybox size.
  47249. * 20 by default.
  47250. */
  47251. skyboxSize: number;
  47252. /**
  47253. * The texture used on the skybox for the main color.
  47254. * Comes from the BabylonJS CDN by default.
  47255. *
  47256. * Remarks: Can be either a texture or a url.
  47257. */
  47258. skyboxTexture: string | BaseTexture;
  47259. /**
  47260. * The color mixed in the skybox texture by default.
  47261. * BabylonJS clearColor by default.
  47262. */
  47263. skyboxColor: Color3;
  47264. /**
  47265. * The background rotation around the Y axis of the scene.
  47266. * This helps aligning the key lights of your scene with the background.
  47267. * 0 by default.
  47268. */
  47269. backgroundYRotation: number;
  47270. /**
  47271. * Compute automatically the size of the elements to best fit with the scene.
  47272. */
  47273. sizeAuto: boolean;
  47274. /**
  47275. * Default position of the rootMesh if autoSize is not true.
  47276. */
  47277. rootPosition: Vector3;
  47278. /**
  47279. * Sets up the image processing in the scene.
  47280. * true by default.
  47281. */
  47282. setupImageProcessing: boolean;
  47283. /**
  47284. * The texture used as your environment texture in the scene.
  47285. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  47286. *
  47287. * Remarks: Can be either a texture or a url.
  47288. */
  47289. environmentTexture: string | BaseTexture;
  47290. /**
  47291. * The value of the exposure to apply to the scene.
  47292. * 0.6 by default if setupImageProcessing is true.
  47293. */
  47294. cameraExposure: number;
  47295. /**
  47296. * The value of the contrast to apply to the scene.
  47297. * 1.6 by default if setupImageProcessing is true.
  47298. */
  47299. cameraContrast: number;
  47300. /**
  47301. * Specifies wether or not tonemapping should be enabled in the scene.
  47302. * true by default if setupImageProcessing is true.
  47303. */
  47304. toneMappingEnabled: boolean;
  47305. }
  47306. /**
  47307. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  47308. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  47309. * It also helps with the default setup of your imageProcessing configuration.
  47310. */
  47311. export class EnvironmentHelper {
  47312. /**
  47313. * Default ground texture URL.
  47314. */
  47315. private static _groundTextureCDNUrl;
  47316. /**
  47317. * Default skybox texture URL.
  47318. */
  47319. private static _skyboxTextureCDNUrl;
  47320. /**
  47321. * Default environment texture URL.
  47322. */
  47323. private static _environmentTextureCDNUrl;
  47324. /**
  47325. * Creates the default options for the helper.
  47326. */
  47327. private static _getDefaultOptions;
  47328. private _rootMesh;
  47329. /**
  47330. * Gets the root mesh created by the helper.
  47331. */
  47332. readonly rootMesh: Mesh;
  47333. private _skybox;
  47334. /**
  47335. * Gets the skybox created by the helper.
  47336. */
  47337. readonly skybox: Nullable<Mesh>;
  47338. private _skyboxTexture;
  47339. /**
  47340. * Gets the skybox texture created by the helper.
  47341. */
  47342. readonly skyboxTexture: Nullable<BaseTexture>;
  47343. private _skyboxMaterial;
  47344. /**
  47345. * Gets the skybox material created by the helper.
  47346. */
  47347. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  47348. private _ground;
  47349. /**
  47350. * Gets the ground mesh created by the helper.
  47351. */
  47352. readonly ground: Nullable<Mesh>;
  47353. private _groundTexture;
  47354. /**
  47355. * Gets the ground texture created by the helper.
  47356. */
  47357. readonly groundTexture: Nullable<BaseTexture>;
  47358. private _groundMirror;
  47359. /**
  47360. * Gets the ground mirror created by the helper.
  47361. */
  47362. readonly groundMirror: Nullable<MirrorTexture>;
  47363. /**
  47364. * Gets the ground mirror render list to helps pushing the meshes
  47365. * you wish in the ground reflection.
  47366. */
  47367. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  47368. private _groundMaterial;
  47369. /**
  47370. * Gets the ground material created by the helper.
  47371. */
  47372. readonly groundMaterial: Nullable<BackgroundMaterial>;
  47373. /**
  47374. * Stores the creation options.
  47375. */
  47376. private readonly _scene;
  47377. private _options;
  47378. /**
  47379. * This observable will be notified with any error during the creation of the environment,
  47380. * mainly texture creation errors.
  47381. */
  47382. onErrorObservable: Observable<{
  47383. message?: string;
  47384. exception?: any;
  47385. }>;
  47386. /**
  47387. * constructor
  47388. * @param options Defines the options we want to customize the helper
  47389. * @param scene The scene to add the material to
  47390. */
  47391. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  47392. /**
  47393. * Updates the background according to the new options
  47394. * @param options
  47395. */
  47396. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  47397. /**
  47398. * Sets the primary color of all the available elements.
  47399. * @param color the main color to affect to the ground and the background
  47400. */
  47401. setMainColor(color: Color3): void;
  47402. /**
  47403. * Setup the image processing according to the specified options.
  47404. */
  47405. private _setupImageProcessing;
  47406. /**
  47407. * Setup the environment texture according to the specified options.
  47408. */
  47409. private _setupEnvironmentTexture;
  47410. /**
  47411. * Setup the background according to the specified options.
  47412. */
  47413. private _setupBackground;
  47414. /**
  47415. * Get the scene sizes according to the setup.
  47416. */
  47417. private _getSceneSize;
  47418. /**
  47419. * Setup the ground according to the specified options.
  47420. */
  47421. private _setupGround;
  47422. /**
  47423. * Setup the ground material according to the specified options.
  47424. */
  47425. private _setupGroundMaterial;
  47426. /**
  47427. * Setup the ground diffuse texture according to the specified options.
  47428. */
  47429. private _setupGroundDiffuseTexture;
  47430. /**
  47431. * Setup the ground mirror texture according to the specified options.
  47432. */
  47433. private _setupGroundMirrorTexture;
  47434. /**
  47435. * Setup the ground to receive the mirror texture.
  47436. */
  47437. private _setupMirrorInGroundMaterial;
  47438. /**
  47439. * Setup the skybox according to the specified options.
  47440. */
  47441. private _setupSkybox;
  47442. /**
  47443. * Setup the skybox material according to the specified options.
  47444. */
  47445. private _setupSkyboxMaterial;
  47446. /**
  47447. * Setup the skybox reflection texture according to the specified options.
  47448. */
  47449. private _setupSkyboxReflectionTexture;
  47450. private _errorHandler;
  47451. /**
  47452. * Dispose all the elements created by the Helper.
  47453. */
  47454. dispose(): void;
  47455. }
  47456. }
  47457. declare module BABYLON {
  47458. /**
  47459. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  47460. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  47461. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  47462. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  47463. */
  47464. export class PhotoDome extends TransformNode {
  47465. /**
  47466. * Define the image as a Monoscopic panoramic 360 image.
  47467. */
  47468. static readonly MODE_MONOSCOPIC: number;
  47469. /**
  47470. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  47471. */
  47472. static readonly MODE_TOPBOTTOM: number;
  47473. /**
  47474. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  47475. */
  47476. static readonly MODE_SIDEBYSIDE: number;
  47477. private _useDirectMapping;
  47478. /**
  47479. * The texture being displayed on the sphere
  47480. */
  47481. protected _photoTexture: Texture;
  47482. /**
  47483. * Gets or sets the texture being displayed on the sphere
  47484. */
  47485. photoTexture: Texture;
  47486. /**
  47487. * Observable raised when an error occured while loading the 360 image
  47488. */
  47489. onLoadErrorObservable: Observable<string>;
  47490. /**
  47491. * The skybox material
  47492. */
  47493. protected _material: BackgroundMaterial;
  47494. /**
  47495. * The surface used for the skybox
  47496. */
  47497. protected _mesh: Mesh;
  47498. /**
  47499. * Gets the mesh used for the skybox.
  47500. */
  47501. readonly mesh: Mesh;
  47502. /**
  47503. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47504. * Also see the options.resolution property.
  47505. */
  47506. fovMultiplier: number;
  47507. private _imageMode;
  47508. /**
  47509. * Gets or set the current video mode for the video. It can be:
  47510. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  47511. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  47512. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  47513. */
  47514. imageMode: number;
  47515. /**
  47516. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  47517. * @param name Element's name, child elements will append suffixes for their own names.
  47518. * @param urlsOfPhoto defines the url of the photo to display
  47519. * @param options defines an object containing optional or exposed sub element properties
  47520. * @param onError defines a callback called when an error occured while loading the texture
  47521. */
  47522. constructor(name: string, urlOfPhoto: string, options: {
  47523. resolution?: number;
  47524. size?: number;
  47525. useDirectMapping?: boolean;
  47526. faceForward?: boolean;
  47527. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  47528. private _onBeforeCameraRenderObserver;
  47529. private _changeImageMode;
  47530. /**
  47531. * Releases resources associated with this node.
  47532. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  47533. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  47534. */
  47535. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  47536. }
  47537. }
  47538. declare module BABYLON {
  47539. /**
  47540. * Class used to host RGBD texture specific utilities
  47541. */
  47542. export class RGBDTextureTools {
  47543. /**
  47544. * Expand the RGBD Texture from RGBD to Half Float if possible.
  47545. * @param texture the texture to expand.
  47546. */
  47547. static ExpandRGBDTexture(texture: Texture): void;
  47548. }
  47549. }
  47550. declare module BABYLON {
  47551. /**
  47552. * Class used to host texture specific utilities
  47553. */
  47554. export class BRDFTextureTools {
  47555. /**
  47556. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  47557. * @param scene defines the hosting scene
  47558. * @returns the environment BRDF texture
  47559. */
  47560. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  47561. private static _environmentBRDFBase64Texture;
  47562. }
  47563. }
  47564. declare module BABYLON {
  47565. /**
  47566. * @hidden
  47567. */
  47568. export interface IMaterialClearCoatDefines {
  47569. CLEARCOAT: boolean;
  47570. CLEARCOAT_DEFAULTIOR: boolean;
  47571. CLEARCOAT_TEXTURE: boolean;
  47572. CLEARCOAT_TEXTUREDIRECTUV: number;
  47573. CLEARCOAT_BUMP: boolean;
  47574. CLEARCOAT_BUMPDIRECTUV: number;
  47575. CLEARCOAT_TINT: boolean;
  47576. CLEARCOAT_TINT_TEXTURE: boolean;
  47577. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  47578. /** @hidden */
  47579. _areTexturesDirty: boolean;
  47580. }
  47581. /**
  47582. * Define the code related to the clear coat parameters of the pbr material.
  47583. */
  47584. export class PBRClearCoatConfiguration {
  47585. /**
  47586. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  47587. * The default fits with a polyurethane material.
  47588. */
  47589. private static readonly _DefaultIndexOfRefraction;
  47590. private _isEnabled;
  47591. /**
  47592. * Defines if the clear coat is enabled in the material.
  47593. */
  47594. isEnabled: boolean;
  47595. /**
  47596. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  47597. */
  47598. intensity: number;
  47599. /**
  47600. * Defines the clear coat layer roughness.
  47601. */
  47602. roughness: number;
  47603. private _indexOfRefraction;
  47604. /**
  47605. * Defines the index of refraction of the clear coat.
  47606. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  47607. * The default fits with a polyurethane material.
  47608. * Changing the default value is more performance intensive.
  47609. */
  47610. indexOfRefraction: number;
  47611. private _texture;
  47612. /**
  47613. * Stores the clear coat values in a texture.
  47614. */
  47615. texture: Nullable<BaseTexture>;
  47616. private _bumpTexture;
  47617. /**
  47618. * Define the clear coat specific bump texture.
  47619. */
  47620. bumpTexture: Nullable<BaseTexture>;
  47621. private _isTintEnabled;
  47622. /**
  47623. * Defines if the clear coat tint is enabled in the material.
  47624. */
  47625. isTintEnabled: boolean;
  47626. /**
  47627. * Defines the clear coat tint of the material.
  47628. * This is only use if tint is enabled
  47629. */
  47630. tintColor: Color3;
  47631. /**
  47632. * Defines the distance at which the tint color should be found in the
  47633. * clear coat media.
  47634. * This is only use if tint is enabled
  47635. */
  47636. tintColorAtDistance: number;
  47637. /**
  47638. * Defines the clear coat layer thickness.
  47639. * This is only use if tint is enabled
  47640. */
  47641. tintThickness: number;
  47642. private _tintTexture;
  47643. /**
  47644. * Stores the clear tint values in a texture.
  47645. * rgb is tint
  47646. * a is a thickness factor
  47647. */
  47648. tintTexture: Nullable<BaseTexture>;
  47649. /** @hidden */
  47650. private _internalMarkAllSubMeshesAsTexturesDirty;
  47651. /** @hidden */
  47652. _markAllSubMeshesAsTexturesDirty(): void;
  47653. /**
  47654. * Instantiate a new istance of clear coat configuration.
  47655. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47656. */
  47657. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47658. /**
  47659. * Gets wehter the submesh is ready to be used or not.
  47660. * @param defines the list of "defines" to update.
  47661. * @param scene defines the scene the material belongs to.
  47662. * @param engine defines the engine the material belongs to.
  47663. * @param disableBumpMap defines wether the material disables bump or not.
  47664. * @returns - boolean indicating that the submesh is ready or not.
  47665. */
  47666. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  47667. /**
  47668. * Checks to see if a texture is used in the material.
  47669. * @param defines the list of "defines" to update.
  47670. * @param scene defines the scene to the material belongs to.
  47671. */
  47672. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  47673. /**
  47674. * Binds the material data.
  47675. * @param uniformBuffer defines the Uniform buffer to fill in.
  47676. * @param scene defines the scene the material belongs to.
  47677. * @param engine defines the engine the material belongs to.
  47678. * @param disableBumpMap defines wether the material disables bump or not.
  47679. * @param isFrozen defines wether the material is frozen or not.
  47680. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  47681. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  47682. */
  47683. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  47684. /**
  47685. * Checks to see if a texture is used in the material.
  47686. * @param texture - Base texture to use.
  47687. * @returns - Boolean specifying if a texture is used in the material.
  47688. */
  47689. hasTexture(texture: BaseTexture): boolean;
  47690. /**
  47691. * Returns an array of the actively used textures.
  47692. * @param activeTextures Array of BaseTextures
  47693. */
  47694. getActiveTextures(activeTextures: BaseTexture[]): void;
  47695. /**
  47696. * Returns the animatable textures.
  47697. * @param animatables Array of animatable textures.
  47698. */
  47699. getAnimatables(animatables: IAnimatable[]): void;
  47700. /**
  47701. * Disposes the resources of the material.
  47702. * @param forceDisposeTextures - Forces the disposal of all textures.
  47703. */
  47704. dispose(forceDisposeTextures?: boolean): void;
  47705. /**
  47706. * Get the current class name of the texture useful for serialization or dynamic coding.
  47707. * @returns "PBRClearCoatConfiguration"
  47708. */
  47709. getClassName(): string;
  47710. /**
  47711. * Add fallbacks to the effect fallbacks list.
  47712. * @param defines defines the Base texture to use.
  47713. * @param fallbacks defines the current fallback list.
  47714. * @param currentRank defines the current fallback rank.
  47715. * @returns the new fallback rank.
  47716. */
  47717. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47718. /**
  47719. * Add the required uniforms to the current list.
  47720. * @param uniforms defines the current uniform list.
  47721. */
  47722. static AddUniforms(uniforms: string[]): void;
  47723. /**
  47724. * Add the required samplers to the current list.
  47725. * @param samplers defines the current sampler list.
  47726. */
  47727. static AddSamplers(samplers: string[]): void;
  47728. /**
  47729. * Add the required uniforms to the current buffer.
  47730. * @param uniformBuffer defines the current uniform buffer.
  47731. */
  47732. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47733. /**
  47734. * Makes a duplicate of the current configuration into another one.
  47735. * @param clearCoatConfiguration define the config where to copy the info
  47736. */
  47737. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  47738. /**
  47739. * Serializes this clear coat configuration.
  47740. * @returns - An object with the serialized config.
  47741. */
  47742. serialize(): any;
  47743. /**
  47744. * Parses a anisotropy Configuration from a serialized object.
  47745. * @param source - Serialized object.
  47746. * @param scene Defines the scene we are parsing for
  47747. * @param rootUrl Defines the rootUrl to load from
  47748. */
  47749. parse(source: any, scene: Scene, rootUrl: string): void;
  47750. }
  47751. }
  47752. declare module BABYLON {
  47753. /**
  47754. * @hidden
  47755. */
  47756. export interface IMaterialAnisotropicDefines {
  47757. ANISOTROPIC: boolean;
  47758. ANISOTROPIC_TEXTURE: boolean;
  47759. ANISOTROPIC_TEXTUREDIRECTUV: number;
  47760. MAINUV1: boolean;
  47761. _areTexturesDirty: boolean;
  47762. _needUVs: boolean;
  47763. }
  47764. /**
  47765. * Define the code related to the anisotropic parameters of the pbr material.
  47766. */
  47767. export class PBRAnisotropicConfiguration {
  47768. private _isEnabled;
  47769. /**
  47770. * Defines if the anisotropy is enabled in the material.
  47771. */
  47772. isEnabled: boolean;
  47773. /**
  47774. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  47775. */
  47776. intensity: number;
  47777. /**
  47778. * Defines if the effect is along the tangents, bitangents or in between.
  47779. * By default, the effect is "strectching" the highlights along the tangents.
  47780. */
  47781. direction: Vector2;
  47782. private _texture;
  47783. /**
  47784. * Stores the anisotropy values in a texture.
  47785. * rg is direction (like normal from -1 to 1)
  47786. * b is a intensity
  47787. */
  47788. texture: Nullable<BaseTexture>;
  47789. /** @hidden */
  47790. private _internalMarkAllSubMeshesAsTexturesDirty;
  47791. /** @hidden */
  47792. _markAllSubMeshesAsTexturesDirty(): void;
  47793. /**
  47794. * Instantiate a new istance of anisotropy configuration.
  47795. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47796. */
  47797. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47798. /**
  47799. * Specifies that the submesh is ready to be used.
  47800. * @param defines the list of "defines" to update.
  47801. * @param scene defines the scene the material belongs to.
  47802. * @returns - boolean indicating that the submesh is ready or not.
  47803. */
  47804. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  47805. /**
  47806. * Checks to see if a texture is used in the material.
  47807. * @param defines the list of "defines" to update.
  47808. * @param mesh the mesh we are preparing the defines for.
  47809. * @param scene defines the scene the material belongs to.
  47810. */
  47811. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  47812. /**
  47813. * Binds the material data.
  47814. * @param uniformBuffer defines the Uniform buffer to fill in.
  47815. * @param scene defines the scene the material belongs to.
  47816. * @param isFrozen defines wether the material is frozen or not.
  47817. */
  47818. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  47819. /**
  47820. * Checks to see if a texture is used in the material.
  47821. * @param texture - Base texture to use.
  47822. * @returns - Boolean specifying if a texture is used in the material.
  47823. */
  47824. hasTexture(texture: BaseTexture): boolean;
  47825. /**
  47826. * Returns an array of the actively used textures.
  47827. * @param activeTextures Array of BaseTextures
  47828. */
  47829. getActiveTextures(activeTextures: BaseTexture[]): void;
  47830. /**
  47831. * Returns the animatable textures.
  47832. * @param animatables Array of animatable textures.
  47833. */
  47834. getAnimatables(animatables: IAnimatable[]): void;
  47835. /**
  47836. * Disposes the resources of the material.
  47837. * @param forceDisposeTextures - Forces the disposal of all textures.
  47838. */
  47839. dispose(forceDisposeTextures?: boolean): void;
  47840. /**
  47841. * Get the current class name of the texture useful for serialization or dynamic coding.
  47842. * @returns "PBRAnisotropicConfiguration"
  47843. */
  47844. getClassName(): string;
  47845. /**
  47846. * Add fallbacks to the effect fallbacks list.
  47847. * @param defines defines the Base texture to use.
  47848. * @param fallbacks defines the current fallback list.
  47849. * @param currentRank defines the current fallback rank.
  47850. * @returns the new fallback rank.
  47851. */
  47852. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47853. /**
  47854. * Add the required uniforms to the current list.
  47855. * @param uniforms defines the current uniform list.
  47856. */
  47857. static AddUniforms(uniforms: string[]): void;
  47858. /**
  47859. * Add the required uniforms to the current buffer.
  47860. * @param uniformBuffer defines the current uniform buffer.
  47861. */
  47862. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47863. /**
  47864. * Add the required samplers to the current list.
  47865. * @param samplers defines the current sampler list.
  47866. */
  47867. static AddSamplers(samplers: string[]): void;
  47868. /**
  47869. * Makes a duplicate of the current configuration into another one.
  47870. * @param anisotropicConfiguration define the config where to copy the info
  47871. */
  47872. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  47873. /**
  47874. * Serializes this anisotropy configuration.
  47875. * @returns - An object with the serialized config.
  47876. */
  47877. serialize(): any;
  47878. /**
  47879. * Parses a anisotropy Configuration from a serialized object.
  47880. * @param source - Serialized object.
  47881. * @param scene Defines the scene we are parsing for
  47882. * @param rootUrl Defines the rootUrl to load from
  47883. */
  47884. parse(source: any, scene: Scene, rootUrl: string): void;
  47885. }
  47886. }
  47887. declare module BABYLON {
  47888. /**
  47889. * @hidden
  47890. */
  47891. export interface IMaterialBRDFDefines {
  47892. BRDF_V_HEIGHT_CORRELATED: boolean;
  47893. MS_BRDF_ENERGY_CONSERVATION: boolean;
  47894. SPHERICAL_HARMONICS: boolean;
  47895. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  47896. /** @hidden */
  47897. _areMiscDirty: boolean;
  47898. }
  47899. /**
  47900. * Define the code related to the BRDF parameters of the pbr material.
  47901. */
  47902. export class PBRBRDFConfiguration {
  47903. /**
  47904. * Default value used for the energy conservation.
  47905. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  47906. */
  47907. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  47908. /**
  47909. * Default value used for the Smith Visibility Height Correlated mode.
  47910. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  47911. */
  47912. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  47913. /**
  47914. * Default value used for the IBL diffuse part.
  47915. * This can help switching back to the polynomials mode globally which is a tiny bit
  47916. * less GPU intensive at the drawback of a lower quality.
  47917. */
  47918. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  47919. /**
  47920. * Default value used for activating energy conservation for the specular workflow.
  47921. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  47922. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  47923. */
  47924. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  47925. private _useEnergyConservation;
  47926. /**
  47927. * Defines if the material uses energy conservation.
  47928. */
  47929. useEnergyConservation: boolean;
  47930. private _useSmithVisibilityHeightCorrelated;
  47931. /**
  47932. * LEGACY Mode set to false
  47933. * Defines if the material uses height smith correlated visibility term.
  47934. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  47935. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  47936. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  47937. * Not relying on height correlated will also disable energy conservation.
  47938. */
  47939. useSmithVisibilityHeightCorrelated: boolean;
  47940. private _useSphericalHarmonics;
  47941. /**
  47942. * LEGACY Mode set to false
  47943. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  47944. * diffuse part of the IBL.
  47945. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  47946. * to the ground truth.
  47947. */
  47948. useSphericalHarmonics: boolean;
  47949. private _useSpecularGlossinessInputEnergyConservation;
  47950. /**
  47951. * Defines if the material uses energy conservation, when the specular workflow is active.
  47952. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  47953. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  47954. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  47955. */
  47956. useSpecularGlossinessInputEnergyConservation: boolean;
  47957. /** @hidden */
  47958. private _internalMarkAllSubMeshesAsMiscDirty;
  47959. /** @hidden */
  47960. _markAllSubMeshesAsMiscDirty(): void;
  47961. /**
  47962. * Instantiate a new istance of clear coat configuration.
  47963. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  47964. */
  47965. constructor(markAllSubMeshesAsMiscDirty: () => void);
  47966. /**
  47967. * Checks to see if a texture is used in the material.
  47968. * @param defines the list of "defines" to update.
  47969. */
  47970. prepareDefines(defines: IMaterialBRDFDefines): void;
  47971. /**
  47972. * Get the current class name of the texture useful for serialization or dynamic coding.
  47973. * @returns "PBRClearCoatConfiguration"
  47974. */
  47975. getClassName(): string;
  47976. /**
  47977. * Makes a duplicate of the current configuration into another one.
  47978. * @param brdfConfiguration define the config where to copy the info
  47979. */
  47980. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  47981. /**
  47982. * Serializes this BRDF configuration.
  47983. * @returns - An object with the serialized config.
  47984. */
  47985. serialize(): any;
  47986. /**
  47987. * Parses a anisotropy Configuration from a serialized object.
  47988. * @param source - Serialized object.
  47989. * @param scene Defines the scene we are parsing for
  47990. * @param rootUrl Defines the rootUrl to load from
  47991. */
  47992. parse(source: any, scene: Scene, rootUrl: string): void;
  47993. }
  47994. }
  47995. declare module BABYLON {
  47996. /**
  47997. * @hidden
  47998. */
  47999. export interface IMaterialSheenDefines {
  48000. SHEEN: boolean;
  48001. SHEEN_TEXTURE: boolean;
  48002. SHEEN_TEXTUREDIRECTUV: number;
  48003. SHEEN_LINKWITHALBEDO: boolean;
  48004. /** @hidden */
  48005. _areTexturesDirty: boolean;
  48006. }
  48007. /**
  48008. * Define the code related to the Sheen parameters of the pbr material.
  48009. */
  48010. export class PBRSheenConfiguration {
  48011. private _isEnabled;
  48012. /**
  48013. * Defines if the material uses sheen.
  48014. */
  48015. isEnabled: boolean;
  48016. private _linkSheenWithAlbedo;
  48017. /**
  48018. * Defines if the sheen is linked to the sheen color.
  48019. */
  48020. linkSheenWithAlbedo: boolean;
  48021. /**
  48022. * Defines the sheen intensity.
  48023. */
  48024. intensity: number;
  48025. /**
  48026. * Defines the sheen color.
  48027. */
  48028. color: Color3;
  48029. private _texture;
  48030. /**
  48031. * Stores the sheen tint values in a texture.
  48032. * rgb is tint
  48033. * a is a intensity
  48034. */
  48035. texture: Nullable<BaseTexture>;
  48036. /** @hidden */
  48037. private _internalMarkAllSubMeshesAsTexturesDirty;
  48038. /** @hidden */
  48039. _markAllSubMeshesAsTexturesDirty(): void;
  48040. /**
  48041. * Instantiate a new istance of clear coat configuration.
  48042. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48043. */
  48044. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48045. /**
  48046. * Specifies that the submesh is ready to be used.
  48047. * @param defines the list of "defines" to update.
  48048. * @param scene defines the scene the material belongs to.
  48049. * @returns - boolean indicating that the submesh is ready or not.
  48050. */
  48051. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  48052. /**
  48053. * Checks to see if a texture is used in the material.
  48054. * @param defines the list of "defines" to update.
  48055. * @param scene defines the scene the material belongs to.
  48056. */
  48057. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  48058. /**
  48059. * Binds the material data.
  48060. * @param uniformBuffer defines the Uniform buffer to fill in.
  48061. * @param scene defines the scene the material belongs to.
  48062. * @param isFrozen defines wether the material is frozen or not.
  48063. */
  48064. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  48065. /**
  48066. * Checks to see if a texture is used in the material.
  48067. * @param texture - Base texture to use.
  48068. * @returns - Boolean specifying if a texture is used in the material.
  48069. */
  48070. hasTexture(texture: BaseTexture): boolean;
  48071. /**
  48072. * Returns an array of the actively used textures.
  48073. * @param activeTextures Array of BaseTextures
  48074. */
  48075. getActiveTextures(activeTextures: BaseTexture[]): void;
  48076. /**
  48077. * Returns the animatable textures.
  48078. * @param animatables Array of animatable textures.
  48079. */
  48080. getAnimatables(animatables: IAnimatable[]): void;
  48081. /**
  48082. * Disposes the resources of the material.
  48083. * @param forceDisposeTextures - Forces the disposal of all textures.
  48084. */
  48085. dispose(forceDisposeTextures?: boolean): void;
  48086. /**
  48087. * Get the current class name of the texture useful for serialization or dynamic coding.
  48088. * @returns "PBRSheenConfiguration"
  48089. */
  48090. getClassName(): string;
  48091. /**
  48092. * Add fallbacks to the effect fallbacks list.
  48093. * @param defines defines the Base texture to use.
  48094. * @param fallbacks defines the current fallback list.
  48095. * @param currentRank defines the current fallback rank.
  48096. * @returns the new fallback rank.
  48097. */
  48098. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48099. /**
  48100. * Add the required uniforms to the current list.
  48101. * @param uniforms defines the current uniform list.
  48102. */
  48103. static AddUniforms(uniforms: string[]): void;
  48104. /**
  48105. * Add the required uniforms to the current buffer.
  48106. * @param uniformBuffer defines the current uniform buffer.
  48107. */
  48108. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48109. /**
  48110. * Add the required samplers to the current list.
  48111. * @param samplers defines the current sampler list.
  48112. */
  48113. static AddSamplers(samplers: string[]): void;
  48114. /**
  48115. * Makes a duplicate of the current configuration into another one.
  48116. * @param sheenConfiguration define the config where to copy the info
  48117. */
  48118. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  48119. /**
  48120. * Serializes this BRDF configuration.
  48121. * @returns - An object with the serialized config.
  48122. */
  48123. serialize(): any;
  48124. /**
  48125. * Parses a anisotropy Configuration from a serialized object.
  48126. * @param source - Serialized object.
  48127. * @param scene Defines the scene we are parsing for
  48128. * @param rootUrl Defines the rootUrl to load from
  48129. */
  48130. parse(source: any, scene: Scene, rootUrl: string): void;
  48131. }
  48132. }
  48133. declare module BABYLON {
  48134. /**
  48135. * @hidden
  48136. */
  48137. export interface IMaterialSubSurfaceDefines {
  48138. SUBSURFACE: boolean;
  48139. SS_REFRACTION: boolean;
  48140. SS_TRANSLUCENCY: boolean;
  48141. SS_SCATERRING: boolean;
  48142. SS_THICKNESSANDMASK_TEXTURE: boolean;
  48143. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  48144. SS_REFRACTIONMAP_3D: boolean;
  48145. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  48146. SS_LODINREFRACTIONALPHA: boolean;
  48147. SS_GAMMAREFRACTION: boolean;
  48148. SS_RGBDREFRACTION: boolean;
  48149. SS_LINEARSPECULARREFRACTION: boolean;
  48150. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  48151. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  48152. /** @hidden */
  48153. _areTexturesDirty: boolean;
  48154. }
  48155. /**
  48156. * Define the code related to the sub surface parameters of the pbr material.
  48157. */
  48158. export class PBRSubSurfaceConfiguration {
  48159. private _isRefractionEnabled;
  48160. /**
  48161. * Defines if the refraction is enabled in the material.
  48162. */
  48163. isRefractionEnabled: boolean;
  48164. private _isTranslucencyEnabled;
  48165. /**
  48166. * Defines if the translucency is enabled in the material.
  48167. */
  48168. isTranslucencyEnabled: boolean;
  48169. private _isScatteringEnabled;
  48170. /**
  48171. * Defines the refraction intensity of the material.
  48172. * The refraction when enabled replaces the Diffuse part of the material.
  48173. * The intensity helps transitionning between diffuse and refraction.
  48174. */
  48175. refractionIntensity: number;
  48176. /**
  48177. * Defines the translucency intensity of the material.
  48178. * When translucency has been enabled, this defines how much of the "translucency"
  48179. * is addded to the diffuse part of the material.
  48180. */
  48181. translucencyIntensity: number;
  48182. /**
  48183. * Defines the scattering intensity of the material.
  48184. * When scattering has been enabled, this defines how much of the "scattered light"
  48185. * is addded to the diffuse part of the material.
  48186. */
  48187. scatteringIntensity: number;
  48188. private _thicknessTexture;
  48189. /**
  48190. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  48191. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  48192. * 0 would mean minimumThickness
  48193. * 1 would mean maximumThickness
  48194. * The other channels might be use as a mask to vary the different effects intensity.
  48195. */
  48196. thicknessTexture: Nullable<BaseTexture>;
  48197. private _refractionTexture;
  48198. /**
  48199. * Defines the texture to use for refraction.
  48200. */
  48201. refractionTexture: Nullable<BaseTexture>;
  48202. private _indexOfRefraction;
  48203. /**
  48204. * Defines the index of refraction used in the material.
  48205. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  48206. */
  48207. indexOfRefraction: number;
  48208. private _invertRefractionY;
  48209. /**
  48210. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  48211. */
  48212. invertRefractionY: boolean;
  48213. private _linkRefractionWithTransparency;
  48214. /**
  48215. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  48216. * Materials half opaque for instance using refraction could benefit from this control.
  48217. */
  48218. linkRefractionWithTransparency: boolean;
  48219. /**
  48220. * Defines the minimum thickness stored in the thickness map.
  48221. * If no thickness map is defined, this value will be used to simulate thickness.
  48222. */
  48223. minimumThickness: number;
  48224. /**
  48225. * Defines the maximum thickness stored in the thickness map.
  48226. */
  48227. maximumThickness: number;
  48228. /**
  48229. * Defines the volume tint of the material.
  48230. * This is used for both translucency and scattering.
  48231. */
  48232. tintColor: Color3;
  48233. /**
  48234. * Defines the distance at which the tint color should be found in the media.
  48235. * This is used for refraction only.
  48236. */
  48237. tintColorAtDistance: number;
  48238. /**
  48239. * Defines how far each channel transmit through the media.
  48240. * It is defined as a color to simplify it selection.
  48241. */
  48242. diffusionDistance: Color3;
  48243. private _useMaskFromThicknessTexture;
  48244. /**
  48245. * Stores the intensity of the different subsurface effects in the thickness texture.
  48246. * * the green channel is the translucency intensity.
  48247. * * the blue channel is the scattering intensity.
  48248. * * the alpha channel is the refraction intensity.
  48249. */
  48250. useMaskFromThicknessTexture: boolean;
  48251. /** @hidden */
  48252. private _internalMarkAllSubMeshesAsTexturesDirty;
  48253. /** @hidden */
  48254. _markAllSubMeshesAsTexturesDirty(): void;
  48255. /**
  48256. * Instantiate a new istance of sub surface configuration.
  48257. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48258. */
  48259. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48260. /**
  48261. * Gets wehter the submesh is ready to be used or not.
  48262. * @param defines the list of "defines" to update.
  48263. * @param scene defines the scene the material belongs to.
  48264. * @returns - boolean indicating that the submesh is ready or not.
  48265. */
  48266. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  48267. /**
  48268. * Checks to see if a texture is used in the material.
  48269. * @param defines the list of "defines" to update.
  48270. * @param scene defines the scene to the material belongs to.
  48271. */
  48272. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  48273. /**
  48274. * Binds the material data.
  48275. * @param uniformBuffer defines the Uniform buffer to fill in.
  48276. * @param scene defines the scene the material belongs to.
  48277. * @param engine defines the engine the material belongs to.
  48278. * @param isFrozen defines wether the material is frozen or not.
  48279. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  48280. */
  48281. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  48282. /**
  48283. * Unbinds the material from the mesh.
  48284. * @param activeEffect defines the effect that should be unbound from.
  48285. * @returns true if unbound, otherwise false
  48286. */
  48287. unbind(activeEffect: Effect): boolean;
  48288. /**
  48289. * Returns the texture used for refraction or null if none is used.
  48290. * @param scene defines the scene the material belongs to.
  48291. * @returns - Refraction texture if present. If no refraction texture and refraction
  48292. * is linked with transparency, returns environment texture. Otherwise, returns null.
  48293. */
  48294. private _getRefractionTexture;
  48295. /**
  48296. * Returns true if alpha blending should be disabled.
  48297. */
  48298. readonly disableAlphaBlending: boolean;
  48299. /**
  48300. * Fills the list of render target textures.
  48301. * @param renderTargets the list of render targets to update
  48302. */
  48303. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  48304. /**
  48305. * Checks to see if a texture is used in the material.
  48306. * @param texture - Base texture to use.
  48307. * @returns - Boolean specifying if a texture is used in the material.
  48308. */
  48309. hasTexture(texture: BaseTexture): boolean;
  48310. /**
  48311. * Gets a boolean indicating that current material needs to register RTT
  48312. * @returns true if this uses a render target otherwise false.
  48313. */
  48314. hasRenderTargetTextures(): boolean;
  48315. /**
  48316. * Returns an array of the actively used textures.
  48317. * @param activeTextures Array of BaseTextures
  48318. */
  48319. getActiveTextures(activeTextures: BaseTexture[]): void;
  48320. /**
  48321. * Returns the animatable textures.
  48322. * @param animatables Array of animatable textures.
  48323. */
  48324. getAnimatables(animatables: IAnimatable[]): void;
  48325. /**
  48326. * Disposes the resources of the material.
  48327. * @param forceDisposeTextures - Forces the disposal of all textures.
  48328. */
  48329. dispose(forceDisposeTextures?: boolean): void;
  48330. /**
  48331. * Get the current class name of the texture useful for serialization or dynamic coding.
  48332. * @returns "PBRSubSurfaceConfiguration"
  48333. */
  48334. getClassName(): string;
  48335. /**
  48336. * Add fallbacks to the effect fallbacks list.
  48337. * @param defines defines the Base texture to use.
  48338. * @param fallbacks defines the current fallback list.
  48339. * @param currentRank defines the current fallback rank.
  48340. * @returns the new fallback rank.
  48341. */
  48342. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48343. /**
  48344. * Add the required uniforms to the current list.
  48345. * @param uniforms defines the current uniform list.
  48346. */
  48347. static AddUniforms(uniforms: string[]): void;
  48348. /**
  48349. * Add the required samplers to the current list.
  48350. * @param samplers defines the current sampler list.
  48351. */
  48352. static AddSamplers(samplers: string[]): void;
  48353. /**
  48354. * Add the required uniforms to the current buffer.
  48355. * @param uniformBuffer defines the current uniform buffer.
  48356. */
  48357. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48358. /**
  48359. * Makes a duplicate of the current configuration into another one.
  48360. * @param configuration define the config where to copy the info
  48361. */
  48362. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  48363. /**
  48364. * Serializes this Sub Surface configuration.
  48365. * @returns - An object with the serialized config.
  48366. */
  48367. serialize(): any;
  48368. /**
  48369. * Parses a anisotropy Configuration from a serialized object.
  48370. * @param source - Serialized object.
  48371. * @param scene Defines the scene we are parsing for
  48372. * @param rootUrl Defines the rootUrl to load from
  48373. */
  48374. parse(source: any, scene: Scene, rootUrl: string): void;
  48375. }
  48376. }
  48377. declare module BABYLON {
  48378. /** @hidden */
  48379. export var pbrFragmentDeclaration: {
  48380. name: string;
  48381. shader: string;
  48382. };
  48383. }
  48384. declare module BABYLON {
  48385. /** @hidden */
  48386. export var pbrUboDeclaration: {
  48387. name: string;
  48388. shader: string;
  48389. };
  48390. }
  48391. declare module BABYLON {
  48392. /** @hidden */
  48393. export var pbrFragmentExtraDeclaration: {
  48394. name: string;
  48395. shader: string;
  48396. };
  48397. }
  48398. declare module BABYLON {
  48399. /** @hidden */
  48400. export var pbrFragmentSamplersDeclaration: {
  48401. name: string;
  48402. shader: string;
  48403. };
  48404. }
  48405. declare module BABYLON {
  48406. /** @hidden */
  48407. export var pbrHelperFunctions: {
  48408. name: string;
  48409. shader: string;
  48410. };
  48411. }
  48412. declare module BABYLON {
  48413. /** @hidden */
  48414. export var harmonicsFunctions: {
  48415. name: string;
  48416. shader: string;
  48417. };
  48418. }
  48419. declare module BABYLON {
  48420. /** @hidden */
  48421. export var pbrDirectLightingSetupFunctions: {
  48422. name: string;
  48423. shader: string;
  48424. };
  48425. }
  48426. declare module BABYLON {
  48427. /** @hidden */
  48428. export var pbrDirectLightingFalloffFunctions: {
  48429. name: string;
  48430. shader: string;
  48431. };
  48432. }
  48433. declare module BABYLON {
  48434. /** @hidden */
  48435. export var pbrBRDFFunctions: {
  48436. name: string;
  48437. shader: string;
  48438. };
  48439. }
  48440. declare module BABYLON {
  48441. /** @hidden */
  48442. export var pbrDirectLightingFunctions: {
  48443. name: string;
  48444. shader: string;
  48445. };
  48446. }
  48447. declare module BABYLON {
  48448. /** @hidden */
  48449. export var pbrIBLFunctions: {
  48450. name: string;
  48451. shader: string;
  48452. };
  48453. }
  48454. declare module BABYLON {
  48455. /** @hidden */
  48456. export var pbrDebug: {
  48457. name: string;
  48458. shader: string;
  48459. };
  48460. }
  48461. declare module BABYLON {
  48462. /** @hidden */
  48463. export var pbrPixelShader: {
  48464. name: string;
  48465. shader: string;
  48466. };
  48467. }
  48468. declare module BABYLON {
  48469. /** @hidden */
  48470. export var pbrVertexDeclaration: {
  48471. name: string;
  48472. shader: string;
  48473. };
  48474. }
  48475. declare module BABYLON {
  48476. /** @hidden */
  48477. export var pbrVertexShader: {
  48478. name: string;
  48479. shader: string;
  48480. };
  48481. }
  48482. declare module BABYLON {
  48483. /**
  48484. * Manages the defines for the PBR Material.
  48485. * @hidden
  48486. */
  48487. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  48488. PBR: boolean;
  48489. MAINUV1: boolean;
  48490. MAINUV2: boolean;
  48491. UV1: boolean;
  48492. UV2: boolean;
  48493. ALBEDO: boolean;
  48494. ALBEDODIRECTUV: number;
  48495. VERTEXCOLOR: boolean;
  48496. AMBIENT: boolean;
  48497. AMBIENTDIRECTUV: number;
  48498. AMBIENTINGRAYSCALE: boolean;
  48499. OPACITY: boolean;
  48500. VERTEXALPHA: boolean;
  48501. OPACITYDIRECTUV: number;
  48502. OPACITYRGB: boolean;
  48503. ALPHATEST: boolean;
  48504. DEPTHPREPASS: boolean;
  48505. ALPHABLEND: boolean;
  48506. ALPHAFROMALBEDO: boolean;
  48507. ALPHATESTVALUE: string;
  48508. SPECULAROVERALPHA: boolean;
  48509. RADIANCEOVERALPHA: boolean;
  48510. ALPHAFRESNEL: boolean;
  48511. LINEARALPHAFRESNEL: boolean;
  48512. PREMULTIPLYALPHA: boolean;
  48513. EMISSIVE: boolean;
  48514. EMISSIVEDIRECTUV: number;
  48515. REFLECTIVITY: boolean;
  48516. REFLECTIVITYDIRECTUV: number;
  48517. SPECULARTERM: boolean;
  48518. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  48519. MICROSURFACEAUTOMATIC: boolean;
  48520. LODBASEDMICROSFURACE: boolean;
  48521. MICROSURFACEMAP: boolean;
  48522. MICROSURFACEMAPDIRECTUV: number;
  48523. METALLICWORKFLOW: boolean;
  48524. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  48525. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  48526. METALLNESSSTOREINMETALMAPBLUE: boolean;
  48527. AOSTOREINMETALMAPRED: boolean;
  48528. METALLICF0FACTORFROMMETALLICMAP: boolean;
  48529. ENVIRONMENTBRDF: boolean;
  48530. ENVIRONMENTBRDF_RGBD: boolean;
  48531. NORMAL: boolean;
  48532. TANGENT: boolean;
  48533. BUMP: boolean;
  48534. BUMPDIRECTUV: number;
  48535. OBJECTSPACE_NORMALMAP: boolean;
  48536. PARALLAX: boolean;
  48537. PARALLAXOCCLUSION: boolean;
  48538. NORMALXYSCALE: boolean;
  48539. LIGHTMAP: boolean;
  48540. LIGHTMAPDIRECTUV: number;
  48541. USELIGHTMAPASSHADOWMAP: boolean;
  48542. GAMMALIGHTMAP: boolean;
  48543. RGBDLIGHTMAP: boolean;
  48544. REFLECTION: boolean;
  48545. REFLECTIONMAP_3D: boolean;
  48546. REFLECTIONMAP_SPHERICAL: boolean;
  48547. REFLECTIONMAP_PLANAR: boolean;
  48548. REFLECTIONMAP_CUBIC: boolean;
  48549. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  48550. REFLECTIONMAP_PROJECTION: boolean;
  48551. REFLECTIONMAP_SKYBOX: boolean;
  48552. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  48553. REFLECTIONMAP_EXPLICIT: boolean;
  48554. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  48555. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  48556. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  48557. INVERTCUBICMAP: boolean;
  48558. USESPHERICALFROMREFLECTIONMAP: boolean;
  48559. USEIRRADIANCEMAP: boolean;
  48560. SPHERICAL_HARMONICS: boolean;
  48561. USESPHERICALINVERTEX: boolean;
  48562. REFLECTIONMAP_OPPOSITEZ: boolean;
  48563. LODINREFLECTIONALPHA: boolean;
  48564. GAMMAREFLECTION: boolean;
  48565. RGBDREFLECTION: boolean;
  48566. LINEARSPECULARREFLECTION: boolean;
  48567. RADIANCEOCCLUSION: boolean;
  48568. HORIZONOCCLUSION: boolean;
  48569. INSTANCES: boolean;
  48570. NUM_BONE_INFLUENCERS: number;
  48571. BonesPerMesh: number;
  48572. BONETEXTURE: boolean;
  48573. NONUNIFORMSCALING: boolean;
  48574. MORPHTARGETS: boolean;
  48575. MORPHTARGETS_NORMAL: boolean;
  48576. MORPHTARGETS_TANGENT: boolean;
  48577. MORPHTARGETS_UV: boolean;
  48578. NUM_MORPH_INFLUENCERS: number;
  48579. IMAGEPROCESSING: boolean;
  48580. VIGNETTE: boolean;
  48581. VIGNETTEBLENDMODEMULTIPLY: boolean;
  48582. VIGNETTEBLENDMODEOPAQUE: boolean;
  48583. TONEMAPPING: boolean;
  48584. TONEMAPPING_ACES: boolean;
  48585. CONTRAST: boolean;
  48586. COLORCURVES: boolean;
  48587. COLORGRADING: boolean;
  48588. COLORGRADING3D: boolean;
  48589. SAMPLER3DGREENDEPTH: boolean;
  48590. SAMPLER3DBGRMAP: boolean;
  48591. IMAGEPROCESSINGPOSTPROCESS: boolean;
  48592. EXPOSURE: boolean;
  48593. MULTIVIEW: boolean;
  48594. USEPHYSICALLIGHTFALLOFF: boolean;
  48595. USEGLTFLIGHTFALLOFF: boolean;
  48596. TWOSIDEDLIGHTING: boolean;
  48597. SHADOWFLOAT: boolean;
  48598. CLIPPLANE: boolean;
  48599. CLIPPLANE2: boolean;
  48600. CLIPPLANE3: boolean;
  48601. CLIPPLANE4: boolean;
  48602. POINTSIZE: boolean;
  48603. FOG: boolean;
  48604. LOGARITHMICDEPTH: boolean;
  48605. FORCENORMALFORWARD: boolean;
  48606. SPECULARAA: boolean;
  48607. CLEARCOAT: boolean;
  48608. CLEARCOAT_DEFAULTIOR: boolean;
  48609. CLEARCOAT_TEXTURE: boolean;
  48610. CLEARCOAT_TEXTUREDIRECTUV: number;
  48611. CLEARCOAT_BUMP: boolean;
  48612. CLEARCOAT_BUMPDIRECTUV: number;
  48613. CLEARCOAT_TINT: boolean;
  48614. CLEARCOAT_TINT_TEXTURE: boolean;
  48615. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  48616. ANISOTROPIC: boolean;
  48617. ANISOTROPIC_TEXTURE: boolean;
  48618. ANISOTROPIC_TEXTUREDIRECTUV: number;
  48619. BRDF_V_HEIGHT_CORRELATED: boolean;
  48620. MS_BRDF_ENERGY_CONSERVATION: boolean;
  48621. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  48622. SHEEN: boolean;
  48623. SHEEN_TEXTURE: boolean;
  48624. SHEEN_TEXTUREDIRECTUV: number;
  48625. SHEEN_LINKWITHALBEDO: boolean;
  48626. SUBSURFACE: boolean;
  48627. SS_REFRACTION: boolean;
  48628. SS_TRANSLUCENCY: boolean;
  48629. SS_SCATERRING: boolean;
  48630. SS_THICKNESSANDMASK_TEXTURE: boolean;
  48631. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  48632. SS_REFRACTIONMAP_3D: boolean;
  48633. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  48634. SS_LODINREFRACTIONALPHA: boolean;
  48635. SS_GAMMAREFRACTION: boolean;
  48636. SS_RGBDREFRACTION: boolean;
  48637. SS_LINEARSPECULARREFRACTION: boolean;
  48638. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  48639. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  48640. UNLIT: boolean;
  48641. DEBUGMODE: number;
  48642. /**
  48643. * Initializes the PBR Material defines.
  48644. */
  48645. constructor();
  48646. /**
  48647. * Resets the PBR Material defines.
  48648. */
  48649. reset(): void;
  48650. }
  48651. /**
  48652. * The Physically based material base class of BJS.
  48653. *
  48654. * This offers the main features of a standard PBR material.
  48655. * For more information, please refer to the documentation :
  48656. * https://doc.babylonjs.com/how_to/physically_based_rendering
  48657. */
  48658. export abstract class PBRBaseMaterial extends PushMaterial {
  48659. /**
  48660. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  48661. */
  48662. static readonly PBRMATERIAL_OPAQUE: number;
  48663. /**
  48664. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  48665. */
  48666. static readonly PBRMATERIAL_ALPHATEST: number;
  48667. /**
  48668. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48669. */
  48670. static readonly PBRMATERIAL_ALPHABLEND: number;
  48671. /**
  48672. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48673. * They are also discarded below the alpha cutoff threshold to improve performances.
  48674. */
  48675. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  48676. /**
  48677. * Defines the default value of how much AO map is occluding the analytical lights
  48678. * (point spot...).
  48679. */
  48680. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  48681. /**
  48682. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  48683. */
  48684. static readonly LIGHTFALLOFF_PHYSICAL: number;
  48685. /**
  48686. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  48687. * to enhance interoperability with other engines.
  48688. */
  48689. static readonly LIGHTFALLOFF_GLTF: number;
  48690. /**
  48691. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  48692. * to enhance interoperability with other materials.
  48693. */
  48694. static readonly LIGHTFALLOFF_STANDARD: number;
  48695. /**
  48696. * Intensity of the direct lights e.g. the four lights available in your scene.
  48697. * This impacts both the direct diffuse and specular highlights.
  48698. */
  48699. protected _directIntensity: number;
  48700. /**
  48701. * Intensity of the emissive part of the material.
  48702. * This helps controlling the emissive effect without modifying the emissive color.
  48703. */
  48704. protected _emissiveIntensity: number;
  48705. /**
  48706. * Intensity of the environment e.g. how much the environment will light the object
  48707. * either through harmonics for rough material or through the refelction for shiny ones.
  48708. */
  48709. protected _environmentIntensity: number;
  48710. /**
  48711. * This is a special control allowing the reduction of the specular highlights coming from the
  48712. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  48713. */
  48714. protected _specularIntensity: number;
  48715. /**
  48716. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  48717. */
  48718. private _lightingInfos;
  48719. /**
  48720. * Debug Control allowing disabling the bump map on this material.
  48721. */
  48722. protected _disableBumpMap: boolean;
  48723. /**
  48724. * AKA Diffuse Texture in standard nomenclature.
  48725. */
  48726. protected _albedoTexture: Nullable<BaseTexture>;
  48727. /**
  48728. * AKA Occlusion Texture in other nomenclature.
  48729. */
  48730. protected _ambientTexture: Nullable<BaseTexture>;
  48731. /**
  48732. * AKA Occlusion Texture Intensity in other nomenclature.
  48733. */
  48734. protected _ambientTextureStrength: number;
  48735. /**
  48736. * Defines how much the AO map is occluding the analytical lights (point spot...).
  48737. * 1 means it completely occludes it
  48738. * 0 mean it has no impact
  48739. */
  48740. protected _ambientTextureImpactOnAnalyticalLights: number;
  48741. /**
  48742. * Stores the alpha values in a texture.
  48743. */
  48744. protected _opacityTexture: Nullable<BaseTexture>;
  48745. /**
  48746. * Stores the reflection values in a texture.
  48747. */
  48748. protected _reflectionTexture: Nullable<BaseTexture>;
  48749. /**
  48750. * Stores the emissive values in a texture.
  48751. */
  48752. protected _emissiveTexture: Nullable<BaseTexture>;
  48753. /**
  48754. * AKA Specular texture in other nomenclature.
  48755. */
  48756. protected _reflectivityTexture: Nullable<BaseTexture>;
  48757. /**
  48758. * Used to switch from specular/glossiness to metallic/roughness workflow.
  48759. */
  48760. protected _metallicTexture: Nullable<BaseTexture>;
  48761. /**
  48762. * Specifies the metallic scalar of the metallic/roughness workflow.
  48763. * Can also be used to scale the metalness values of the metallic texture.
  48764. */
  48765. protected _metallic: Nullable<number>;
  48766. /**
  48767. * Specifies the roughness scalar of the metallic/roughness workflow.
  48768. * Can also be used to scale the roughness values of the metallic texture.
  48769. */
  48770. protected _roughness: Nullable<number>;
  48771. /**
  48772. * Specifies the an F0 factor to help configuring the material F0.
  48773. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  48774. * to 0.5 the previously hard coded value stays the same.
  48775. * Can also be used to scale the F0 values of the metallic texture.
  48776. */
  48777. protected _metallicF0Factor: number;
  48778. /**
  48779. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  48780. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  48781. * your expectation as it multiplies with the texture data.
  48782. */
  48783. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  48784. /**
  48785. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  48786. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  48787. */
  48788. protected _microSurfaceTexture: Nullable<BaseTexture>;
  48789. /**
  48790. * Stores surface normal data used to displace a mesh in a texture.
  48791. */
  48792. protected _bumpTexture: Nullable<BaseTexture>;
  48793. /**
  48794. * Stores the pre-calculated light information of a mesh in a texture.
  48795. */
  48796. protected _lightmapTexture: Nullable<BaseTexture>;
  48797. /**
  48798. * The color of a material in ambient lighting.
  48799. */
  48800. protected _ambientColor: Color3;
  48801. /**
  48802. * AKA Diffuse Color in other nomenclature.
  48803. */
  48804. protected _albedoColor: Color3;
  48805. /**
  48806. * AKA Specular Color in other nomenclature.
  48807. */
  48808. protected _reflectivityColor: Color3;
  48809. /**
  48810. * The color applied when light is reflected from a material.
  48811. */
  48812. protected _reflectionColor: Color3;
  48813. /**
  48814. * The color applied when light is emitted from a material.
  48815. */
  48816. protected _emissiveColor: Color3;
  48817. /**
  48818. * AKA Glossiness in other nomenclature.
  48819. */
  48820. protected _microSurface: number;
  48821. /**
  48822. * Specifies that the material will use the light map as a show map.
  48823. */
  48824. protected _useLightmapAsShadowmap: boolean;
  48825. /**
  48826. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  48827. * makes the reflect vector face the model (under horizon).
  48828. */
  48829. protected _useHorizonOcclusion: boolean;
  48830. /**
  48831. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  48832. * too much the area relying on ambient texture to define their ambient occlusion.
  48833. */
  48834. protected _useRadianceOcclusion: boolean;
  48835. /**
  48836. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  48837. */
  48838. protected _useAlphaFromAlbedoTexture: boolean;
  48839. /**
  48840. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  48841. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  48842. */
  48843. protected _useSpecularOverAlpha: boolean;
  48844. /**
  48845. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  48846. */
  48847. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  48848. /**
  48849. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  48850. */
  48851. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  48852. /**
  48853. * Specifies if the metallic texture contains the roughness information in its green channel.
  48854. */
  48855. protected _useRoughnessFromMetallicTextureGreen: boolean;
  48856. /**
  48857. * Specifies if the metallic texture contains the metallness information in its blue channel.
  48858. */
  48859. protected _useMetallnessFromMetallicTextureBlue: boolean;
  48860. /**
  48861. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  48862. */
  48863. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  48864. /**
  48865. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  48866. */
  48867. protected _useAmbientInGrayScale: boolean;
  48868. /**
  48869. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  48870. * The material will try to infer what glossiness each pixel should be.
  48871. */
  48872. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  48873. /**
  48874. * Defines the falloff type used in this material.
  48875. * It by default is Physical.
  48876. */
  48877. protected _lightFalloff: number;
  48878. /**
  48879. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  48880. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  48881. */
  48882. protected _useRadianceOverAlpha: boolean;
  48883. /**
  48884. * Allows using an object space normal map (instead of tangent space).
  48885. */
  48886. protected _useObjectSpaceNormalMap: boolean;
  48887. /**
  48888. * Allows using the bump map in parallax mode.
  48889. */
  48890. protected _useParallax: boolean;
  48891. /**
  48892. * Allows using the bump map in parallax occlusion mode.
  48893. */
  48894. protected _useParallaxOcclusion: boolean;
  48895. /**
  48896. * Controls the scale bias of the parallax mode.
  48897. */
  48898. protected _parallaxScaleBias: number;
  48899. /**
  48900. * If sets to true, disables all the lights affecting the material.
  48901. */
  48902. protected _disableLighting: boolean;
  48903. /**
  48904. * Number of Simultaneous lights allowed on the material.
  48905. */
  48906. protected _maxSimultaneousLights: number;
  48907. /**
  48908. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  48909. */
  48910. protected _invertNormalMapX: boolean;
  48911. /**
  48912. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  48913. */
  48914. protected _invertNormalMapY: boolean;
  48915. /**
  48916. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48917. */
  48918. protected _twoSidedLighting: boolean;
  48919. /**
  48920. * Defines the alpha limits in alpha test mode.
  48921. */
  48922. protected _alphaCutOff: number;
  48923. /**
  48924. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  48925. */
  48926. protected _forceAlphaTest: boolean;
  48927. /**
  48928. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48929. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  48930. */
  48931. protected _useAlphaFresnel: boolean;
  48932. /**
  48933. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48934. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  48935. */
  48936. protected _useLinearAlphaFresnel: boolean;
  48937. /**
  48938. * The transparency mode of the material.
  48939. */
  48940. protected _transparencyMode: Nullable<number>;
  48941. /**
  48942. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  48943. * from cos thetav and roughness:
  48944. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  48945. */
  48946. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  48947. /**
  48948. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  48949. */
  48950. protected _forceIrradianceInFragment: boolean;
  48951. /**
  48952. * Force normal to face away from face.
  48953. */
  48954. protected _forceNormalForward: boolean;
  48955. /**
  48956. * Enables specular anti aliasing in the PBR shader.
  48957. * It will both interacts on the Geometry for analytical and IBL lighting.
  48958. * It also prefilter the roughness map based on the bump values.
  48959. */
  48960. protected _enableSpecularAntiAliasing: boolean;
  48961. /**
  48962. * Default configuration related to image processing available in the PBR Material.
  48963. */
  48964. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  48965. /**
  48966. * Keep track of the image processing observer to allow dispose and replace.
  48967. */
  48968. private _imageProcessingObserver;
  48969. /**
  48970. * Attaches a new image processing configuration to the PBR Material.
  48971. * @param configuration
  48972. */
  48973. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  48974. /**
  48975. * Stores the available render targets.
  48976. */
  48977. private _renderTargets;
  48978. /**
  48979. * Sets the global ambient color for the material used in lighting calculations.
  48980. */
  48981. private _globalAmbientColor;
  48982. /**
  48983. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  48984. */
  48985. private _useLogarithmicDepth;
  48986. /**
  48987. * If set to true, no lighting calculations will be applied.
  48988. */
  48989. private _unlit;
  48990. private _debugMode;
  48991. /**
  48992. * @hidden
  48993. * This is reserved for the inspector.
  48994. * Defines the material debug mode.
  48995. * It helps seeing only some components of the material while troubleshooting.
  48996. */
  48997. debugMode: number;
  48998. /**
  48999. * @hidden
  49000. * This is reserved for the inspector.
  49001. * Specify from where on screen the debug mode should start.
  49002. * The value goes from -1 (full screen) to 1 (not visible)
  49003. * It helps with side by side comparison against the final render
  49004. * This defaults to -1
  49005. */
  49006. private debugLimit;
  49007. /**
  49008. * @hidden
  49009. * This is reserved for the inspector.
  49010. * As the default viewing range might not be enough (if the ambient is really small for instance)
  49011. * You can use the factor to better multiply the final value.
  49012. */
  49013. private debugFactor;
  49014. /**
  49015. * Defines the clear coat layer parameters for the material.
  49016. */
  49017. readonly clearCoat: PBRClearCoatConfiguration;
  49018. /**
  49019. * Defines the anisotropic parameters for the material.
  49020. */
  49021. readonly anisotropy: PBRAnisotropicConfiguration;
  49022. /**
  49023. * Defines the BRDF parameters for the material.
  49024. */
  49025. readonly brdf: PBRBRDFConfiguration;
  49026. /**
  49027. * Defines the Sheen parameters for the material.
  49028. */
  49029. readonly sheen: PBRSheenConfiguration;
  49030. /**
  49031. * Defines the SubSurface parameters for the material.
  49032. */
  49033. readonly subSurface: PBRSubSurfaceConfiguration;
  49034. /**
  49035. * Custom callback helping to override the default shader used in the material.
  49036. */
  49037. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  49038. protected _rebuildInParallel: boolean;
  49039. /**
  49040. * Instantiates a new PBRMaterial instance.
  49041. *
  49042. * @param name The material name
  49043. * @param scene The scene the material will be use in.
  49044. */
  49045. constructor(name: string, scene: Scene);
  49046. /**
  49047. * Gets a boolean indicating that current material needs to register RTT
  49048. */
  49049. readonly hasRenderTargetTextures: boolean;
  49050. /**
  49051. * Gets the name of the material class.
  49052. */
  49053. getClassName(): string;
  49054. /**
  49055. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  49056. */
  49057. /**
  49058. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  49059. */
  49060. useLogarithmicDepth: boolean;
  49061. /**
  49062. * Gets the current transparency mode.
  49063. */
  49064. /**
  49065. * Sets the transparency mode of the material.
  49066. *
  49067. * | Value | Type | Description |
  49068. * | ----- | ----------------------------------- | ----------- |
  49069. * | 0 | OPAQUE | |
  49070. * | 1 | ALPHATEST | |
  49071. * | 2 | ALPHABLEND | |
  49072. * | 3 | ALPHATESTANDBLEND | |
  49073. *
  49074. */
  49075. transparencyMode: Nullable<number>;
  49076. /**
  49077. * Returns true if alpha blending should be disabled.
  49078. */
  49079. private readonly _disableAlphaBlending;
  49080. /**
  49081. * Specifies whether or not this material should be rendered in alpha blend mode.
  49082. */
  49083. needAlphaBlending(): boolean;
  49084. /**
  49085. * Specifies if the mesh will require alpha blending.
  49086. * @param mesh - BJS mesh.
  49087. */
  49088. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  49089. /**
  49090. * Specifies whether or not this material should be rendered in alpha test mode.
  49091. */
  49092. needAlphaTesting(): boolean;
  49093. /**
  49094. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  49095. */
  49096. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  49097. /**
  49098. * Gets the texture used for the alpha test.
  49099. */
  49100. getAlphaTestTexture(): Nullable<BaseTexture>;
  49101. /**
  49102. * Specifies that the submesh is ready to be used.
  49103. * @param mesh - BJS mesh.
  49104. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  49105. * @param useInstances - Specifies that instances should be used.
  49106. * @returns - boolean indicating that the submesh is ready or not.
  49107. */
  49108. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  49109. /**
  49110. * Specifies if the material uses metallic roughness workflow.
  49111. * @returns boolean specifiying if the material uses metallic roughness workflow.
  49112. */
  49113. isMetallicWorkflow(): boolean;
  49114. private _prepareEffect;
  49115. private _prepareDefines;
  49116. /**
  49117. * Force shader compilation
  49118. */
  49119. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  49120. /**
  49121. * Initializes the uniform buffer layout for the shader.
  49122. */
  49123. buildUniformLayout(): void;
  49124. /**
  49125. * Unbinds the material from the mesh
  49126. */
  49127. unbind(): void;
  49128. /**
  49129. * Binds the submesh data.
  49130. * @param world - The world matrix.
  49131. * @param mesh - The BJS mesh.
  49132. * @param subMesh - A submesh of the BJS mesh.
  49133. */
  49134. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  49135. /**
  49136. * Returns the animatable textures.
  49137. * @returns - Array of animatable textures.
  49138. */
  49139. getAnimatables(): IAnimatable[];
  49140. /**
  49141. * Returns the texture used for reflections.
  49142. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  49143. */
  49144. private _getReflectionTexture;
  49145. /**
  49146. * Returns an array of the actively used textures.
  49147. * @returns - Array of BaseTextures
  49148. */
  49149. getActiveTextures(): BaseTexture[];
  49150. /**
  49151. * Checks to see if a texture is used in the material.
  49152. * @param texture - Base texture to use.
  49153. * @returns - Boolean specifying if a texture is used in the material.
  49154. */
  49155. hasTexture(texture: BaseTexture): boolean;
  49156. /**
  49157. * Disposes the resources of the material.
  49158. * @param forceDisposeEffect - Forces the disposal of effects.
  49159. * @param forceDisposeTextures - Forces the disposal of all textures.
  49160. */
  49161. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  49162. }
  49163. }
  49164. declare module BABYLON {
  49165. /**
  49166. * The Physically based material of BJS.
  49167. *
  49168. * This offers the main features of a standard PBR material.
  49169. * For more information, please refer to the documentation :
  49170. * https://doc.babylonjs.com/how_to/physically_based_rendering
  49171. */
  49172. export class PBRMaterial extends PBRBaseMaterial {
  49173. /**
  49174. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  49175. */
  49176. static readonly PBRMATERIAL_OPAQUE: number;
  49177. /**
  49178. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  49179. */
  49180. static readonly PBRMATERIAL_ALPHATEST: number;
  49181. /**
  49182. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49183. */
  49184. static readonly PBRMATERIAL_ALPHABLEND: number;
  49185. /**
  49186. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49187. * They are also discarded below the alpha cutoff threshold to improve performances.
  49188. */
  49189. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  49190. /**
  49191. * Defines the default value of how much AO map is occluding the analytical lights
  49192. * (point spot...).
  49193. */
  49194. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  49195. /**
  49196. * Intensity of the direct lights e.g. the four lights available in your scene.
  49197. * This impacts both the direct diffuse and specular highlights.
  49198. */
  49199. directIntensity: number;
  49200. /**
  49201. * Intensity of the emissive part of the material.
  49202. * This helps controlling the emissive effect without modifying the emissive color.
  49203. */
  49204. emissiveIntensity: number;
  49205. /**
  49206. * Intensity of the environment e.g. how much the environment will light the object
  49207. * either through harmonics for rough material or through the refelction for shiny ones.
  49208. */
  49209. environmentIntensity: number;
  49210. /**
  49211. * This is a special control allowing the reduction of the specular highlights coming from the
  49212. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  49213. */
  49214. specularIntensity: number;
  49215. /**
  49216. * Debug Control allowing disabling the bump map on this material.
  49217. */
  49218. disableBumpMap: boolean;
  49219. /**
  49220. * AKA Diffuse Texture in standard nomenclature.
  49221. */
  49222. albedoTexture: BaseTexture;
  49223. /**
  49224. * AKA Occlusion Texture in other nomenclature.
  49225. */
  49226. ambientTexture: BaseTexture;
  49227. /**
  49228. * AKA Occlusion Texture Intensity in other nomenclature.
  49229. */
  49230. ambientTextureStrength: number;
  49231. /**
  49232. * Defines how much the AO map is occluding the analytical lights (point spot...).
  49233. * 1 means it completely occludes it
  49234. * 0 mean it has no impact
  49235. */
  49236. ambientTextureImpactOnAnalyticalLights: number;
  49237. /**
  49238. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  49239. */
  49240. opacityTexture: BaseTexture;
  49241. /**
  49242. * Stores the reflection values in a texture.
  49243. */
  49244. reflectionTexture: Nullable<BaseTexture>;
  49245. /**
  49246. * Stores the emissive values in a texture.
  49247. */
  49248. emissiveTexture: BaseTexture;
  49249. /**
  49250. * AKA Specular texture in other nomenclature.
  49251. */
  49252. reflectivityTexture: BaseTexture;
  49253. /**
  49254. * Used to switch from specular/glossiness to metallic/roughness workflow.
  49255. */
  49256. metallicTexture: BaseTexture;
  49257. /**
  49258. * Specifies the metallic scalar of the metallic/roughness workflow.
  49259. * Can also be used to scale the metalness values of the metallic texture.
  49260. */
  49261. metallic: Nullable<number>;
  49262. /**
  49263. * Specifies the roughness scalar of the metallic/roughness workflow.
  49264. * Can also be used to scale the roughness values of the metallic texture.
  49265. */
  49266. roughness: Nullable<number>;
  49267. /**
  49268. * Specifies the an F0 factor to help configuring the material F0.
  49269. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  49270. * to 0.5 the previously hard coded value stays the same.
  49271. * Can also be used to scale the F0 values of the metallic texture.
  49272. */
  49273. metallicF0Factor: number;
  49274. /**
  49275. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  49276. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  49277. * your expectation as it multiplies with the texture data.
  49278. */
  49279. useMetallicF0FactorFromMetallicTexture: boolean;
  49280. /**
  49281. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  49282. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  49283. */
  49284. microSurfaceTexture: BaseTexture;
  49285. /**
  49286. * Stores surface normal data used to displace a mesh in a texture.
  49287. */
  49288. bumpTexture: BaseTexture;
  49289. /**
  49290. * Stores the pre-calculated light information of a mesh in a texture.
  49291. */
  49292. lightmapTexture: BaseTexture;
  49293. /**
  49294. * Stores the refracted light information in a texture.
  49295. */
  49296. refractionTexture: Nullable<BaseTexture>;
  49297. /**
  49298. * The color of a material in ambient lighting.
  49299. */
  49300. ambientColor: Color3;
  49301. /**
  49302. * AKA Diffuse Color in other nomenclature.
  49303. */
  49304. albedoColor: Color3;
  49305. /**
  49306. * AKA Specular Color in other nomenclature.
  49307. */
  49308. reflectivityColor: Color3;
  49309. /**
  49310. * The color reflected from the material.
  49311. */
  49312. reflectionColor: Color3;
  49313. /**
  49314. * The color emitted from the material.
  49315. */
  49316. emissiveColor: Color3;
  49317. /**
  49318. * AKA Glossiness in other nomenclature.
  49319. */
  49320. microSurface: number;
  49321. /**
  49322. * source material index of refraction (IOR)' / 'destination material IOR.
  49323. */
  49324. indexOfRefraction: number;
  49325. /**
  49326. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  49327. */
  49328. invertRefractionY: boolean;
  49329. /**
  49330. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  49331. * Materials half opaque for instance using refraction could benefit from this control.
  49332. */
  49333. linkRefractionWithTransparency: boolean;
  49334. /**
  49335. * If true, the light map contains occlusion information instead of lighting info.
  49336. */
  49337. useLightmapAsShadowmap: boolean;
  49338. /**
  49339. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  49340. */
  49341. useAlphaFromAlbedoTexture: boolean;
  49342. /**
  49343. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  49344. */
  49345. forceAlphaTest: boolean;
  49346. /**
  49347. * Defines the alpha limits in alpha test mode.
  49348. */
  49349. alphaCutOff: number;
  49350. /**
  49351. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  49352. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  49353. */
  49354. useSpecularOverAlpha: boolean;
  49355. /**
  49356. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  49357. */
  49358. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  49359. /**
  49360. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  49361. */
  49362. useRoughnessFromMetallicTextureAlpha: boolean;
  49363. /**
  49364. * Specifies if the metallic texture contains the roughness information in its green channel.
  49365. */
  49366. useRoughnessFromMetallicTextureGreen: boolean;
  49367. /**
  49368. * Specifies if the metallic texture contains the metallness information in its blue channel.
  49369. */
  49370. useMetallnessFromMetallicTextureBlue: boolean;
  49371. /**
  49372. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  49373. */
  49374. useAmbientOcclusionFromMetallicTextureRed: boolean;
  49375. /**
  49376. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  49377. */
  49378. useAmbientInGrayScale: boolean;
  49379. /**
  49380. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  49381. * The material will try to infer what glossiness each pixel should be.
  49382. */
  49383. useAutoMicroSurfaceFromReflectivityMap: boolean;
  49384. /**
  49385. * BJS is using an harcoded light falloff based on a manually sets up range.
  49386. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  49387. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  49388. */
  49389. /**
  49390. * BJS is using an harcoded light falloff based on a manually sets up range.
  49391. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  49392. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  49393. */
  49394. usePhysicalLightFalloff: boolean;
  49395. /**
  49396. * In order to support the falloff compatibility with gltf, a special mode has been added
  49397. * to reproduce the gltf light falloff.
  49398. */
  49399. /**
  49400. * In order to support the falloff compatibility with gltf, a special mode has been added
  49401. * to reproduce the gltf light falloff.
  49402. */
  49403. useGLTFLightFalloff: boolean;
  49404. /**
  49405. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  49406. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  49407. */
  49408. useRadianceOverAlpha: boolean;
  49409. /**
  49410. * Allows using an object space normal map (instead of tangent space).
  49411. */
  49412. useObjectSpaceNormalMap: boolean;
  49413. /**
  49414. * Allows using the bump map in parallax mode.
  49415. */
  49416. useParallax: boolean;
  49417. /**
  49418. * Allows using the bump map in parallax occlusion mode.
  49419. */
  49420. useParallaxOcclusion: boolean;
  49421. /**
  49422. * Controls the scale bias of the parallax mode.
  49423. */
  49424. parallaxScaleBias: number;
  49425. /**
  49426. * If sets to true, disables all the lights affecting the material.
  49427. */
  49428. disableLighting: boolean;
  49429. /**
  49430. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  49431. */
  49432. forceIrradianceInFragment: boolean;
  49433. /**
  49434. * Number of Simultaneous lights allowed on the material.
  49435. */
  49436. maxSimultaneousLights: number;
  49437. /**
  49438. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  49439. */
  49440. invertNormalMapX: boolean;
  49441. /**
  49442. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  49443. */
  49444. invertNormalMapY: boolean;
  49445. /**
  49446. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49447. */
  49448. twoSidedLighting: boolean;
  49449. /**
  49450. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49451. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  49452. */
  49453. useAlphaFresnel: boolean;
  49454. /**
  49455. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49456. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  49457. */
  49458. useLinearAlphaFresnel: boolean;
  49459. /**
  49460. * Let user defines the brdf lookup texture used for IBL.
  49461. * A default 8bit version is embedded but you could point at :
  49462. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  49463. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  49464. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  49465. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  49466. */
  49467. environmentBRDFTexture: Nullable<BaseTexture>;
  49468. /**
  49469. * Force normal to face away from face.
  49470. */
  49471. forceNormalForward: boolean;
  49472. /**
  49473. * Enables specular anti aliasing in the PBR shader.
  49474. * It will both interacts on the Geometry for analytical and IBL lighting.
  49475. * It also prefilter the roughness map based on the bump values.
  49476. */
  49477. enableSpecularAntiAliasing: boolean;
  49478. /**
  49479. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  49480. * makes the reflect vector face the model (under horizon).
  49481. */
  49482. useHorizonOcclusion: boolean;
  49483. /**
  49484. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  49485. * too much the area relying on ambient texture to define their ambient occlusion.
  49486. */
  49487. useRadianceOcclusion: boolean;
  49488. /**
  49489. * If set to true, no lighting calculations will be applied.
  49490. */
  49491. unlit: boolean;
  49492. /**
  49493. * Gets the image processing configuration used either in this material.
  49494. */
  49495. /**
  49496. * Sets the Default image processing configuration used either in the this material.
  49497. *
  49498. * If sets to null, the scene one is in use.
  49499. */
  49500. imageProcessingConfiguration: ImageProcessingConfiguration;
  49501. /**
  49502. * Gets wether the color curves effect is enabled.
  49503. */
  49504. /**
  49505. * Sets wether the color curves effect is enabled.
  49506. */
  49507. cameraColorCurvesEnabled: boolean;
  49508. /**
  49509. * Gets wether the color grading effect is enabled.
  49510. */
  49511. /**
  49512. * Gets wether the color grading effect is enabled.
  49513. */
  49514. cameraColorGradingEnabled: boolean;
  49515. /**
  49516. * Gets wether tonemapping is enabled or not.
  49517. */
  49518. /**
  49519. * Sets wether tonemapping is enabled or not
  49520. */
  49521. cameraToneMappingEnabled: boolean;
  49522. /**
  49523. * The camera exposure used on this material.
  49524. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49525. * This corresponds to a photographic exposure.
  49526. */
  49527. /**
  49528. * The camera exposure used on this material.
  49529. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49530. * This corresponds to a photographic exposure.
  49531. */
  49532. cameraExposure: number;
  49533. /**
  49534. * Gets The camera contrast used on this material.
  49535. */
  49536. /**
  49537. * Sets The camera contrast used on this material.
  49538. */
  49539. cameraContrast: number;
  49540. /**
  49541. * Gets the Color Grading 2D Lookup Texture.
  49542. */
  49543. /**
  49544. * Sets the Color Grading 2D Lookup Texture.
  49545. */
  49546. cameraColorGradingTexture: Nullable<BaseTexture>;
  49547. /**
  49548. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49549. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49550. * 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;
  49551. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49552. */
  49553. /**
  49554. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49555. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49556. * 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;
  49557. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49558. */
  49559. cameraColorCurves: Nullable<ColorCurves>;
  49560. /**
  49561. * Instantiates a new PBRMaterial instance.
  49562. *
  49563. * @param name The material name
  49564. * @param scene The scene the material will be use in.
  49565. */
  49566. constructor(name: string, scene: Scene);
  49567. /**
  49568. * Returns the name of this material class.
  49569. */
  49570. getClassName(): string;
  49571. /**
  49572. * Makes a duplicate of the current material.
  49573. * @param name - name to use for the new material.
  49574. */
  49575. clone(name: string): PBRMaterial;
  49576. /**
  49577. * Serializes this PBR Material.
  49578. * @returns - An object with the serialized material.
  49579. */
  49580. serialize(): any;
  49581. /**
  49582. * Parses a PBR Material from a serialized object.
  49583. * @param source - Serialized object.
  49584. * @param scene - BJS scene instance.
  49585. * @param rootUrl - url for the scene object
  49586. * @returns - PBRMaterial
  49587. */
  49588. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  49589. }
  49590. }
  49591. declare module BABYLON {
  49592. /**
  49593. * Direct draw surface info
  49594. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  49595. */
  49596. export interface DDSInfo {
  49597. /**
  49598. * Width of the texture
  49599. */
  49600. width: number;
  49601. /**
  49602. * Width of the texture
  49603. */
  49604. height: number;
  49605. /**
  49606. * Number of Mipmaps for the texture
  49607. * @see https://en.wikipedia.org/wiki/Mipmap
  49608. */
  49609. mipmapCount: number;
  49610. /**
  49611. * If the textures format is a known fourCC format
  49612. * @see https://www.fourcc.org/
  49613. */
  49614. isFourCC: boolean;
  49615. /**
  49616. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  49617. */
  49618. isRGB: boolean;
  49619. /**
  49620. * If the texture is a lumincance format
  49621. */
  49622. isLuminance: boolean;
  49623. /**
  49624. * If this is a cube texture
  49625. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  49626. */
  49627. isCube: boolean;
  49628. /**
  49629. * If the texture is a compressed format eg. FOURCC_DXT1
  49630. */
  49631. isCompressed: boolean;
  49632. /**
  49633. * The dxgiFormat of the texture
  49634. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  49635. */
  49636. dxgiFormat: number;
  49637. /**
  49638. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  49639. */
  49640. textureType: number;
  49641. /**
  49642. * Sphericle polynomial created for the dds texture
  49643. */
  49644. sphericalPolynomial?: SphericalPolynomial;
  49645. }
  49646. /**
  49647. * Class used to provide DDS decompression tools
  49648. */
  49649. export class DDSTools {
  49650. /**
  49651. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  49652. */
  49653. static StoreLODInAlphaChannel: boolean;
  49654. /**
  49655. * Gets DDS information from an array buffer
  49656. * @param arrayBuffer defines the array buffer to read data from
  49657. * @returns the DDS information
  49658. */
  49659. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  49660. private static _FloatView;
  49661. private static _Int32View;
  49662. private static _ToHalfFloat;
  49663. private static _FromHalfFloat;
  49664. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  49665. private static _GetHalfFloatRGBAArrayBuffer;
  49666. private static _GetFloatRGBAArrayBuffer;
  49667. private static _GetFloatAsUIntRGBAArrayBuffer;
  49668. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  49669. private static _GetRGBAArrayBuffer;
  49670. private static _ExtractLongWordOrder;
  49671. private static _GetRGBArrayBuffer;
  49672. private static _GetLuminanceArrayBuffer;
  49673. /**
  49674. * Uploads DDS Levels to a Babylon Texture
  49675. * @hidden
  49676. */
  49677. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  49678. }
  49679. interface ThinEngine {
  49680. /**
  49681. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  49682. * @param rootUrl defines the url where the file to load is located
  49683. * @param scene defines the current scene
  49684. * @param lodScale defines scale to apply to the mip map selection
  49685. * @param lodOffset defines offset to apply to the mip map selection
  49686. * @param onLoad defines an optional callback raised when the texture is loaded
  49687. * @param onError defines an optional callback raised if there is an issue to load the texture
  49688. * @param format defines the format of the data
  49689. * @param forcedExtension defines the extension to use to pick the right loader
  49690. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  49691. * @returns the cube texture as an InternalTexture
  49692. */
  49693. 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;
  49694. }
  49695. }
  49696. declare module BABYLON {
  49697. /**
  49698. * Implementation of the DDS Texture Loader.
  49699. * @hidden
  49700. */
  49701. export class _DDSTextureLoader implements IInternalTextureLoader {
  49702. /**
  49703. * Defines wether the loader supports cascade loading the different faces.
  49704. */
  49705. readonly supportCascades: boolean;
  49706. /**
  49707. * This returns if the loader support the current file information.
  49708. * @param extension defines the file extension of the file being loaded
  49709. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49710. * @param fallback defines the fallback internal texture if any
  49711. * @param isBase64 defines whether the texture is encoded as a base64
  49712. * @param isBuffer defines whether the texture data are stored as a buffer
  49713. * @returns true if the loader can load the specified file
  49714. */
  49715. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49716. /**
  49717. * Transform the url before loading if required.
  49718. * @param rootUrl the url of the texture
  49719. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49720. * @returns the transformed texture
  49721. */
  49722. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49723. /**
  49724. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49725. * @param rootUrl the url of the texture
  49726. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49727. * @returns the fallback texture
  49728. */
  49729. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49730. /**
  49731. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49732. * @param data contains the texture data
  49733. * @param texture defines the BabylonJS internal texture
  49734. * @param createPolynomials will be true if polynomials have been requested
  49735. * @param onLoad defines the callback to trigger once the texture is ready
  49736. * @param onError defines the callback to trigger in case of error
  49737. */
  49738. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49739. /**
  49740. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49741. * @param data contains the texture data
  49742. * @param texture defines the BabylonJS internal texture
  49743. * @param callback defines the method to call once ready to upload
  49744. */
  49745. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49746. }
  49747. }
  49748. declare module BABYLON {
  49749. /**
  49750. * Implementation of the ENV Texture Loader.
  49751. * @hidden
  49752. */
  49753. export class _ENVTextureLoader implements IInternalTextureLoader {
  49754. /**
  49755. * Defines wether the loader supports cascade loading the different faces.
  49756. */
  49757. readonly supportCascades: boolean;
  49758. /**
  49759. * This returns if the loader support the current file information.
  49760. * @param extension defines the file extension of the file being loaded
  49761. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49762. * @param fallback defines the fallback internal texture if any
  49763. * @param isBase64 defines whether the texture is encoded as a base64
  49764. * @param isBuffer defines whether the texture data are stored as a buffer
  49765. * @returns true if the loader can load the specified file
  49766. */
  49767. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49768. /**
  49769. * Transform the url before loading if required.
  49770. * @param rootUrl the url of the texture
  49771. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49772. * @returns the transformed texture
  49773. */
  49774. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49775. /**
  49776. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49777. * @param rootUrl the url of the texture
  49778. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49779. * @returns the fallback texture
  49780. */
  49781. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49782. /**
  49783. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49784. * @param data contains the texture data
  49785. * @param texture defines the BabylonJS internal texture
  49786. * @param createPolynomials will be true if polynomials have been requested
  49787. * @param onLoad defines the callback to trigger once the texture is ready
  49788. * @param onError defines the callback to trigger in case of error
  49789. */
  49790. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49791. /**
  49792. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49793. * @param data contains the texture data
  49794. * @param texture defines the BabylonJS internal texture
  49795. * @param callback defines the method to call once ready to upload
  49796. */
  49797. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49798. }
  49799. }
  49800. declare module BABYLON {
  49801. /**
  49802. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  49803. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  49804. */
  49805. export class KhronosTextureContainer {
  49806. /** contents of the KTX container file */
  49807. arrayBuffer: any;
  49808. private static HEADER_LEN;
  49809. private static COMPRESSED_2D;
  49810. private static COMPRESSED_3D;
  49811. private static TEX_2D;
  49812. private static TEX_3D;
  49813. /**
  49814. * Gets the openGL type
  49815. */
  49816. glType: number;
  49817. /**
  49818. * Gets the openGL type size
  49819. */
  49820. glTypeSize: number;
  49821. /**
  49822. * Gets the openGL format
  49823. */
  49824. glFormat: number;
  49825. /**
  49826. * Gets the openGL internal format
  49827. */
  49828. glInternalFormat: number;
  49829. /**
  49830. * Gets the base internal format
  49831. */
  49832. glBaseInternalFormat: number;
  49833. /**
  49834. * Gets image width in pixel
  49835. */
  49836. pixelWidth: number;
  49837. /**
  49838. * Gets image height in pixel
  49839. */
  49840. pixelHeight: number;
  49841. /**
  49842. * Gets image depth in pixels
  49843. */
  49844. pixelDepth: number;
  49845. /**
  49846. * Gets the number of array elements
  49847. */
  49848. numberOfArrayElements: number;
  49849. /**
  49850. * Gets the number of faces
  49851. */
  49852. numberOfFaces: number;
  49853. /**
  49854. * Gets the number of mipmap levels
  49855. */
  49856. numberOfMipmapLevels: number;
  49857. /**
  49858. * Gets the bytes of key value data
  49859. */
  49860. bytesOfKeyValueData: number;
  49861. /**
  49862. * Gets the load type
  49863. */
  49864. loadType: number;
  49865. /**
  49866. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  49867. */
  49868. isInvalid: boolean;
  49869. /**
  49870. * Creates a new KhronosTextureContainer
  49871. * @param arrayBuffer contents of the KTX container file
  49872. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  49873. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  49874. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  49875. */
  49876. constructor(
  49877. /** contents of the KTX container file */
  49878. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  49879. /**
  49880. * Uploads KTX content to a Babylon Texture.
  49881. * It is assumed that the texture has already been created & is currently bound
  49882. * @hidden
  49883. */
  49884. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  49885. private _upload2DCompressedLevels;
  49886. }
  49887. }
  49888. declare module BABYLON {
  49889. /**
  49890. * Implementation of the KTX Texture Loader.
  49891. * @hidden
  49892. */
  49893. export class _KTXTextureLoader implements IInternalTextureLoader {
  49894. /**
  49895. * Defines wether the loader supports cascade loading the different faces.
  49896. */
  49897. readonly supportCascades: boolean;
  49898. /**
  49899. * This returns if the loader support the current file information.
  49900. * @param extension defines the file extension of the file being loaded
  49901. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49902. * @param fallback defines the fallback internal texture if any
  49903. * @param isBase64 defines whether the texture is encoded as a base64
  49904. * @param isBuffer defines whether the texture data are stored as a buffer
  49905. * @returns true if the loader can load the specified file
  49906. */
  49907. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49908. /**
  49909. * Transform the url before loading if required.
  49910. * @param rootUrl the url of the texture
  49911. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49912. * @returns the transformed texture
  49913. */
  49914. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49915. /**
  49916. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49917. * @param rootUrl the url of the texture
  49918. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49919. * @returns the fallback texture
  49920. */
  49921. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49922. /**
  49923. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49924. * @param data contains the texture data
  49925. * @param texture defines the BabylonJS internal texture
  49926. * @param createPolynomials will be true if polynomials have been requested
  49927. * @param onLoad defines the callback to trigger once the texture is ready
  49928. * @param onError defines the callback to trigger in case of error
  49929. */
  49930. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49931. /**
  49932. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49933. * @param data contains the texture data
  49934. * @param texture defines the BabylonJS internal texture
  49935. * @param callback defines the method to call once ready to upload
  49936. */
  49937. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  49938. }
  49939. }
  49940. declare module BABYLON {
  49941. /** @hidden */
  49942. export var _forceSceneHelpersToBundle: boolean;
  49943. interface Scene {
  49944. /**
  49945. * Creates a default light for the scene.
  49946. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  49947. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  49948. */
  49949. createDefaultLight(replace?: boolean): void;
  49950. /**
  49951. * Creates a default camera for the scene.
  49952. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  49953. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  49954. * @param replace has default false, when true replaces the active camera in the scene
  49955. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  49956. */
  49957. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  49958. /**
  49959. * Creates a default camera and a default light.
  49960. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  49961. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  49962. * @param replace has the default false, when true replaces the active camera/light in the scene
  49963. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  49964. */
  49965. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  49966. /**
  49967. * Creates a new sky box
  49968. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  49969. * @param environmentTexture defines the texture to use as environment texture
  49970. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  49971. * @param scale defines the overall scale of the skybox
  49972. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  49973. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  49974. * @returns a new mesh holding the sky box
  49975. */
  49976. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  49977. /**
  49978. * Creates a new environment
  49979. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  49980. * @param options defines the options you can use to configure the environment
  49981. * @returns the new EnvironmentHelper
  49982. */
  49983. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  49984. /**
  49985. * Creates a new VREXperienceHelper
  49986. * @see http://doc.babylonjs.com/how_to/webvr_helper
  49987. * @param webVROptions defines the options used to create the new VREXperienceHelper
  49988. * @returns a new VREXperienceHelper
  49989. */
  49990. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  49991. /**
  49992. * Creates a new WebXRDefaultExperience
  49993. * @see http://doc.babylonjs.com/how_to/webxr
  49994. * @param options experience options
  49995. * @returns a promise for a new WebXRDefaultExperience
  49996. */
  49997. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  49998. }
  49999. }
  50000. declare module BABYLON {
  50001. /**
  50002. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  50003. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  50004. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  50005. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  50006. */
  50007. export class VideoDome extends TransformNode {
  50008. /**
  50009. * Define the video source as a Monoscopic panoramic 360 video.
  50010. */
  50011. static readonly MODE_MONOSCOPIC: number;
  50012. /**
  50013. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  50014. */
  50015. static readonly MODE_TOPBOTTOM: number;
  50016. /**
  50017. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  50018. */
  50019. static readonly MODE_SIDEBYSIDE: number;
  50020. private _halfDome;
  50021. private _useDirectMapping;
  50022. /**
  50023. * The video texture being displayed on the sphere
  50024. */
  50025. protected _videoTexture: VideoTexture;
  50026. /**
  50027. * Gets the video texture being displayed on the sphere
  50028. */
  50029. readonly videoTexture: VideoTexture;
  50030. /**
  50031. * The skybox material
  50032. */
  50033. protected _material: BackgroundMaterial;
  50034. /**
  50035. * The surface used for the skybox
  50036. */
  50037. protected _mesh: Mesh;
  50038. /**
  50039. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  50040. */
  50041. private _halfDomeMask;
  50042. /**
  50043. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  50044. * Also see the options.resolution property.
  50045. */
  50046. fovMultiplier: number;
  50047. private _videoMode;
  50048. /**
  50049. * Gets or set the current video mode for the video. It can be:
  50050. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  50051. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  50052. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  50053. */
  50054. videoMode: number;
  50055. /**
  50056. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  50057. *
  50058. */
  50059. /**
  50060. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  50061. */
  50062. halfDome: boolean;
  50063. /**
  50064. * Oberserver used in Stereoscopic VR Mode.
  50065. */
  50066. private _onBeforeCameraRenderObserver;
  50067. /**
  50068. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  50069. * @param name Element's name, child elements will append suffixes for their own names.
  50070. * @param urlsOrVideo defines the url(s) or the video element to use
  50071. * @param options An object containing optional or exposed sub element properties
  50072. */
  50073. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  50074. resolution?: number;
  50075. clickToPlay?: boolean;
  50076. autoPlay?: boolean;
  50077. loop?: boolean;
  50078. size?: number;
  50079. poster?: string;
  50080. faceForward?: boolean;
  50081. useDirectMapping?: boolean;
  50082. halfDomeMode?: boolean;
  50083. }, scene: Scene);
  50084. private _changeVideoMode;
  50085. /**
  50086. * Releases resources associated with this node.
  50087. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  50088. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  50089. */
  50090. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  50091. }
  50092. }
  50093. declare module BABYLON {
  50094. /**
  50095. * This class can be used to get instrumentation data from a Babylon engine
  50096. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  50097. */
  50098. export class EngineInstrumentation implements IDisposable {
  50099. /**
  50100. * Define the instrumented engine.
  50101. */
  50102. engine: Engine;
  50103. private _captureGPUFrameTime;
  50104. private _gpuFrameTimeToken;
  50105. private _gpuFrameTime;
  50106. private _captureShaderCompilationTime;
  50107. private _shaderCompilationTime;
  50108. private _onBeginFrameObserver;
  50109. private _onEndFrameObserver;
  50110. private _onBeforeShaderCompilationObserver;
  50111. private _onAfterShaderCompilationObserver;
  50112. /**
  50113. * Gets the perf counter used for GPU frame time
  50114. */
  50115. readonly gpuFrameTimeCounter: PerfCounter;
  50116. /**
  50117. * Gets the GPU frame time capture status
  50118. */
  50119. /**
  50120. * Enable or disable the GPU frame time capture
  50121. */
  50122. captureGPUFrameTime: boolean;
  50123. /**
  50124. * Gets the perf counter used for shader compilation time
  50125. */
  50126. readonly shaderCompilationTimeCounter: PerfCounter;
  50127. /**
  50128. * Gets the shader compilation time capture status
  50129. */
  50130. /**
  50131. * Enable or disable the shader compilation time capture
  50132. */
  50133. captureShaderCompilationTime: boolean;
  50134. /**
  50135. * Instantiates a new engine instrumentation.
  50136. * This class can be used to get instrumentation data from a Babylon engine
  50137. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  50138. * @param engine Defines the engine to instrument
  50139. */
  50140. constructor(
  50141. /**
  50142. * Define the instrumented engine.
  50143. */
  50144. engine: Engine);
  50145. /**
  50146. * Dispose and release associated resources.
  50147. */
  50148. dispose(): void;
  50149. }
  50150. }
  50151. declare module BABYLON {
  50152. /**
  50153. * This class can be used to get instrumentation data from a Babylon engine
  50154. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  50155. */
  50156. export class SceneInstrumentation implements IDisposable {
  50157. /**
  50158. * Defines the scene to instrument
  50159. */
  50160. scene: Scene;
  50161. private _captureActiveMeshesEvaluationTime;
  50162. private _activeMeshesEvaluationTime;
  50163. private _captureRenderTargetsRenderTime;
  50164. private _renderTargetsRenderTime;
  50165. private _captureFrameTime;
  50166. private _frameTime;
  50167. private _captureRenderTime;
  50168. private _renderTime;
  50169. private _captureInterFrameTime;
  50170. private _interFrameTime;
  50171. private _captureParticlesRenderTime;
  50172. private _particlesRenderTime;
  50173. private _captureSpritesRenderTime;
  50174. private _spritesRenderTime;
  50175. private _capturePhysicsTime;
  50176. private _physicsTime;
  50177. private _captureAnimationsTime;
  50178. private _animationsTime;
  50179. private _captureCameraRenderTime;
  50180. private _cameraRenderTime;
  50181. private _onBeforeActiveMeshesEvaluationObserver;
  50182. private _onAfterActiveMeshesEvaluationObserver;
  50183. private _onBeforeRenderTargetsRenderObserver;
  50184. private _onAfterRenderTargetsRenderObserver;
  50185. private _onAfterRenderObserver;
  50186. private _onBeforeDrawPhaseObserver;
  50187. private _onAfterDrawPhaseObserver;
  50188. private _onBeforeAnimationsObserver;
  50189. private _onBeforeParticlesRenderingObserver;
  50190. private _onAfterParticlesRenderingObserver;
  50191. private _onBeforeSpritesRenderingObserver;
  50192. private _onAfterSpritesRenderingObserver;
  50193. private _onBeforePhysicsObserver;
  50194. private _onAfterPhysicsObserver;
  50195. private _onAfterAnimationsObserver;
  50196. private _onBeforeCameraRenderObserver;
  50197. private _onAfterCameraRenderObserver;
  50198. /**
  50199. * Gets the perf counter used for active meshes evaluation time
  50200. */
  50201. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  50202. /**
  50203. * Gets the active meshes evaluation time capture status
  50204. */
  50205. /**
  50206. * Enable or disable the active meshes evaluation time capture
  50207. */
  50208. captureActiveMeshesEvaluationTime: boolean;
  50209. /**
  50210. * Gets the perf counter used for render targets render time
  50211. */
  50212. readonly renderTargetsRenderTimeCounter: PerfCounter;
  50213. /**
  50214. * Gets the render targets render time capture status
  50215. */
  50216. /**
  50217. * Enable or disable the render targets render time capture
  50218. */
  50219. captureRenderTargetsRenderTime: boolean;
  50220. /**
  50221. * Gets the perf counter used for particles render time
  50222. */
  50223. readonly particlesRenderTimeCounter: PerfCounter;
  50224. /**
  50225. * Gets the particles render time capture status
  50226. */
  50227. /**
  50228. * Enable or disable the particles render time capture
  50229. */
  50230. captureParticlesRenderTime: boolean;
  50231. /**
  50232. * Gets the perf counter used for sprites render time
  50233. */
  50234. readonly spritesRenderTimeCounter: PerfCounter;
  50235. /**
  50236. * Gets the sprites render time capture status
  50237. */
  50238. /**
  50239. * Enable or disable the sprites render time capture
  50240. */
  50241. captureSpritesRenderTime: boolean;
  50242. /**
  50243. * Gets the perf counter used for physics time
  50244. */
  50245. readonly physicsTimeCounter: PerfCounter;
  50246. /**
  50247. * Gets the physics time capture status
  50248. */
  50249. /**
  50250. * Enable or disable the physics time capture
  50251. */
  50252. capturePhysicsTime: boolean;
  50253. /**
  50254. * Gets the perf counter used for animations time
  50255. */
  50256. readonly animationsTimeCounter: PerfCounter;
  50257. /**
  50258. * Gets the animations time capture status
  50259. */
  50260. /**
  50261. * Enable or disable the animations time capture
  50262. */
  50263. captureAnimationsTime: boolean;
  50264. /**
  50265. * Gets the perf counter used for frame time capture
  50266. */
  50267. readonly frameTimeCounter: PerfCounter;
  50268. /**
  50269. * Gets the frame time capture status
  50270. */
  50271. /**
  50272. * Enable or disable the frame time capture
  50273. */
  50274. captureFrameTime: boolean;
  50275. /**
  50276. * Gets the perf counter used for inter-frames time capture
  50277. */
  50278. readonly interFrameTimeCounter: PerfCounter;
  50279. /**
  50280. * Gets the inter-frames time capture status
  50281. */
  50282. /**
  50283. * Enable or disable the inter-frames time capture
  50284. */
  50285. captureInterFrameTime: boolean;
  50286. /**
  50287. * Gets the perf counter used for render time capture
  50288. */
  50289. readonly renderTimeCounter: PerfCounter;
  50290. /**
  50291. * Gets the render time capture status
  50292. */
  50293. /**
  50294. * Enable or disable the render time capture
  50295. */
  50296. captureRenderTime: boolean;
  50297. /**
  50298. * Gets the perf counter used for camera render time capture
  50299. */
  50300. readonly cameraRenderTimeCounter: PerfCounter;
  50301. /**
  50302. * Gets the camera render time capture status
  50303. */
  50304. /**
  50305. * Enable or disable the camera render time capture
  50306. */
  50307. captureCameraRenderTime: boolean;
  50308. /**
  50309. * Gets the perf counter used for draw calls
  50310. */
  50311. readonly drawCallsCounter: PerfCounter;
  50312. /**
  50313. * Instantiates a new scene instrumentation.
  50314. * This class can be used to get instrumentation data from a Babylon engine
  50315. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  50316. * @param scene Defines the scene to instrument
  50317. */
  50318. constructor(
  50319. /**
  50320. * Defines the scene to instrument
  50321. */
  50322. scene: Scene);
  50323. /**
  50324. * Dispose and release associated resources.
  50325. */
  50326. dispose(): void;
  50327. }
  50328. }
  50329. declare module BABYLON {
  50330. /** @hidden */
  50331. export var glowMapGenerationPixelShader: {
  50332. name: string;
  50333. shader: string;
  50334. };
  50335. }
  50336. declare module BABYLON {
  50337. /** @hidden */
  50338. export var glowMapGenerationVertexShader: {
  50339. name: string;
  50340. shader: string;
  50341. };
  50342. }
  50343. declare module BABYLON {
  50344. /**
  50345. * Effect layer options. This helps customizing the behaviour
  50346. * of the effect layer.
  50347. */
  50348. export interface IEffectLayerOptions {
  50349. /**
  50350. * Multiplication factor apply to the canvas size to compute the render target size
  50351. * used to generated the objects (the smaller the faster).
  50352. */
  50353. mainTextureRatio: number;
  50354. /**
  50355. * Enforces a fixed size texture to ensure effect stability across devices.
  50356. */
  50357. mainTextureFixedSize?: number;
  50358. /**
  50359. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  50360. */
  50361. alphaBlendingMode: number;
  50362. /**
  50363. * The camera attached to the layer.
  50364. */
  50365. camera: Nullable<Camera>;
  50366. /**
  50367. * The rendering group to draw the layer in.
  50368. */
  50369. renderingGroupId: number;
  50370. }
  50371. /**
  50372. * The effect layer Helps adding post process effect blended with the main pass.
  50373. *
  50374. * This can be for instance use to generate glow or higlight effects on the scene.
  50375. *
  50376. * The effect layer class can not be used directly and is intented to inherited from to be
  50377. * customized per effects.
  50378. */
  50379. export abstract class EffectLayer {
  50380. private _vertexBuffers;
  50381. private _indexBuffer;
  50382. private _cachedDefines;
  50383. private _effectLayerMapGenerationEffect;
  50384. private _effectLayerOptions;
  50385. private _mergeEffect;
  50386. protected _scene: Scene;
  50387. protected _engine: Engine;
  50388. protected _maxSize: number;
  50389. protected _mainTextureDesiredSize: ISize;
  50390. protected _mainTexture: RenderTargetTexture;
  50391. protected _shouldRender: boolean;
  50392. protected _postProcesses: PostProcess[];
  50393. protected _textures: BaseTexture[];
  50394. protected _emissiveTextureAndColor: {
  50395. texture: Nullable<BaseTexture>;
  50396. color: Color4;
  50397. };
  50398. /**
  50399. * The name of the layer
  50400. */
  50401. name: string;
  50402. /**
  50403. * The clear color of the texture used to generate the glow map.
  50404. */
  50405. neutralColor: Color4;
  50406. /**
  50407. * Specifies wether the highlight layer is enabled or not.
  50408. */
  50409. isEnabled: boolean;
  50410. /**
  50411. * Gets the camera attached to the layer.
  50412. */
  50413. readonly camera: Nullable<Camera>;
  50414. /**
  50415. * Gets the rendering group id the layer should render in.
  50416. */
  50417. renderingGroupId: number;
  50418. /**
  50419. * An event triggered when the effect layer has been disposed.
  50420. */
  50421. onDisposeObservable: Observable<EffectLayer>;
  50422. /**
  50423. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  50424. */
  50425. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  50426. /**
  50427. * An event triggered when the generated texture is being merged in the scene.
  50428. */
  50429. onBeforeComposeObservable: Observable<EffectLayer>;
  50430. /**
  50431. * An event triggered when the mesh is rendered into the effect render target.
  50432. */
  50433. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  50434. /**
  50435. * An event triggered after the mesh has been rendered into the effect render target.
  50436. */
  50437. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  50438. /**
  50439. * An event triggered when the generated texture has been merged in the scene.
  50440. */
  50441. onAfterComposeObservable: Observable<EffectLayer>;
  50442. /**
  50443. * An event triggered when the efffect layer changes its size.
  50444. */
  50445. onSizeChangedObservable: Observable<EffectLayer>;
  50446. /** @hidden */
  50447. static _SceneComponentInitialization: (scene: Scene) => void;
  50448. /**
  50449. * Instantiates a new effect Layer and references it in the scene.
  50450. * @param name The name of the layer
  50451. * @param scene The scene to use the layer in
  50452. */
  50453. constructor(
  50454. /** The Friendly of the effect in the scene */
  50455. name: string, scene: Scene);
  50456. /**
  50457. * Get the effect name of the layer.
  50458. * @return The effect name
  50459. */
  50460. abstract getEffectName(): string;
  50461. /**
  50462. * Checks for the readiness of the element composing the layer.
  50463. * @param subMesh the mesh to check for
  50464. * @param useInstances specify wether or not to use instances to render the mesh
  50465. * @return true if ready otherwise, false
  50466. */
  50467. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50468. /**
  50469. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  50470. * @returns true if the effect requires stencil during the main canvas render pass.
  50471. */
  50472. abstract needStencil(): boolean;
  50473. /**
  50474. * Create the merge effect. This is the shader use to blit the information back
  50475. * to the main canvas at the end of the scene rendering.
  50476. * @returns The effect containing the shader used to merge the effect on the main canvas
  50477. */
  50478. protected abstract _createMergeEffect(): Effect;
  50479. /**
  50480. * Creates the render target textures and post processes used in the effect layer.
  50481. */
  50482. protected abstract _createTextureAndPostProcesses(): void;
  50483. /**
  50484. * Implementation specific of rendering the generating effect on the main canvas.
  50485. * @param effect The effect used to render through
  50486. */
  50487. protected abstract _internalRender(effect: Effect): void;
  50488. /**
  50489. * Sets the required values for both the emissive texture and and the main color.
  50490. */
  50491. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  50492. /**
  50493. * Free any resources and references associated to a mesh.
  50494. * Internal use
  50495. * @param mesh The mesh to free.
  50496. */
  50497. abstract _disposeMesh(mesh: Mesh): void;
  50498. /**
  50499. * Serializes this layer (Glow or Highlight for example)
  50500. * @returns a serialized layer object
  50501. */
  50502. abstract serialize?(): any;
  50503. /**
  50504. * Initializes the effect layer with the required options.
  50505. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  50506. */
  50507. protected _init(options: Partial<IEffectLayerOptions>): void;
  50508. /**
  50509. * Generates the index buffer of the full screen quad blending to the main canvas.
  50510. */
  50511. private _generateIndexBuffer;
  50512. /**
  50513. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  50514. */
  50515. private _generateVertexBuffer;
  50516. /**
  50517. * Sets the main texture desired size which is the closest power of two
  50518. * of the engine canvas size.
  50519. */
  50520. private _setMainTextureSize;
  50521. /**
  50522. * Creates the main texture for the effect layer.
  50523. */
  50524. protected _createMainTexture(): void;
  50525. /**
  50526. * Adds specific effects defines.
  50527. * @param defines The defines to add specifics to.
  50528. */
  50529. protected _addCustomEffectDefines(defines: string[]): void;
  50530. /**
  50531. * Checks for the readiness of the element composing the layer.
  50532. * @param subMesh the mesh to check for
  50533. * @param useInstances specify wether or not to use instances to render the mesh
  50534. * @param emissiveTexture the associated emissive texture used to generate the glow
  50535. * @return true if ready otherwise, false
  50536. */
  50537. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  50538. /**
  50539. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  50540. */
  50541. render(): void;
  50542. /**
  50543. * Determine if a given mesh will be used in the current effect.
  50544. * @param mesh mesh to test
  50545. * @returns true if the mesh will be used
  50546. */
  50547. hasMesh(mesh: AbstractMesh): boolean;
  50548. /**
  50549. * Returns true if the layer contains information to display, otherwise false.
  50550. * @returns true if the glow layer should be rendered
  50551. */
  50552. shouldRender(): boolean;
  50553. /**
  50554. * Returns true if the mesh should render, otherwise false.
  50555. * @param mesh The mesh to render
  50556. * @returns true if it should render otherwise false
  50557. */
  50558. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  50559. /**
  50560. * Returns true if the mesh can be rendered, otherwise false.
  50561. * @param mesh The mesh to render
  50562. * @param material The material used on the mesh
  50563. * @returns true if it can be rendered otherwise false
  50564. */
  50565. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  50566. /**
  50567. * Returns true if the mesh should render, otherwise false.
  50568. * @param mesh The mesh to render
  50569. * @returns true if it should render otherwise false
  50570. */
  50571. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  50572. /**
  50573. * Renders the submesh passed in parameter to the generation map.
  50574. */
  50575. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  50576. /**
  50577. * Defines wether the current material of the mesh should be use to render the effect.
  50578. * @param mesh defines the current mesh to render
  50579. */
  50580. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  50581. /**
  50582. * Rebuild the required buffers.
  50583. * @hidden Internal use only.
  50584. */
  50585. _rebuild(): void;
  50586. /**
  50587. * Dispose only the render target textures and post process.
  50588. */
  50589. private _disposeTextureAndPostProcesses;
  50590. /**
  50591. * Dispose the highlight layer and free resources.
  50592. */
  50593. dispose(): void;
  50594. /**
  50595. * Gets the class name of the effect layer
  50596. * @returns the string with the class name of the effect layer
  50597. */
  50598. getClassName(): string;
  50599. /**
  50600. * Creates an effect layer from parsed effect layer data
  50601. * @param parsedEffectLayer defines effect layer data
  50602. * @param scene defines the current scene
  50603. * @param rootUrl defines the root URL containing the effect layer information
  50604. * @returns a parsed effect Layer
  50605. */
  50606. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  50607. }
  50608. }
  50609. declare module BABYLON {
  50610. interface AbstractScene {
  50611. /**
  50612. * The list of effect layers (highlights/glow) added to the scene
  50613. * @see http://doc.babylonjs.com/how_to/highlight_layer
  50614. * @see http://doc.babylonjs.com/how_to/glow_layer
  50615. */
  50616. effectLayers: Array<EffectLayer>;
  50617. /**
  50618. * Removes the given effect layer from this scene.
  50619. * @param toRemove defines the effect layer to remove
  50620. * @returns the index of the removed effect layer
  50621. */
  50622. removeEffectLayer(toRemove: EffectLayer): number;
  50623. /**
  50624. * Adds the given effect layer to this scene
  50625. * @param newEffectLayer defines the effect layer to add
  50626. */
  50627. addEffectLayer(newEffectLayer: EffectLayer): void;
  50628. }
  50629. /**
  50630. * Defines the layer scene component responsible to manage any effect layers
  50631. * in a given scene.
  50632. */
  50633. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  50634. /**
  50635. * The component name helpfull to identify the component in the list of scene components.
  50636. */
  50637. readonly name: string;
  50638. /**
  50639. * The scene the component belongs to.
  50640. */
  50641. scene: Scene;
  50642. private _engine;
  50643. private _renderEffects;
  50644. private _needStencil;
  50645. private _previousStencilState;
  50646. /**
  50647. * Creates a new instance of the component for the given scene
  50648. * @param scene Defines the scene to register the component in
  50649. */
  50650. constructor(scene: Scene);
  50651. /**
  50652. * Registers the component in a given scene
  50653. */
  50654. register(): void;
  50655. /**
  50656. * Rebuilds the elements related to this component in case of
  50657. * context lost for instance.
  50658. */
  50659. rebuild(): void;
  50660. /**
  50661. * Serializes the component data to the specified json object
  50662. * @param serializationObject The object to serialize to
  50663. */
  50664. serialize(serializationObject: any): void;
  50665. /**
  50666. * Adds all the elements from the container to the scene
  50667. * @param container the container holding the elements
  50668. */
  50669. addFromContainer(container: AbstractScene): void;
  50670. /**
  50671. * Removes all the elements in the container from the scene
  50672. * @param container contains the elements to remove
  50673. * @param dispose if the removed element should be disposed (default: false)
  50674. */
  50675. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50676. /**
  50677. * Disposes the component and the associated ressources.
  50678. */
  50679. dispose(): void;
  50680. private _isReadyForMesh;
  50681. private _renderMainTexture;
  50682. private _setStencil;
  50683. private _setStencilBack;
  50684. private _draw;
  50685. private _drawCamera;
  50686. private _drawRenderingGroup;
  50687. }
  50688. }
  50689. declare module BABYLON {
  50690. /** @hidden */
  50691. export var glowMapMergePixelShader: {
  50692. name: string;
  50693. shader: string;
  50694. };
  50695. }
  50696. declare module BABYLON {
  50697. /** @hidden */
  50698. export var glowMapMergeVertexShader: {
  50699. name: string;
  50700. shader: string;
  50701. };
  50702. }
  50703. declare module BABYLON {
  50704. interface AbstractScene {
  50705. /**
  50706. * Return a the first highlight layer of the scene with a given name.
  50707. * @param name The name of the highlight layer to look for.
  50708. * @return The highlight layer if found otherwise null.
  50709. */
  50710. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  50711. }
  50712. /**
  50713. * Glow layer options. This helps customizing the behaviour
  50714. * of the glow layer.
  50715. */
  50716. export interface IGlowLayerOptions {
  50717. /**
  50718. * Multiplication factor apply to the canvas size to compute the render target size
  50719. * used to generated the glowing objects (the smaller the faster).
  50720. */
  50721. mainTextureRatio: number;
  50722. /**
  50723. * Enforces a fixed size texture to ensure resize independant blur.
  50724. */
  50725. mainTextureFixedSize?: number;
  50726. /**
  50727. * How big is the kernel of the blur texture.
  50728. */
  50729. blurKernelSize: number;
  50730. /**
  50731. * The camera attached to the layer.
  50732. */
  50733. camera: Nullable<Camera>;
  50734. /**
  50735. * Enable MSAA by chosing the number of samples.
  50736. */
  50737. mainTextureSamples?: number;
  50738. /**
  50739. * The rendering group to draw the layer in.
  50740. */
  50741. renderingGroupId: number;
  50742. }
  50743. /**
  50744. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  50745. *
  50746. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  50747. *
  50748. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  50749. */
  50750. export class GlowLayer extends EffectLayer {
  50751. /**
  50752. * Effect Name of the layer.
  50753. */
  50754. static readonly EffectName: string;
  50755. /**
  50756. * The default blur kernel size used for the glow.
  50757. */
  50758. static DefaultBlurKernelSize: number;
  50759. /**
  50760. * The default texture size ratio used for the glow.
  50761. */
  50762. static DefaultTextureRatio: number;
  50763. /**
  50764. * Sets the kernel size of the blur.
  50765. */
  50766. /**
  50767. * Gets the kernel size of the blur.
  50768. */
  50769. blurKernelSize: number;
  50770. /**
  50771. * Sets the glow intensity.
  50772. */
  50773. /**
  50774. * Gets the glow intensity.
  50775. */
  50776. intensity: number;
  50777. private _options;
  50778. private _intensity;
  50779. private _horizontalBlurPostprocess1;
  50780. private _verticalBlurPostprocess1;
  50781. private _horizontalBlurPostprocess2;
  50782. private _verticalBlurPostprocess2;
  50783. private _blurTexture1;
  50784. private _blurTexture2;
  50785. private _postProcesses1;
  50786. private _postProcesses2;
  50787. private _includedOnlyMeshes;
  50788. private _excludedMeshes;
  50789. private _meshesUsingTheirOwnMaterials;
  50790. /**
  50791. * Callback used to let the user override the color selection on a per mesh basis
  50792. */
  50793. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  50794. /**
  50795. * Callback used to let the user override the texture selection on a per mesh basis
  50796. */
  50797. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  50798. /**
  50799. * Instantiates a new glow Layer and references it to the scene.
  50800. * @param name The name of the layer
  50801. * @param scene The scene to use the layer in
  50802. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  50803. */
  50804. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  50805. /**
  50806. * Get the effect name of the layer.
  50807. * @return The effect name
  50808. */
  50809. getEffectName(): string;
  50810. /**
  50811. * Create the merge effect. This is the shader use to blit the information back
  50812. * to the main canvas at the end of the scene rendering.
  50813. */
  50814. protected _createMergeEffect(): Effect;
  50815. /**
  50816. * Creates the render target textures and post processes used in the glow layer.
  50817. */
  50818. protected _createTextureAndPostProcesses(): void;
  50819. /**
  50820. * Checks for the readiness of the element composing the layer.
  50821. * @param subMesh the mesh to check for
  50822. * @param useInstances specify wether or not to use instances to render the mesh
  50823. * @param emissiveTexture the associated emissive texture used to generate the glow
  50824. * @return true if ready otherwise, false
  50825. */
  50826. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50827. /**
  50828. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  50829. */
  50830. needStencil(): boolean;
  50831. /**
  50832. * Returns true if the mesh can be rendered, otherwise false.
  50833. * @param mesh The mesh to render
  50834. * @param material The material used on the mesh
  50835. * @returns true if it can be rendered otherwise false
  50836. */
  50837. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  50838. /**
  50839. * Implementation specific of rendering the generating effect on the main canvas.
  50840. * @param effect The effect used to render through
  50841. */
  50842. protected _internalRender(effect: Effect): void;
  50843. /**
  50844. * Sets the required values for both the emissive texture and and the main color.
  50845. */
  50846. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  50847. /**
  50848. * Returns true if the mesh should render, otherwise false.
  50849. * @param mesh The mesh to render
  50850. * @returns true if it should render otherwise false
  50851. */
  50852. protected _shouldRenderMesh(mesh: Mesh): boolean;
  50853. /**
  50854. * Adds specific effects defines.
  50855. * @param defines The defines to add specifics to.
  50856. */
  50857. protected _addCustomEffectDefines(defines: string[]): void;
  50858. /**
  50859. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  50860. * @param mesh The mesh to exclude from the glow layer
  50861. */
  50862. addExcludedMesh(mesh: Mesh): void;
  50863. /**
  50864. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  50865. * @param mesh The mesh to remove
  50866. */
  50867. removeExcludedMesh(mesh: Mesh): void;
  50868. /**
  50869. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  50870. * @param mesh The mesh to include in the glow layer
  50871. */
  50872. addIncludedOnlyMesh(mesh: Mesh): void;
  50873. /**
  50874. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  50875. * @param mesh The mesh to remove
  50876. */
  50877. removeIncludedOnlyMesh(mesh: Mesh): void;
  50878. /**
  50879. * Determine if a given mesh will be used in the glow layer
  50880. * @param mesh The mesh to test
  50881. * @returns true if the mesh will be highlighted by the current glow layer
  50882. */
  50883. hasMesh(mesh: AbstractMesh): boolean;
  50884. /**
  50885. * Defines wether the current material of the mesh should be use to render the effect.
  50886. * @param mesh defines the current mesh to render
  50887. */
  50888. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  50889. /**
  50890. * Add a mesh to be rendered through its own material and not with emissive only.
  50891. * @param mesh The mesh for which we need to use its material
  50892. */
  50893. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  50894. /**
  50895. * Remove a mesh from being rendered through its own material and not with emissive only.
  50896. * @param mesh The mesh for which we need to not use its material
  50897. */
  50898. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  50899. /**
  50900. * Free any resources and references associated to a mesh.
  50901. * Internal use
  50902. * @param mesh The mesh to free.
  50903. * @hidden
  50904. */
  50905. _disposeMesh(mesh: Mesh): void;
  50906. /**
  50907. * Gets the class name of the effect layer
  50908. * @returns the string with the class name of the effect layer
  50909. */
  50910. getClassName(): string;
  50911. /**
  50912. * Serializes this glow layer
  50913. * @returns a serialized glow layer object
  50914. */
  50915. serialize(): any;
  50916. /**
  50917. * Creates a Glow Layer from parsed glow layer data
  50918. * @param parsedGlowLayer defines glow layer data
  50919. * @param scene defines the current scene
  50920. * @param rootUrl defines the root URL containing the glow layer information
  50921. * @returns a parsed Glow Layer
  50922. */
  50923. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  50924. }
  50925. }
  50926. declare module BABYLON {
  50927. /** @hidden */
  50928. export var glowBlurPostProcessPixelShader: {
  50929. name: string;
  50930. shader: string;
  50931. };
  50932. }
  50933. declare module BABYLON {
  50934. interface AbstractScene {
  50935. /**
  50936. * Return a the first highlight layer of the scene with a given name.
  50937. * @param name The name of the highlight layer to look for.
  50938. * @return The highlight layer if found otherwise null.
  50939. */
  50940. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  50941. }
  50942. /**
  50943. * Highlight layer options. This helps customizing the behaviour
  50944. * of the highlight layer.
  50945. */
  50946. export interface IHighlightLayerOptions {
  50947. /**
  50948. * Multiplication factor apply to the canvas size to compute the render target size
  50949. * used to generated the glowing objects (the smaller the faster).
  50950. */
  50951. mainTextureRatio: number;
  50952. /**
  50953. * Enforces a fixed size texture to ensure resize independant blur.
  50954. */
  50955. mainTextureFixedSize?: number;
  50956. /**
  50957. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  50958. * of the picture to blur (the smaller the faster).
  50959. */
  50960. blurTextureSizeRatio: number;
  50961. /**
  50962. * How big in texel of the blur texture is the vertical blur.
  50963. */
  50964. blurVerticalSize: number;
  50965. /**
  50966. * How big in texel of the blur texture is the horizontal blur.
  50967. */
  50968. blurHorizontalSize: number;
  50969. /**
  50970. * Alpha blending mode used to apply the blur. Default is combine.
  50971. */
  50972. alphaBlendingMode: number;
  50973. /**
  50974. * The camera attached to the layer.
  50975. */
  50976. camera: Nullable<Camera>;
  50977. /**
  50978. * Should we display highlight as a solid stroke?
  50979. */
  50980. isStroke?: boolean;
  50981. /**
  50982. * The rendering group to draw the layer in.
  50983. */
  50984. renderingGroupId: number;
  50985. }
  50986. /**
  50987. * The highlight layer Helps adding a glow effect around a mesh.
  50988. *
  50989. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  50990. * glowy meshes to your scene.
  50991. *
  50992. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  50993. */
  50994. export class HighlightLayer extends EffectLayer {
  50995. name: string;
  50996. /**
  50997. * Effect Name of the highlight layer.
  50998. */
  50999. static readonly EffectName: string;
  51000. /**
  51001. * The neutral color used during the preparation of the glow effect.
  51002. * This is black by default as the blend operation is a blend operation.
  51003. */
  51004. static NeutralColor: Color4;
  51005. /**
  51006. * Stencil value used for glowing meshes.
  51007. */
  51008. static GlowingMeshStencilReference: number;
  51009. /**
  51010. * Stencil value used for the other meshes in the scene.
  51011. */
  51012. static NormalMeshStencilReference: number;
  51013. /**
  51014. * Specifies whether or not the inner glow is ACTIVE in the layer.
  51015. */
  51016. innerGlow: boolean;
  51017. /**
  51018. * Specifies whether or not the outer glow is ACTIVE in the layer.
  51019. */
  51020. outerGlow: boolean;
  51021. /**
  51022. * Specifies the horizontal size of the blur.
  51023. */
  51024. /**
  51025. * Gets the horizontal size of the blur.
  51026. */
  51027. blurHorizontalSize: number;
  51028. /**
  51029. * Specifies the vertical size of the blur.
  51030. */
  51031. /**
  51032. * Gets the vertical size of the blur.
  51033. */
  51034. blurVerticalSize: number;
  51035. /**
  51036. * An event triggered when the highlight layer is being blurred.
  51037. */
  51038. onBeforeBlurObservable: Observable<HighlightLayer>;
  51039. /**
  51040. * An event triggered when the highlight layer has been blurred.
  51041. */
  51042. onAfterBlurObservable: Observable<HighlightLayer>;
  51043. private _instanceGlowingMeshStencilReference;
  51044. private _options;
  51045. private _downSamplePostprocess;
  51046. private _horizontalBlurPostprocess;
  51047. private _verticalBlurPostprocess;
  51048. private _blurTexture;
  51049. private _meshes;
  51050. private _excludedMeshes;
  51051. /**
  51052. * Instantiates a new highlight Layer and references it to the scene..
  51053. * @param name The name of the layer
  51054. * @param scene The scene to use the layer in
  51055. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  51056. */
  51057. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  51058. /**
  51059. * Get the effect name of the layer.
  51060. * @return The effect name
  51061. */
  51062. getEffectName(): string;
  51063. /**
  51064. * Create the merge effect. This is the shader use to blit the information back
  51065. * to the main canvas at the end of the scene rendering.
  51066. */
  51067. protected _createMergeEffect(): Effect;
  51068. /**
  51069. * Creates the render target textures and post processes used in the highlight layer.
  51070. */
  51071. protected _createTextureAndPostProcesses(): void;
  51072. /**
  51073. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51074. */
  51075. needStencil(): boolean;
  51076. /**
  51077. * Checks for the readiness of the element composing the layer.
  51078. * @param subMesh the mesh to check for
  51079. * @param useInstances specify wether or not to use instances to render the mesh
  51080. * @param emissiveTexture the associated emissive texture used to generate the glow
  51081. * @return true if ready otherwise, false
  51082. */
  51083. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51084. /**
  51085. * Implementation specific of rendering the generating effect on the main canvas.
  51086. * @param effect The effect used to render through
  51087. */
  51088. protected _internalRender(effect: Effect): void;
  51089. /**
  51090. * Returns true if the layer contains information to display, otherwise false.
  51091. */
  51092. shouldRender(): boolean;
  51093. /**
  51094. * Returns true if the mesh should render, otherwise false.
  51095. * @param mesh The mesh to render
  51096. * @returns true if it should render otherwise false
  51097. */
  51098. protected _shouldRenderMesh(mesh: Mesh): boolean;
  51099. /**
  51100. * Sets the required values for both the emissive texture and and the main color.
  51101. */
  51102. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51103. /**
  51104. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  51105. * @param mesh The mesh to exclude from the highlight layer
  51106. */
  51107. addExcludedMesh(mesh: Mesh): void;
  51108. /**
  51109. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  51110. * @param mesh The mesh to highlight
  51111. */
  51112. removeExcludedMesh(mesh: Mesh): void;
  51113. /**
  51114. * Determine if a given mesh will be highlighted by the current HighlightLayer
  51115. * @param mesh mesh to test
  51116. * @returns true if the mesh will be highlighted by the current HighlightLayer
  51117. */
  51118. hasMesh(mesh: AbstractMesh): boolean;
  51119. /**
  51120. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  51121. * @param mesh The mesh to highlight
  51122. * @param color The color of the highlight
  51123. * @param glowEmissiveOnly Extract the glow from the emissive texture
  51124. */
  51125. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  51126. /**
  51127. * Remove a mesh from the highlight layer in order to make it stop glowing.
  51128. * @param mesh The mesh to highlight
  51129. */
  51130. removeMesh(mesh: Mesh): void;
  51131. /**
  51132. * Force the stencil to the normal expected value for none glowing parts
  51133. */
  51134. private _defaultStencilReference;
  51135. /**
  51136. * Free any resources and references associated to a mesh.
  51137. * Internal use
  51138. * @param mesh The mesh to free.
  51139. * @hidden
  51140. */
  51141. _disposeMesh(mesh: Mesh): void;
  51142. /**
  51143. * Dispose the highlight layer and free resources.
  51144. */
  51145. dispose(): void;
  51146. /**
  51147. * Gets the class name of the effect layer
  51148. * @returns the string with the class name of the effect layer
  51149. */
  51150. getClassName(): string;
  51151. /**
  51152. * Serializes this Highlight layer
  51153. * @returns a serialized Highlight layer object
  51154. */
  51155. serialize(): any;
  51156. /**
  51157. * Creates a Highlight layer from parsed Highlight layer data
  51158. * @param parsedHightlightLayer defines the Highlight layer data
  51159. * @param scene defines the current scene
  51160. * @param rootUrl defines the root URL containing the Highlight layer information
  51161. * @returns a parsed Highlight layer
  51162. */
  51163. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  51164. }
  51165. }
  51166. declare module BABYLON {
  51167. interface AbstractScene {
  51168. /**
  51169. * The list of layers (background and foreground) of the scene
  51170. */
  51171. layers: Array<Layer>;
  51172. }
  51173. /**
  51174. * Defines the layer scene component responsible to manage any layers
  51175. * in a given scene.
  51176. */
  51177. export class LayerSceneComponent implements ISceneComponent {
  51178. /**
  51179. * The component name helpfull to identify the component in the list of scene components.
  51180. */
  51181. readonly name: string;
  51182. /**
  51183. * The scene the component belongs to.
  51184. */
  51185. scene: Scene;
  51186. private _engine;
  51187. /**
  51188. * Creates a new instance of the component for the given scene
  51189. * @param scene Defines the scene to register the component in
  51190. */
  51191. constructor(scene: Scene);
  51192. /**
  51193. * Registers the component in a given scene
  51194. */
  51195. register(): void;
  51196. /**
  51197. * Rebuilds the elements related to this component in case of
  51198. * context lost for instance.
  51199. */
  51200. rebuild(): void;
  51201. /**
  51202. * Disposes the component and the associated ressources.
  51203. */
  51204. dispose(): void;
  51205. private _draw;
  51206. private _drawCameraPredicate;
  51207. private _drawCameraBackground;
  51208. private _drawCameraForeground;
  51209. private _drawRenderTargetPredicate;
  51210. private _drawRenderTargetBackground;
  51211. private _drawRenderTargetForeground;
  51212. /**
  51213. * Adds all the elements from the container to the scene
  51214. * @param container the container holding the elements
  51215. */
  51216. addFromContainer(container: AbstractScene): void;
  51217. /**
  51218. * Removes all the elements in the container from the scene
  51219. * @param container contains the elements to remove
  51220. * @param dispose if the removed element should be disposed (default: false)
  51221. */
  51222. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51223. }
  51224. }
  51225. declare module BABYLON {
  51226. /** @hidden */
  51227. export var layerPixelShader: {
  51228. name: string;
  51229. shader: string;
  51230. };
  51231. }
  51232. declare module BABYLON {
  51233. /** @hidden */
  51234. export var layerVertexShader: {
  51235. name: string;
  51236. shader: string;
  51237. };
  51238. }
  51239. declare module BABYLON {
  51240. /**
  51241. * This represents a full screen 2d layer.
  51242. * This can be useful to display a picture in the background of your scene for instance.
  51243. * @see https://www.babylonjs-playground.com/#08A2BS#1
  51244. */
  51245. export class Layer {
  51246. /**
  51247. * Define the name of the layer.
  51248. */
  51249. name: string;
  51250. /**
  51251. * Define the texture the layer should display.
  51252. */
  51253. texture: Nullable<Texture>;
  51254. /**
  51255. * Is the layer in background or foreground.
  51256. */
  51257. isBackground: boolean;
  51258. /**
  51259. * Define the color of the layer (instead of texture).
  51260. */
  51261. color: Color4;
  51262. /**
  51263. * Define the scale of the layer in order to zoom in out of the texture.
  51264. */
  51265. scale: Vector2;
  51266. /**
  51267. * Define an offset for the layer in order to shift the texture.
  51268. */
  51269. offset: Vector2;
  51270. /**
  51271. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  51272. */
  51273. alphaBlendingMode: number;
  51274. /**
  51275. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  51276. * Alpha test will not mix with the background color in case of transparency.
  51277. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  51278. */
  51279. alphaTest: boolean;
  51280. /**
  51281. * Define a mask to restrict the layer to only some of the scene cameras.
  51282. */
  51283. layerMask: number;
  51284. /**
  51285. * Define the list of render target the layer is visible into.
  51286. */
  51287. renderTargetTextures: RenderTargetTexture[];
  51288. /**
  51289. * Define if the layer is only used in renderTarget or if it also
  51290. * renders in the main frame buffer of the canvas.
  51291. */
  51292. renderOnlyInRenderTargetTextures: boolean;
  51293. private _scene;
  51294. private _vertexBuffers;
  51295. private _indexBuffer;
  51296. private _effect;
  51297. private _previousDefines;
  51298. /**
  51299. * An event triggered when the layer is disposed.
  51300. */
  51301. onDisposeObservable: Observable<Layer>;
  51302. private _onDisposeObserver;
  51303. /**
  51304. * Back compatibility with callback before the onDisposeObservable existed.
  51305. * The set callback will be triggered when the layer has been disposed.
  51306. */
  51307. onDispose: () => void;
  51308. /**
  51309. * An event triggered before rendering the scene
  51310. */
  51311. onBeforeRenderObservable: Observable<Layer>;
  51312. private _onBeforeRenderObserver;
  51313. /**
  51314. * Back compatibility with callback before the onBeforeRenderObservable existed.
  51315. * The set callback will be triggered just before rendering the layer.
  51316. */
  51317. onBeforeRender: () => void;
  51318. /**
  51319. * An event triggered after rendering the scene
  51320. */
  51321. onAfterRenderObservable: Observable<Layer>;
  51322. private _onAfterRenderObserver;
  51323. /**
  51324. * Back compatibility with callback before the onAfterRenderObservable existed.
  51325. * The set callback will be triggered just after rendering the layer.
  51326. */
  51327. onAfterRender: () => void;
  51328. /**
  51329. * Instantiates a new layer.
  51330. * This represents a full screen 2d layer.
  51331. * This can be useful to display a picture in the background of your scene for instance.
  51332. * @see https://www.babylonjs-playground.com/#08A2BS#1
  51333. * @param name Define the name of the layer in the scene
  51334. * @param imgUrl Define the url of the texture to display in the layer
  51335. * @param scene Define the scene the layer belongs to
  51336. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  51337. * @param color Defines a color for the layer
  51338. */
  51339. constructor(
  51340. /**
  51341. * Define the name of the layer.
  51342. */
  51343. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  51344. private _createIndexBuffer;
  51345. /** @hidden */
  51346. _rebuild(): void;
  51347. /**
  51348. * Renders the layer in the scene.
  51349. */
  51350. render(): void;
  51351. /**
  51352. * Disposes and releases the associated ressources.
  51353. */
  51354. dispose(): void;
  51355. }
  51356. }
  51357. declare module BABYLON {
  51358. /** @hidden */
  51359. export var lensFlarePixelShader: {
  51360. name: string;
  51361. shader: string;
  51362. };
  51363. }
  51364. declare module BABYLON {
  51365. /** @hidden */
  51366. export var lensFlareVertexShader: {
  51367. name: string;
  51368. shader: string;
  51369. };
  51370. }
  51371. declare module BABYLON {
  51372. /**
  51373. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  51374. * It is usually composed of several `lensFlare`.
  51375. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51376. */
  51377. export class LensFlareSystem {
  51378. /**
  51379. * Define the name of the lens flare system
  51380. */
  51381. name: string;
  51382. /**
  51383. * List of lens flares used in this system.
  51384. */
  51385. lensFlares: LensFlare[];
  51386. /**
  51387. * Define a limit from the border the lens flare can be visible.
  51388. */
  51389. borderLimit: number;
  51390. /**
  51391. * Define a viewport border we do not want to see the lens flare in.
  51392. */
  51393. viewportBorder: number;
  51394. /**
  51395. * Define a predicate which could limit the list of meshes able to occlude the effect.
  51396. */
  51397. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  51398. /**
  51399. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  51400. */
  51401. layerMask: number;
  51402. /**
  51403. * Define the id of the lens flare system in the scene.
  51404. * (equal to name by default)
  51405. */
  51406. id: string;
  51407. private _scene;
  51408. private _emitter;
  51409. private _vertexBuffers;
  51410. private _indexBuffer;
  51411. private _effect;
  51412. private _positionX;
  51413. private _positionY;
  51414. private _isEnabled;
  51415. /** @hidden */
  51416. static _SceneComponentInitialization: (scene: Scene) => void;
  51417. /**
  51418. * Instantiates a lens flare system.
  51419. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  51420. * It is usually composed of several `lensFlare`.
  51421. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51422. * @param name Define the name of the lens flare system in the scene
  51423. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  51424. * @param scene Define the scene the lens flare system belongs to
  51425. */
  51426. constructor(
  51427. /**
  51428. * Define the name of the lens flare system
  51429. */
  51430. name: string, emitter: any, scene: Scene);
  51431. /**
  51432. * Define if the lens flare system is enabled.
  51433. */
  51434. isEnabled: boolean;
  51435. /**
  51436. * Get the scene the effects belongs to.
  51437. * @returns the scene holding the lens flare system
  51438. */
  51439. getScene(): Scene;
  51440. /**
  51441. * Get the emitter of the lens flare system.
  51442. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  51443. * @returns the emitter of the lens flare system
  51444. */
  51445. getEmitter(): any;
  51446. /**
  51447. * Set the emitter of the lens flare system.
  51448. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  51449. * @param newEmitter Define the new emitter of the system
  51450. */
  51451. setEmitter(newEmitter: any): void;
  51452. /**
  51453. * Get the lens flare system emitter position.
  51454. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  51455. * @returns the position
  51456. */
  51457. getEmitterPosition(): Vector3;
  51458. /**
  51459. * @hidden
  51460. */
  51461. computeEffectivePosition(globalViewport: Viewport): boolean;
  51462. /** @hidden */
  51463. _isVisible(): boolean;
  51464. /**
  51465. * @hidden
  51466. */
  51467. render(): boolean;
  51468. /**
  51469. * Dispose and release the lens flare with its associated resources.
  51470. */
  51471. dispose(): void;
  51472. /**
  51473. * Parse a lens flare system from a JSON repressentation
  51474. * @param parsedLensFlareSystem Define the JSON to parse
  51475. * @param scene Define the scene the parsed system should be instantiated in
  51476. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  51477. * @returns the parsed system
  51478. */
  51479. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  51480. /**
  51481. * Serialize the current Lens Flare System into a JSON representation.
  51482. * @returns the serialized JSON
  51483. */
  51484. serialize(): any;
  51485. }
  51486. }
  51487. declare module BABYLON {
  51488. /**
  51489. * This represents one of the lens effect in a `lensFlareSystem`.
  51490. * It controls one of the indiviual texture used in the effect.
  51491. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51492. */
  51493. export class LensFlare {
  51494. /**
  51495. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  51496. */
  51497. size: number;
  51498. /**
  51499. * 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.
  51500. */
  51501. position: number;
  51502. /**
  51503. * Define the lens color.
  51504. */
  51505. color: Color3;
  51506. /**
  51507. * Define the lens texture.
  51508. */
  51509. texture: Nullable<Texture>;
  51510. /**
  51511. * Define the alpha mode to render this particular lens.
  51512. */
  51513. alphaMode: number;
  51514. private _system;
  51515. /**
  51516. * Creates a new Lens Flare.
  51517. * This represents one of the lens effect in a `lensFlareSystem`.
  51518. * It controls one of the indiviual texture used in the effect.
  51519. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51520. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  51521. * @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.
  51522. * @param color Define the lens color
  51523. * @param imgUrl Define the lens texture url
  51524. * @param system Define the `lensFlareSystem` this flare is part of
  51525. * @returns The newly created Lens Flare
  51526. */
  51527. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  51528. /**
  51529. * Instantiates a new Lens Flare.
  51530. * This represents one of the lens effect in a `lensFlareSystem`.
  51531. * It controls one of the indiviual texture used in the effect.
  51532. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51533. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  51534. * @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.
  51535. * @param color Define the lens color
  51536. * @param imgUrl Define the lens texture url
  51537. * @param system Define the `lensFlareSystem` this flare is part of
  51538. */
  51539. constructor(
  51540. /**
  51541. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  51542. */
  51543. size: number,
  51544. /**
  51545. * 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.
  51546. */
  51547. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  51548. /**
  51549. * Dispose and release the lens flare with its associated resources.
  51550. */
  51551. dispose(): void;
  51552. }
  51553. }
  51554. declare module BABYLON {
  51555. interface AbstractScene {
  51556. /**
  51557. * The list of lens flare system added to the scene
  51558. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51559. */
  51560. lensFlareSystems: Array<LensFlareSystem>;
  51561. /**
  51562. * Removes the given lens flare system from this scene.
  51563. * @param toRemove The lens flare system to remove
  51564. * @returns The index of the removed lens flare system
  51565. */
  51566. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  51567. /**
  51568. * Adds the given lens flare system to this scene
  51569. * @param newLensFlareSystem The lens flare system to add
  51570. */
  51571. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  51572. /**
  51573. * Gets a lens flare system using its name
  51574. * @param name defines the name to look for
  51575. * @returns the lens flare system or null if not found
  51576. */
  51577. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  51578. /**
  51579. * Gets a lens flare system using its id
  51580. * @param id defines the id to look for
  51581. * @returns the lens flare system or null if not found
  51582. */
  51583. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  51584. }
  51585. /**
  51586. * Defines the lens flare scene component responsible to manage any lens flares
  51587. * in a given scene.
  51588. */
  51589. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  51590. /**
  51591. * The component name helpfull to identify the component in the list of scene components.
  51592. */
  51593. readonly name: string;
  51594. /**
  51595. * The scene the component belongs to.
  51596. */
  51597. scene: Scene;
  51598. /**
  51599. * Creates a new instance of the component for the given scene
  51600. * @param scene Defines the scene to register the component in
  51601. */
  51602. constructor(scene: Scene);
  51603. /**
  51604. * Registers the component in a given scene
  51605. */
  51606. register(): void;
  51607. /**
  51608. * Rebuilds the elements related to this component in case of
  51609. * context lost for instance.
  51610. */
  51611. rebuild(): void;
  51612. /**
  51613. * Adds all the elements from the container to the scene
  51614. * @param container the container holding the elements
  51615. */
  51616. addFromContainer(container: AbstractScene): void;
  51617. /**
  51618. * Removes all the elements in the container from the scene
  51619. * @param container contains the elements to remove
  51620. * @param dispose if the removed element should be disposed (default: false)
  51621. */
  51622. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51623. /**
  51624. * Serializes the component data to the specified json object
  51625. * @param serializationObject The object to serialize to
  51626. */
  51627. serialize(serializationObject: any): void;
  51628. /**
  51629. * Disposes the component and the associated ressources.
  51630. */
  51631. dispose(): void;
  51632. private _draw;
  51633. }
  51634. }
  51635. declare module BABYLON {
  51636. /**
  51637. * Defines the shadow generator component responsible to manage any shadow generators
  51638. * in a given scene.
  51639. */
  51640. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  51641. /**
  51642. * The component name helpfull to identify the component in the list of scene components.
  51643. */
  51644. readonly name: string;
  51645. /**
  51646. * The scene the component belongs to.
  51647. */
  51648. scene: Scene;
  51649. /**
  51650. * Creates a new instance of the component for the given scene
  51651. * @param scene Defines the scene to register the component in
  51652. */
  51653. constructor(scene: Scene);
  51654. /**
  51655. * Registers the component in a given scene
  51656. */
  51657. register(): void;
  51658. /**
  51659. * Rebuilds the elements related to this component in case of
  51660. * context lost for instance.
  51661. */
  51662. rebuild(): void;
  51663. /**
  51664. * Serializes the component data to the specified json object
  51665. * @param serializationObject The object to serialize to
  51666. */
  51667. serialize(serializationObject: any): void;
  51668. /**
  51669. * Adds all the elements from the container to the scene
  51670. * @param container the container holding the elements
  51671. */
  51672. addFromContainer(container: AbstractScene): void;
  51673. /**
  51674. * Removes all the elements in the container from the scene
  51675. * @param container contains the elements to remove
  51676. * @param dispose if the removed element should be disposed (default: false)
  51677. */
  51678. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51679. /**
  51680. * Rebuilds the elements related to this component in case of
  51681. * context lost for instance.
  51682. */
  51683. dispose(): void;
  51684. private _gatherRenderTargets;
  51685. }
  51686. }
  51687. declare module BABYLON {
  51688. /**
  51689. * A point light is a light defined by an unique point in world space.
  51690. * The light is emitted in every direction from this point.
  51691. * A good example of a point light is a standard light bulb.
  51692. * Documentation: https://doc.babylonjs.com/babylon101/lights
  51693. */
  51694. export class PointLight extends ShadowLight {
  51695. private _shadowAngle;
  51696. /**
  51697. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51698. * This specifies what angle the shadow will use to be created.
  51699. *
  51700. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  51701. */
  51702. /**
  51703. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51704. * This specifies what angle the shadow will use to be created.
  51705. *
  51706. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  51707. */
  51708. shadowAngle: number;
  51709. /**
  51710. * Gets the direction if it has been set.
  51711. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51712. */
  51713. /**
  51714. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51715. */
  51716. direction: Vector3;
  51717. /**
  51718. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  51719. * A PointLight emits the light in every direction.
  51720. * It can cast shadows.
  51721. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  51722. * ```javascript
  51723. * var pointLight = new PointLight("pl", camera.position, scene);
  51724. * ```
  51725. * Documentation : https://doc.babylonjs.com/babylon101/lights
  51726. * @param name The light friendly name
  51727. * @param position The position of the point light in the scene
  51728. * @param scene The scene the lights belongs to
  51729. */
  51730. constructor(name: string, position: Vector3, scene: Scene);
  51731. /**
  51732. * Returns the string "PointLight"
  51733. * @returns the class name
  51734. */
  51735. getClassName(): string;
  51736. /**
  51737. * Returns the integer 0.
  51738. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  51739. */
  51740. getTypeID(): number;
  51741. /**
  51742. * Specifies wether or not the shadowmap should be a cube texture.
  51743. * @returns true if the shadowmap needs to be a cube texture.
  51744. */
  51745. needCube(): boolean;
  51746. /**
  51747. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  51748. * @param faceIndex The index of the face we are computed the direction to generate shadow
  51749. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  51750. */
  51751. getShadowDirection(faceIndex?: number): Vector3;
  51752. /**
  51753. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  51754. * - fov = PI / 2
  51755. * - aspect ratio : 1.0
  51756. * - z-near and far equal to the active camera minZ and maxZ.
  51757. * Returns the PointLight.
  51758. */
  51759. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51760. protected _buildUniformLayout(): void;
  51761. /**
  51762. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  51763. * @param effect The effect to update
  51764. * @param lightIndex The index of the light in the effect to update
  51765. * @returns The point light
  51766. */
  51767. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  51768. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  51769. /**
  51770. * Prepares the list of defines specific to the light type.
  51771. * @param defines the list of defines
  51772. * @param lightIndex defines the index of the light for the effect
  51773. */
  51774. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  51775. }
  51776. }
  51777. declare module BABYLON {
  51778. /**
  51779. * Header information of HDR texture files.
  51780. */
  51781. export interface HDRInfo {
  51782. /**
  51783. * The height of the texture in pixels.
  51784. */
  51785. height: number;
  51786. /**
  51787. * The width of the texture in pixels.
  51788. */
  51789. width: number;
  51790. /**
  51791. * The index of the beginning of the data in the binary file.
  51792. */
  51793. dataPosition: number;
  51794. }
  51795. /**
  51796. * This groups tools to convert HDR texture to native colors array.
  51797. */
  51798. export class HDRTools {
  51799. private static Ldexp;
  51800. private static Rgbe2float;
  51801. private static readStringLine;
  51802. /**
  51803. * Reads header information from an RGBE texture stored in a native array.
  51804. * More information on this format are available here:
  51805. * https://en.wikipedia.org/wiki/RGBE_image_format
  51806. *
  51807. * @param uint8array The binary file stored in native array.
  51808. * @return The header information.
  51809. */
  51810. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  51811. /**
  51812. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  51813. * This RGBE texture needs to store the information as a panorama.
  51814. *
  51815. * More information on this format are available here:
  51816. * https://en.wikipedia.org/wiki/RGBE_image_format
  51817. *
  51818. * @param buffer The binary file stored in an array buffer.
  51819. * @param size The expected size of the extracted cubemap.
  51820. * @return The Cube Map information.
  51821. */
  51822. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  51823. /**
  51824. * Returns the pixels data extracted from an RGBE texture.
  51825. * This pixels will be stored left to right up to down in the R G B order in one array.
  51826. *
  51827. * More information on this format are available here:
  51828. * https://en.wikipedia.org/wiki/RGBE_image_format
  51829. *
  51830. * @param uint8array The binary file stored in an array buffer.
  51831. * @param hdrInfo The header information of the file.
  51832. * @return The pixels data in RGB right to left up to down order.
  51833. */
  51834. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  51835. private static RGBE_ReadPixels_RLE;
  51836. }
  51837. }
  51838. declare module BABYLON {
  51839. /**
  51840. * This represents a texture coming from an HDR input.
  51841. *
  51842. * The only supported format is currently panorama picture stored in RGBE format.
  51843. * Example of such files can be found on HDRLib: http://hdrlib.com/
  51844. */
  51845. export class HDRCubeTexture extends BaseTexture {
  51846. private static _facesMapping;
  51847. private _generateHarmonics;
  51848. private _noMipmap;
  51849. private _textureMatrix;
  51850. private _size;
  51851. private _onLoad;
  51852. private _onError;
  51853. /**
  51854. * The texture URL.
  51855. */
  51856. url: string;
  51857. /**
  51858. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  51859. */
  51860. coordinatesMode: number;
  51861. protected _isBlocking: boolean;
  51862. /**
  51863. * Sets wether or not the texture is blocking during loading.
  51864. */
  51865. /**
  51866. * Gets wether or not the texture is blocking during loading.
  51867. */
  51868. isBlocking: boolean;
  51869. protected _rotationY: number;
  51870. /**
  51871. * Sets texture matrix rotation angle around Y axis in radians.
  51872. */
  51873. /**
  51874. * Gets texture matrix rotation angle around Y axis radians.
  51875. */
  51876. rotationY: number;
  51877. /**
  51878. * Gets or sets the center of the bounding box associated with the cube texture
  51879. * It must define where the camera used to render the texture was set
  51880. */
  51881. boundingBoxPosition: Vector3;
  51882. private _boundingBoxSize;
  51883. /**
  51884. * Gets or sets the size of the bounding box associated with the cube texture
  51885. * When defined, the cubemap will switch to local mode
  51886. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  51887. * @example https://www.babylonjs-playground.com/#RNASML
  51888. */
  51889. boundingBoxSize: Vector3;
  51890. /**
  51891. * Instantiates an HDRTexture from the following parameters.
  51892. *
  51893. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  51894. * @param scene The scene the texture will be used in
  51895. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  51896. * @param noMipmap Forces to not generate the mipmap if true
  51897. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  51898. * @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)
  51899. * @param reserved Reserved flag for internal use.
  51900. */
  51901. 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>);
  51902. /**
  51903. * Get the current class name of the texture useful for serialization or dynamic coding.
  51904. * @returns "HDRCubeTexture"
  51905. */
  51906. getClassName(): string;
  51907. /**
  51908. * Occurs when the file is raw .hdr file.
  51909. */
  51910. private loadTexture;
  51911. clone(): HDRCubeTexture;
  51912. delayLoad(): void;
  51913. /**
  51914. * Get the texture reflection matrix used to rotate/transform the reflection.
  51915. * @returns the reflection matrix
  51916. */
  51917. getReflectionTextureMatrix(): Matrix;
  51918. /**
  51919. * Set the texture reflection matrix used to rotate/transform the reflection.
  51920. * @param value Define the reflection matrix to set
  51921. */
  51922. setReflectionTextureMatrix(value: Matrix): void;
  51923. /**
  51924. * Parses a JSON representation of an HDR Texture in order to create the texture
  51925. * @param parsedTexture Define the JSON representation
  51926. * @param scene Define the scene the texture should be created in
  51927. * @param rootUrl Define the root url in case we need to load relative dependencies
  51928. * @returns the newly created texture after parsing
  51929. */
  51930. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  51931. serialize(): any;
  51932. }
  51933. }
  51934. declare module BABYLON {
  51935. /**
  51936. * Class used to control physics engine
  51937. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  51938. */
  51939. export class PhysicsEngine implements IPhysicsEngine {
  51940. private _physicsPlugin;
  51941. /**
  51942. * Global value used to control the smallest number supported by the simulation
  51943. */
  51944. static Epsilon: number;
  51945. private _impostors;
  51946. private _joints;
  51947. private _subTimeStep;
  51948. /**
  51949. * Gets the gravity vector used by the simulation
  51950. */
  51951. gravity: Vector3;
  51952. /**
  51953. * Factory used to create the default physics plugin.
  51954. * @returns The default physics plugin
  51955. */
  51956. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  51957. /**
  51958. * Creates a new Physics Engine
  51959. * @param gravity defines the gravity vector used by the simulation
  51960. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  51961. */
  51962. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  51963. /**
  51964. * Sets the gravity vector used by the simulation
  51965. * @param gravity defines the gravity vector to use
  51966. */
  51967. setGravity(gravity: Vector3): void;
  51968. /**
  51969. * Set the time step of the physics engine.
  51970. * Default is 1/60.
  51971. * To slow it down, enter 1/600 for example.
  51972. * To speed it up, 1/30
  51973. * @param newTimeStep defines the new timestep to apply to this world.
  51974. */
  51975. setTimeStep(newTimeStep?: number): void;
  51976. /**
  51977. * Get the time step of the physics engine.
  51978. * @returns the current time step
  51979. */
  51980. getTimeStep(): number;
  51981. /**
  51982. * Set the sub time step of the physics engine.
  51983. * Default is 0 meaning there is no sub steps
  51984. * To increase physics resolution precision, set a small value (like 1 ms)
  51985. * @param subTimeStep defines the new sub timestep used for physics resolution.
  51986. */
  51987. setSubTimeStep(subTimeStep?: number): void;
  51988. /**
  51989. * Get the sub time step of the physics engine.
  51990. * @returns the current sub time step
  51991. */
  51992. getSubTimeStep(): number;
  51993. /**
  51994. * Release all resources
  51995. */
  51996. dispose(): void;
  51997. /**
  51998. * Gets the name of the current physics plugin
  51999. * @returns the name of the plugin
  52000. */
  52001. getPhysicsPluginName(): string;
  52002. /**
  52003. * Adding a new impostor for the impostor tracking.
  52004. * This will be done by the impostor itself.
  52005. * @param impostor the impostor to add
  52006. */
  52007. addImpostor(impostor: PhysicsImpostor): void;
  52008. /**
  52009. * Remove an impostor from the engine.
  52010. * This impostor and its mesh will not longer be updated by the physics engine.
  52011. * @param impostor the impostor to remove
  52012. */
  52013. removeImpostor(impostor: PhysicsImpostor): void;
  52014. /**
  52015. * Add a joint to the physics engine
  52016. * @param mainImpostor defines the main impostor to which the joint is added.
  52017. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  52018. * @param joint defines the joint that will connect both impostors.
  52019. */
  52020. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  52021. /**
  52022. * Removes a joint from the simulation
  52023. * @param mainImpostor defines the impostor used with the joint
  52024. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  52025. * @param joint defines the joint to remove
  52026. */
  52027. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  52028. /**
  52029. * Called by the scene. No need to call it.
  52030. * @param delta defines the timespam between frames
  52031. */
  52032. _step(delta: number): void;
  52033. /**
  52034. * Gets the current plugin used to run the simulation
  52035. * @returns current plugin
  52036. */
  52037. getPhysicsPlugin(): IPhysicsEnginePlugin;
  52038. /**
  52039. * Gets the list of physic impostors
  52040. * @returns an array of PhysicsImpostor
  52041. */
  52042. getImpostors(): Array<PhysicsImpostor>;
  52043. /**
  52044. * Gets the impostor for a physics enabled object
  52045. * @param object defines the object impersonated by the impostor
  52046. * @returns the PhysicsImpostor or null if not found
  52047. */
  52048. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  52049. /**
  52050. * Gets the impostor for a physics body object
  52051. * @param body defines physics body used by the impostor
  52052. * @returns the PhysicsImpostor or null if not found
  52053. */
  52054. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  52055. /**
  52056. * Does a raycast in the physics world
  52057. * @param from when should the ray start?
  52058. * @param to when should the ray end?
  52059. * @returns PhysicsRaycastResult
  52060. */
  52061. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52062. }
  52063. }
  52064. declare module BABYLON {
  52065. /** @hidden */
  52066. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  52067. private _useDeltaForWorldStep;
  52068. world: any;
  52069. name: string;
  52070. private _physicsMaterials;
  52071. private _fixedTimeStep;
  52072. private _cannonRaycastResult;
  52073. private _raycastResult;
  52074. private _physicsBodysToRemoveAfterStep;
  52075. BJSCANNON: any;
  52076. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  52077. setGravity(gravity: Vector3): void;
  52078. setTimeStep(timeStep: number): void;
  52079. getTimeStep(): number;
  52080. executeStep(delta: number): void;
  52081. private _removeMarkedPhysicsBodiesFromWorld;
  52082. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52083. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52084. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52085. private _processChildMeshes;
  52086. removePhysicsBody(impostor: PhysicsImpostor): void;
  52087. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52088. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52089. private _addMaterial;
  52090. private _checkWithEpsilon;
  52091. private _createShape;
  52092. private _createHeightmap;
  52093. private _minus90X;
  52094. private _plus90X;
  52095. private _tmpPosition;
  52096. private _tmpDeltaPosition;
  52097. private _tmpUnityRotation;
  52098. private _updatePhysicsBodyTransformation;
  52099. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52100. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52101. isSupported(): boolean;
  52102. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52103. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52104. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52105. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52106. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52107. getBodyMass(impostor: PhysicsImpostor): number;
  52108. getBodyFriction(impostor: PhysicsImpostor): number;
  52109. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52110. getBodyRestitution(impostor: PhysicsImpostor): number;
  52111. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52112. sleepBody(impostor: PhysicsImpostor): void;
  52113. wakeUpBody(impostor: PhysicsImpostor): void;
  52114. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  52115. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  52116. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  52117. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52118. getRadius(impostor: PhysicsImpostor): number;
  52119. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52120. dispose(): void;
  52121. private _extendNamespace;
  52122. /**
  52123. * Does a raycast in the physics world
  52124. * @param from when should the ray start?
  52125. * @param to when should the ray end?
  52126. * @returns PhysicsRaycastResult
  52127. */
  52128. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52129. }
  52130. }
  52131. declare module BABYLON {
  52132. /** @hidden */
  52133. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  52134. world: any;
  52135. name: string;
  52136. BJSOIMO: any;
  52137. private _raycastResult;
  52138. constructor(iterations?: number, oimoInjection?: any);
  52139. setGravity(gravity: Vector3): void;
  52140. setTimeStep(timeStep: number): void;
  52141. getTimeStep(): number;
  52142. private _tmpImpostorsArray;
  52143. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  52144. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52145. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52146. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52147. private _tmpPositionVector;
  52148. removePhysicsBody(impostor: PhysicsImpostor): void;
  52149. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52150. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52151. isSupported(): boolean;
  52152. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52153. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52154. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52155. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52156. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52157. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52158. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52159. getBodyMass(impostor: PhysicsImpostor): number;
  52160. getBodyFriction(impostor: PhysicsImpostor): number;
  52161. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52162. getBodyRestitution(impostor: PhysicsImpostor): number;
  52163. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52164. sleepBody(impostor: PhysicsImpostor): void;
  52165. wakeUpBody(impostor: PhysicsImpostor): void;
  52166. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  52167. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  52168. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  52169. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52170. getRadius(impostor: PhysicsImpostor): number;
  52171. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52172. dispose(): void;
  52173. /**
  52174. * Does a raycast in the physics world
  52175. * @param from when should the ray start?
  52176. * @param to when should the ray end?
  52177. * @returns PhysicsRaycastResult
  52178. */
  52179. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52180. }
  52181. }
  52182. declare module BABYLON {
  52183. /**
  52184. * Class containing static functions to help procedurally build meshes
  52185. */
  52186. export class RibbonBuilder {
  52187. /**
  52188. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52189. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  52190. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  52191. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  52192. * * 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
  52193. * * 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
  52194. * * 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
  52195. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52196. * * 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
  52197. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52198. * * 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
  52199. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  52200. * * 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
  52201. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  52202. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52203. * @param name defines the name of the mesh
  52204. * @param options defines the options used to create the mesh
  52205. * @param scene defines the hosting scene
  52206. * @returns the ribbon mesh
  52207. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  52208. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52209. */
  52210. static CreateRibbon(name: string, options: {
  52211. pathArray: Vector3[][];
  52212. closeArray?: boolean;
  52213. closePath?: boolean;
  52214. offset?: number;
  52215. updatable?: boolean;
  52216. sideOrientation?: number;
  52217. frontUVs?: Vector4;
  52218. backUVs?: Vector4;
  52219. instance?: Mesh;
  52220. invertUV?: boolean;
  52221. uvs?: Vector2[];
  52222. colors?: Color4[];
  52223. }, scene?: Nullable<Scene>): Mesh;
  52224. }
  52225. }
  52226. declare module BABYLON {
  52227. /**
  52228. * Class containing static functions to help procedurally build meshes
  52229. */
  52230. export class ShapeBuilder {
  52231. /**
  52232. * 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.
  52233. * * 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.
  52234. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52235. * * 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.
  52236. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  52237. * * 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
  52238. * * 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
  52239. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  52240. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52241. * * 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
  52242. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  52243. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52244. * @param name defines the name of the mesh
  52245. * @param options defines the options used to create the mesh
  52246. * @param scene defines the hosting scene
  52247. * @returns the extruded shape mesh
  52248. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52249. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52250. */
  52251. static ExtrudeShape(name: string, options: {
  52252. shape: Vector3[];
  52253. path: Vector3[];
  52254. scale?: number;
  52255. rotation?: number;
  52256. cap?: number;
  52257. updatable?: boolean;
  52258. sideOrientation?: number;
  52259. frontUVs?: Vector4;
  52260. backUVs?: Vector4;
  52261. instance?: Mesh;
  52262. invertUV?: boolean;
  52263. }, scene?: Nullable<Scene>): Mesh;
  52264. /**
  52265. * Creates an custom extruded shape mesh.
  52266. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  52267. * * 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.
  52268. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52269. * * 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
  52270. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  52271. * * 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
  52272. * * It must returns a float value that will be the scale value applied to the shape on each path point
  52273. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  52274. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  52275. * * 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
  52276. * * 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
  52277. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  52278. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52279. * * 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
  52280. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52281. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52282. * @param name defines the name of the mesh
  52283. * @param options defines the options used to create the mesh
  52284. * @param scene defines the hosting scene
  52285. * @returns the custom extruded shape mesh
  52286. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  52287. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52288. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52289. */
  52290. static ExtrudeShapeCustom(name: string, options: {
  52291. shape: Vector3[];
  52292. path: Vector3[];
  52293. scaleFunction?: any;
  52294. rotationFunction?: any;
  52295. ribbonCloseArray?: boolean;
  52296. ribbonClosePath?: boolean;
  52297. cap?: number;
  52298. updatable?: boolean;
  52299. sideOrientation?: number;
  52300. frontUVs?: Vector4;
  52301. backUVs?: Vector4;
  52302. instance?: Mesh;
  52303. invertUV?: boolean;
  52304. }, scene?: Nullable<Scene>): Mesh;
  52305. private static _ExtrudeShapeGeneric;
  52306. }
  52307. }
  52308. declare module BABYLON {
  52309. /**
  52310. * AmmoJS Physics plugin
  52311. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52312. * @see https://github.com/kripken/ammo.js/
  52313. */
  52314. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  52315. private _useDeltaForWorldStep;
  52316. /**
  52317. * Reference to the Ammo library
  52318. */
  52319. bjsAMMO: any;
  52320. /**
  52321. * Created ammoJS world which physics bodies are added to
  52322. */
  52323. world: any;
  52324. /**
  52325. * Name of the plugin
  52326. */
  52327. name: string;
  52328. private _timeStep;
  52329. private _fixedTimeStep;
  52330. private _maxSteps;
  52331. private _tmpQuaternion;
  52332. private _tmpAmmoTransform;
  52333. private _tmpAmmoQuaternion;
  52334. private _tmpAmmoConcreteContactResultCallback;
  52335. private _collisionConfiguration;
  52336. private _dispatcher;
  52337. private _overlappingPairCache;
  52338. private _solver;
  52339. private _softBodySolver;
  52340. private _tmpAmmoVectorA;
  52341. private _tmpAmmoVectorB;
  52342. private _tmpAmmoVectorC;
  52343. private _tmpAmmoVectorD;
  52344. private _tmpContactCallbackResult;
  52345. private _tmpAmmoVectorRCA;
  52346. private _tmpAmmoVectorRCB;
  52347. private _raycastResult;
  52348. private static readonly DISABLE_COLLISION_FLAG;
  52349. private static readonly KINEMATIC_FLAG;
  52350. private static readonly DISABLE_DEACTIVATION_FLAG;
  52351. /**
  52352. * Initializes the ammoJS plugin
  52353. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  52354. * @param ammoInjection can be used to inject your own ammo reference
  52355. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  52356. */
  52357. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  52358. /**
  52359. * Sets the gravity of the physics world (m/(s^2))
  52360. * @param gravity Gravity to set
  52361. */
  52362. setGravity(gravity: Vector3): void;
  52363. /**
  52364. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  52365. * @param timeStep timestep to use in seconds
  52366. */
  52367. setTimeStep(timeStep: number): void;
  52368. /**
  52369. * 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)
  52370. * @param fixedTimeStep fixedTimeStep to use in seconds
  52371. */
  52372. setFixedTimeStep(fixedTimeStep: number): void;
  52373. /**
  52374. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  52375. * @param maxSteps the maximum number of steps by the physics engine per frame
  52376. */
  52377. setMaxSteps(maxSteps: number): void;
  52378. /**
  52379. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  52380. * @returns the current timestep in seconds
  52381. */
  52382. getTimeStep(): number;
  52383. /**
  52384. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  52385. */
  52386. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  52387. private _isImpostorInContact;
  52388. private _isImpostorPairInContact;
  52389. private _stepSimulation;
  52390. /**
  52391. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  52392. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  52393. * After the step the babylon meshes are set to the position of the physics imposters
  52394. * @param delta amount of time to step forward
  52395. * @param impostors array of imposters to update before/after the step
  52396. */
  52397. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  52398. /**
  52399. * Update babylon mesh to match physics world object
  52400. * @param impostor imposter to match
  52401. */
  52402. private _afterSoftStep;
  52403. /**
  52404. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  52405. * @param impostor imposter to match
  52406. */
  52407. private _ropeStep;
  52408. /**
  52409. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  52410. * @param impostor imposter to match
  52411. */
  52412. private _softbodyOrClothStep;
  52413. private _tmpVector;
  52414. private _tmpMatrix;
  52415. /**
  52416. * Applies an impulse on the imposter
  52417. * @param impostor imposter to apply impulse to
  52418. * @param force amount of force to be applied to the imposter
  52419. * @param contactPoint the location to apply the impulse on the imposter
  52420. */
  52421. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52422. /**
  52423. * Applies a force on the imposter
  52424. * @param impostor imposter to apply force
  52425. * @param force amount of force to be applied to the imposter
  52426. * @param contactPoint the location to apply the force on the imposter
  52427. */
  52428. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52429. /**
  52430. * Creates a physics body using the plugin
  52431. * @param impostor the imposter to create the physics body on
  52432. */
  52433. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52434. /**
  52435. * Removes the physics body from the imposter and disposes of the body's memory
  52436. * @param impostor imposter to remove the physics body from
  52437. */
  52438. removePhysicsBody(impostor: PhysicsImpostor): void;
  52439. /**
  52440. * Generates a joint
  52441. * @param impostorJoint the imposter joint to create the joint with
  52442. */
  52443. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52444. /**
  52445. * Removes a joint
  52446. * @param impostorJoint the imposter joint to remove the joint from
  52447. */
  52448. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52449. private _addMeshVerts;
  52450. /**
  52451. * Initialise the soft body vertices to match its object's (mesh) vertices
  52452. * Softbody vertices (nodes) are in world space and to match this
  52453. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  52454. * @param impostor to create the softbody for
  52455. */
  52456. private _softVertexData;
  52457. /**
  52458. * Create an impostor's soft body
  52459. * @param impostor to create the softbody for
  52460. */
  52461. private _createSoftbody;
  52462. /**
  52463. * Create cloth for an impostor
  52464. * @param impostor to create the softbody for
  52465. */
  52466. private _createCloth;
  52467. /**
  52468. * Create rope for an impostor
  52469. * @param impostor to create the softbody for
  52470. */
  52471. private _createRope;
  52472. /**
  52473. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  52474. * @param impostor to create the custom physics shape for
  52475. */
  52476. private _createCustom;
  52477. private _addHullVerts;
  52478. private _createShape;
  52479. /**
  52480. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  52481. * @param impostor imposter containing the physics body and babylon object
  52482. */
  52483. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52484. /**
  52485. * Sets the babylon object's position/rotation from the physics body's position/rotation
  52486. * @param impostor imposter containing the physics body and babylon object
  52487. * @param newPosition new position
  52488. * @param newRotation new rotation
  52489. */
  52490. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52491. /**
  52492. * If this plugin is supported
  52493. * @returns true if its supported
  52494. */
  52495. isSupported(): boolean;
  52496. /**
  52497. * Sets the linear velocity of the physics body
  52498. * @param impostor imposter to set the velocity on
  52499. * @param velocity velocity to set
  52500. */
  52501. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52502. /**
  52503. * Sets the angular velocity of the physics body
  52504. * @param impostor imposter to set the velocity on
  52505. * @param velocity velocity to set
  52506. */
  52507. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52508. /**
  52509. * gets the linear velocity
  52510. * @param impostor imposter to get linear velocity from
  52511. * @returns linear velocity
  52512. */
  52513. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52514. /**
  52515. * gets the angular velocity
  52516. * @param impostor imposter to get angular velocity from
  52517. * @returns angular velocity
  52518. */
  52519. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52520. /**
  52521. * Sets the mass of physics body
  52522. * @param impostor imposter to set the mass on
  52523. * @param mass mass to set
  52524. */
  52525. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52526. /**
  52527. * Gets the mass of the physics body
  52528. * @param impostor imposter to get the mass from
  52529. * @returns mass
  52530. */
  52531. getBodyMass(impostor: PhysicsImpostor): number;
  52532. /**
  52533. * Gets friction of the impostor
  52534. * @param impostor impostor to get friction from
  52535. * @returns friction value
  52536. */
  52537. getBodyFriction(impostor: PhysicsImpostor): number;
  52538. /**
  52539. * Sets friction of the impostor
  52540. * @param impostor impostor to set friction on
  52541. * @param friction friction value
  52542. */
  52543. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52544. /**
  52545. * Gets restitution of the impostor
  52546. * @param impostor impostor to get restitution from
  52547. * @returns restitution value
  52548. */
  52549. getBodyRestitution(impostor: PhysicsImpostor): number;
  52550. /**
  52551. * Sets resitution of the impostor
  52552. * @param impostor impostor to set resitution on
  52553. * @param restitution resitution value
  52554. */
  52555. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52556. /**
  52557. * Gets pressure inside the impostor
  52558. * @param impostor impostor to get pressure from
  52559. * @returns pressure value
  52560. */
  52561. getBodyPressure(impostor: PhysicsImpostor): number;
  52562. /**
  52563. * Sets pressure inside a soft body impostor
  52564. * Cloth and rope must remain 0 pressure
  52565. * @param impostor impostor to set pressure on
  52566. * @param pressure pressure value
  52567. */
  52568. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  52569. /**
  52570. * Gets stiffness of the impostor
  52571. * @param impostor impostor to get stiffness from
  52572. * @returns pressure value
  52573. */
  52574. getBodyStiffness(impostor: PhysicsImpostor): number;
  52575. /**
  52576. * Sets stiffness of the impostor
  52577. * @param impostor impostor to set stiffness on
  52578. * @param stiffness stiffness value from 0 to 1
  52579. */
  52580. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  52581. /**
  52582. * Gets velocityIterations of the impostor
  52583. * @param impostor impostor to get velocity iterations from
  52584. * @returns velocityIterations value
  52585. */
  52586. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  52587. /**
  52588. * Sets velocityIterations of the impostor
  52589. * @param impostor impostor to set velocity iterations on
  52590. * @param velocityIterations velocityIterations value
  52591. */
  52592. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  52593. /**
  52594. * Gets positionIterations of the impostor
  52595. * @param impostor impostor to get position iterations from
  52596. * @returns positionIterations value
  52597. */
  52598. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  52599. /**
  52600. * Sets positionIterations of the impostor
  52601. * @param impostor impostor to set position on
  52602. * @param positionIterations positionIterations value
  52603. */
  52604. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  52605. /**
  52606. * Append an anchor to a cloth object
  52607. * @param impostor is the cloth impostor to add anchor to
  52608. * @param otherImpostor is the rigid impostor to anchor to
  52609. * @param width ratio across width from 0 to 1
  52610. * @param height ratio up height from 0 to 1
  52611. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  52612. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  52613. */
  52614. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  52615. /**
  52616. * Append an hook to a rope object
  52617. * @param impostor is the rope impostor to add hook to
  52618. * @param otherImpostor is the rigid impostor to hook to
  52619. * @param length ratio along the rope from 0 to 1
  52620. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  52621. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  52622. */
  52623. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  52624. /**
  52625. * Sleeps the physics body and stops it from being active
  52626. * @param impostor impostor to sleep
  52627. */
  52628. sleepBody(impostor: PhysicsImpostor): void;
  52629. /**
  52630. * Activates the physics body
  52631. * @param impostor impostor to activate
  52632. */
  52633. wakeUpBody(impostor: PhysicsImpostor): void;
  52634. /**
  52635. * Updates the distance parameters of the joint
  52636. * @param joint joint to update
  52637. * @param maxDistance maximum distance of the joint
  52638. * @param minDistance minimum distance of the joint
  52639. */
  52640. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  52641. /**
  52642. * Sets a motor on the joint
  52643. * @param joint joint to set motor on
  52644. * @param speed speed of the motor
  52645. * @param maxForce maximum force of the motor
  52646. * @param motorIndex index of the motor
  52647. */
  52648. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  52649. /**
  52650. * Sets the motors limit
  52651. * @param joint joint to set limit on
  52652. * @param upperLimit upper limit
  52653. * @param lowerLimit lower limit
  52654. */
  52655. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  52656. /**
  52657. * Syncs the position and rotation of a mesh with the impostor
  52658. * @param mesh mesh to sync
  52659. * @param impostor impostor to update the mesh with
  52660. */
  52661. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52662. /**
  52663. * Gets the radius of the impostor
  52664. * @param impostor impostor to get radius from
  52665. * @returns the radius
  52666. */
  52667. getRadius(impostor: PhysicsImpostor): number;
  52668. /**
  52669. * Gets the box size of the impostor
  52670. * @param impostor impostor to get box size from
  52671. * @param result the resulting box size
  52672. */
  52673. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52674. /**
  52675. * Disposes of the impostor
  52676. */
  52677. dispose(): void;
  52678. /**
  52679. * Does a raycast in the physics world
  52680. * @param from when should the ray start?
  52681. * @param to when should the ray end?
  52682. * @returns PhysicsRaycastResult
  52683. */
  52684. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52685. }
  52686. }
  52687. declare module BABYLON {
  52688. interface AbstractScene {
  52689. /**
  52690. * The list of reflection probes added to the scene
  52691. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  52692. */
  52693. reflectionProbes: Array<ReflectionProbe>;
  52694. /**
  52695. * Removes the given reflection probe from this scene.
  52696. * @param toRemove The reflection probe to remove
  52697. * @returns The index of the removed reflection probe
  52698. */
  52699. removeReflectionProbe(toRemove: ReflectionProbe): number;
  52700. /**
  52701. * Adds the given reflection probe to this scene.
  52702. * @param newReflectionProbe The reflection probe to add
  52703. */
  52704. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  52705. }
  52706. /**
  52707. * Class used to generate realtime reflection / refraction cube textures
  52708. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  52709. */
  52710. export class ReflectionProbe {
  52711. /** defines the name of the probe */
  52712. name: string;
  52713. private _scene;
  52714. private _renderTargetTexture;
  52715. private _projectionMatrix;
  52716. private _viewMatrix;
  52717. private _target;
  52718. private _add;
  52719. private _attachedMesh;
  52720. private _invertYAxis;
  52721. /** Gets or sets probe position (center of the cube map) */
  52722. position: Vector3;
  52723. /**
  52724. * Creates a new reflection probe
  52725. * @param name defines the name of the probe
  52726. * @param size defines the texture resolution (for each face)
  52727. * @param scene defines the hosting scene
  52728. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  52729. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  52730. */
  52731. constructor(
  52732. /** defines the name of the probe */
  52733. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  52734. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  52735. samples: number;
  52736. /** Gets or sets the refresh rate to use (on every frame by default) */
  52737. refreshRate: number;
  52738. /**
  52739. * Gets the hosting scene
  52740. * @returns a Scene
  52741. */
  52742. getScene(): Scene;
  52743. /** Gets the internal CubeTexture used to render to */
  52744. readonly cubeTexture: RenderTargetTexture;
  52745. /** Gets the list of meshes to render */
  52746. readonly renderList: Nullable<AbstractMesh[]>;
  52747. /**
  52748. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  52749. * @param mesh defines the mesh to attach to
  52750. */
  52751. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  52752. /**
  52753. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  52754. * @param renderingGroupId The rendering group id corresponding to its index
  52755. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  52756. */
  52757. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  52758. /**
  52759. * Clean all associated resources
  52760. */
  52761. dispose(): void;
  52762. /**
  52763. * Converts the reflection probe information to a readable string for debug purpose.
  52764. * @param fullDetails Supports for multiple levels of logging within scene loading
  52765. * @returns the human readable reflection probe info
  52766. */
  52767. toString(fullDetails?: boolean): string;
  52768. /**
  52769. * Get the class name of the relfection probe.
  52770. * @returns "ReflectionProbe"
  52771. */
  52772. getClassName(): string;
  52773. /**
  52774. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  52775. * @returns The JSON representation of the texture
  52776. */
  52777. serialize(): any;
  52778. /**
  52779. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  52780. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  52781. * @param scene Define the scene the parsed reflection probe should be instantiated in
  52782. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  52783. * @returns The parsed reflection probe if successful
  52784. */
  52785. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  52786. }
  52787. }
  52788. declare module BABYLON {
  52789. /** @hidden */
  52790. export var _BabylonLoaderRegistered: boolean;
  52791. /**
  52792. * Helps setting up some configuration for the babylon file loader.
  52793. */
  52794. export class BabylonFileLoaderConfiguration {
  52795. /**
  52796. * The loader does not allow injecting custom physix engine into the plugins.
  52797. * Unfortunately in ES6, we need to manually inject them into the plugin.
  52798. * So you could set this variable to your engine import to make it work.
  52799. */
  52800. static LoaderInjectedPhysicsEngine: any;
  52801. }
  52802. }
  52803. declare module BABYLON {
  52804. /**
  52805. * The Physically based simple base material of BJS.
  52806. *
  52807. * This enables better naming and convention enforcements on top of the pbrMaterial.
  52808. * It is used as the base class for both the specGloss and metalRough conventions.
  52809. */
  52810. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  52811. /**
  52812. * Number of Simultaneous lights allowed on the material.
  52813. */
  52814. maxSimultaneousLights: number;
  52815. /**
  52816. * If sets to true, disables all the lights affecting the material.
  52817. */
  52818. disableLighting: boolean;
  52819. /**
  52820. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  52821. */
  52822. environmentTexture: BaseTexture;
  52823. /**
  52824. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  52825. */
  52826. invertNormalMapX: boolean;
  52827. /**
  52828. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  52829. */
  52830. invertNormalMapY: boolean;
  52831. /**
  52832. * Normal map used in the model.
  52833. */
  52834. normalTexture: BaseTexture;
  52835. /**
  52836. * Emissivie color used to self-illuminate the model.
  52837. */
  52838. emissiveColor: Color3;
  52839. /**
  52840. * Emissivie texture used to self-illuminate the model.
  52841. */
  52842. emissiveTexture: BaseTexture;
  52843. /**
  52844. * Occlusion Channel Strenght.
  52845. */
  52846. occlusionStrength: number;
  52847. /**
  52848. * Occlusion Texture of the material (adding extra occlusion effects).
  52849. */
  52850. occlusionTexture: BaseTexture;
  52851. /**
  52852. * Defines the alpha limits in alpha test mode.
  52853. */
  52854. alphaCutOff: number;
  52855. /**
  52856. * Gets the current double sided mode.
  52857. */
  52858. /**
  52859. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52860. */
  52861. doubleSided: boolean;
  52862. /**
  52863. * Stores the pre-calculated light information of a mesh in a texture.
  52864. */
  52865. lightmapTexture: BaseTexture;
  52866. /**
  52867. * If true, the light map contains occlusion information instead of lighting info.
  52868. */
  52869. useLightmapAsShadowmap: boolean;
  52870. /**
  52871. * Instantiates a new PBRMaterial instance.
  52872. *
  52873. * @param name The material name
  52874. * @param scene The scene the material will be use in.
  52875. */
  52876. constructor(name: string, scene: Scene);
  52877. getClassName(): string;
  52878. }
  52879. }
  52880. declare module BABYLON {
  52881. /**
  52882. * The PBR material of BJS following the metal roughness convention.
  52883. *
  52884. * This fits to the PBR convention in the GLTF definition:
  52885. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  52886. */
  52887. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  52888. /**
  52889. * The base color has two different interpretations depending on the value of metalness.
  52890. * When the material is a metal, the base color is the specific measured reflectance value
  52891. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  52892. * of the material.
  52893. */
  52894. baseColor: Color3;
  52895. /**
  52896. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  52897. * well as opacity information in the alpha channel.
  52898. */
  52899. baseTexture: BaseTexture;
  52900. /**
  52901. * Specifies the metallic scalar value of the material.
  52902. * Can also be used to scale the metalness values of the metallic texture.
  52903. */
  52904. metallic: number;
  52905. /**
  52906. * Specifies the roughness scalar value of the material.
  52907. * Can also be used to scale the roughness values of the metallic texture.
  52908. */
  52909. roughness: number;
  52910. /**
  52911. * Texture containing both the metallic value in the B channel and the
  52912. * roughness value in the G channel to keep better precision.
  52913. */
  52914. metallicRoughnessTexture: BaseTexture;
  52915. /**
  52916. * Instantiates a new PBRMetalRoughnessMaterial instance.
  52917. *
  52918. * @param name The material name
  52919. * @param scene The scene the material will be use in.
  52920. */
  52921. constructor(name: string, scene: Scene);
  52922. /**
  52923. * Return the currrent class name of the material.
  52924. */
  52925. getClassName(): string;
  52926. /**
  52927. * Makes a duplicate of the current material.
  52928. * @param name - name to use for the new material.
  52929. */
  52930. clone(name: string): PBRMetallicRoughnessMaterial;
  52931. /**
  52932. * Serialize the material to a parsable JSON object.
  52933. */
  52934. serialize(): any;
  52935. /**
  52936. * Parses a JSON object correponding to the serialize function.
  52937. */
  52938. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  52939. }
  52940. }
  52941. declare module BABYLON {
  52942. /**
  52943. * The PBR material of BJS following the specular glossiness convention.
  52944. *
  52945. * This fits to the PBR convention in the GLTF definition:
  52946. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  52947. */
  52948. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  52949. /**
  52950. * Specifies the diffuse color of the material.
  52951. */
  52952. diffuseColor: Color3;
  52953. /**
  52954. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  52955. * channel.
  52956. */
  52957. diffuseTexture: BaseTexture;
  52958. /**
  52959. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  52960. */
  52961. specularColor: Color3;
  52962. /**
  52963. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  52964. */
  52965. glossiness: number;
  52966. /**
  52967. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  52968. */
  52969. specularGlossinessTexture: BaseTexture;
  52970. /**
  52971. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  52972. *
  52973. * @param name The material name
  52974. * @param scene The scene the material will be use in.
  52975. */
  52976. constructor(name: string, scene: Scene);
  52977. /**
  52978. * Return the currrent class name of the material.
  52979. */
  52980. getClassName(): string;
  52981. /**
  52982. * Makes a duplicate of the current material.
  52983. * @param name - name to use for the new material.
  52984. */
  52985. clone(name: string): PBRSpecularGlossinessMaterial;
  52986. /**
  52987. * Serialize the material to a parsable JSON object.
  52988. */
  52989. serialize(): any;
  52990. /**
  52991. * Parses a JSON object correponding to the serialize function.
  52992. */
  52993. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  52994. }
  52995. }
  52996. declare module BABYLON {
  52997. /**
  52998. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  52999. * It can help converting any input color in a desired output one. This can then be used to create effects
  53000. * from sepia, black and white to sixties or futuristic rendering...
  53001. *
  53002. * The only supported format is currently 3dl.
  53003. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  53004. */
  53005. export class ColorGradingTexture extends BaseTexture {
  53006. /**
  53007. * The current texture matrix. (will always be identity in color grading texture)
  53008. */
  53009. private _textureMatrix;
  53010. /**
  53011. * The texture URL.
  53012. */
  53013. url: string;
  53014. /**
  53015. * Empty line regex stored for GC.
  53016. */
  53017. private static _noneEmptyLineRegex;
  53018. private _engine;
  53019. /**
  53020. * Instantiates a ColorGradingTexture from the following parameters.
  53021. *
  53022. * @param url The location of the color gradind data (currently only supporting 3dl)
  53023. * @param scene The scene the texture will be used in
  53024. */
  53025. constructor(url: string, scene: Scene);
  53026. /**
  53027. * Returns the texture matrix used in most of the material.
  53028. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  53029. */
  53030. getTextureMatrix(): Matrix;
  53031. /**
  53032. * Occurs when the file being loaded is a .3dl LUT file.
  53033. */
  53034. private load3dlTexture;
  53035. /**
  53036. * Starts the loading process of the texture.
  53037. */
  53038. private loadTexture;
  53039. /**
  53040. * Clones the color gradind texture.
  53041. */
  53042. clone(): ColorGradingTexture;
  53043. /**
  53044. * Called during delayed load for textures.
  53045. */
  53046. delayLoad(): void;
  53047. /**
  53048. * Parses a color grading texture serialized by Babylon.
  53049. * @param parsedTexture The texture information being parsedTexture
  53050. * @param scene The scene to load the texture in
  53051. * @param rootUrl The root url of the data assets to load
  53052. * @return A color gradind texture
  53053. */
  53054. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  53055. /**
  53056. * Serializes the LUT texture to json format.
  53057. */
  53058. serialize(): any;
  53059. }
  53060. }
  53061. declare module BABYLON {
  53062. /**
  53063. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  53064. */
  53065. export class EquiRectangularCubeTexture extends BaseTexture {
  53066. /** The six faces of the cube. */
  53067. private static _FacesMapping;
  53068. private _noMipmap;
  53069. private _onLoad;
  53070. private _onError;
  53071. /** The size of the cubemap. */
  53072. private _size;
  53073. /** The buffer of the image. */
  53074. private _buffer;
  53075. /** The width of the input image. */
  53076. private _width;
  53077. /** The height of the input image. */
  53078. private _height;
  53079. /** The URL to the image. */
  53080. url: string;
  53081. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  53082. coordinatesMode: number;
  53083. /**
  53084. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  53085. * @param url The location of the image
  53086. * @param scene The scene the texture will be used in
  53087. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  53088. * @param noMipmap Forces to not generate the mipmap if true
  53089. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  53090. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  53091. * @param onLoad — defines a callback called when texture is loaded
  53092. * @param onError — defines a callback called if there is an error
  53093. */
  53094. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  53095. /**
  53096. * Load the image data, by putting the image on a canvas and extracting its buffer.
  53097. */
  53098. private loadImage;
  53099. /**
  53100. * Convert the image buffer into a cubemap and create a CubeTexture.
  53101. */
  53102. private loadTexture;
  53103. /**
  53104. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  53105. * @param buffer The ArrayBuffer that should be converted.
  53106. * @returns The buffer as Float32Array.
  53107. */
  53108. private getFloat32ArrayFromArrayBuffer;
  53109. /**
  53110. * Get the current class name of the texture useful for serialization or dynamic coding.
  53111. * @returns "EquiRectangularCubeTexture"
  53112. */
  53113. getClassName(): string;
  53114. /**
  53115. * Create a clone of the current EquiRectangularCubeTexture and return it.
  53116. * @returns A clone of the current EquiRectangularCubeTexture.
  53117. */
  53118. clone(): EquiRectangularCubeTexture;
  53119. }
  53120. }
  53121. declare module BABYLON {
  53122. /**
  53123. * Based on jsTGALoader - Javascript loader for TGA file
  53124. * By Vincent Thibault
  53125. * @see http://blog.robrowser.com/javascript-tga-loader.html
  53126. */
  53127. export class TGATools {
  53128. private static _TYPE_INDEXED;
  53129. private static _TYPE_RGB;
  53130. private static _TYPE_GREY;
  53131. private static _TYPE_RLE_INDEXED;
  53132. private static _TYPE_RLE_RGB;
  53133. private static _TYPE_RLE_GREY;
  53134. private static _ORIGIN_MASK;
  53135. private static _ORIGIN_SHIFT;
  53136. private static _ORIGIN_BL;
  53137. private static _ORIGIN_BR;
  53138. private static _ORIGIN_UL;
  53139. private static _ORIGIN_UR;
  53140. /**
  53141. * Gets the header of a TGA file
  53142. * @param data defines the TGA data
  53143. * @returns the header
  53144. */
  53145. static GetTGAHeader(data: Uint8Array): any;
  53146. /**
  53147. * Uploads TGA content to a Babylon Texture
  53148. * @hidden
  53149. */
  53150. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  53151. /** @hidden */
  53152. 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;
  53153. /** @hidden */
  53154. 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;
  53155. /** @hidden */
  53156. 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;
  53157. /** @hidden */
  53158. 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;
  53159. /** @hidden */
  53160. 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;
  53161. /** @hidden */
  53162. 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;
  53163. }
  53164. }
  53165. declare module BABYLON {
  53166. /**
  53167. * Implementation of the TGA Texture Loader.
  53168. * @hidden
  53169. */
  53170. export class _TGATextureLoader implements IInternalTextureLoader {
  53171. /**
  53172. * Defines wether the loader supports cascade loading the different faces.
  53173. */
  53174. readonly supportCascades: boolean;
  53175. /**
  53176. * This returns if the loader support the current file information.
  53177. * @param extension defines the file extension of the file being loaded
  53178. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53179. * @param fallback defines the fallback internal texture if any
  53180. * @param isBase64 defines whether the texture is encoded as a base64
  53181. * @param isBuffer defines whether the texture data are stored as a buffer
  53182. * @returns true if the loader can load the specified file
  53183. */
  53184. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  53185. /**
  53186. * Transform the url before loading if required.
  53187. * @param rootUrl the url of the texture
  53188. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53189. * @returns the transformed texture
  53190. */
  53191. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  53192. /**
  53193. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53194. * @param rootUrl the url of the texture
  53195. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53196. * @returns the fallback texture
  53197. */
  53198. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  53199. /**
  53200. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  53201. * @param data contains the texture data
  53202. * @param texture defines the BabylonJS internal texture
  53203. * @param createPolynomials will be true if polynomials have been requested
  53204. * @param onLoad defines the callback to trigger once the texture is ready
  53205. * @param onError defines the callback to trigger in case of error
  53206. */
  53207. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53208. /**
  53209. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53210. * @param data contains the texture data
  53211. * @param texture defines the BabylonJS internal texture
  53212. * @param callback defines the method to call once ready to upload
  53213. */
  53214. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  53215. }
  53216. }
  53217. declare module BABYLON {
  53218. /**
  53219. * Info about the .basis files
  53220. */
  53221. class BasisFileInfo {
  53222. /**
  53223. * If the file has alpha
  53224. */
  53225. hasAlpha: boolean;
  53226. /**
  53227. * Info about each image of the basis file
  53228. */
  53229. images: Array<{
  53230. levels: Array<{
  53231. width: number;
  53232. height: number;
  53233. transcodedPixels: ArrayBufferView;
  53234. }>;
  53235. }>;
  53236. }
  53237. /**
  53238. * Result of transcoding a basis file
  53239. */
  53240. class TranscodeResult {
  53241. /**
  53242. * Info about the .basis file
  53243. */
  53244. fileInfo: BasisFileInfo;
  53245. /**
  53246. * Format to use when loading the file
  53247. */
  53248. format: number;
  53249. }
  53250. /**
  53251. * Configuration options for the Basis transcoder
  53252. */
  53253. export class BasisTranscodeConfiguration {
  53254. /**
  53255. * Supported compression formats used to determine the supported output format of the transcoder
  53256. */
  53257. supportedCompressionFormats?: {
  53258. /**
  53259. * etc1 compression format
  53260. */
  53261. etc1?: boolean;
  53262. /**
  53263. * s3tc compression format
  53264. */
  53265. s3tc?: boolean;
  53266. /**
  53267. * pvrtc compression format
  53268. */
  53269. pvrtc?: boolean;
  53270. /**
  53271. * etc2 compression format
  53272. */
  53273. etc2?: boolean;
  53274. };
  53275. /**
  53276. * If mipmap levels should be loaded for transcoded images (Default: true)
  53277. */
  53278. loadMipmapLevels?: boolean;
  53279. /**
  53280. * Index of a single image to load (Default: all images)
  53281. */
  53282. loadSingleImage?: number;
  53283. }
  53284. /**
  53285. * Used to load .Basis files
  53286. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  53287. */
  53288. export class BasisTools {
  53289. private static _IgnoreSupportedFormats;
  53290. /**
  53291. * URL to use when loading the basis transcoder
  53292. */
  53293. static JSModuleURL: string;
  53294. /**
  53295. * URL to use when loading the wasm module for the transcoder
  53296. */
  53297. static WasmModuleURL: string;
  53298. /**
  53299. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  53300. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  53301. * @returns internal format corresponding to the Basis format
  53302. */
  53303. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  53304. private static _WorkerPromise;
  53305. private static _Worker;
  53306. private static _actionId;
  53307. private static _CreateWorkerAsync;
  53308. /**
  53309. * Transcodes a loaded image file to compressed pixel data
  53310. * @param imageData image data to transcode
  53311. * @param config configuration options for the transcoding
  53312. * @returns a promise resulting in the transcoded image
  53313. */
  53314. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  53315. /**
  53316. * Loads a texture from the transcode result
  53317. * @param texture texture load to
  53318. * @param transcodeResult the result of transcoding the basis file to load from
  53319. */
  53320. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  53321. }
  53322. }
  53323. declare module BABYLON {
  53324. /**
  53325. * Loader for .basis file format
  53326. */
  53327. export class _BasisTextureLoader implements IInternalTextureLoader {
  53328. /**
  53329. * Defines whether the loader supports cascade loading the different faces.
  53330. */
  53331. readonly supportCascades: boolean;
  53332. /**
  53333. * This returns if the loader support the current file information.
  53334. * @param extension defines the file extension of the file being loaded
  53335. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53336. * @param fallback defines the fallback internal texture if any
  53337. * @param isBase64 defines whether the texture is encoded as a base64
  53338. * @param isBuffer defines whether the texture data are stored as a buffer
  53339. * @returns true if the loader can load the specified file
  53340. */
  53341. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  53342. /**
  53343. * Transform the url before loading if required.
  53344. * @param rootUrl the url of the texture
  53345. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53346. * @returns the transformed texture
  53347. */
  53348. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  53349. /**
  53350. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53351. * @param rootUrl the url of the texture
  53352. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53353. * @returns the fallback texture
  53354. */
  53355. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  53356. /**
  53357. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  53358. * @param data contains the texture data
  53359. * @param texture defines the BabylonJS internal texture
  53360. * @param createPolynomials will be true if polynomials have been requested
  53361. * @param onLoad defines the callback to trigger once the texture is ready
  53362. * @param onError defines the callback to trigger in case of error
  53363. */
  53364. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53365. /**
  53366. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53367. * @param data contains the texture data
  53368. * @param texture defines the BabylonJS internal texture
  53369. * @param callback defines the method to call once ready to upload
  53370. */
  53371. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  53372. }
  53373. }
  53374. declare module BABYLON {
  53375. /**
  53376. * 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.
  53377. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  53378. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  53379. */
  53380. export class CustomProceduralTexture extends ProceduralTexture {
  53381. private _animate;
  53382. private _time;
  53383. private _config;
  53384. private _texturePath;
  53385. /**
  53386. * Instantiates a new Custom Procedural Texture.
  53387. * 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.
  53388. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  53389. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  53390. * @param name Define the name of the texture
  53391. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  53392. * @param size Define the size of the texture to create
  53393. * @param scene Define the scene the texture belongs to
  53394. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  53395. * @param generateMipMaps Define if the texture should creates mip maps or not
  53396. */
  53397. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  53398. private _loadJson;
  53399. /**
  53400. * Is the texture ready to be used ? (rendered at least once)
  53401. * @returns true if ready, otherwise, false.
  53402. */
  53403. isReady(): boolean;
  53404. /**
  53405. * Render the texture to its associated render target.
  53406. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  53407. */
  53408. render(useCameraPostProcess?: boolean): void;
  53409. /**
  53410. * Update the list of dependant textures samplers in the shader.
  53411. */
  53412. updateTextures(): void;
  53413. /**
  53414. * Update the uniform values of the procedural texture in the shader.
  53415. */
  53416. updateShaderUniforms(): void;
  53417. /**
  53418. * Define if the texture animates or not.
  53419. */
  53420. animate: boolean;
  53421. }
  53422. }
  53423. declare module BABYLON {
  53424. /** @hidden */
  53425. export var noisePixelShader: {
  53426. name: string;
  53427. shader: string;
  53428. };
  53429. }
  53430. declare module BABYLON {
  53431. /**
  53432. * Class used to generate noise procedural textures
  53433. */
  53434. export class NoiseProceduralTexture extends ProceduralTexture {
  53435. private _time;
  53436. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  53437. brightness: number;
  53438. /** Defines the number of octaves to process */
  53439. octaves: number;
  53440. /** Defines the level of persistence (0.8 by default) */
  53441. persistence: number;
  53442. /** Gets or sets animation speed factor (default is 1) */
  53443. animationSpeedFactor: number;
  53444. /**
  53445. * Creates a new NoiseProceduralTexture
  53446. * @param name defines the name fo the texture
  53447. * @param size defines the size of the texture (default is 256)
  53448. * @param scene defines the hosting scene
  53449. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  53450. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  53451. */
  53452. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  53453. private _updateShaderUniforms;
  53454. protected _getDefines(): string;
  53455. /** Generate the current state of the procedural texture */
  53456. render(useCameraPostProcess?: boolean): void;
  53457. /**
  53458. * Serializes this noise procedural texture
  53459. * @returns a serialized noise procedural texture object
  53460. */
  53461. serialize(): any;
  53462. /**
  53463. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  53464. * @param parsedTexture defines parsed texture data
  53465. * @param scene defines the current scene
  53466. * @param rootUrl defines the root URL containing noise procedural texture information
  53467. * @returns a parsed NoiseProceduralTexture
  53468. */
  53469. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  53470. }
  53471. }
  53472. declare module BABYLON {
  53473. /**
  53474. * Raw cube texture where the raw buffers are passed in
  53475. */
  53476. export class RawCubeTexture extends CubeTexture {
  53477. /**
  53478. * Creates a cube texture where the raw buffers are passed in.
  53479. * @param scene defines the scene the texture is attached to
  53480. * @param data defines the array of data to use to create each face
  53481. * @param size defines the size of the textures
  53482. * @param format defines the format of the data
  53483. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  53484. * @param generateMipMaps defines if the engine should generate the mip levels
  53485. * @param invertY defines if data must be stored with Y axis inverted
  53486. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  53487. * @param compression defines the compression used (null by default)
  53488. */
  53489. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  53490. /**
  53491. * Updates the raw cube texture.
  53492. * @param data defines the data to store
  53493. * @param format defines the data format
  53494. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  53495. * @param invertY defines if data must be stored with Y axis inverted
  53496. * @param compression defines the compression used (null by default)
  53497. * @param level defines which level of the texture to update
  53498. */
  53499. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  53500. /**
  53501. * Updates a raw cube texture with RGBD encoded data.
  53502. * @param data defines the array of data [mipmap][face] to use to create each face
  53503. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  53504. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  53505. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  53506. * @returns a promsie that resolves when the operation is complete
  53507. */
  53508. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  53509. /**
  53510. * Clones the raw cube texture.
  53511. * @return a new cube texture
  53512. */
  53513. clone(): CubeTexture;
  53514. /** @hidden */
  53515. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  53516. }
  53517. }
  53518. declare module BABYLON {
  53519. /**
  53520. * Class used to store 3D textures containing user data
  53521. */
  53522. export class RawTexture3D extends Texture {
  53523. /** Gets or sets the texture format to use */
  53524. format: number;
  53525. private _engine;
  53526. /**
  53527. * Create a new RawTexture3D
  53528. * @param data defines the data of the texture
  53529. * @param width defines the width of the texture
  53530. * @param height defines the height of the texture
  53531. * @param depth defines the depth of the texture
  53532. * @param format defines the texture format to use
  53533. * @param scene defines the hosting scene
  53534. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  53535. * @param invertY defines if texture must be stored with Y axis inverted
  53536. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  53537. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  53538. */
  53539. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  53540. /** Gets or sets the texture format to use */
  53541. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  53542. /**
  53543. * Update the texture with new data
  53544. * @param data defines the data to store in the texture
  53545. */
  53546. update(data: ArrayBufferView): void;
  53547. }
  53548. }
  53549. declare module BABYLON {
  53550. /**
  53551. * Class used to store 2D array textures containing user data
  53552. */
  53553. export class RawTexture2DArray extends Texture {
  53554. /** Gets or sets the texture format to use */
  53555. format: number;
  53556. private _engine;
  53557. /**
  53558. * Create a new RawTexture2DArray
  53559. * @param data defines the data of the texture
  53560. * @param width defines the width of the texture
  53561. * @param height defines the height of the texture
  53562. * @param depth defines the number of layers of the texture
  53563. * @param format defines the texture format to use
  53564. * @param scene defines the hosting scene
  53565. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  53566. * @param invertY defines if texture must be stored with Y axis inverted
  53567. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  53568. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  53569. */
  53570. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  53571. /** Gets or sets the texture format to use */
  53572. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  53573. /**
  53574. * Update the texture with new data
  53575. * @param data defines the data to store in the texture
  53576. */
  53577. update(data: ArrayBufferView): void;
  53578. }
  53579. }
  53580. declare module BABYLON {
  53581. /**
  53582. * Creates a refraction texture used by refraction channel of the standard material.
  53583. * It is like a mirror but to see through a material.
  53584. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  53585. */
  53586. export class RefractionTexture extends RenderTargetTexture {
  53587. /**
  53588. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  53589. * 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.
  53590. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  53591. */
  53592. refractionPlane: Plane;
  53593. /**
  53594. * Define how deep under the surface we should see.
  53595. */
  53596. depth: number;
  53597. /**
  53598. * Creates a refraction texture used by refraction channel of the standard material.
  53599. * It is like a mirror but to see through a material.
  53600. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  53601. * @param name Define the texture name
  53602. * @param size Define the size of the underlying texture
  53603. * @param scene Define the scene the refraction belongs to
  53604. * @param generateMipMaps Define if we need to generate mips level for the refraction
  53605. */
  53606. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  53607. /**
  53608. * Clone the refraction texture.
  53609. * @returns the cloned texture
  53610. */
  53611. clone(): RefractionTexture;
  53612. /**
  53613. * Serialize the texture to a JSON representation you could use in Parse later on
  53614. * @returns the serialized JSON representation
  53615. */
  53616. serialize(): any;
  53617. }
  53618. }
  53619. declare module BABYLON {
  53620. /**
  53621. * Defines the options related to the creation of an HtmlElementTexture
  53622. */
  53623. export interface IHtmlElementTextureOptions {
  53624. /**
  53625. * Defines wether mip maps should be created or not.
  53626. */
  53627. generateMipMaps?: boolean;
  53628. /**
  53629. * Defines the sampling mode of the texture.
  53630. */
  53631. samplingMode?: number;
  53632. /**
  53633. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  53634. */
  53635. engine: Nullable<ThinEngine>;
  53636. /**
  53637. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  53638. */
  53639. scene: Nullable<Scene>;
  53640. }
  53641. /**
  53642. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  53643. * To be as efficient as possible depending on your constraints nothing aside the first upload
  53644. * is automatically managed.
  53645. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  53646. * in your application.
  53647. *
  53648. * As the update is not automatic, you need to call them manually.
  53649. */
  53650. export class HtmlElementTexture extends BaseTexture {
  53651. /**
  53652. * The texture URL.
  53653. */
  53654. element: HTMLVideoElement | HTMLCanvasElement;
  53655. private static readonly DefaultOptions;
  53656. private _textureMatrix;
  53657. private _engine;
  53658. private _isVideo;
  53659. private _generateMipMaps;
  53660. private _samplingMode;
  53661. /**
  53662. * Instantiates a HtmlElementTexture from the following parameters.
  53663. *
  53664. * @param name Defines the name of the texture
  53665. * @param element Defines the video or canvas the texture is filled with
  53666. * @param options Defines the other none mandatory texture creation options
  53667. */
  53668. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  53669. private _createInternalTexture;
  53670. /**
  53671. * Returns the texture matrix used in most of the material.
  53672. */
  53673. getTextureMatrix(): Matrix;
  53674. /**
  53675. * Updates the content of the texture.
  53676. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  53677. */
  53678. update(invertY?: Nullable<boolean>): void;
  53679. }
  53680. }
  53681. declare module BABYLON {
  53682. /**
  53683. * Enum used to define the target of a block
  53684. */
  53685. export enum NodeMaterialBlockTargets {
  53686. /** Vertex shader */
  53687. Vertex = 1,
  53688. /** Fragment shader */
  53689. Fragment = 2,
  53690. /** Neutral */
  53691. Neutral = 4,
  53692. /** Vertex and Fragment */
  53693. VertexAndFragment = 3
  53694. }
  53695. }
  53696. declare module BABYLON {
  53697. /**
  53698. * Defines the kind of connection point for node based material
  53699. */
  53700. export enum NodeMaterialBlockConnectionPointTypes {
  53701. /** Float */
  53702. Float = 1,
  53703. /** Int */
  53704. Int = 2,
  53705. /** Vector2 */
  53706. Vector2 = 4,
  53707. /** Vector3 */
  53708. Vector3 = 8,
  53709. /** Vector4 */
  53710. Vector4 = 16,
  53711. /** Color3 */
  53712. Color3 = 32,
  53713. /** Color4 */
  53714. Color4 = 64,
  53715. /** Matrix */
  53716. Matrix = 128,
  53717. /** Detect type based on connection */
  53718. AutoDetect = 1024,
  53719. /** Output type that will be defined by input type */
  53720. BasedOnInput = 2048
  53721. }
  53722. }
  53723. declare module BABYLON {
  53724. /**
  53725. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  53726. */
  53727. export enum NodeMaterialBlockConnectionPointMode {
  53728. /** Value is an uniform */
  53729. Uniform = 0,
  53730. /** Value is a mesh attribute */
  53731. Attribute = 1,
  53732. /** Value is a varying between vertex and fragment shaders */
  53733. Varying = 2,
  53734. /** Mode is undefined */
  53735. Undefined = 3
  53736. }
  53737. }
  53738. declare module BABYLON {
  53739. /**
  53740. * Enum used to define system values e.g. values automatically provided by the system
  53741. */
  53742. export enum NodeMaterialSystemValues {
  53743. /** World */
  53744. World = 1,
  53745. /** View */
  53746. View = 2,
  53747. /** Projection */
  53748. Projection = 3,
  53749. /** ViewProjection */
  53750. ViewProjection = 4,
  53751. /** WorldView */
  53752. WorldView = 5,
  53753. /** WorldViewProjection */
  53754. WorldViewProjection = 6,
  53755. /** CameraPosition */
  53756. CameraPosition = 7,
  53757. /** Fog Color */
  53758. FogColor = 8,
  53759. /** Delta time */
  53760. DeltaTime = 9
  53761. }
  53762. }
  53763. declare module BABYLON {
  53764. /**
  53765. * Root class for all node material optimizers
  53766. */
  53767. export class NodeMaterialOptimizer {
  53768. /**
  53769. * Function used to optimize a NodeMaterial graph
  53770. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  53771. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  53772. */
  53773. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  53774. }
  53775. }
  53776. declare module BABYLON {
  53777. /**
  53778. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  53779. */
  53780. export class TransformBlock extends NodeMaterialBlock {
  53781. /**
  53782. * Defines the value to use to complement W value to transform it to a Vector4
  53783. */
  53784. complementW: number;
  53785. /**
  53786. * Defines the value to use to complement z value to transform it to a Vector4
  53787. */
  53788. complementZ: number;
  53789. /**
  53790. * Creates a new TransformBlock
  53791. * @param name defines the block name
  53792. */
  53793. constructor(name: string);
  53794. /**
  53795. * Gets the current class name
  53796. * @returns the class name
  53797. */
  53798. getClassName(): string;
  53799. /**
  53800. * Gets the vector input
  53801. */
  53802. readonly vector: NodeMaterialConnectionPoint;
  53803. /**
  53804. * Gets the output component
  53805. */
  53806. readonly output: NodeMaterialConnectionPoint;
  53807. /**
  53808. * Gets the matrix transform input
  53809. */
  53810. readonly transform: NodeMaterialConnectionPoint;
  53811. protected _buildBlock(state: NodeMaterialBuildState): this;
  53812. serialize(): any;
  53813. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53814. protected _dumpPropertiesCode(): string;
  53815. }
  53816. }
  53817. declare module BABYLON {
  53818. /**
  53819. * Block used to output the vertex position
  53820. */
  53821. export class VertexOutputBlock extends NodeMaterialBlock {
  53822. /**
  53823. * Creates a new VertexOutputBlock
  53824. * @param name defines the block name
  53825. */
  53826. constructor(name: string);
  53827. /**
  53828. * Gets the current class name
  53829. * @returns the class name
  53830. */
  53831. getClassName(): string;
  53832. /**
  53833. * Gets the vector input component
  53834. */
  53835. readonly vector: NodeMaterialConnectionPoint;
  53836. protected _buildBlock(state: NodeMaterialBuildState): this;
  53837. }
  53838. }
  53839. declare module BABYLON {
  53840. /**
  53841. * Block used to output the final color
  53842. */
  53843. export class FragmentOutputBlock extends NodeMaterialBlock {
  53844. /**
  53845. * Create a new FragmentOutputBlock
  53846. * @param name defines the block name
  53847. */
  53848. constructor(name: string);
  53849. /**
  53850. * Gets the current class name
  53851. * @returns the class name
  53852. */
  53853. getClassName(): string;
  53854. /**
  53855. * Gets the rgba input component
  53856. */
  53857. readonly rgba: NodeMaterialConnectionPoint;
  53858. /**
  53859. * Gets the rgb input component
  53860. */
  53861. readonly rgb: NodeMaterialConnectionPoint;
  53862. /**
  53863. * Gets the a input component
  53864. */
  53865. readonly a: NodeMaterialConnectionPoint;
  53866. protected _buildBlock(state: NodeMaterialBuildState): this;
  53867. }
  53868. }
  53869. declare module BABYLON {
  53870. /**
  53871. * Block used to read a reflection texture from a sampler
  53872. */
  53873. export class ReflectionTextureBlock extends NodeMaterialBlock {
  53874. private _define3DName;
  53875. private _defineCubicName;
  53876. private _defineExplicitName;
  53877. private _defineProjectionName;
  53878. private _defineLocalCubicName;
  53879. private _defineSphericalName;
  53880. private _definePlanarName;
  53881. private _defineEquirectangularName;
  53882. private _defineMirroredEquirectangularFixedName;
  53883. private _defineEquirectangularFixedName;
  53884. private _defineSkyboxName;
  53885. private _cubeSamplerName;
  53886. private _2DSamplerName;
  53887. private _positionUVWName;
  53888. private _directionWName;
  53889. private _reflectionCoordsName;
  53890. private _reflection2DCoordsName;
  53891. private _reflectionColorName;
  53892. private _reflectionMatrixName;
  53893. /**
  53894. * Gets or sets the texture associated with the node
  53895. */
  53896. texture: Nullable<BaseTexture>;
  53897. /**
  53898. * Create a new TextureBlock
  53899. * @param name defines the block name
  53900. */
  53901. constructor(name: string);
  53902. /**
  53903. * Gets the current class name
  53904. * @returns the class name
  53905. */
  53906. getClassName(): string;
  53907. /**
  53908. * Gets the world position input component
  53909. */
  53910. readonly position: NodeMaterialConnectionPoint;
  53911. /**
  53912. * Gets the world position input component
  53913. */
  53914. readonly worldPosition: NodeMaterialConnectionPoint;
  53915. /**
  53916. * Gets the world normal input component
  53917. */
  53918. readonly worldNormal: NodeMaterialConnectionPoint;
  53919. /**
  53920. * Gets the world input component
  53921. */
  53922. readonly world: NodeMaterialConnectionPoint;
  53923. /**
  53924. * Gets the camera (or eye) position component
  53925. */
  53926. readonly cameraPosition: NodeMaterialConnectionPoint;
  53927. /**
  53928. * Gets the view input component
  53929. */
  53930. readonly view: NodeMaterialConnectionPoint;
  53931. /**
  53932. * Gets the rgb output component
  53933. */
  53934. readonly rgb: NodeMaterialConnectionPoint;
  53935. /**
  53936. * Gets the r output component
  53937. */
  53938. readonly r: NodeMaterialConnectionPoint;
  53939. /**
  53940. * Gets the g output component
  53941. */
  53942. readonly g: NodeMaterialConnectionPoint;
  53943. /**
  53944. * Gets the b output component
  53945. */
  53946. readonly b: NodeMaterialConnectionPoint;
  53947. autoConfigure(material: NodeMaterial): void;
  53948. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53949. isReady(): boolean;
  53950. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53951. private _injectVertexCode;
  53952. private _writeOutput;
  53953. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  53954. protected _dumpPropertiesCode(): string;
  53955. serialize(): any;
  53956. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53957. }
  53958. }
  53959. declare module BABYLON {
  53960. /**
  53961. * Interface used to configure the node material editor
  53962. */
  53963. export interface INodeMaterialEditorOptions {
  53964. /** Define the URl to load node editor script */
  53965. editorURL?: string;
  53966. }
  53967. /** @hidden */
  53968. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  53969. /** BONES */
  53970. NUM_BONE_INFLUENCERS: number;
  53971. BonesPerMesh: number;
  53972. BONETEXTURE: boolean;
  53973. /** MORPH TARGETS */
  53974. MORPHTARGETS: boolean;
  53975. MORPHTARGETS_NORMAL: boolean;
  53976. MORPHTARGETS_TANGENT: boolean;
  53977. MORPHTARGETS_UV: boolean;
  53978. NUM_MORPH_INFLUENCERS: number;
  53979. /** IMAGE PROCESSING */
  53980. IMAGEPROCESSING: boolean;
  53981. VIGNETTE: boolean;
  53982. VIGNETTEBLENDMODEMULTIPLY: boolean;
  53983. VIGNETTEBLENDMODEOPAQUE: boolean;
  53984. TONEMAPPING: boolean;
  53985. TONEMAPPING_ACES: boolean;
  53986. CONTRAST: boolean;
  53987. EXPOSURE: boolean;
  53988. COLORCURVES: boolean;
  53989. COLORGRADING: boolean;
  53990. COLORGRADING3D: boolean;
  53991. SAMPLER3DGREENDEPTH: boolean;
  53992. SAMPLER3DBGRMAP: boolean;
  53993. IMAGEPROCESSINGPOSTPROCESS: boolean;
  53994. /** MISC. */
  53995. BUMPDIRECTUV: number;
  53996. constructor();
  53997. setValue(name: string, value: boolean): void;
  53998. }
  53999. /**
  54000. * Class used to configure NodeMaterial
  54001. */
  54002. export interface INodeMaterialOptions {
  54003. /**
  54004. * Defines if blocks should emit comments
  54005. */
  54006. emitComments: boolean;
  54007. }
  54008. /**
  54009. * Class used to create a node based material built by assembling shader blocks
  54010. */
  54011. export class NodeMaterial extends PushMaterial {
  54012. private static _BuildIdGenerator;
  54013. private _options;
  54014. private _vertexCompilationState;
  54015. private _fragmentCompilationState;
  54016. private _sharedData;
  54017. private _buildId;
  54018. private _buildWasSuccessful;
  54019. private _cachedWorldViewMatrix;
  54020. private _cachedWorldViewProjectionMatrix;
  54021. private _optimizers;
  54022. private _animationFrame;
  54023. /** Define the URl to load node editor script */
  54024. static EditorURL: string;
  54025. private BJSNODEMATERIALEDITOR;
  54026. /** Get the inspector from bundle or global */
  54027. private _getGlobalNodeMaterialEditor;
  54028. /**
  54029. * Gets or sets data used by visual editor
  54030. * @see https://nme.babylonjs.com
  54031. */
  54032. editorData: any;
  54033. /**
  54034. * 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)
  54035. */
  54036. ignoreAlpha: boolean;
  54037. /**
  54038. * Defines the maximum number of lights that can be used in the material
  54039. */
  54040. maxSimultaneousLights: number;
  54041. /**
  54042. * Observable raised when the material is built
  54043. */
  54044. onBuildObservable: Observable<NodeMaterial>;
  54045. /**
  54046. * Gets or sets the root nodes of the material vertex shader
  54047. */
  54048. _vertexOutputNodes: NodeMaterialBlock[];
  54049. /**
  54050. * Gets or sets the root nodes of the material fragment (pixel) shader
  54051. */
  54052. _fragmentOutputNodes: NodeMaterialBlock[];
  54053. /** Gets or sets options to control the node material overall behavior */
  54054. options: INodeMaterialOptions;
  54055. /**
  54056. * Default configuration related to image processing available in the standard Material.
  54057. */
  54058. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  54059. /**
  54060. * Gets the image processing configuration used either in this material.
  54061. */
  54062. /**
  54063. * Sets the Default image processing configuration used either in the this material.
  54064. *
  54065. * If sets to null, the scene one is in use.
  54066. */
  54067. imageProcessingConfiguration: ImageProcessingConfiguration;
  54068. /**
  54069. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  54070. */
  54071. attachedBlocks: NodeMaterialBlock[];
  54072. /**
  54073. * Create a new node based material
  54074. * @param name defines the material name
  54075. * @param scene defines the hosting scene
  54076. * @param options defines creation option
  54077. */
  54078. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  54079. /**
  54080. * Gets the current class name of the material e.g. "NodeMaterial"
  54081. * @returns the class name
  54082. */
  54083. getClassName(): string;
  54084. /**
  54085. * Keep track of the image processing observer to allow dispose and replace.
  54086. */
  54087. private _imageProcessingObserver;
  54088. /**
  54089. * Attaches a new image processing configuration to the Standard Material.
  54090. * @param configuration
  54091. */
  54092. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  54093. /**
  54094. * Get a block by its name
  54095. * @param name defines the name of the block to retrieve
  54096. * @returns the required block or null if not found
  54097. */
  54098. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  54099. /**
  54100. * Get a block by its name
  54101. * @param predicate defines the predicate used to find the good candidate
  54102. * @returns the required block or null if not found
  54103. */
  54104. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  54105. /**
  54106. * Get an input block by its name
  54107. * @param predicate defines the predicate used to find the good candidate
  54108. * @returns the required input block or null if not found
  54109. */
  54110. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  54111. /**
  54112. * Gets the list of input blocks attached to this material
  54113. * @returns an array of InputBlocks
  54114. */
  54115. getInputBlocks(): InputBlock[];
  54116. /**
  54117. * Adds a new optimizer to the list of optimizers
  54118. * @param optimizer defines the optimizers to add
  54119. * @returns the current material
  54120. */
  54121. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  54122. /**
  54123. * Remove an optimizer from the list of optimizers
  54124. * @param optimizer defines the optimizers to remove
  54125. * @returns the current material
  54126. */
  54127. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  54128. /**
  54129. * Add a new block to the list of output nodes
  54130. * @param node defines the node to add
  54131. * @returns the current material
  54132. */
  54133. addOutputNode(node: NodeMaterialBlock): this;
  54134. /**
  54135. * Remove a block from the list of root nodes
  54136. * @param node defines the node to remove
  54137. * @returns the current material
  54138. */
  54139. removeOutputNode(node: NodeMaterialBlock): this;
  54140. private _addVertexOutputNode;
  54141. private _removeVertexOutputNode;
  54142. private _addFragmentOutputNode;
  54143. private _removeFragmentOutputNode;
  54144. /**
  54145. * Specifies if the material will require alpha blending
  54146. * @returns a boolean specifying if alpha blending is needed
  54147. */
  54148. needAlphaBlending(): boolean;
  54149. /**
  54150. * Specifies if this material should be rendered in alpha test mode
  54151. * @returns a boolean specifying if an alpha test is needed.
  54152. */
  54153. needAlphaTesting(): boolean;
  54154. private _initializeBlock;
  54155. private _resetDualBlocks;
  54156. /**
  54157. * Remove a block from the current node material
  54158. * @param block defines the block to remove
  54159. */
  54160. removeBlock(block: NodeMaterialBlock): void;
  54161. /**
  54162. * Build the material and generates the inner effect
  54163. * @param verbose defines if the build should log activity
  54164. */
  54165. build(verbose?: boolean): void;
  54166. /**
  54167. * Runs an otpimization phase to try to improve the shader code
  54168. */
  54169. optimize(): void;
  54170. private _prepareDefinesForAttributes;
  54171. /**
  54172. * Get if the submesh is ready to be used and all its information available.
  54173. * Child classes can use it to update shaders
  54174. * @param mesh defines the mesh to check
  54175. * @param subMesh defines which submesh to check
  54176. * @param useInstances specifies that instances should be used
  54177. * @returns a boolean indicating that the submesh is ready or not
  54178. */
  54179. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  54180. /**
  54181. * Get a string representing the shaders built by the current node graph
  54182. */
  54183. readonly compiledShaders: string;
  54184. /**
  54185. * Binds the world matrix to the material
  54186. * @param world defines the world transformation matrix
  54187. */
  54188. bindOnlyWorldMatrix(world: Matrix): void;
  54189. /**
  54190. * Binds the submesh to this material by preparing the effect and shader to draw
  54191. * @param world defines the world transformation matrix
  54192. * @param mesh defines the mesh containing the submesh
  54193. * @param subMesh defines the submesh to bind the material to
  54194. */
  54195. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  54196. /**
  54197. * Gets the active textures from the material
  54198. * @returns an array of textures
  54199. */
  54200. getActiveTextures(): BaseTexture[];
  54201. /**
  54202. * Gets the list of texture blocks
  54203. * @returns an array of texture blocks
  54204. */
  54205. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  54206. /**
  54207. * Specifies if the material uses a texture
  54208. * @param texture defines the texture to check against the material
  54209. * @returns a boolean specifying if the material uses the texture
  54210. */
  54211. hasTexture(texture: BaseTexture): boolean;
  54212. /**
  54213. * Disposes the material
  54214. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  54215. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  54216. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  54217. */
  54218. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  54219. /** Creates the node editor window. */
  54220. private _createNodeEditor;
  54221. /**
  54222. * Launch the node material editor
  54223. * @param config Define the configuration of the editor
  54224. * @return a promise fulfilled when the node editor is visible
  54225. */
  54226. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  54227. /**
  54228. * Clear the current material
  54229. */
  54230. clear(): void;
  54231. /**
  54232. * Clear the current material and set it to a default state
  54233. */
  54234. setToDefault(): void;
  54235. /**
  54236. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  54237. * @param url defines the url to load from
  54238. * @returns a promise that will fullfil when the material is fully loaded
  54239. */
  54240. loadAsync(url: string): Promise<void>;
  54241. private _gatherBlocks;
  54242. /**
  54243. * Generate a string containing the code declaration required to create an equivalent of this material
  54244. * @returns a string
  54245. */
  54246. generateCode(): string;
  54247. /**
  54248. * Serializes this material in a JSON representation
  54249. * @returns the serialized material object
  54250. */
  54251. serialize(): any;
  54252. private _restoreConnections;
  54253. /**
  54254. * Clear the current graph and load a new one from a serialization object
  54255. * @param source defines the JSON representation of the material
  54256. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  54257. */
  54258. loadFromSerialization(source: any, rootUrl?: string): void;
  54259. /**
  54260. * Creates a node material from parsed material data
  54261. * @param source defines the JSON representation of the material
  54262. * @param scene defines the hosting scene
  54263. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  54264. * @returns a new node material
  54265. */
  54266. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  54267. /**
  54268. * Creates a new node material set to default basic configuration
  54269. * @param name defines the name of the material
  54270. * @param scene defines the hosting scene
  54271. * @returns a new NodeMaterial
  54272. */
  54273. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  54274. }
  54275. }
  54276. declare module BABYLON {
  54277. /**
  54278. * Block used to read a texture from a sampler
  54279. */
  54280. export class TextureBlock extends NodeMaterialBlock {
  54281. private _defineName;
  54282. private _linearDefineName;
  54283. private _tempTextureRead;
  54284. private _samplerName;
  54285. private _transformedUVName;
  54286. private _textureTransformName;
  54287. private _textureInfoName;
  54288. private _mainUVName;
  54289. private _mainUVDefineName;
  54290. /**
  54291. * Gets or sets the texture associated with the node
  54292. */
  54293. texture: Nullable<Texture>;
  54294. /**
  54295. * Create a new TextureBlock
  54296. * @param name defines the block name
  54297. */
  54298. constructor(name: string);
  54299. /**
  54300. * Gets the current class name
  54301. * @returns the class name
  54302. */
  54303. getClassName(): string;
  54304. /**
  54305. * Gets the uv input component
  54306. */
  54307. readonly uv: NodeMaterialConnectionPoint;
  54308. /**
  54309. * Gets the rgba output component
  54310. */
  54311. readonly rgba: NodeMaterialConnectionPoint;
  54312. /**
  54313. * Gets the rgb output component
  54314. */
  54315. readonly rgb: NodeMaterialConnectionPoint;
  54316. /**
  54317. * Gets the r output component
  54318. */
  54319. readonly r: NodeMaterialConnectionPoint;
  54320. /**
  54321. * Gets the g output component
  54322. */
  54323. readonly g: NodeMaterialConnectionPoint;
  54324. /**
  54325. * Gets the b output component
  54326. */
  54327. readonly b: NodeMaterialConnectionPoint;
  54328. /**
  54329. * Gets the a output component
  54330. */
  54331. readonly a: NodeMaterialConnectionPoint;
  54332. readonly target: NodeMaterialBlockTargets;
  54333. autoConfigure(material: NodeMaterial): void;
  54334. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  54335. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54336. private _getTextureBase;
  54337. isReady(): boolean;
  54338. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54339. private readonly _isMixed;
  54340. private _injectVertexCode;
  54341. private _writeTextureRead;
  54342. private _writeOutput;
  54343. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54344. protected _dumpPropertiesCode(): string;
  54345. serialize(): any;
  54346. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54347. }
  54348. }
  54349. declare module BABYLON {
  54350. /**
  54351. * Class used to store shared data between 2 NodeMaterialBuildState
  54352. */
  54353. export class NodeMaterialBuildStateSharedData {
  54354. /**
  54355. * Gets the list of emitted varyings
  54356. */
  54357. temps: string[];
  54358. /**
  54359. * Gets the list of emitted varyings
  54360. */
  54361. varyings: string[];
  54362. /**
  54363. * Gets the varying declaration string
  54364. */
  54365. varyingDeclaration: string;
  54366. /**
  54367. * Input blocks
  54368. */
  54369. inputBlocks: InputBlock[];
  54370. /**
  54371. * Input blocks
  54372. */
  54373. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  54374. /**
  54375. * Bindable blocks (Blocks that need to set data to the effect)
  54376. */
  54377. bindableBlocks: NodeMaterialBlock[];
  54378. /**
  54379. * List of blocks that can provide a compilation fallback
  54380. */
  54381. blocksWithFallbacks: NodeMaterialBlock[];
  54382. /**
  54383. * List of blocks that can provide a define update
  54384. */
  54385. blocksWithDefines: NodeMaterialBlock[];
  54386. /**
  54387. * List of blocks that can provide a repeatable content
  54388. */
  54389. repeatableContentBlocks: NodeMaterialBlock[];
  54390. /**
  54391. * List of blocks that can provide a dynamic list of uniforms
  54392. */
  54393. dynamicUniformBlocks: NodeMaterialBlock[];
  54394. /**
  54395. * List of blocks that can block the isReady function for the material
  54396. */
  54397. blockingBlocks: NodeMaterialBlock[];
  54398. /**
  54399. * Gets the list of animated inputs
  54400. */
  54401. animatedInputs: InputBlock[];
  54402. /**
  54403. * Build Id used to avoid multiple recompilations
  54404. */
  54405. buildId: number;
  54406. /** List of emitted variables */
  54407. variableNames: {
  54408. [key: string]: number;
  54409. };
  54410. /** List of emitted defines */
  54411. defineNames: {
  54412. [key: string]: number;
  54413. };
  54414. /** Should emit comments? */
  54415. emitComments: boolean;
  54416. /** Emit build activity */
  54417. verbose: boolean;
  54418. /** Gets or sets the hosting scene */
  54419. scene: Scene;
  54420. /**
  54421. * Gets the compilation hints emitted at compilation time
  54422. */
  54423. hints: {
  54424. needWorldViewMatrix: boolean;
  54425. needWorldViewProjectionMatrix: boolean;
  54426. needAlphaBlending: boolean;
  54427. needAlphaTesting: boolean;
  54428. };
  54429. /**
  54430. * List of compilation checks
  54431. */
  54432. checks: {
  54433. emitVertex: boolean;
  54434. emitFragment: boolean;
  54435. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  54436. };
  54437. /** Creates a new shared data */
  54438. constructor();
  54439. /**
  54440. * Emits console errors and exceptions if there is a failing check
  54441. */
  54442. emitErrors(): void;
  54443. }
  54444. }
  54445. declare module BABYLON {
  54446. /**
  54447. * Class used to store node based material build state
  54448. */
  54449. export class NodeMaterialBuildState {
  54450. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  54451. supportUniformBuffers: boolean;
  54452. /**
  54453. * Gets the list of emitted attributes
  54454. */
  54455. attributes: string[];
  54456. /**
  54457. * Gets the list of emitted uniforms
  54458. */
  54459. uniforms: string[];
  54460. /**
  54461. * Gets the list of emitted constants
  54462. */
  54463. constants: string[];
  54464. /**
  54465. * Gets the list of emitted samplers
  54466. */
  54467. samplers: string[];
  54468. /**
  54469. * Gets the list of emitted functions
  54470. */
  54471. functions: {
  54472. [key: string]: string;
  54473. };
  54474. /**
  54475. * Gets the list of emitted extensions
  54476. */
  54477. extensions: {
  54478. [key: string]: string;
  54479. };
  54480. /**
  54481. * Gets the target of the compilation state
  54482. */
  54483. target: NodeMaterialBlockTargets;
  54484. /**
  54485. * Gets the list of emitted counters
  54486. */
  54487. counters: {
  54488. [key: string]: number;
  54489. };
  54490. /**
  54491. * Shared data between multiple NodeMaterialBuildState instances
  54492. */
  54493. sharedData: NodeMaterialBuildStateSharedData;
  54494. /** @hidden */
  54495. _vertexState: NodeMaterialBuildState;
  54496. /** @hidden */
  54497. _attributeDeclaration: string;
  54498. /** @hidden */
  54499. _uniformDeclaration: string;
  54500. /** @hidden */
  54501. _constantDeclaration: string;
  54502. /** @hidden */
  54503. _samplerDeclaration: string;
  54504. /** @hidden */
  54505. _varyingTransfer: string;
  54506. private _repeatableContentAnchorIndex;
  54507. /** @hidden */
  54508. _builtCompilationString: string;
  54509. /**
  54510. * Gets the emitted compilation strings
  54511. */
  54512. compilationString: string;
  54513. /**
  54514. * Finalize the compilation strings
  54515. * @param state defines the current compilation state
  54516. */
  54517. finalize(state: NodeMaterialBuildState): void;
  54518. /** @hidden */
  54519. readonly _repeatableContentAnchor: string;
  54520. /** @hidden */
  54521. _getFreeVariableName(prefix: string): string;
  54522. /** @hidden */
  54523. _getFreeDefineName(prefix: string): string;
  54524. /** @hidden */
  54525. _excludeVariableName(name: string): void;
  54526. /** @hidden */
  54527. _emit2DSampler(name: string): void;
  54528. /** @hidden */
  54529. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  54530. /** @hidden */
  54531. _emitExtension(name: string, extension: string): void;
  54532. /** @hidden */
  54533. _emitFunction(name: string, code: string, comments: string): void;
  54534. /** @hidden */
  54535. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  54536. replaceStrings?: {
  54537. search: RegExp;
  54538. replace: string;
  54539. }[];
  54540. repeatKey?: string;
  54541. }): string;
  54542. /** @hidden */
  54543. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  54544. repeatKey?: string;
  54545. removeAttributes?: boolean;
  54546. removeUniforms?: boolean;
  54547. removeVaryings?: boolean;
  54548. removeIfDef?: boolean;
  54549. replaceStrings?: {
  54550. search: RegExp;
  54551. replace: string;
  54552. }[];
  54553. }, storeKey?: string): void;
  54554. /** @hidden */
  54555. _registerTempVariable(name: string): boolean;
  54556. /** @hidden */
  54557. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  54558. /** @hidden */
  54559. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  54560. /** @hidden */
  54561. _emitFloat(value: number): string;
  54562. }
  54563. }
  54564. declare module BABYLON {
  54565. /**
  54566. * Defines a block that can be used inside a node based material
  54567. */
  54568. export class NodeMaterialBlock {
  54569. private _buildId;
  54570. private _buildTarget;
  54571. private _target;
  54572. private _isFinalMerger;
  54573. private _isInput;
  54574. protected _isUnique: boolean;
  54575. /** @hidden */
  54576. _codeVariableName: string;
  54577. /** @hidden */
  54578. _inputs: NodeMaterialConnectionPoint[];
  54579. /** @hidden */
  54580. _outputs: NodeMaterialConnectionPoint[];
  54581. /** @hidden */
  54582. _preparationId: number;
  54583. /**
  54584. * Gets or sets the name of the block
  54585. */
  54586. name: string;
  54587. /**
  54588. * Gets or sets the unique id of the node
  54589. */
  54590. uniqueId: number;
  54591. /**
  54592. * Gets or sets the comments associated with this block
  54593. */
  54594. comments: string;
  54595. /**
  54596. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  54597. */
  54598. readonly isUnique: boolean;
  54599. /**
  54600. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  54601. */
  54602. readonly isFinalMerger: boolean;
  54603. /**
  54604. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  54605. */
  54606. readonly isInput: boolean;
  54607. /**
  54608. * Gets or sets the build Id
  54609. */
  54610. buildId: number;
  54611. /**
  54612. * Gets or sets the target of the block
  54613. */
  54614. target: NodeMaterialBlockTargets;
  54615. /**
  54616. * Gets the list of input points
  54617. */
  54618. readonly inputs: NodeMaterialConnectionPoint[];
  54619. /** Gets the list of output points */
  54620. readonly outputs: NodeMaterialConnectionPoint[];
  54621. /**
  54622. * Find an input by its name
  54623. * @param name defines the name of the input to look for
  54624. * @returns the input or null if not found
  54625. */
  54626. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  54627. /**
  54628. * Find an output by its name
  54629. * @param name defines the name of the outputto look for
  54630. * @returns the output or null if not found
  54631. */
  54632. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  54633. /**
  54634. * Creates a new NodeMaterialBlock
  54635. * @param name defines the block name
  54636. * @param target defines the target of that block (Vertex by default)
  54637. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  54638. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  54639. */
  54640. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  54641. /**
  54642. * Initialize the block and prepare the context for build
  54643. * @param state defines the state that will be used for the build
  54644. */
  54645. initialize(state: NodeMaterialBuildState): void;
  54646. /**
  54647. * Bind data to effect. Will only be called for blocks with isBindable === true
  54648. * @param effect defines the effect to bind data to
  54649. * @param nodeMaterial defines the hosting NodeMaterial
  54650. * @param mesh defines the mesh that will be rendered
  54651. */
  54652. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54653. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  54654. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  54655. protected _writeFloat(value: number): string;
  54656. /**
  54657. * Gets the current class name e.g. "NodeMaterialBlock"
  54658. * @returns the class name
  54659. */
  54660. getClassName(): string;
  54661. /**
  54662. * Register a new input. Must be called inside a block constructor
  54663. * @param name defines the connection point name
  54664. * @param type defines the connection point type
  54665. * @param isOptional defines a boolean indicating that this input can be omitted
  54666. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  54667. * @returns the current block
  54668. */
  54669. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  54670. /**
  54671. * Register a new output. Must be called inside a block constructor
  54672. * @param name defines the connection point name
  54673. * @param type defines the connection point type
  54674. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  54675. * @returns the current block
  54676. */
  54677. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  54678. /**
  54679. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  54680. * @param forOutput defines an optional connection point to check compatibility with
  54681. * @returns the first available input or null
  54682. */
  54683. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  54684. /**
  54685. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  54686. * @param forBlock defines an optional block to check compatibility with
  54687. * @returns the first available input or null
  54688. */
  54689. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  54690. /**
  54691. * Gets the sibling of the given output
  54692. * @param current defines the current output
  54693. * @returns the next output in the list or null
  54694. */
  54695. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  54696. /**
  54697. * Connect current block with another block
  54698. * @param other defines the block to connect with
  54699. * @param options define the various options to help pick the right connections
  54700. * @returns the current block
  54701. */
  54702. connectTo(other: NodeMaterialBlock, options?: {
  54703. input?: string;
  54704. output?: string;
  54705. outputSwizzle?: string;
  54706. }): this | undefined;
  54707. protected _buildBlock(state: NodeMaterialBuildState): void;
  54708. /**
  54709. * Add uniforms, samplers and uniform buffers at compilation time
  54710. * @param state defines the state to update
  54711. * @param nodeMaterial defines the node material requesting the update
  54712. * @param defines defines the material defines to update
  54713. * @param uniformBuffers defines the list of uniform buffer names
  54714. */
  54715. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  54716. /**
  54717. * Add potential fallbacks if shader compilation fails
  54718. * @param mesh defines the mesh to be rendered
  54719. * @param fallbacks defines the current prioritized list of fallbacks
  54720. */
  54721. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  54722. /**
  54723. * Initialize defines for shader compilation
  54724. * @param mesh defines the mesh to be rendered
  54725. * @param nodeMaterial defines the node material requesting the update
  54726. * @param defines defines the material defines to update
  54727. * @param useInstances specifies that instances should be used
  54728. */
  54729. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  54730. /**
  54731. * Update defines for shader compilation
  54732. * @param mesh defines the mesh to be rendered
  54733. * @param nodeMaterial defines the node material requesting the update
  54734. * @param defines defines the material defines to update
  54735. * @param useInstances specifies that instances should be used
  54736. */
  54737. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  54738. /**
  54739. * Lets the block try to connect some inputs automatically
  54740. * @param material defines the hosting NodeMaterial
  54741. */
  54742. autoConfigure(material: NodeMaterial): void;
  54743. /**
  54744. * Function called when a block is declared as repeatable content generator
  54745. * @param vertexShaderState defines the current compilation state for the vertex shader
  54746. * @param fragmentShaderState defines the current compilation state for the fragment shader
  54747. * @param mesh defines the mesh to be rendered
  54748. * @param defines defines the material defines to update
  54749. */
  54750. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  54751. /**
  54752. * Checks if the block is ready
  54753. * @param mesh defines the mesh to be rendered
  54754. * @param nodeMaterial defines the node material requesting the update
  54755. * @param defines defines the material defines to update
  54756. * @param useInstances specifies that instances should be used
  54757. * @returns true if the block is ready
  54758. */
  54759. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  54760. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  54761. private _processBuild;
  54762. /**
  54763. * Compile the current node and generate the shader code
  54764. * @param state defines the current compilation state (uniforms, samplers, current string)
  54765. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  54766. * @returns true if already built
  54767. */
  54768. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  54769. protected _inputRename(name: string): string;
  54770. protected _outputRename(name: string): string;
  54771. protected _dumpPropertiesCode(): string;
  54772. /** @hidden */
  54773. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  54774. /** @hidden */
  54775. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  54776. /**
  54777. * Clone the current block to a new identical block
  54778. * @param scene defines the hosting scene
  54779. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  54780. * @returns a copy of the current block
  54781. */
  54782. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  54783. /**
  54784. * Serializes this block in a JSON representation
  54785. * @returns the serialized block object
  54786. */
  54787. serialize(): any;
  54788. /** @hidden */
  54789. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54790. /**
  54791. * Release resources
  54792. */
  54793. dispose(): void;
  54794. }
  54795. }
  54796. declare module BABYLON {
  54797. /**
  54798. * Enum defining the type of animations supported by InputBlock
  54799. */
  54800. export enum AnimatedInputBlockTypes {
  54801. /** No animation */
  54802. None = 0,
  54803. /** Time based animation. Will only work for floats */
  54804. Time = 1
  54805. }
  54806. }
  54807. declare module BABYLON {
  54808. /**
  54809. * Block used to expose an input value
  54810. */
  54811. export class InputBlock extends NodeMaterialBlock {
  54812. private _mode;
  54813. private _associatedVariableName;
  54814. private _storedValue;
  54815. private _valueCallback;
  54816. private _type;
  54817. private _animationType;
  54818. /** Gets or set a value used to limit the range of float values */
  54819. min: number;
  54820. /** Gets or set a value used to limit the range of float values */
  54821. max: number;
  54822. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  54823. matrixMode: number;
  54824. /** @hidden */
  54825. _systemValue: Nullable<NodeMaterialSystemValues>;
  54826. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  54827. visibleInInspector: boolean;
  54828. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  54829. isConstant: boolean;
  54830. /**
  54831. * Gets or sets the connection point type (default is float)
  54832. */
  54833. readonly type: NodeMaterialBlockConnectionPointTypes;
  54834. /**
  54835. * Creates a new InputBlock
  54836. * @param name defines the block name
  54837. * @param target defines the target of that block (Vertex by default)
  54838. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  54839. */
  54840. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  54841. /**
  54842. * Gets the output component
  54843. */
  54844. readonly output: NodeMaterialConnectionPoint;
  54845. /**
  54846. * Set the source of this connection point to a vertex attribute
  54847. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  54848. * @returns the current connection point
  54849. */
  54850. setAsAttribute(attributeName?: string): InputBlock;
  54851. /**
  54852. * Set the source of this connection point to a system value
  54853. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  54854. * @returns the current connection point
  54855. */
  54856. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  54857. /**
  54858. * Gets or sets the value of that point.
  54859. * Please note that this value will be ignored if valueCallback is defined
  54860. */
  54861. value: any;
  54862. /**
  54863. * Gets or sets a callback used to get the value of that point.
  54864. * Please note that setting this value will force the connection point to ignore the value property
  54865. */
  54866. valueCallback: () => any;
  54867. /**
  54868. * Gets or sets the associated variable name in the shader
  54869. */
  54870. associatedVariableName: string;
  54871. /** Gets or sets the type of animation applied to the input */
  54872. animationType: AnimatedInputBlockTypes;
  54873. /**
  54874. * Gets a boolean indicating that this connection point not defined yet
  54875. */
  54876. readonly isUndefined: boolean;
  54877. /**
  54878. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  54879. * In this case the connection point name must be the name of the uniform to use.
  54880. * Can only be set on inputs
  54881. */
  54882. isUniform: boolean;
  54883. /**
  54884. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  54885. * In this case the connection point name must be the name of the attribute to use
  54886. * Can only be set on inputs
  54887. */
  54888. isAttribute: boolean;
  54889. /**
  54890. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  54891. * Can only be set on exit points
  54892. */
  54893. isVarying: boolean;
  54894. /**
  54895. * Gets a boolean indicating that the current connection point is a system value
  54896. */
  54897. readonly isSystemValue: boolean;
  54898. /**
  54899. * Gets or sets the current well known value or null if not defined as a system value
  54900. */
  54901. systemValue: Nullable<NodeMaterialSystemValues>;
  54902. /**
  54903. * Gets the current class name
  54904. * @returns the class name
  54905. */
  54906. getClassName(): string;
  54907. /**
  54908. * Animate the input if animationType !== None
  54909. * @param scene defines the rendering scene
  54910. */
  54911. animate(scene: Scene): void;
  54912. private _emitDefine;
  54913. initialize(state: NodeMaterialBuildState): void;
  54914. /**
  54915. * Set the input block to its default value (based on its type)
  54916. */
  54917. setDefaultValue(): void;
  54918. private _emitConstant;
  54919. private _emit;
  54920. /** @hidden */
  54921. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  54922. /** @hidden */
  54923. _transmit(effect: Effect, scene: Scene): void;
  54924. protected _buildBlock(state: NodeMaterialBuildState): void;
  54925. protected _dumpPropertiesCode(): string;
  54926. serialize(): any;
  54927. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54928. }
  54929. }
  54930. declare module BABYLON {
  54931. /**
  54932. * Enum used to define the compatibility state between two connection points
  54933. */
  54934. export enum NodeMaterialConnectionPointCompatibilityStates {
  54935. /** Points are compatibles */
  54936. Compatible = 0,
  54937. /** Points are incompatible because of their types */
  54938. TypeIncompatible = 1,
  54939. /** Points are incompatible because of their targets (vertex vs fragment) */
  54940. TargetIncompatible = 2
  54941. }
  54942. /**
  54943. * Defines the direction of a connection point
  54944. */
  54945. export enum NodeMaterialConnectionPointDirection {
  54946. /** Input */
  54947. Input = 0,
  54948. /** Output */
  54949. Output = 1
  54950. }
  54951. /**
  54952. * Defines a connection point for a block
  54953. */
  54954. export class NodeMaterialConnectionPoint {
  54955. /** @hidden */
  54956. _ownerBlock: NodeMaterialBlock;
  54957. /** @hidden */
  54958. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  54959. private _endpoints;
  54960. private _associatedVariableName;
  54961. private _direction;
  54962. /** @hidden */
  54963. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  54964. /** @hidden */
  54965. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  54966. private _type;
  54967. /** @hidden */
  54968. _enforceAssociatedVariableName: boolean;
  54969. /** Gets the direction of the point */
  54970. readonly direction: NodeMaterialConnectionPointDirection;
  54971. /**
  54972. * Gets or sets the additional types supported by this connection point
  54973. */
  54974. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  54975. /**
  54976. * Gets or sets the additional types excluded by this connection point
  54977. */
  54978. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  54979. /**
  54980. * Observable triggered when this point is connected
  54981. */
  54982. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  54983. /**
  54984. * Gets or sets the associated variable name in the shader
  54985. */
  54986. associatedVariableName: string;
  54987. /**
  54988. * Gets or sets the connection point type (default is float)
  54989. */
  54990. type: NodeMaterialBlockConnectionPointTypes;
  54991. /**
  54992. * Gets or sets the connection point name
  54993. */
  54994. name: string;
  54995. /**
  54996. * Gets or sets a boolean indicating that this connection point can be omitted
  54997. */
  54998. isOptional: boolean;
  54999. /**
  55000. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  55001. */
  55002. define: string;
  55003. /** @hidden */
  55004. _prioritizeVertex: boolean;
  55005. private _target;
  55006. /** Gets or sets the target of that connection point */
  55007. target: NodeMaterialBlockTargets;
  55008. /**
  55009. * Gets a boolean indicating that the current point is connected
  55010. */
  55011. readonly isConnected: boolean;
  55012. /**
  55013. * Gets a boolean indicating that the current point is connected to an input block
  55014. */
  55015. readonly isConnectedToInputBlock: boolean;
  55016. /**
  55017. * Gets a the connected input block (if any)
  55018. */
  55019. readonly connectInputBlock: Nullable<InputBlock>;
  55020. /** Get the other side of the connection (if any) */
  55021. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  55022. /** Get the block that owns this connection point */
  55023. readonly ownerBlock: NodeMaterialBlock;
  55024. /** Get the block connected on the other side of this connection (if any) */
  55025. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  55026. /** Get the block connected on the endpoints of this connection (if any) */
  55027. readonly connectedBlocks: Array<NodeMaterialBlock>;
  55028. /** Gets the list of connected endpoints */
  55029. readonly endpoints: NodeMaterialConnectionPoint[];
  55030. /** Gets a boolean indicating if that output point is connected to at least one input */
  55031. readonly hasEndpoints: boolean;
  55032. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  55033. readonly isConnectedInVertexShader: boolean;
  55034. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  55035. readonly isConnectedInFragmentShader: boolean;
  55036. /**
  55037. * Creates a new connection point
  55038. * @param name defines the connection point name
  55039. * @param ownerBlock defines the block hosting this connection point
  55040. * @param direction defines the direction of the connection point
  55041. */
  55042. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  55043. /**
  55044. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  55045. * @returns the class name
  55046. */
  55047. getClassName(): string;
  55048. /**
  55049. * Gets a boolean indicating if the current point can be connected to another point
  55050. * @param connectionPoint defines the other connection point
  55051. * @returns a boolean
  55052. */
  55053. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  55054. /**
  55055. * Gets a number indicating if the current point can be connected to another point
  55056. * @param connectionPoint defines the other connection point
  55057. * @returns a number defining the compatibility state
  55058. */
  55059. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  55060. /**
  55061. * Connect this point to another connection point
  55062. * @param connectionPoint defines the other connection point
  55063. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  55064. * @returns the current connection point
  55065. */
  55066. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  55067. /**
  55068. * Disconnect this point from one of his endpoint
  55069. * @param endpoint defines the other connection point
  55070. * @returns the current connection point
  55071. */
  55072. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  55073. /**
  55074. * Serializes this point in a JSON representation
  55075. * @returns the serialized point object
  55076. */
  55077. serialize(): any;
  55078. /**
  55079. * Release resources
  55080. */
  55081. dispose(): void;
  55082. }
  55083. }
  55084. declare module BABYLON {
  55085. /**
  55086. * Block used to add support for vertex skinning (bones)
  55087. */
  55088. export class BonesBlock extends NodeMaterialBlock {
  55089. /**
  55090. * Creates a new BonesBlock
  55091. * @param name defines the block name
  55092. */
  55093. constructor(name: string);
  55094. /**
  55095. * Initialize the block and prepare the context for build
  55096. * @param state defines the state that will be used for the build
  55097. */
  55098. initialize(state: NodeMaterialBuildState): void;
  55099. /**
  55100. * Gets the current class name
  55101. * @returns the class name
  55102. */
  55103. getClassName(): string;
  55104. /**
  55105. * Gets the matrix indices input component
  55106. */
  55107. readonly matricesIndices: NodeMaterialConnectionPoint;
  55108. /**
  55109. * Gets the matrix weights input component
  55110. */
  55111. readonly matricesWeights: NodeMaterialConnectionPoint;
  55112. /**
  55113. * Gets the extra matrix indices input component
  55114. */
  55115. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  55116. /**
  55117. * Gets the extra matrix weights input component
  55118. */
  55119. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  55120. /**
  55121. * Gets the world input component
  55122. */
  55123. readonly world: NodeMaterialConnectionPoint;
  55124. /**
  55125. * Gets the output component
  55126. */
  55127. readonly output: NodeMaterialConnectionPoint;
  55128. autoConfigure(material: NodeMaterial): void;
  55129. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  55130. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55131. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55132. protected _buildBlock(state: NodeMaterialBuildState): this;
  55133. }
  55134. }
  55135. declare module BABYLON {
  55136. /**
  55137. * Block used to add support for instances
  55138. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  55139. */
  55140. export class InstancesBlock extends NodeMaterialBlock {
  55141. /**
  55142. * Creates a new InstancesBlock
  55143. * @param name defines the block name
  55144. */
  55145. constructor(name: string);
  55146. /**
  55147. * Gets the current class name
  55148. * @returns the class name
  55149. */
  55150. getClassName(): string;
  55151. /**
  55152. * Gets the first world row input component
  55153. */
  55154. readonly world0: NodeMaterialConnectionPoint;
  55155. /**
  55156. * Gets the second world row input component
  55157. */
  55158. readonly world1: NodeMaterialConnectionPoint;
  55159. /**
  55160. * Gets the third world row input component
  55161. */
  55162. readonly world2: NodeMaterialConnectionPoint;
  55163. /**
  55164. * Gets the forth world row input component
  55165. */
  55166. readonly world3: NodeMaterialConnectionPoint;
  55167. /**
  55168. * Gets the world input component
  55169. */
  55170. readonly world: NodeMaterialConnectionPoint;
  55171. /**
  55172. * Gets the output component
  55173. */
  55174. readonly output: NodeMaterialConnectionPoint;
  55175. autoConfigure(material: NodeMaterial): void;
  55176. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55177. protected _buildBlock(state: NodeMaterialBuildState): this;
  55178. }
  55179. }
  55180. declare module BABYLON {
  55181. /**
  55182. * Block used to add morph targets support to vertex shader
  55183. */
  55184. export class MorphTargetsBlock extends NodeMaterialBlock {
  55185. private _repeatableContentAnchor;
  55186. private _repeatebleContentGenerated;
  55187. /**
  55188. * Create a new MorphTargetsBlock
  55189. * @param name defines the block name
  55190. */
  55191. constructor(name: string);
  55192. /**
  55193. * Gets the current class name
  55194. * @returns the class name
  55195. */
  55196. getClassName(): string;
  55197. /**
  55198. * Gets the position input component
  55199. */
  55200. readonly position: NodeMaterialConnectionPoint;
  55201. /**
  55202. * Gets the normal input component
  55203. */
  55204. readonly normal: NodeMaterialConnectionPoint;
  55205. /**
  55206. * Gets the tangent input component
  55207. */
  55208. readonly tangent: NodeMaterialConnectionPoint;
  55209. /**
  55210. * Gets the tangent input component
  55211. */
  55212. readonly uv: NodeMaterialConnectionPoint;
  55213. /**
  55214. * Gets the position output component
  55215. */
  55216. readonly positionOutput: NodeMaterialConnectionPoint;
  55217. /**
  55218. * Gets the normal output component
  55219. */
  55220. readonly normalOutput: NodeMaterialConnectionPoint;
  55221. /**
  55222. * Gets the tangent output component
  55223. */
  55224. readonly tangentOutput: NodeMaterialConnectionPoint;
  55225. /**
  55226. * Gets the tangent output component
  55227. */
  55228. readonly uvOutput: NodeMaterialConnectionPoint;
  55229. initialize(state: NodeMaterialBuildState): void;
  55230. autoConfigure(material: NodeMaterial): void;
  55231. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55232. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55233. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  55234. protected _buildBlock(state: NodeMaterialBuildState): this;
  55235. }
  55236. }
  55237. declare module BABYLON {
  55238. /**
  55239. * Block used to get data information from a light
  55240. */
  55241. export class LightInformationBlock extends NodeMaterialBlock {
  55242. private _lightDataUniformName;
  55243. private _lightColorUniformName;
  55244. private _lightTypeDefineName;
  55245. /**
  55246. * Gets or sets the light associated with this block
  55247. */
  55248. light: Nullable<Light>;
  55249. /**
  55250. * Creates a new LightInformationBlock
  55251. * @param name defines the block name
  55252. */
  55253. constructor(name: string);
  55254. /**
  55255. * Gets the current class name
  55256. * @returns the class name
  55257. */
  55258. getClassName(): string;
  55259. /**
  55260. * Gets the world position input component
  55261. */
  55262. readonly worldPosition: NodeMaterialConnectionPoint;
  55263. /**
  55264. * Gets the direction output component
  55265. */
  55266. readonly direction: NodeMaterialConnectionPoint;
  55267. /**
  55268. * Gets the direction output component
  55269. */
  55270. readonly color: NodeMaterialConnectionPoint;
  55271. /**
  55272. * Gets the direction output component
  55273. */
  55274. readonly intensity: NodeMaterialConnectionPoint;
  55275. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55276. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55277. protected _buildBlock(state: NodeMaterialBuildState): this;
  55278. serialize(): any;
  55279. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55280. }
  55281. }
  55282. declare module BABYLON {
  55283. /**
  55284. * Block used to add image processing support to fragment shader
  55285. */
  55286. export class ImageProcessingBlock extends NodeMaterialBlock {
  55287. /**
  55288. * Create a new ImageProcessingBlock
  55289. * @param name defines the block name
  55290. */
  55291. constructor(name: string);
  55292. /**
  55293. * Gets the current class name
  55294. * @returns the class name
  55295. */
  55296. getClassName(): string;
  55297. /**
  55298. * Gets the color input component
  55299. */
  55300. readonly color: NodeMaterialConnectionPoint;
  55301. /**
  55302. * Gets the output component
  55303. */
  55304. readonly output: NodeMaterialConnectionPoint;
  55305. /**
  55306. * Initialize the block and prepare the context for build
  55307. * @param state defines the state that will be used for the build
  55308. */
  55309. initialize(state: NodeMaterialBuildState): void;
  55310. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  55311. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55312. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55313. protected _buildBlock(state: NodeMaterialBuildState): this;
  55314. }
  55315. }
  55316. declare module BABYLON {
  55317. /**
  55318. * Block used to pertub normals based on a normal map
  55319. */
  55320. export class PerturbNormalBlock extends NodeMaterialBlock {
  55321. private _tangentSpaceParameterName;
  55322. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  55323. invertX: boolean;
  55324. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  55325. invertY: boolean;
  55326. /**
  55327. * Create a new PerturbNormalBlock
  55328. * @param name defines the block name
  55329. */
  55330. constructor(name: string);
  55331. /**
  55332. * Gets the current class name
  55333. * @returns the class name
  55334. */
  55335. getClassName(): string;
  55336. /**
  55337. * Gets the world position input component
  55338. */
  55339. readonly worldPosition: NodeMaterialConnectionPoint;
  55340. /**
  55341. * Gets the world normal input component
  55342. */
  55343. readonly worldNormal: NodeMaterialConnectionPoint;
  55344. /**
  55345. * Gets the uv input component
  55346. */
  55347. readonly uv: NodeMaterialConnectionPoint;
  55348. /**
  55349. * Gets the normal map color input component
  55350. */
  55351. readonly normalMapColor: NodeMaterialConnectionPoint;
  55352. /**
  55353. * Gets the strength input component
  55354. */
  55355. readonly strength: NodeMaterialConnectionPoint;
  55356. /**
  55357. * Gets the output component
  55358. */
  55359. readonly output: NodeMaterialConnectionPoint;
  55360. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55361. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55362. autoConfigure(material: NodeMaterial): void;
  55363. protected _buildBlock(state: NodeMaterialBuildState): this;
  55364. protected _dumpPropertiesCode(): string;
  55365. serialize(): any;
  55366. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55367. }
  55368. }
  55369. declare module BABYLON {
  55370. /**
  55371. * Block used to discard a pixel if a value is smaller than a cutoff
  55372. */
  55373. export class DiscardBlock extends NodeMaterialBlock {
  55374. /**
  55375. * Create a new DiscardBlock
  55376. * @param name defines the block name
  55377. */
  55378. constructor(name: string);
  55379. /**
  55380. * Gets the current class name
  55381. * @returns the class name
  55382. */
  55383. getClassName(): string;
  55384. /**
  55385. * Gets the color input component
  55386. */
  55387. readonly value: NodeMaterialConnectionPoint;
  55388. /**
  55389. * Gets the cutoff input component
  55390. */
  55391. readonly cutoff: NodeMaterialConnectionPoint;
  55392. protected _buildBlock(state: NodeMaterialBuildState): this;
  55393. }
  55394. }
  55395. declare module BABYLON {
  55396. /**
  55397. * Block used to test if the fragment shader is front facing
  55398. */
  55399. export class FrontFacingBlock extends NodeMaterialBlock {
  55400. /**
  55401. * Creates a new FrontFacingBlock
  55402. * @param name defines the block name
  55403. */
  55404. constructor(name: string);
  55405. /**
  55406. * Gets the current class name
  55407. * @returns the class name
  55408. */
  55409. getClassName(): string;
  55410. /**
  55411. * Gets the output component
  55412. */
  55413. readonly output: NodeMaterialConnectionPoint;
  55414. protected _buildBlock(state: NodeMaterialBuildState): this;
  55415. }
  55416. }
  55417. declare module BABYLON {
  55418. /**
  55419. * Block used to get the derivative value on x and y of a given input
  55420. */
  55421. export class DerivativeBlock extends NodeMaterialBlock {
  55422. /**
  55423. * Create a new DerivativeBlock
  55424. * @param name defines the block name
  55425. */
  55426. constructor(name: string);
  55427. /**
  55428. * Gets the current class name
  55429. * @returns the class name
  55430. */
  55431. getClassName(): string;
  55432. /**
  55433. * Gets the input component
  55434. */
  55435. readonly input: NodeMaterialConnectionPoint;
  55436. /**
  55437. * Gets the derivative output on x
  55438. */
  55439. readonly dx: NodeMaterialConnectionPoint;
  55440. /**
  55441. * Gets the derivative output on y
  55442. */
  55443. readonly dy: NodeMaterialConnectionPoint;
  55444. protected _buildBlock(state: NodeMaterialBuildState): this;
  55445. }
  55446. }
  55447. declare module BABYLON {
  55448. /**
  55449. * Block used to add support for scene fog
  55450. */
  55451. export class FogBlock extends NodeMaterialBlock {
  55452. private _fogDistanceName;
  55453. private _fogParameters;
  55454. /**
  55455. * Create a new FogBlock
  55456. * @param name defines the block name
  55457. */
  55458. constructor(name: string);
  55459. /**
  55460. * Gets the current class name
  55461. * @returns the class name
  55462. */
  55463. getClassName(): string;
  55464. /**
  55465. * Gets the world position input component
  55466. */
  55467. readonly worldPosition: NodeMaterialConnectionPoint;
  55468. /**
  55469. * Gets the view input component
  55470. */
  55471. readonly view: NodeMaterialConnectionPoint;
  55472. /**
  55473. * Gets the color input component
  55474. */
  55475. readonly input: NodeMaterialConnectionPoint;
  55476. /**
  55477. * Gets the fog color input component
  55478. */
  55479. readonly fogColor: NodeMaterialConnectionPoint;
  55480. /**
  55481. * Gets the output component
  55482. */
  55483. readonly output: NodeMaterialConnectionPoint;
  55484. autoConfigure(material: NodeMaterial): void;
  55485. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55486. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55487. protected _buildBlock(state: NodeMaterialBuildState): this;
  55488. }
  55489. }
  55490. declare module BABYLON {
  55491. /**
  55492. * Block used to add light in the fragment shader
  55493. */
  55494. export class LightBlock extends NodeMaterialBlock {
  55495. private _lightId;
  55496. /**
  55497. * Gets or sets the light associated with this block
  55498. */
  55499. light: Nullable<Light>;
  55500. /**
  55501. * Create a new LightBlock
  55502. * @param name defines the block name
  55503. */
  55504. constructor(name: string);
  55505. /**
  55506. * Gets the current class name
  55507. * @returns the class name
  55508. */
  55509. getClassName(): string;
  55510. /**
  55511. * Gets the world position input component
  55512. */
  55513. readonly worldPosition: NodeMaterialConnectionPoint;
  55514. /**
  55515. * Gets the world normal input component
  55516. */
  55517. readonly worldNormal: NodeMaterialConnectionPoint;
  55518. /**
  55519. * Gets the camera (or eye) position component
  55520. */
  55521. readonly cameraPosition: NodeMaterialConnectionPoint;
  55522. /**
  55523. * Gets the glossiness component
  55524. */
  55525. readonly glossiness: NodeMaterialConnectionPoint;
  55526. /**
  55527. * Gets the glossinness power component
  55528. */
  55529. readonly glossPower: NodeMaterialConnectionPoint;
  55530. /**
  55531. * Gets the diffuse color component
  55532. */
  55533. readonly diffuseColor: NodeMaterialConnectionPoint;
  55534. /**
  55535. * Gets the specular color component
  55536. */
  55537. readonly specularColor: NodeMaterialConnectionPoint;
  55538. /**
  55539. * Gets the diffuse output component
  55540. */
  55541. readonly diffuseOutput: NodeMaterialConnectionPoint;
  55542. /**
  55543. * Gets the specular output component
  55544. */
  55545. readonly specularOutput: NodeMaterialConnectionPoint;
  55546. autoConfigure(material: NodeMaterial): void;
  55547. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55548. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  55549. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55550. private _injectVertexCode;
  55551. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55552. serialize(): any;
  55553. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55554. }
  55555. }
  55556. declare module BABYLON {
  55557. /**
  55558. * Block used to multiply 2 values
  55559. */
  55560. export class MultiplyBlock extends NodeMaterialBlock {
  55561. /**
  55562. * Creates a new MultiplyBlock
  55563. * @param name defines the block name
  55564. */
  55565. constructor(name: string);
  55566. /**
  55567. * Gets the current class name
  55568. * @returns the class name
  55569. */
  55570. getClassName(): string;
  55571. /**
  55572. * Gets the left operand input component
  55573. */
  55574. readonly left: NodeMaterialConnectionPoint;
  55575. /**
  55576. * Gets the right operand input component
  55577. */
  55578. readonly right: NodeMaterialConnectionPoint;
  55579. /**
  55580. * Gets the output component
  55581. */
  55582. readonly output: NodeMaterialConnectionPoint;
  55583. protected _buildBlock(state: NodeMaterialBuildState): this;
  55584. }
  55585. }
  55586. declare module BABYLON {
  55587. /**
  55588. * Block used to add 2 vectors
  55589. */
  55590. export class AddBlock extends NodeMaterialBlock {
  55591. /**
  55592. * Creates a new AddBlock
  55593. * @param name defines the block name
  55594. */
  55595. constructor(name: string);
  55596. /**
  55597. * Gets the current class name
  55598. * @returns the class name
  55599. */
  55600. getClassName(): string;
  55601. /**
  55602. * Gets the left operand input component
  55603. */
  55604. readonly left: NodeMaterialConnectionPoint;
  55605. /**
  55606. * Gets the right operand input component
  55607. */
  55608. readonly right: NodeMaterialConnectionPoint;
  55609. /**
  55610. * Gets the output component
  55611. */
  55612. readonly output: NodeMaterialConnectionPoint;
  55613. protected _buildBlock(state: NodeMaterialBuildState): this;
  55614. }
  55615. }
  55616. declare module BABYLON {
  55617. /**
  55618. * Block used to scale a vector by a float
  55619. */
  55620. export class ScaleBlock extends NodeMaterialBlock {
  55621. /**
  55622. * Creates a new ScaleBlock
  55623. * @param name defines the block name
  55624. */
  55625. constructor(name: string);
  55626. /**
  55627. * Gets the current class name
  55628. * @returns the class name
  55629. */
  55630. getClassName(): string;
  55631. /**
  55632. * Gets the input component
  55633. */
  55634. readonly input: NodeMaterialConnectionPoint;
  55635. /**
  55636. * Gets the factor input component
  55637. */
  55638. readonly factor: NodeMaterialConnectionPoint;
  55639. /**
  55640. * Gets the output component
  55641. */
  55642. readonly output: NodeMaterialConnectionPoint;
  55643. protected _buildBlock(state: NodeMaterialBuildState): this;
  55644. }
  55645. }
  55646. declare module BABYLON {
  55647. /**
  55648. * Block used to clamp a float
  55649. */
  55650. export class ClampBlock extends NodeMaterialBlock {
  55651. /** Gets or sets the minimum range */
  55652. minimum: number;
  55653. /** Gets or sets the maximum range */
  55654. maximum: number;
  55655. /**
  55656. * Creates a new ClampBlock
  55657. * @param name defines the block name
  55658. */
  55659. constructor(name: string);
  55660. /**
  55661. * Gets the current class name
  55662. * @returns the class name
  55663. */
  55664. getClassName(): string;
  55665. /**
  55666. * Gets the value input component
  55667. */
  55668. readonly value: NodeMaterialConnectionPoint;
  55669. /**
  55670. * Gets the output component
  55671. */
  55672. readonly output: NodeMaterialConnectionPoint;
  55673. protected _buildBlock(state: NodeMaterialBuildState): this;
  55674. protected _dumpPropertiesCode(): string;
  55675. serialize(): any;
  55676. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55677. }
  55678. }
  55679. declare module BABYLON {
  55680. /**
  55681. * Block used to apply a cross product between 2 vectors
  55682. */
  55683. export class CrossBlock extends NodeMaterialBlock {
  55684. /**
  55685. * Creates a new CrossBlock
  55686. * @param name defines the block name
  55687. */
  55688. constructor(name: string);
  55689. /**
  55690. * Gets the current class name
  55691. * @returns the class name
  55692. */
  55693. getClassName(): string;
  55694. /**
  55695. * Gets the left operand input component
  55696. */
  55697. readonly left: NodeMaterialConnectionPoint;
  55698. /**
  55699. * Gets the right operand input component
  55700. */
  55701. readonly right: NodeMaterialConnectionPoint;
  55702. /**
  55703. * Gets the output component
  55704. */
  55705. readonly output: NodeMaterialConnectionPoint;
  55706. protected _buildBlock(state: NodeMaterialBuildState): this;
  55707. }
  55708. }
  55709. declare module BABYLON {
  55710. /**
  55711. * Block used to apply a dot product between 2 vectors
  55712. */
  55713. export class DotBlock extends NodeMaterialBlock {
  55714. /**
  55715. * Creates a new DotBlock
  55716. * @param name defines the block name
  55717. */
  55718. constructor(name: string);
  55719. /**
  55720. * Gets the current class name
  55721. * @returns the class name
  55722. */
  55723. getClassName(): string;
  55724. /**
  55725. * Gets the left operand input component
  55726. */
  55727. readonly left: NodeMaterialConnectionPoint;
  55728. /**
  55729. * Gets the right operand input component
  55730. */
  55731. readonly right: NodeMaterialConnectionPoint;
  55732. /**
  55733. * Gets the output component
  55734. */
  55735. readonly output: NodeMaterialConnectionPoint;
  55736. protected _buildBlock(state: NodeMaterialBuildState): this;
  55737. }
  55738. }
  55739. declare module BABYLON {
  55740. /**
  55741. * Block used to remap a float from a range to a new one
  55742. */
  55743. export class RemapBlock extends NodeMaterialBlock {
  55744. /**
  55745. * Gets or sets the source range
  55746. */
  55747. sourceRange: Vector2;
  55748. /**
  55749. * Gets or sets the target range
  55750. */
  55751. targetRange: Vector2;
  55752. /**
  55753. * Creates a new RemapBlock
  55754. * @param name defines the block name
  55755. */
  55756. constructor(name: string);
  55757. /**
  55758. * Gets the current class name
  55759. * @returns the class name
  55760. */
  55761. getClassName(): string;
  55762. /**
  55763. * Gets the input component
  55764. */
  55765. readonly input: NodeMaterialConnectionPoint;
  55766. /**
  55767. * Gets the source min input component
  55768. */
  55769. readonly sourceMin: NodeMaterialConnectionPoint;
  55770. /**
  55771. * Gets the source max input component
  55772. */
  55773. readonly sourceMax: NodeMaterialConnectionPoint;
  55774. /**
  55775. * Gets the target min input component
  55776. */
  55777. readonly targetMin: NodeMaterialConnectionPoint;
  55778. /**
  55779. * Gets the target max input component
  55780. */
  55781. readonly targetMax: NodeMaterialConnectionPoint;
  55782. /**
  55783. * Gets the output component
  55784. */
  55785. readonly output: NodeMaterialConnectionPoint;
  55786. protected _buildBlock(state: NodeMaterialBuildState): this;
  55787. protected _dumpPropertiesCode(): string;
  55788. serialize(): any;
  55789. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55790. }
  55791. }
  55792. declare module BABYLON {
  55793. /**
  55794. * Block used to normalize a vector
  55795. */
  55796. export class NormalizeBlock extends NodeMaterialBlock {
  55797. /**
  55798. * Creates a new NormalizeBlock
  55799. * @param name defines the block name
  55800. */
  55801. constructor(name: string);
  55802. /**
  55803. * Gets the current class name
  55804. * @returns the class name
  55805. */
  55806. getClassName(): string;
  55807. /**
  55808. * Gets the input component
  55809. */
  55810. readonly input: NodeMaterialConnectionPoint;
  55811. /**
  55812. * Gets the output component
  55813. */
  55814. readonly output: NodeMaterialConnectionPoint;
  55815. protected _buildBlock(state: NodeMaterialBuildState): this;
  55816. }
  55817. }
  55818. declare module BABYLON {
  55819. /**
  55820. * Operations supported by the Trigonometry block
  55821. */
  55822. export enum TrigonometryBlockOperations {
  55823. /** Cos */
  55824. Cos = 0,
  55825. /** Sin */
  55826. Sin = 1,
  55827. /** Abs */
  55828. Abs = 2,
  55829. /** Exp */
  55830. Exp = 3,
  55831. /** Exp2 */
  55832. Exp2 = 4,
  55833. /** Round */
  55834. Round = 5,
  55835. /** Floor */
  55836. Floor = 6,
  55837. /** Ceiling */
  55838. Ceiling = 7,
  55839. /** Square root */
  55840. Sqrt = 8,
  55841. /** Log */
  55842. Log = 9,
  55843. /** Tangent */
  55844. Tan = 10,
  55845. /** Arc tangent */
  55846. ArcTan = 11,
  55847. /** Arc cosinus */
  55848. ArcCos = 12,
  55849. /** Arc sinus */
  55850. ArcSin = 13,
  55851. /** Fraction */
  55852. Fract = 14,
  55853. /** Sign */
  55854. Sign = 15,
  55855. /** To radians (from degrees) */
  55856. Radians = 16,
  55857. /** To degrees (from radians) */
  55858. Degrees = 17
  55859. }
  55860. /**
  55861. * Block used to apply trigonometry operation to floats
  55862. */
  55863. export class TrigonometryBlock extends NodeMaterialBlock {
  55864. /**
  55865. * Gets or sets the operation applied by the block
  55866. */
  55867. operation: TrigonometryBlockOperations;
  55868. /**
  55869. * Creates a new TrigonometryBlock
  55870. * @param name defines the block name
  55871. */
  55872. constructor(name: string);
  55873. /**
  55874. * Gets the current class name
  55875. * @returns the class name
  55876. */
  55877. getClassName(): string;
  55878. /**
  55879. * Gets the input component
  55880. */
  55881. readonly input: NodeMaterialConnectionPoint;
  55882. /**
  55883. * Gets the output component
  55884. */
  55885. readonly output: NodeMaterialConnectionPoint;
  55886. protected _buildBlock(state: NodeMaterialBuildState): this;
  55887. serialize(): any;
  55888. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55889. protected _dumpPropertiesCode(): string;
  55890. }
  55891. }
  55892. declare module BABYLON {
  55893. /**
  55894. * Block used to create a Color3/4 out of individual inputs (one for each component)
  55895. */
  55896. export class ColorMergerBlock extends NodeMaterialBlock {
  55897. /**
  55898. * Create a new ColorMergerBlock
  55899. * @param name defines the block name
  55900. */
  55901. constructor(name: string);
  55902. /**
  55903. * Gets the current class name
  55904. * @returns the class name
  55905. */
  55906. getClassName(): string;
  55907. /**
  55908. * Gets the rgb component (input)
  55909. */
  55910. readonly rgbIn: NodeMaterialConnectionPoint;
  55911. /**
  55912. * Gets the r component (input)
  55913. */
  55914. readonly r: NodeMaterialConnectionPoint;
  55915. /**
  55916. * Gets the g component (input)
  55917. */
  55918. readonly g: NodeMaterialConnectionPoint;
  55919. /**
  55920. * Gets the b component (input)
  55921. */
  55922. readonly b: NodeMaterialConnectionPoint;
  55923. /**
  55924. * Gets the a component (input)
  55925. */
  55926. readonly a: NodeMaterialConnectionPoint;
  55927. /**
  55928. * Gets the rgba component (output)
  55929. */
  55930. readonly rgba: NodeMaterialConnectionPoint;
  55931. /**
  55932. * Gets the rgb component (output)
  55933. */
  55934. readonly rgbOut: NodeMaterialConnectionPoint;
  55935. /**
  55936. * Gets the rgb component (output)
  55937. * @deprecated Please use rgbOut instead.
  55938. */
  55939. readonly rgb: NodeMaterialConnectionPoint;
  55940. protected _buildBlock(state: NodeMaterialBuildState): this;
  55941. }
  55942. }
  55943. declare module BABYLON {
  55944. /**
  55945. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  55946. */
  55947. export class VectorMergerBlock extends NodeMaterialBlock {
  55948. /**
  55949. * Create a new VectorMergerBlock
  55950. * @param name defines the block name
  55951. */
  55952. constructor(name: string);
  55953. /**
  55954. * Gets the current class name
  55955. * @returns the class name
  55956. */
  55957. getClassName(): string;
  55958. /**
  55959. * Gets the xyz component (input)
  55960. */
  55961. readonly xyzIn: NodeMaterialConnectionPoint;
  55962. /**
  55963. * Gets the xy component (input)
  55964. */
  55965. readonly xyIn: NodeMaterialConnectionPoint;
  55966. /**
  55967. * Gets the x component (input)
  55968. */
  55969. readonly x: NodeMaterialConnectionPoint;
  55970. /**
  55971. * Gets the y component (input)
  55972. */
  55973. readonly y: NodeMaterialConnectionPoint;
  55974. /**
  55975. * Gets the z component (input)
  55976. */
  55977. readonly z: NodeMaterialConnectionPoint;
  55978. /**
  55979. * Gets the w component (input)
  55980. */
  55981. readonly w: NodeMaterialConnectionPoint;
  55982. /**
  55983. * Gets the xyzw component (output)
  55984. */
  55985. readonly xyzw: NodeMaterialConnectionPoint;
  55986. /**
  55987. * Gets the xyz component (output)
  55988. */
  55989. readonly xyzOut: NodeMaterialConnectionPoint;
  55990. /**
  55991. * Gets the xy component (output)
  55992. */
  55993. readonly xyOut: NodeMaterialConnectionPoint;
  55994. /**
  55995. * Gets the xy component (output)
  55996. * @deprecated Please use xyOut instead.
  55997. */
  55998. readonly xy: NodeMaterialConnectionPoint;
  55999. /**
  56000. * Gets the xyz component (output)
  56001. * @deprecated Please use xyzOut instead.
  56002. */
  56003. readonly xyz: NodeMaterialConnectionPoint;
  56004. protected _buildBlock(state: NodeMaterialBuildState): this;
  56005. }
  56006. }
  56007. declare module BABYLON {
  56008. /**
  56009. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  56010. */
  56011. export class ColorSplitterBlock extends NodeMaterialBlock {
  56012. /**
  56013. * Create a new ColorSplitterBlock
  56014. * @param name defines the block name
  56015. */
  56016. constructor(name: string);
  56017. /**
  56018. * Gets the current class name
  56019. * @returns the class name
  56020. */
  56021. getClassName(): string;
  56022. /**
  56023. * Gets the rgba component (input)
  56024. */
  56025. readonly rgba: NodeMaterialConnectionPoint;
  56026. /**
  56027. * Gets the rgb component (input)
  56028. */
  56029. readonly rgbIn: NodeMaterialConnectionPoint;
  56030. /**
  56031. * Gets the rgb component (output)
  56032. */
  56033. readonly rgbOut: NodeMaterialConnectionPoint;
  56034. /**
  56035. * Gets the r component (output)
  56036. */
  56037. readonly r: NodeMaterialConnectionPoint;
  56038. /**
  56039. * Gets the g component (output)
  56040. */
  56041. readonly g: NodeMaterialConnectionPoint;
  56042. /**
  56043. * Gets the b component (output)
  56044. */
  56045. readonly b: NodeMaterialConnectionPoint;
  56046. /**
  56047. * Gets the a component (output)
  56048. */
  56049. readonly a: NodeMaterialConnectionPoint;
  56050. protected _inputRename(name: string): string;
  56051. protected _outputRename(name: string): string;
  56052. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56053. }
  56054. }
  56055. declare module BABYLON {
  56056. /**
  56057. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  56058. */
  56059. export class VectorSplitterBlock extends NodeMaterialBlock {
  56060. /**
  56061. * Create a new VectorSplitterBlock
  56062. * @param name defines the block name
  56063. */
  56064. constructor(name: string);
  56065. /**
  56066. * Gets the current class name
  56067. * @returns the class name
  56068. */
  56069. getClassName(): string;
  56070. /**
  56071. * Gets the xyzw component (input)
  56072. */
  56073. readonly xyzw: NodeMaterialConnectionPoint;
  56074. /**
  56075. * Gets the xyz component (input)
  56076. */
  56077. readonly xyzIn: NodeMaterialConnectionPoint;
  56078. /**
  56079. * Gets the xy component (input)
  56080. */
  56081. readonly xyIn: NodeMaterialConnectionPoint;
  56082. /**
  56083. * Gets the xyz component (output)
  56084. */
  56085. readonly xyzOut: NodeMaterialConnectionPoint;
  56086. /**
  56087. * Gets the xy component (output)
  56088. */
  56089. readonly xyOut: NodeMaterialConnectionPoint;
  56090. /**
  56091. * Gets the x component (output)
  56092. */
  56093. readonly x: NodeMaterialConnectionPoint;
  56094. /**
  56095. * Gets the y component (output)
  56096. */
  56097. readonly y: NodeMaterialConnectionPoint;
  56098. /**
  56099. * Gets the z component (output)
  56100. */
  56101. readonly z: NodeMaterialConnectionPoint;
  56102. /**
  56103. * Gets the w component (output)
  56104. */
  56105. readonly w: NodeMaterialConnectionPoint;
  56106. protected _inputRename(name: string): string;
  56107. protected _outputRename(name: string): string;
  56108. protected _buildBlock(state: NodeMaterialBuildState): this;
  56109. }
  56110. }
  56111. declare module BABYLON {
  56112. /**
  56113. * Block used to lerp between 2 values
  56114. */
  56115. export class LerpBlock extends NodeMaterialBlock {
  56116. /**
  56117. * Creates a new LerpBlock
  56118. * @param name defines the block name
  56119. */
  56120. constructor(name: string);
  56121. /**
  56122. * Gets the current class name
  56123. * @returns the class name
  56124. */
  56125. getClassName(): string;
  56126. /**
  56127. * Gets the left operand input component
  56128. */
  56129. readonly left: NodeMaterialConnectionPoint;
  56130. /**
  56131. * Gets the right operand input component
  56132. */
  56133. readonly right: NodeMaterialConnectionPoint;
  56134. /**
  56135. * Gets the gradient operand input component
  56136. */
  56137. readonly gradient: NodeMaterialConnectionPoint;
  56138. /**
  56139. * Gets the output component
  56140. */
  56141. readonly output: NodeMaterialConnectionPoint;
  56142. protected _buildBlock(state: NodeMaterialBuildState): this;
  56143. }
  56144. }
  56145. declare module BABYLON {
  56146. /**
  56147. * Block used to divide 2 vectors
  56148. */
  56149. export class DivideBlock extends NodeMaterialBlock {
  56150. /**
  56151. * Creates a new DivideBlock
  56152. * @param name defines the block name
  56153. */
  56154. constructor(name: string);
  56155. /**
  56156. * Gets the current class name
  56157. * @returns the class name
  56158. */
  56159. getClassName(): string;
  56160. /**
  56161. * Gets the left operand input component
  56162. */
  56163. readonly left: NodeMaterialConnectionPoint;
  56164. /**
  56165. * Gets the right operand input component
  56166. */
  56167. readonly right: NodeMaterialConnectionPoint;
  56168. /**
  56169. * Gets the output component
  56170. */
  56171. readonly output: NodeMaterialConnectionPoint;
  56172. protected _buildBlock(state: NodeMaterialBuildState): this;
  56173. }
  56174. }
  56175. declare module BABYLON {
  56176. /**
  56177. * Block used to subtract 2 vectors
  56178. */
  56179. export class SubtractBlock extends NodeMaterialBlock {
  56180. /**
  56181. * Creates a new SubtractBlock
  56182. * @param name defines the block name
  56183. */
  56184. constructor(name: string);
  56185. /**
  56186. * Gets the current class name
  56187. * @returns the class name
  56188. */
  56189. getClassName(): string;
  56190. /**
  56191. * Gets the left operand input component
  56192. */
  56193. readonly left: NodeMaterialConnectionPoint;
  56194. /**
  56195. * Gets the right operand input component
  56196. */
  56197. readonly right: NodeMaterialConnectionPoint;
  56198. /**
  56199. * Gets the output component
  56200. */
  56201. readonly output: NodeMaterialConnectionPoint;
  56202. protected _buildBlock(state: NodeMaterialBuildState): this;
  56203. }
  56204. }
  56205. declare module BABYLON {
  56206. /**
  56207. * Block used to step a value
  56208. */
  56209. export class StepBlock extends NodeMaterialBlock {
  56210. /**
  56211. * Creates a new StepBlock
  56212. * @param name defines the block name
  56213. */
  56214. constructor(name: string);
  56215. /**
  56216. * Gets the current class name
  56217. * @returns the class name
  56218. */
  56219. getClassName(): string;
  56220. /**
  56221. * Gets the value operand input component
  56222. */
  56223. readonly value: NodeMaterialConnectionPoint;
  56224. /**
  56225. * Gets the edge operand input component
  56226. */
  56227. readonly edge: NodeMaterialConnectionPoint;
  56228. /**
  56229. * Gets the output component
  56230. */
  56231. readonly output: NodeMaterialConnectionPoint;
  56232. protected _buildBlock(state: NodeMaterialBuildState): this;
  56233. }
  56234. }
  56235. declare module BABYLON {
  56236. /**
  56237. * Block used to get the opposite (1 - x) of a value
  56238. */
  56239. export class OneMinusBlock extends NodeMaterialBlock {
  56240. /**
  56241. * Creates a new OneMinusBlock
  56242. * @param name defines the block name
  56243. */
  56244. constructor(name: string);
  56245. /**
  56246. * Gets the current class name
  56247. * @returns the class name
  56248. */
  56249. getClassName(): string;
  56250. /**
  56251. * Gets the input component
  56252. */
  56253. readonly input: NodeMaterialConnectionPoint;
  56254. /**
  56255. * Gets the output component
  56256. */
  56257. readonly output: NodeMaterialConnectionPoint;
  56258. protected _buildBlock(state: NodeMaterialBuildState): this;
  56259. }
  56260. }
  56261. declare module BABYLON {
  56262. /**
  56263. * Block used to get the view direction
  56264. */
  56265. export class ViewDirectionBlock extends NodeMaterialBlock {
  56266. /**
  56267. * Creates a new ViewDirectionBlock
  56268. * @param name defines the block name
  56269. */
  56270. constructor(name: string);
  56271. /**
  56272. * Gets the current class name
  56273. * @returns the class name
  56274. */
  56275. getClassName(): string;
  56276. /**
  56277. * Gets the world position component
  56278. */
  56279. readonly worldPosition: NodeMaterialConnectionPoint;
  56280. /**
  56281. * Gets the camera position component
  56282. */
  56283. readonly cameraPosition: NodeMaterialConnectionPoint;
  56284. /**
  56285. * Gets the output component
  56286. */
  56287. readonly output: NodeMaterialConnectionPoint;
  56288. autoConfigure(material: NodeMaterial): void;
  56289. protected _buildBlock(state: NodeMaterialBuildState): this;
  56290. }
  56291. }
  56292. declare module BABYLON {
  56293. /**
  56294. * Block used to compute fresnel value
  56295. */
  56296. export class FresnelBlock extends NodeMaterialBlock {
  56297. /**
  56298. * Create a new FresnelBlock
  56299. * @param name defines the block name
  56300. */
  56301. constructor(name: string);
  56302. /**
  56303. * Gets the current class name
  56304. * @returns the class name
  56305. */
  56306. getClassName(): string;
  56307. /**
  56308. * Gets the world normal input component
  56309. */
  56310. readonly worldNormal: NodeMaterialConnectionPoint;
  56311. /**
  56312. * Gets the view direction input component
  56313. */
  56314. readonly viewDirection: NodeMaterialConnectionPoint;
  56315. /**
  56316. * Gets the bias input component
  56317. */
  56318. readonly bias: NodeMaterialConnectionPoint;
  56319. /**
  56320. * Gets the camera (or eye) position component
  56321. */
  56322. readonly power: NodeMaterialConnectionPoint;
  56323. /**
  56324. * Gets the fresnel output component
  56325. */
  56326. readonly fresnel: NodeMaterialConnectionPoint;
  56327. autoConfigure(material: NodeMaterial): void;
  56328. protected _buildBlock(state: NodeMaterialBuildState): this;
  56329. }
  56330. }
  56331. declare module BABYLON {
  56332. /**
  56333. * Block used to get the max of 2 values
  56334. */
  56335. export class MaxBlock extends NodeMaterialBlock {
  56336. /**
  56337. * Creates a new MaxBlock
  56338. * @param name defines the block name
  56339. */
  56340. constructor(name: string);
  56341. /**
  56342. * Gets the current class name
  56343. * @returns the class name
  56344. */
  56345. getClassName(): string;
  56346. /**
  56347. * Gets the left operand input component
  56348. */
  56349. readonly left: NodeMaterialConnectionPoint;
  56350. /**
  56351. * Gets the right operand input component
  56352. */
  56353. readonly right: NodeMaterialConnectionPoint;
  56354. /**
  56355. * Gets the output component
  56356. */
  56357. readonly output: NodeMaterialConnectionPoint;
  56358. protected _buildBlock(state: NodeMaterialBuildState): this;
  56359. }
  56360. }
  56361. declare module BABYLON {
  56362. /**
  56363. * Block used to get the min of 2 values
  56364. */
  56365. export class MinBlock extends NodeMaterialBlock {
  56366. /**
  56367. * Creates a new MinBlock
  56368. * @param name defines the block name
  56369. */
  56370. constructor(name: string);
  56371. /**
  56372. * Gets the current class name
  56373. * @returns the class name
  56374. */
  56375. getClassName(): string;
  56376. /**
  56377. * Gets the left operand input component
  56378. */
  56379. readonly left: NodeMaterialConnectionPoint;
  56380. /**
  56381. * Gets the right operand input component
  56382. */
  56383. readonly right: NodeMaterialConnectionPoint;
  56384. /**
  56385. * Gets the output component
  56386. */
  56387. readonly output: NodeMaterialConnectionPoint;
  56388. protected _buildBlock(state: NodeMaterialBuildState): this;
  56389. }
  56390. }
  56391. declare module BABYLON {
  56392. /**
  56393. * Block used to get the distance between 2 values
  56394. */
  56395. export class DistanceBlock extends NodeMaterialBlock {
  56396. /**
  56397. * Creates a new DistanceBlock
  56398. * @param name defines the block name
  56399. */
  56400. constructor(name: string);
  56401. /**
  56402. * Gets the current class name
  56403. * @returns the class name
  56404. */
  56405. getClassName(): string;
  56406. /**
  56407. * Gets the left operand input component
  56408. */
  56409. readonly left: NodeMaterialConnectionPoint;
  56410. /**
  56411. * Gets the right operand input component
  56412. */
  56413. readonly right: NodeMaterialConnectionPoint;
  56414. /**
  56415. * Gets the output component
  56416. */
  56417. readonly output: NodeMaterialConnectionPoint;
  56418. protected _buildBlock(state: NodeMaterialBuildState): this;
  56419. }
  56420. }
  56421. declare module BABYLON {
  56422. /**
  56423. * Block used to get the length of a vector
  56424. */
  56425. export class LengthBlock extends NodeMaterialBlock {
  56426. /**
  56427. * Creates a new LengthBlock
  56428. * @param name defines the block name
  56429. */
  56430. constructor(name: string);
  56431. /**
  56432. * Gets the current class name
  56433. * @returns the class name
  56434. */
  56435. getClassName(): string;
  56436. /**
  56437. * Gets the value input component
  56438. */
  56439. readonly value: NodeMaterialConnectionPoint;
  56440. /**
  56441. * Gets the output component
  56442. */
  56443. readonly output: NodeMaterialConnectionPoint;
  56444. protected _buildBlock(state: NodeMaterialBuildState): this;
  56445. }
  56446. }
  56447. declare module BABYLON {
  56448. /**
  56449. * Block used to get negative version of a value (i.e. x * -1)
  56450. */
  56451. export class NegateBlock extends NodeMaterialBlock {
  56452. /**
  56453. * Creates a new NegateBlock
  56454. * @param name defines the block name
  56455. */
  56456. constructor(name: string);
  56457. /**
  56458. * Gets the current class name
  56459. * @returns the class name
  56460. */
  56461. getClassName(): string;
  56462. /**
  56463. * Gets the value input component
  56464. */
  56465. readonly value: NodeMaterialConnectionPoint;
  56466. /**
  56467. * Gets the output component
  56468. */
  56469. readonly output: NodeMaterialConnectionPoint;
  56470. protected _buildBlock(state: NodeMaterialBuildState): this;
  56471. }
  56472. }
  56473. declare module BABYLON {
  56474. /**
  56475. * Block used to get the value of the first parameter raised to the power of the second
  56476. */
  56477. export class PowBlock extends NodeMaterialBlock {
  56478. /**
  56479. * Creates a new PowBlock
  56480. * @param name defines the block name
  56481. */
  56482. constructor(name: string);
  56483. /**
  56484. * Gets the current class name
  56485. * @returns the class name
  56486. */
  56487. getClassName(): string;
  56488. /**
  56489. * Gets the value operand input component
  56490. */
  56491. readonly value: NodeMaterialConnectionPoint;
  56492. /**
  56493. * Gets the power operand input component
  56494. */
  56495. readonly power: NodeMaterialConnectionPoint;
  56496. /**
  56497. * Gets the output component
  56498. */
  56499. readonly output: NodeMaterialConnectionPoint;
  56500. protected _buildBlock(state: NodeMaterialBuildState): this;
  56501. }
  56502. }
  56503. declare module BABYLON {
  56504. /**
  56505. * Block used to get a random number
  56506. */
  56507. export class RandomNumberBlock extends NodeMaterialBlock {
  56508. /**
  56509. * Creates a new RandomNumberBlock
  56510. * @param name defines the block name
  56511. */
  56512. constructor(name: string);
  56513. /**
  56514. * Gets the current class name
  56515. * @returns the class name
  56516. */
  56517. getClassName(): string;
  56518. /**
  56519. * Gets the seed input component
  56520. */
  56521. readonly seed: NodeMaterialConnectionPoint;
  56522. /**
  56523. * Gets the output component
  56524. */
  56525. readonly output: NodeMaterialConnectionPoint;
  56526. protected _buildBlock(state: NodeMaterialBuildState): this;
  56527. }
  56528. }
  56529. declare module BABYLON {
  56530. /**
  56531. * Block used to compute arc tangent of 2 values
  56532. */
  56533. export class ArcTan2Block extends NodeMaterialBlock {
  56534. /**
  56535. * Creates a new ArcTan2Block
  56536. * @param name defines the block name
  56537. */
  56538. constructor(name: string);
  56539. /**
  56540. * Gets the current class name
  56541. * @returns the class name
  56542. */
  56543. getClassName(): string;
  56544. /**
  56545. * Gets the x operand input component
  56546. */
  56547. readonly x: NodeMaterialConnectionPoint;
  56548. /**
  56549. * Gets the y operand input component
  56550. */
  56551. readonly y: NodeMaterialConnectionPoint;
  56552. /**
  56553. * Gets the output component
  56554. */
  56555. readonly output: NodeMaterialConnectionPoint;
  56556. protected _buildBlock(state: NodeMaterialBuildState): this;
  56557. }
  56558. }
  56559. declare module BABYLON {
  56560. /**
  56561. * Block used to smooth step a value
  56562. */
  56563. export class SmoothStepBlock extends NodeMaterialBlock {
  56564. /**
  56565. * Creates a new SmoothStepBlock
  56566. * @param name defines the block name
  56567. */
  56568. constructor(name: string);
  56569. /**
  56570. * Gets the current class name
  56571. * @returns the class name
  56572. */
  56573. getClassName(): string;
  56574. /**
  56575. * Gets the value operand input component
  56576. */
  56577. readonly value: NodeMaterialConnectionPoint;
  56578. /**
  56579. * Gets the first edge operand input component
  56580. */
  56581. readonly edge0: NodeMaterialConnectionPoint;
  56582. /**
  56583. * Gets the second edge operand input component
  56584. */
  56585. readonly edge1: NodeMaterialConnectionPoint;
  56586. /**
  56587. * Gets the output component
  56588. */
  56589. readonly output: NodeMaterialConnectionPoint;
  56590. protected _buildBlock(state: NodeMaterialBuildState): this;
  56591. }
  56592. }
  56593. declare module BABYLON {
  56594. /**
  56595. * Block used to get the reciprocal (1 / x) of a value
  56596. */
  56597. export class ReciprocalBlock extends NodeMaterialBlock {
  56598. /**
  56599. * Creates a new ReciprocalBlock
  56600. * @param name defines the block name
  56601. */
  56602. constructor(name: string);
  56603. /**
  56604. * Gets the current class name
  56605. * @returns the class name
  56606. */
  56607. getClassName(): string;
  56608. /**
  56609. * Gets the input component
  56610. */
  56611. readonly input: NodeMaterialConnectionPoint;
  56612. /**
  56613. * Gets the output component
  56614. */
  56615. readonly output: NodeMaterialConnectionPoint;
  56616. protected _buildBlock(state: NodeMaterialBuildState): this;
  56617. }
  56618. }
  56619. declare module BABYLON {
  56620. /**
  56621. * Block used to replace a color by another one
  56622. */
  56623. export class ReplaceColorBlock extends NodeMaterialBlock {
  56624. /**
  56625. * Creates a new ReplaceColorBlock
  56626. * @param name defines the block name
  56627. */
  56628. constructor(name: string);
  56629. /**
  56630. * Gets the current class name
  56631. * @returns the class name
  56632. */
  56633. getClassName(): string;
  56634. /**
  56635. * Gets the value input component
  56636. */
  56637. readonly value: NodeMaterialConnectionPoint;
  56638. /**
  56639. * Gets the reference input component
  56640. */
  56641. readonly reference: NodeMaterialConnectionPoint;
  56642. /**
  56643. * Gets the distance input component
  56644. */
  56645. readonly distance: NodeMaterialConnectionPoint;
  56646. /**
  56647. * Gets the replacement input component
  56648. */
  56649. readonly replacement: NodeMaterialConnectionPoint;
  56650. /**
  56651. * Gets the output component
  56652. */
  56653. readonly output: NodeMaterialConnectionPoint;
  56654. protected _buildBlock(state: NodeMaterialBuildState): this;
  56655. }
  56656. }
  56657. declare module BABYLON {
  56658. /**
  56659. * Block used to posterize a value
  56660. * @see https://en.wikipedia.org/wiki/Posterization
  56661. */
  56662. export class PosterizeBlock extends NodeMaterialBlock {
  56663. /**
  56664. * Creates a new PosterizeBlock
  56665. * @param name defines the block name
  56666. */
  56667. constructor(name: string);
  56668. /**
  56669. * Gets the current class name
  56670. * @returns the class name
  56671. */
  56672. getClassName(): string;
  56673. /**
  56674. * Gets the value input component
  56675. */
  56676. readonly value: NodeMaterialConnectionPoint;
  56677. /**
  56678. * Gets the steps input component
  56679. */
  56680. readonly steps: NodeMaterialConnectionPoint;
  56681. /**
  56682. * Gets the output component
  56683. */
  56684. readonly output: NodeMaterialConnectionPoint;
  56685. protected _buildBlock(state: NodeMaterialBuildState): this;
  56686. }
  56687. }
  56688. declare module BABYLON {
  56689. /**
  56690. * Operations supported by the Wave block
  56691. */
  56692. export enum WaveBlockKind {
  56693. /** SawTooth */
  56694. SawTooth = 0,
  56695. /** Square */
  56696. Square = 1,
  56697. /** Triangle */
  56698. Triangle = 2
  56699. }
  56700. /**
  56701. * Block used to apply wave operation to floats
  56702. */
  56703. export class WaveBlock extends NodeMaterialBlock {
  56704. /**
  56705. * Gets or sets the kibnd of wave to be applied by the block
  56706. */
  56707. kind: WaveBlockKind;
  56708. /**
  56709. * Creates a new WaveBlock
  56710. * @param name defines the block name
  56711. */
  56712. constructor(name: string);
  56713. /**
  56714. * Gets the current class name
  56715. * @returns the class name
  56716. */
  56717. getClassName(): string;
  56718. /**
  56719. * Gets the input component
  56720. */
  56721. readonly input: NodeMaterialConnectionPoint;
  56722. /**
  56723. * Gets the output component
  56724. */
  56725. readonly output: NodeMaterialConnectionPoint;
  56726. protected _buildBlock(state: NodeMaterialBuildState): this;
  56727. serialize(): any;
  56728. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56729. }
  56730. }
  56731. declare module BABYLON {
  56732. /**
  56733. * Class used to store a color step for the GradientBlock
  56734. */
  56735. export class GradientBlockColorStep {
  56736. /**
  56737. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  56738. */
  56739. step: number;
  56740. /**
  56741. * Gets or sets the color associated with this step
  56742. */
  56743. color: Color3;
  56744. /**
  56745. * Creates a new GradientBlockColorStep
  56746. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  56747. * @param color defines the color associated with this step
  56748. */
  56749. constructor(
  56750. /**
  56751. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  56752. */
  56753. step: number,
  56754. /**
  56755. * Gets or sets the color associated with this step
  56756. */
  56757. color: Color3);
  56758. }
  56759. /**
  56760. * Block used to return a color from a gradient based on an input value between 0 and 1
  56761. */
  56762. export class GradientBlock extends NodeMaterialBlock {
  56763. /**
  56764. * Gets or sets the list of color steps
  56765. */
  56766. colorSteps: GradientBlockColorStep[];
  56767. /**
  56768. * Creates a new GradientBlock
  56769. * @param name defines the block name
  56770. */
  56771. constructor(name: string);
  56772. /**
  56773. * Gets the current class name
  56774. * @returns the class name
  56775. */
  56776. getClassName(): string;
  56777. /**
  56778. * Gets the gradient input component
  56779. */
  56780. readonly gradient: NodeMaterialConnectionPoint;
  56781. /**
  56782. * Gets the output component
  56783. */
  56784. readonly output: NodeMaterialConnectionPoint;
  56785. private _writeColorConstant;
  56786. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56787. serialize(): any;
  56788. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56789. protected _dumpPropertiesCode(): string;
  56790. }
  56791. }
  56792. declare module BABYLON {
  56793. /**
  56794. * Block used to normalize lerp between 2 values
  56795. */
  56796. export class NLerpBlock extends NodeMaterialBlock {
  56797. /**
  56798. * Creates a new NLerpBlock
  56799. * @param name defines the block name
  56800. */
  56801. constructor(name: string);
  56802. /**
  56803. * Gets the current class name
  56804. * @returns the class name
  56805. */
  56806. getClassName(): string;
  56807. /**
  56808. * Gets the left operand input component
  56809. */
  56810. readonly left: NodeMaterialConnectionPoint;
  56811. /**
  56812. * Gets the right operand input component
  56813. */
  56814. readonly right: NodeMaterialConnectionPoint;
  56815. /**
  56816. * Gets the gradient operand input component
  56817. */
  56818. readonly gradient: NodeMaterialConnectionPoint;
  56819. /**
  56820. * Gets the output component
  56821. */
  56822. readonly output: NodeMaterialConnectionPoint;
  56823. protected _buildBlock(state: NodeMaterialBuildState): this;
  56824. }
  56825. }
  56826. declare module BABYLON {
  56827. /**
  56828. * block used to Generate a Worley Noise 3D Noise Pattern
  56829. */
  56830. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  56831. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  56832. manhattanDistance: boolean;
  56833. /**
  56834. * Creates a new WorleyNoise3DBlock
  56835. * @param name defines the block name
  56836. */
  56837. constructor(name: string);
  56838. /**
  56839. * Gets the current class name
  56840. * @returns the class name
  56841. */
  56842. getClassName(): string;
  56843. /**
  56844. * Gets the seed input component
  56845. */
  56846. readonly seed: NodeMaterialConnectionPoint;
  56847. /**
  56848. * Gets the jitter input component
  56849. */
  56850. readonly jitter: NodeMaterialConnectionPoint;
  56851. /**
  56852. * Gets the output component
  56853. */
  56854. readonly output: NodeMaterialConnectionPoint;
  56855. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56856. /**
  56857. * Exposes the properties to the UI?
  56858. */
  56859. protected _dumpPropertiesCode(): string;
  56860. /**
  56861. * Exposes the properties to the Seralize?
  56862. */
  56863. serialize(): any;
  56864. /**
  56865. * Exposes the properties to the deseralize?
  56866. */
  56867. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56868. }
  56869. }
  56870. declare module BABYLON {
  56871. /**
  56872. * block used to Generate a Simplex Perlin 3d Noise Pattern
  56873. */
  56874. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  56875. /**
  56876. * Creates a new SimplexPerlin3DBlock
  56877. * @param name defines the block name
  56878. */
  56879. constructor(name: string);
  56880. /**
  56881. * Gets the current class name
  56882. * @returns the class name
  56883. */
  56884. getClassName(): string;
  56885. /**
  56886. * Gets the seed operand input component
  56887. */
  56888. readonly seed: NodeMaterialConnectionPoint;
  56889. /**
  56890. * Gets the output component
  56891. */
  56892. readonly output: NodeMaterialConnectionPoint;
  56893. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56894. }
  56895. }
  56896. declare module BABYLON {
  56897. /**
  56898. * Block used to blend normals
  56899. */
  56900. export class NormalBlendBlock extends NodeMaterialBlock {
  56901. /**
  56902. * Creates a new NormalBlendBlock
  56903. * @param name defines the block name
  56904. */
  56905. constructor(name: string);
  56906. /**
  56907. * Gets the current class name
  56908. * @returns the class name
  56909. */
  56910. getClassName(): string;
  56911. /**
  56912. * Gets the first input component
  56913. */
  56914. readonly normalMap0: NodeMaterialConnectionPoint;
  56915. /**
  56916. * Gets the second input component
  56917. */
  56918. readonly normalMap1: NodeMaterialConnectionPoint;
  56919. /**
  56920. * Gets the output component
  56921. */
  56922. readonly output: NodeMaterialConnectionPoint;
  56923. protected _buildBlock(state: NodeMaterialBuildState): this;
  56924. }
  56925. }
  56926. declare module BABYLON {
  56927. /**
  56928. * Block used to rotate a 2d vector by a given angle
  56929. */
  56930. export class Rotate2dBlock extends NodeMaterialBlock {
  56931. /**
  56932. * Creates a new Rotate2dBlock
  56933. * @param name defines the block name
  56934. */
  56935. constructor(name: string);
  56936. /**
  56937. * Gets the current class name
  56938. * @returns the class name
  56939. */
  56940. getClassName(): string;
  56941. /**
  56942. * Gets the input vector
  56943. */
  56944. readonly input: NodeMaterialConnectionPoint;
  56945. /**
  56946. * Gets the input angle
  56947. */
  56948. readonly angle: NodeMaterialConnectionPoint;
  56949. /**
  56950. * Gets the output component
  56951. */
  56952. readonly output: NodeMaterialConnectionPoint;
  56953. autoConfigure(material: NodeMaterial): void;
  56954. protected _buildBlock(state: NodeMaterialBuildState): this;
  56955. }
  56956. }
  56957. declare module BABYLON {
  56958. /**
  56959. * Block used to get the reflected vector from a direction and a normal
  56960. */
  56961. export class ReflectBlock extends NodeMaterialBlock {
  56962. /**
  56963. * Creates a new ReflectBlock
  56964. * @param name defines the block name
  56965. */
  56966. constructor(name: string);
  56967. /**
  56968. * Gets the current class name
  56969. * @returns the class name
  56970. */
  56971. getClassName(): string;
  56972. /**
  56973. * Gets the incident component
  56974. */
  56975. readonly incident: NodeMaterialConnectionPoint;
  56976. /**
  56977. * Gets the normal component
  56978. */
  56979. readonly normal: NodeMaterialConnectionPoint;
  56980. /**
  56981. * Gets the output component
  56982. */
  56983. readonly output: NodeMaterialConnectionPoint;
  56984. protected _buildBlock(state: NodeMaterialBuildState): this;
  56985. }
  56986. }
  56987. declare module BABYLON {
  56988. /**
  56989. * Block used to get the refracted vector from a direction and a normal
  56990. */
  56991. export class RefractBlock extends NodeMaterialBlock {
  56992. /**
  56993. * Creates a new RefractBlock
  56994. * @param name defines the block name
  56995. */
  56996. constructor(name: string);
  56997. /**
  56998. * Gets the current class name
  56999. * @returns the class name
  57000. */
  57001. getClassName(): string;
  57002. /**
  57003. * Gets the incident component
  57004. */
  57005. readonly incident: NodeMaterialConnectionPoint;
  57006. /**
  57007. * Gets the normal component
  57008. */
  57009. readonly normal: NodeMaterialConnectionPoint;
  57010. /**
  57011. * Gets the index of refraction component
  57012. */
  57013. readonly ior: NodeMaterialConnectionPoint;
  57014. /**
  57015. * Gets the output component
  57016. */
  57017. readonly output: NodeMaterialConnectionPoint;
  57018. protected _buildBlock(state: NodeMaterialBuildState): this;
  57019. }
  57020. }
  57021. declare module BABYLON {
  57022. /**
  57023. * Block used to desaturate a color
  57024. */
  57025. export class DesaturateBlock extends NodeMaterialBlock {
  57026. /**
  57027. * Creates a new DesaturateBlock
  57028. * @param name defines the block name
  57029. */
  57030. constructor(name: string);
  57031. /**
  57032. * Gets the current class name
  57033. * @returns the class name
  57034. */
  57035. getClassName(): string;
  57036. /**
  57037. * Gets the color operand input component
  57038. */
  57039. readonly color: NodeMaterialConnectionPoint;
  57040. /**
  57041. * Gets the level operand input component
  57042. */
  57043. readonly level: NodeMaterialConnectionPoint;
  57044. /**
  57045. * Gets the output component
  57046. */
  57047. readonly output: NodeMaterialConnectionPoint;
  57048. protected _buildBlock(state: NodeMaterialBuildState): this;
  57049. }
  57050. }
  57051. declare module BABYLON {
  57052. /**
  57053. * Effect Render Options
  57054. */
  57055. export interface IEffectRendererOptions {
  57056. /**
  57057. * Defines the vertices positions.
  57058. */
  57059. positions?: number[];
  57060. /**
  57061. * Defines the indices.
  57062. */
  57063. indices?: number[];
  57064. }
  57065. /**
  57066. * Helper class to render one or more effects
  57067. */
  57068. export class EffectRenderer {
  57069. private engine;
  57070. private static _DefaultOptions;
  57071. private _vertexBuffers;
  57072. private _indexBuffer;
  57073. private _ringBufferIndex;
  57074. private _ringScreenBuffer;
  57075. private _fullscreenViewport;
  57076. private _getNextFrameBuffer;
  57077. /**
  57078. * Creates an effect renderer
  57079. * @param engine the engine to use for rendering
  57080. * @param options defines the options of the effect renderer
  57081. */
  57082. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  57083. /**
  57084. * Sets the current viewport in normalized coordinates 0-1
  57085. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  57086. */
  57087. setViewport(viewport?: Viewport): void;
  57088. /**
  57089. * Binds the embedded attributes buffer to the effect.
  57090. * @param effect Defines the effect to bind the attributes for
  57091. */
  57092. bindBuffers(effect: Effect): void;
  57093. /**
  57094. * Sets the current effect wrapper to use during draw.
  57095. * The effect needs to be ready before calling this api.
  57096. * This also sets the default full screen position attribute.
  57097. * @param effectWrapper Defines the effect to draw with
  57098. */
  57099. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  57100. /**
  57101. * Draws a full screen quad.
  57102. */
  57103. draw(): void;
  57104. /**
  57105. * renders one or more effects to a specified texture
  57106. * @param effectWrappers list of effects to renderer
  57107. * @param outputTexture texture to draw to, if null it will render to the screen
  57108. */
  57109. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  57110. /**
  57111. * Disposes of the effect renderer
  57112. */
  57113. dispose(): void;
  57114. }
  57115. /**
  57116. * Options to create an EffectWrapper
  57117. */
  57118. interface EffectWrapperCreationOptions {
  57119. /**
  57120. * Engine to use to create the effect
  57121. */
  57122. engine: ThinEngine;
  57123. /**
  57124. * Fragment shader for the effect
  57125. */
  57126. fragmentShader: string;
  57127. /**
  57128. * Vertex shader for the effect
  57129. */
  57130. vertexShader?: string;
  57131. /**
  57132. * Attributes to use in the shader
  57133. */
  57134. attributeNames?: Array<string>;
  57135. /**
  57136. * Uniforms to use in the shader
  57137. */
  57138. uniformNames?: Array<string>;
  57139. /**
  57140. * Texture sampler names to use in the shader
  57141. */
  57142. samplerNames?: Array<string>;
  57143. /**
  57144. * The friendly name of the effect displayed in Spector.
  57145. */
  57146. name?: string;
  57147. }
  57148. /**
  57149. * Wraps an effect to be used for rendering
  57150. */
  57151. export class EffectWrapper {
  57152. /**
  57153. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  57154. */
  57155. onApplyObservable: Observable<{}>;
  57156. /**
  57157. * The underlying effect
  57158. */
  57159. effect: Effect;
  57160. /**
  57161. * Creates an effect to be renderer
  57162. * @param creationOptions options to create the effect
  57163. */
  57164. constructor(creationOptions: EffectWrapperCreationOptions);
  57165. /**
  57166. * Disposes of the effect wrapper
  57167. */
  57168. dispose(): void;
  57169. }
  57170. }
  57171. declare module BABYLON {
  57172. /**
  57173. * Helper class to push actions to a pool of workers.
  57174. */
  57175. export class WorkerPool implements IDisposable {
  57176. private _workerInfos;
  57177. private _pendingActions;
  57178. /**
  57179. * Constructor
  57180. * @param workers Array of workers to use for actions
  57181. */
  57182. constructor(workers: Array<Worker>);
  57183. /**
  57184. * Terminates all workers and clears any pending actions.
  57185. */
  57186. dispose(): void;
  57187. /**
  57188. * Pushes an action to the worker pool. If all the workers are active, the action will be
  57189. * pended until a worker has completed its action.
  57190. * @param action The action to perform. Call onComplete when the action is complete.
  57191. */
  57192. push(action: (worker: Worker, onComplete: () => void) => void): void;
  57193. private _execute;
  57194. }
  57195. }
  57196. declare module BABYLON {
  57197. /**
  57198. * Configuration for Draco compression
  57199. */
  57200. export interface IDracoCompressionConfiguration {
  57201. /**
  57202. * Configuration for the decoder.
  57203. */
  57204. decoder: {
  57205. /**
  57206. * The url to the WebAssembly module.
  57207. */
  57208. wasmUrl?: string;
  57209. /**
  57210. * The url to the WebAssembly binary.
  57211. */
  57212. wasmBinaryUrl?: string;
  57213. /**
  57214. * The url to the fallback JavaScript module.
  57215. */
  57216. fallbackUrl?: string;
  57217. };
  57218. }
  57219. /**
  57220. * Draco compression (https://google.github.io/draco/)
  57221. *
  57222. * This class wraps the Draco module.
  57223. *
  57224. * **Encoder**
  57225. *
  57226. * The encoder is not currently implemented.
  57227. *
  57228. * **Decoder**
  57229. *
  57230. * 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.
  57231. *
  57232. * To update the configuration, use the following code:
  57233. * ```javascript
  57234. * DracoCompression.Configuration = {
  57235. * decoder: {
  57236. * wasmUrl: "<url to the WebAssembly library>",
  57237. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  57238. * fallbackUrl: "<url to the fallback JavaScript library>",
  57239. * }
  57240. * };
  57241. * ```
  57242. *
  57243. * 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.
  57244. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  57245. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  57246. *
  57247. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  57248. * ```javascript
  57249. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  57250. * ```
  57251. *
  57252. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  57253. */
  57254. export class DracoCompression implements IDisposable {
  57255. private _workerPoolPromise?;
  57256. private _decoderModulePromise?;
  57257. /**
  57258. * The configuration. Defaults to the following urls:
  57259. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  57260. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  57261. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  57262. */
  57263. static Configuration: IDracoCompressionConfiguration;
  57264. /**
  57265. * Returns true if the decoder configuration is available.
  57266. */
  57267. static readonly DecoderAvailable: boolean;
  57268. /**
  57269. * Default number of workers to create when creating the draco compression object.
  57270. */
  57271. static DefaultNumWorkers: number;
  57272. private static GetDefaultNumWorkers;
  57273. private static _Default;
  57274. /**
  57275. * Default instance for the draco compression object.
  57276. */
  57277. static readonly Default: DracoCompression;
  57278. /**
  57279. * Constructor
  57280. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  57281. */
  57282. constructor(numWorkers?: number);
  57283. /**
  57284. * Stop all async operations and release resources.
  57285. */
  57286. dispose(): void;
  57287. /**
  57288. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  57289. * @returns a promise that resolves when ready
  57290. */
  57291. whenReadyAsync(): Promise<void>;
  57292. /**
  57293. * Decode Draco compressed mesh data to vertex data.
  57294. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  57295. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  57296. * @returns A promise that resolves with the decoded vertex data
  57297. */
  57298. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  57299. [kind: string]: number;
  57300. }): Promise<VertexData>;
  57301. }
  57302. }
  57303. declare module BABYLON {
  57304. /**
  57305. * Class for building Constructive Solid Geometry
  57306. */
  57307. export class CSG {
  57308. private polygons;
  57309. /**
  57310. * The world matrix
  57311. */
  57312. matrix: Matrix;
  57313. /**
  57314. * Stores the position
  57315. */
  57316. position: Vector3;
  57317. /**
  57318. * Stores the rotation
  57319. */
  57320. rotation: Vector3;
  57321. /**
  57322. * Stores the rotation quaternion
  57323. */
  57324. rotationQuaternion: Nullable<Quaternion>;
  57325. /**
  57326. * Stores the scaling vector
  57327. */
  57328. scaling: Vector3;
  57329. /**
  57330. * Convert the Mesh to CSG
  57331. * @param mesh The Mesh to convert to CSG
  57332. * @returns A new CSG from the Mesh
  57333. */
  57334. static FromMesh(mesh: Mesh): CSG;
  57335. /**
  57336. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  57337. * @param polygons Polygons used to construct a CSG solid
  57338. */
  57339. private static FromPolygons;
  57340. /**
  57341. * Clones, or makes a deep copy, of the CSG
  57342. * @returns A new CSG
  57343. */
  57344. clone(): CSG;
  57345. /**
  57346. * Unions this CSG with another CSG
  57347. * @param csg The CSG to union against this CSG
  57348. * @returns The unioned CSG
  57349. */
  57350. union(csg: CSG): CSG;
  57351. /**
  57352. * Unions this CSG with another CSG in place
  57353. * @param csg The CSG to union against this CSG
  57354. */
  57355. unionInPlace(csg: CSG): void;
  57356. /**
  57357. * Subtracts this CSG with another CSG
  57358. * @param csg The CSG to subtract against this CSG
  57359. * @returns A new CSG
  57360. */
  57361. subtract(csg: CSG): CSG;
  57362. /**
  57363. * Subtracts this CSG with another CSG in place
  57364. * @param csg The CSG to subtact against this CSG
  57365. */
  57366. subtractInPlace(csg: CSG): void;
  57367. /**
  57368. * Intersect this CSG with another CSG
  57369. * @param csg The CSG to intersect against this CSG
  57370. * @returns A new CSG
  57371. */
  57372. intersect(csg: CSG): CSG;
  57373. /**
  57374. * Intersects this CSG with another CSG in place
  57375. * @param csg The CSG to intersect against this CSG
  57376. */
  57377. intersectInPlace(csg: CSG): void;
  57378. /**
  57379. * Return a new CSG solid with solid and empty space switched. This solid is
  57380. * not modified.
  57381. * @returns A new CSG solid with solid and empty space switched
  57382. */
  57383. inverse(): CSG;
  57384. /**
  57385. * Inverses the CSG in place
  57386. */
  57387. inverseInPlace(): void;
  57388. /**
  57389. * This is used to keep meshes transformations so they can be restored
  57390. * when we build back a Babylon Mesh
  57391. * NB : All CSG operations are performed in world coordinates
  57392. * @param csg The CSG to copy the transform attributes from
  57393. * @returns This CSG
  57394. */
  57395. copyTransformAttributes(csg: CSG): CSG;
  57396. /**
  57397. * Build Raw mesh from CSG
  57398. * Coordinates here are in world space
  57399. * @param name The name of the mesh geometry
  57400. * @param scene The Scene
  57401. * @param keepSubMeshes Specifies if the submeshes should be kept
  57402. * @returns A new Mesh
  57403. */
  57404. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  57405. /**
  57406. * Build Mesh from CSG taking material and transforms into account
  57407. * @param name The name of the Mesh
  57408. * @param material The material of the Mesh
  57409. * @param scene The Scene
  57410. * @param keepSubMeshes Specifies if submeshes should be kept
  57411. * @returns The new Mesh
  57412. */
  57413. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  57414. }
  57415. }
  57416. declare module BABYLON {
  57417. /**
  57418. * Class used to create a trail following a mesh
  57419. */
  57420. export class TrailMesh extends Mesh {
  57421. private _generator;
  57422. private _autoStart;
  57423. private _running;
  57424. private _diameter;
  57425. private _length;
  57426. private _sectionPolygonPointsCount;
  57427. private _sectionVectors;
  57428. private _sectionNormalVectors;
  57429. private _beforeRenderObserver;
  57430. /**
  57431. * @constructor
  57432. * @param name The value used by scene.getMeshByName() to do a lookup.
  57433. * @param generator The mesh to generate a trail.
  57434. * @param scene The scene to add this mesh to.
  57435. * @param diameter Diameter of trailing mesh. Default is 1.
  57436. * @param length Length of trailing mesh. Default is 60.
  57437. * @param autoStart Automatically start trailing mesh. Default true.
  57438. */
  57439. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  57440. /**
  57441. * "TrailMesh"
  57442. * @returns "TrailMesh"
  57443. */
  57444. getClassName(): string;
  57445. private _createMesh;
  57446. /**
  57447. * Start trailing mesh.
  57448. */
  57449. start(): void;
  57450. /**
  57451. * Stop trailing mesh.
  57452. */
  57453. stop(): void;
  57454. /**
  57455. * Update trailing mesh geometry.
  57456. */
  57457. update(): void;
  57458. /**
  57459. * Returns a new TrailMesh object.
  57460. * @param name is a string, the name given to the new mesh
  57461. * @param newGenerator use new generator object for cloned trail mesh
  57462. * @returns a new mesh
  57463. */
  57464. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  57465. /**
  57466. * Serializes this trail mesh
  57467. * @param serializationObject object to write serialization to
  57468. */
  57469. serialize(serializationObject: any): void;
  57470. /**
  57471. * Parses a serialized trail mesh
  57472. * @param parsedMesh the serialized mesh
  57473. * @param scene the scene to create the trail mesh in
  57474. * @returns the created trail mesh
  57475. */
  57476. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  57477. }
  57478. }
  57479. declare module BABYLON {
  57480. /**
  57481. * Class containing static functions to help procedurally build meshes
  57482. */
  57483. export class TiledBoxBuilder {
  57484. /**
  57485. * Creates a box mesh
  57486. * 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)
  57487. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  57488. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57489. * * 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
  57490. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57491. * @param name defines the name of the mesh
  57492. * @param options defines the options used to create the mesh
  57493. * @param scene defines the hosting scene
  57494. * @returns the box mesh
  57495. */
  57496. static CreateTiledBox(name: string, options: {
  57497. pattern?: number;
  57498. width?: number;
  57499. height?: number;
  57500. depth?: number;
  57501. tileSize?: number;
  57502. tileWidth?: number;
  57503. tileHeight?: number;
  57504. alignHorizontal?: number;
  57505. alignVertical?: number;
  57506. faceUV?: Vector4[];
  57507. faceColors?: Color4[];
  57508. sideOrientation?: number;
  57509. updatable?: boolean;
  57510. }, scene?: Nullable<Scene>): Mesh;
  57511. }
  57512. }
  57513. declare module BABYLON {
  57514. /**
  57515. * Class containing static functions to help procedurally build meshes
  57516. */
  57517. export class TorusKnotBuilder {
  57518. /**
  57519. * Creates a torus knot mesh
  57520. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  57521. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  57522. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  57523. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  57524. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57525. * * 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
  57526. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57527. * @param name defines the name of the mesh
  57528. * @param options defines the options used to create the mesh
  57529. * @param scene defines the hosting scene
  57530. * @returns the torus knot mesh
  57531. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  57532. */
  57533. static CreateTorusKnot(name: string, options: {
  57534. radius?: number;
  57535. tube?: number;
  57536. radialSegments?: number;
  57537. tubularSegments?: number;
  57538. p?: number;
  57539. q?: number;
  57540. updatable?: boolean;
  57541. sideOrientation?: number;
  57542. frontUVs?: Vector4;
  57543. backUVs?: Vector4;
  57544. }, scene: any): Mesh;
  57545. }
  57546. }
  57547. declare module BABYLON {
  57548. /**
  57549. * Polygon
  57550. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  57551. */
  57552. export class Polygon {
  57553. /**
  57554. * Creates a rectangle
  57555. * @param xmin bottom X coord
  57556. * @param ymin bottom Y coord
  57557. * @param xmax top X coord
  57558. * @param ymax top Y coord
  57559. * @returns points that make the resulting rectation
  57560. */
  57561. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  57562. /**
  57563. * Creates a circle
  57564. * @param radius radius of circle
  57565. * @param cx scale in x
  57566. * @param cy scale in y
  57567. * @param numberOfSides number of sides that make up the circle
  57568. * @returns points that make the resulting circle
  57569. */
  57570. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  57571. /**
  57572. * Creates a polygon from input string
  57573. * @param input Input polygon data
  57574. * @returns the parsed points
  57575. */
  57576. static Parse(input: string): Vector2[];
  57577. /**
  57578. * Starts building a polygon from x and y coordinates
  57579. * @param x x coordinate
  57580. * @param y y coordinate
  57581. * @returns the started path2
  57582. */
  57583. static StartingAt(x: number, y: number): Path2;
  57584. }
  57585. /**
  57586. * Builds a polygon
  57587. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  57588. */
  57589. export class PolygonMeshBuilder {
  57590. private _points;
  57591. private _outlinepoints;
  57592. private _holes;
  57593. private _name;
  57594. private _scene;
  57595. private _epoints;
  57596. private _eholes;
  57597. private _addToepoint;
  57598. /**
  57599. * Babylon reference to the earcut plugin.
  57600. */
  57601. bjsEarcut: any;
  57602. /**
  57603. * Creates a PolygonMeshBuilder
  57604. * @param name name of the builder
  57605. * @param contours Path of the polygon
  57606. * @param scene scene to add to when creating the mesh
  57607. * @param earcutInjection can be used to inject your own earcut reference
  57608. */
  57609. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  57610. /**
  57611. * Adds a whole within the polygon
  57612. * @param hole Array of points defining the hole
  57613. * @returns this
  57614. */
  57615. addHole(hole: Vector2[]): PolygonMeshBuilder;
  57616. /**
  57617. * Creates the polygon
  57618. * @param updatable If the mesh should be updatable
  57619. * @param depth The depth of the mesh created
  57620. * @returns the created mesh
  57621. */
  57622. build(updatable?: boolean, depth?: number): Mesh;
  57623. /**
  57624. * Creates the polygon
  57625. * @param depth The depth of the mesh created
  57626. * @returns the created VertexData
  57627. */
  57628. buildVertexData(depth?: number): VertexData;
  57629. /**
  57630. * Adds a side to the polygon
  57631. * @param positions points that make the polygon
  57632. * @param normals normals of the polygon
  57633. * @param uvs uvs of the polygon
  57634. * @param indices indices of the polygon
  57635. * @param bounds bounds of the polygon
  57636. * @param points points of the polygon
  57637. * @param depth depth of the polygon
  57638. * @param flip flip of the polygon
  57639. */
  57640. private addSide;
  57641. }
  57642. }
  57643. declare module BABYLON {
  57644. /**
  57645. * Class containing static functions to help procedurally build meshes
  57646. */
  57647. export class PolygonBuilder {
  57648. /**
  57649. * Creates a polygon mesh
  57650. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  57651. * * 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
  57652. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  57653. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57654. * * 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)
  57655. * * Remember you can only change the shape positions, not their number when updating a polygon
  57656. * @param name defines the name of the mesh
  57657. * @param options defines the options used to create the mesh
  57658. * @param scene defines the hosting scene
  57659. * @param earcutInjection can be used to inject your own earcut reference
  57660. * @returns the polygon mesh
  57661. */
  57662. static CreatePolygon(name: string, options: {
  57663. shape: Vector3[];
  57664. holes?: Vector3[][];
  57665. depth?: number;
  57666. faceUV?: Vector4[];
  57667. faceColors?: Color4[];
  57668. updatable?: boolean;
  57669. sideOrientation?: number;
  57670. frontUVs?: Vector4;
  57671. backUVs?: Vector4;
  57672. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  57673. /**
  57674. * Creates an extruded polygon mesh, with depth in the Y direction.
  57675. * * 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)
  57676. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  57677. * @param name defines the name of the mesh
  57678. * @param options defines the options used to create the mesh
  57679. * @param scene defines the hosting scene
  57680. * @param earcutInjection can be used to inject your own earcut reference
  57681. * @returns the polygon mesh
  57682. */
  57683. static ExtrudePolygon(name: string, options: {
  57684. shape: Vector3[];
  57685. holes?: Vector3[][];
  57686. depth?: number;
  57687. faceUV?: Vector4[];
  57688. faceColors?: Color4[];
  57689. updatable?: boolean;
  57690. sideOrientation?: number;
  57691. frontUVs?: Vector4;
  57692. backUVs?: Vector4;
  57693. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  57694. }
  57695. }
  57696. declare module BABYLON {
  57697. /**
  57698. * Class containing static functions to help procedurally build meshes
  57699. */
  57700. export class LatheBuilder {
  57701. /**
  57702. * Creates lathe mesh.
  57703. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  57704. * * 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
  57705. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  57706. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  57707. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  57708. * * 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
  57709. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  57710. * * 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
  57711. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57712. * * 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
  57713. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57714. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57715. * @param name defines the name of the mesh
  57716. * @param options defines the options used to create the mesh
  57717. * @param scene defines the hosting scene
  57718. * @returns the lathe mesh
  57719. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  57720. */
  57721. static CreateLathe(name: string, options: {
  57722. shape: Vector3[];
  57723. radius?: number;
  57724. tessellation?: number;
  57725. clip?: number;
  57726. arc?: number;
  57727. closed?: boolean;
  57728. updatable?: boolean;
  57729. sideOrientation?: number;
  57730. frontUVs?: Vector4;
  57731. backUVs?: Vector4;
  57732. cap?: number;
  57733. invertUV?: boolean;
  57734. }, scene?: Nullable<Scene>): Mesh;
  57735. }
  57736. }
  57737. declare module BABYLON {
  57738. /**
  57739. * Class containing static functions to help procedurally build meshes
  57740. */
  57741. export class TiledPlaneBuilder {
  57742. /**
  57743. * Creates a tiled plane mesh
  57744. * * The parameter `pattern` will, depending on value, do nothing or
  57745. * * * flip (reflect about central vertical) alternate tiles across and up
  57746. * * * flip every tile on alternate rows
  57747. * * * rotate (180 degs) alternate tiles across and up
  57748. * * * rotate every tile on alternate rows
  57749. * * * flip and rotate alternate tiles across and up
  57750. * * * flip and rotate every tile on alternate rows
  57751. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  57752. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  57753. * * 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
  57754. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  57755. * * 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)
  57756. * * 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)
  57757. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  57758. * @param name defines the name of the mesh
  57759. * @param options defines the options used to create the mesh
  57760. * @param scene defines the hosting scene
  57761. * @returns the box mesh
  57762. */
  57763. static CreateTiledPlane(name: string, options: {
  57764. pattern?: number;
  57765. tileSize?: number;
  57766. tileWidth?: number;
  57767. tileHeight?: number;
  57768. size?: number;
  57769. width?: number;
  57770. height?: number;
  57771. alignHorizontal?: number;
  57772. alignVertical?: number;
  57773. sideOrientation?: number;
  57774. frontUVs?: Vector4;
  57775. backUVs?: Vector4;
  57776. updatable?: boolean;
  57777. }, scene?: Nullable<Scene>): Mesh;
  57778. }
  57779. }
  57780. declare module BABYLON {
  57781. /**
  57782. * Class containing static functions to help procedurally build meshes
  57783. */
  57784. export class TubeBuilder {
  57785. /**
  57786. * Creates a tube mesh.
  57787. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  57788. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  57789. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  57790. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  57791. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  57792. * * 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)
  57793. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  57794. * * 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
  57795. * * 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
  57796. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57797. * * 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
  57798. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57799. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57800. * @param name defines the name of the mesh
  57801. * @param options defines the options used to create the mesh
  57802. * @param scene defines the hosting scene
  57803. * @returns the tube mesh
  57804. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57805. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  57806. */
  57807. static CreateTube(name: string, options: {
  57808. path: Vector3[];
  57809. radius?: number;
  57810. tessellation?: number;
  57811. radiusFunction?: {
  57812. (i: number, distance: number): number;
  57813. };
  57814. cap?: number;
  57815. arc?: number;
  57816. updatable?: boolean;
  57817. sideOrientation?: number;
  57818. frontUVs?: Vector4;
  57819. backUVs?: Vector4;
  57820. instance?: Mesh;
  57821. invertUV?: boolean;
  57822. }, scene?: Nullable<Scene>): Mesh;
  57823. }
  57824. }
  57825. declare module BABYLON {
  57826. /**
  57827. * Class containing static functions to help procedurally build meshes
  57828. */
  57829. export class IcoSphereBuilder {
  57830. /**
  57831. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  57832. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  57833. * * 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`)
  57834. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  57835. * * 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
  57836. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57837. * * 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
  57838. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57839. * @param name defines the name of the mesh
  57840. * @param options defines the options used to create the mesh
  57841. * @param scene defines the hosting scene
  57842. * @returns the icosahedron mesh
  57843. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  57844. */
  57845. static CreateIcoSphere(name: string, options: {
  57846. radius?: number;
  57847. radiusX?: number;
  57848. radiusY?: number;
  57849. radiusZ?: number;
  57850. flat?: boolean;
  57851. subdivisions?: number;
  57852. sideOrientation?: number;
  57853. frontUVs?: Vector4;
  57854. backUVs?: Vector4;
  57855. updatable?: boolean;
  57856. }, scene?: Nullable<Scene>): Mesh;
  57857. }
  57858. }
  57859. declare module BABYLON {
  57860. /**
  57861. * Class containing static functions to help procedurally build meshes
  57862. */
  57863. export class DecalBuilder {
  57864. /**
  57865. * Creates a decal mesh.
  57866. * 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
  57867. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  57868. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  57869. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  57870. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  57871. * @param name defines the name of the mesh
  57872. * @param sourceMesh defines the mesh where the decal must be applied
  57873. * @param options defines the options used to create the mesh
  57874. * @param scene defines the hosting scene
  57875. * @returns the decal mesh
  57876. * @see https://doc.babylonjs.com/how_to/decals
  57877. */
  57878. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  57879. position?: Vector3;
  57880. normal?: Vector3;
  57881. size?: Vector3;
  57882. angle?: number;
  57883. }): Mesh;
  57884. }
  57885. }
  57886. declare module BABYLON {
  57887. /**
  57888. * Class containing static functions to help procedurally build meshes
  57889. */
  57890. export class MeshBuilder {
  57891. /**
  57892. * Creates a box mesh
  57893. * * The parameter `size` sets the size (float) of each box side (default 1)
  57894. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  57895. * * 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)
  57896. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  57897. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57898. * * 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
  57899. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57900. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  57901. * @param name defines the name of the mesh
  57902. * @param options defines the options used to create the mesh
  57903. * @param scene defines the hosting scene
  57904. * @returns the box mesh
  57905. */
  57906. static CreateBox(name: string, options: {
  57907. size?: number;
  57908. width?: number;
  57909. height?: number;
  57910. depth?: number;
  57911. faceUV?: Vector4[];
  57912. faceColors?: Color4[];
  57913. sideOrientation?: number;
  57914. frontUVs?: Vector4;
  57915. backUVs?: Vector4;
  57916. updatable?: boolean;
  57917. }, scene?: Nullable<Scene>): Mesh;
  57918. /**
  57919. * Creates a tiled box mesh
  57920. * * faceTiles sets the pattern, tile size and number of tiles for a face
  57921. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57922. * @param name defines the name of the mesh
  57923. * @param options defines the options used to create the mesh
  57924. * @param scene defines the hosting scene
  57925. * @returns the tiled box mesh
  57926. */
  57927. static CreateTiledBox(name: string, options: {
  57928. pattern?: number;
  57929. size?: number;
  57930. width?: number;
  57931. height?: number;
  57932. depth: number;
  57933. tileSize?: number;
  57934. tileWidth?: number;
  57935. tileHeight?: number;
  57936. faceUV?: Vector4[];
  57937. faceColors?: Color4[];
  57938. alignHorizontal?: number;
  57939. alignVertical?: number;
  57940. sideOrientation?: number;
  57941. updatable?: boolean;
  57942. }, scene?: Nullable<Scene>): Mesh;
  57943. /**
  57944. * Creates a sphere mesh
  57945. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  57946. * * 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`)
  57947. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  57948. * * 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
  57949. * * 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)
  57950. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57951. * * 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
  57952. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57953. * @param name defines the name of the mesh
  57954. * @param options defines the options used to create the mesh
  57955. * @param scene defines the hosting scene
  57956. * @returns the sphere mesh
  57957. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  57958. */
  57959. static CreateSphere(name: string, options: {
  57960. segments?: number;
  57961. diameter?: number;
  57962. diameterX?: number;
  57963. diameterY?: number;
  57964. diameterZ?: number;
  57965. arc?: number;
  57966. slice?: number;
  57967. sideOrientation?: number;
  57968. frontUVs?: Vector4;
  57969. backUVs?: Vector4;
  57970. updatable?: boolean;
  57971. }, scene?: Nullable<Scene>): Mesh;
  57972. /**
  57973. * Creates a plane polygonal mesh. By default, this is a disc
  57974. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  57975. * * 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
  57976. * * 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
  57977. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57978. * * 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
  57979. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57980. * @param name defines the name of the mesh
  57981. * @param options defines the options used to create the mesh
  57982. * @param scene defines the hosting scene
  57983. * @returns the plane polygonal mesh
  57984. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  57985. */
  57986. static CreateDisc(name: string, options: {
  57987. radius?: number;
  57988. tessellation?: number;
  57989. arc?: number;
  57990. updatable?: boolean;
  57991. sideOrientation?: number;
  57992. frontUVs?: Vector4;
  57993. backUVs?: Vector4;
  57994. }, scene?: Nullable<Scene>): Mesh;
  57995. /**
  57996. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  57997. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  57998. * * 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`)
  57999. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  58000. * * 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
  58001. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58002. * * 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
  58003. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58004. * @param name defines the name of the mesh
  58005. * @param options defines the options used to create the mesh
  58006. * @param scene defines the hosting scene
  58007. * @returns the icosahedron mesh
  58008. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  58009. */
  58010. static CreateIcoSphere(name: string, options: {
  58011. radius?: number;
  58012. radiusX?: number;
  58013. radiusY?: number;
  58014. radiusZ?: number;
  58015. flat?: boolean;
  58016. subdivisions?: number;
  58017. sideOrientation?: number;
  58018. frontUVs?: Vector4;
  58019. backUVs?: Vector4;
  58020. updatable?: boolean;
  58021. }, scene?: Nullable<Scene>): Mesh;
  58022. /**
  58023. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58024. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  58025. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  58026. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  58027. * * 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
  58028. * * 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
  58029. * * 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
  58030. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58031. * * 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
  58032. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58033. * * 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
  58034. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  58035. * * 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
  58036. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  58037. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58038. * @param name defines the name of the mesh
  58039. * @param options defines the options used to create the mesh
  58040. * @param scene defines the hosting scene
  58041. * @returns the ribbon mesh
  58042. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  58043. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58044. */
  58045. static CreateRibbon(name: string, options: {
  58046. pathArray: Vector3[][];
  58047. closeArray?: boolean;
  58048. closePath?: boolean;
  58049. offset?: number;
  58050. updatable?: boolean;
  58051. sideOrientation?: number;
  58052. frontUVs?: Vector4;
  58053. backUVs?: Vector4;
  58054. instance?: Mesh;
  58055. invertUV?: boolean;
  58056. uvs?: Vector2[];
  58057. colors?: Color4[];
  58058. }, scene?: Nullable<Scene>): Mesh;
  58059. /**
  58060. * Creates a cylinder or a cone mesh
  58061. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  58062. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  58063. * * 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.
  58064. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  58065. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  58066. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  58067. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  58068. * * 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).
  58069. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  58070. * * 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).
  58071. * * 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
  58072. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  58073. * * 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
  58074. * * 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.
  58075. * * If `enclose` is false, a ring surface is one element.
  58076. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  58077. * * 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
  58078. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58079. * * 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
  58080. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58081. * @param name defines the name of the mesh
  58082. * @param options defines the options used to create the mesh
  58083. * @param scene defines the hosting scene
  58084. * @returns the cylinder mesh
  58085. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  58086. */
  58087. static CreateCylinder(name: string, options: {
  58088. height?: number;
  58089. diameterTop?: number;
  58090. diameterBottom?: number;
  58091. diameter?: number;
  58092. tessellation?: number;
  58093. subdivisions?: number;
  58094. arc?: number;
  58095. faceColors?: Color4[];
  58096. faceUV?: Vector4[];
  58097. updatable?: boolean;
  58098. hasRings?: boolean;
  58099. enclose?: boolean;
  58100. cap?: number;
  58101. sideOrientation?: number;
  58102. frontUVs?: Vector4;
  58103. backUVs?: Vector4;
  58104. }, scene?: Nullable<Scene>): Mesh;
  58105. /**
  58106. * Creates a torus mesh
  58107. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  58108. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  58109. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  58110. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58111. * * 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
  58112. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58113. * @param name defines the name of the mesh
  58114. * @param options defines the options used to create the mesh
  58115. * @param scene defines the hosting scene
  58116. * @returns the torus mesh
  58117. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  58118. */
  58119. static CreateTorus(name: string, options: {
  58120. diameter?: number;
  58121. thickness?: number;
  58122. tessellation?: number;
  58123. updatable?: boolean;
  58124. sideOrientation?: number;
  58125. frontUVs?: Vector4;
  58126. backUVs?: Vector4;
  58127. }, scene?: Nullable<Scene>): Mesh;
  58128. /**
  58129. * Creates a torus knot mesh
  58130. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  58131. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  58132. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  58133. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  58134. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58135. * * 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
  58136. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58137. * @param name defines the name of the mesh
  58138. * @param options defines the options used to create the mesh
  58139. * @param scene defines the hosting scene
  58140. * @returns the torus knot mesh
  58141. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  58142. */
  58143. static CreateTorusKnot(name: string, options: {
  58144. radius?: number;
  58145. tube?: number;
  58146. radialSegments?: number;
  58147. tubularSegments?: number;
  58148. p?: number;
  58149. q?: number;
  58150. updatable?: boolean;
  58151. sideOrientation?: number;
  58152. frontUVs?: Vector4;
  58153. backUVs?: Vector4;
  58154. }, scene?: Nullable<Scene>): Mesh;
  58155. /**
  58156. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  58157. * * 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
  58158. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  58159. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  58160. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  58161. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  58162. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  58163. * * 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
  58164. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  58165. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58166. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  58167. * @param name defines the name of the new line system
  58168. * @param options defines the options used to create the line system
  58169. * @param scene defines the hosting scene
  58170. * @returns a new line system mesh
  58171. */
  58172. static CreateLineSystem(name: string, options: {
  58173. lines: Vector3[][];
  58174. updatable?: boolean;
  58175. instance?: Nullable<LinesMesh>;
  58176. colors?: Nullable<Color4[][]>;
  58177. useVertexAlpha?: boolean;
  58178. }, scene: Nullable<Scene>): LinesMesh;
  58179. /**
  58180. * Creates a line mesh
  58181. * 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
  58182. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  58183. * * The parameter `points` is an array successive Vector3
  58184. * * 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
  58185. * * The optional parameter `colors` is an array of successive Color4, one per line point
  58186. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  58187. * * When updating an instance, remember that only point positions can change, not the number of points
  58188. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58189. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  58190. * @param name defines the name of the new line system
  58191. * @param options defines the options used to create the line system
  58192. * @param scene defines the hosting scene
  58193. * @returns a new line mesh
  58194. */
  58195. static CreateLines(name: string, options: {
  58196. points: Vector3[];
  58197. updatable?: boolean;
  58198. instance?: Nullable<LinesMesh>;
  58199. colors?: Color4[];
  58200. useVertexAlpha?: boolean;
  58201. }, scene?: Nullable<Scene>): LinesMesh;
  58202. /**
  58203. * Creates a dashed line mesh
  58204. * * 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
  58205. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  58206. * * The parameter `points` is an array successive Vector3
  58207. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  58208. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  58209. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  58210. * * 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
  58211. * * When updating an instance, remember that only point positions can change, not the number of points
  58212. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58213. * @param name defines the name of the mesh
  58214. * @param options defines the options used to create the mesh
  58215. * @param scene defines the hosting scene
  58216. * @returns the dashed line mesh
  58217. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  58218. */
  58219. static CreateDashedLines(name: string, options: {
  58220. points: Vector3[];
  58221. dashSize?: number;
  58222. gapSize?: number;
  58223. dashNb?: number;
  58224. updatable?: boolean;
  58225. instance?: LinesMesh;
  58226. }, scene?: Nullable<Scene>): LinesMesh;
  58227. /**
  58228. * 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.
  58229. * * 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.
  58230. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58231. * * 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.
  58232. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  58233. * * 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
  58234. * * 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
  58235. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  58236. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58237. * * 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
  58238. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  58239. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58240. * @param name defines the name of the mesh
  58241. * @param options defines the options used to create the mesh
  58242. * @param scene defines the hosting scene
  58243. * @returns the extruded shape mesh
  58244. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58245. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58246. */
  58247. static ExtrudeShape(name: string, options: {
  58248. shape: Vector3[];
  58249. path: Vector3[];
  58250. scale?: number;
  58251. rotation?: number;
  58252. cap?: number;
  58253. updatable?: boolean;
  58254. sideOrientation?: number;
  58255. frontUVs?: Vector4;
  58256. backUVs?: Vector4;
  58257. instance?: Mesh;
  58258. invertUV?: boolean;
  58259. }, scene?: Nullable<Scene>): Mesh;
  58260. /**
  58261. * Creates an custom extruded shape mesh.
  58262. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  58263. * * 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.
  58264. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58265. * * 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
  58266. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  58267. * * 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
  58268. * * It must returns a float value that will be the scale value applied to the shape on each path point
  58269. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  58270. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  58271. * * 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
  58272. * * 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
  58273. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  58274. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58275. * * 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
  58276. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58277. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58278. * @param name defines the name of the mesh
  58279. * @param options defines the options used to create the mesh
  58280. * @param scene defines the hosting scene
  58281. * @returns the custom extruded shape mesh
  58282. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  58283. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58284. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58285. */
  58286. static ExtrudeShapeCustom(name: string, options: {
  58287. shape: Vector3[];
  58288. path: Vector3[];
  58289. scaleFunction?: any;
  58290. rotationFunction?: any;
  58291. ribbonCloseArray?: boolean;
  58292. ribbonClosePath?: boolean;
  58293. cap?: number;
  58294. updatable?: boolean;
  58295. sideOrientation?: number;
  58296. frontUVs?: Vector4;
  58297. backUVs?: Vector4;
  58298. instance?: Mesh;
  58299. invertUV?: boolean;
  58300. }, scene?: Nullable<Scene>): Mesh;
  58301. /**
  58302. * Creates lathe mesh.
  58303. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  58304. * * 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
  58305. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  58306. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  58307. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  58308. * * 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
  58309. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  58310. * * 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
  58311. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58312. * * 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
  58313. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58314. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58315. * @param name defines the name of the mesh
  58316. * @param options defines the options used to create the mesh
  58317. * @param scene defines the hosting scene
  58318. * @returns the lathe mesh
  58319. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  58320. */
  58321. static CreateLathe(name: string, options: {
  58322. shape: Vector3[];
  58323. radius?: number;
  58324. tessellation?: number;
  58325. clip?: number;
  58326. arc?: number;
  58327. closed?: boolean;
  58328. updatable?: boolean;
  58329. sideOrientation?: number;
  58330. frontUVs?: Vector4;
  58331. backUVs?: Vector4;
  58332. cap?: number;
  58333. invertUV?: boolean;
  58334. }, scene?: Nullable<Scene>): Mesh;
  58335. /**
  58336. * Creates a tiled plane mesh
  58337. * * You can set a limited pattern arrangement with the tiles
  58338. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58339. * * 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
  58340. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58341. * @param name defines the name of the mesh
  58342. * @param options defines the options used to create the mesh
  58343. * @param scene defines the hosting scene
  58344. * @returns the plane mesh
  58345. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  58346. */
  58347. static CreateTiledPlane(name: string, options: {
  58348. pattern?: number;
  58349. tileSize?: number;
  58350. tileWidth?: number;
  58351. tileHeight?: number;
  58352. size?: number;
  58353. width?: number;
  58354. height?: number;
  58355. alignHorizontal?: number;
  58356. alignVertical?: number;
  58357. sideOrientation?: number;
  58358. frontUVs?: Vector4;
  58359. backUVs?: Vector4;
  58360. updatable?: boolean;
  58361. }, scene?: Nullable<Scene>): Mesh;
  58362. /**
  58363. * Creates a plane mesh
  58364. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  58365. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  58366. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  58367. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58368. * * 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
  58369. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58370. * @param name defines the name of the mesh
  58371. * @param options defines the options used to create the mesh
  58372. * @param scene defines the hosting scene
  58373. * @returns the plane mesh
  58374. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  58375. */
  58376. static CreatePlane(name: string, options: {
  58377. size?: number;
  58378. width?: number;
  58379. height?: number;
  58380. sideOrientation?: number;
  58381. frontUVs?: Vector4;
  58382. backUVs?: Vector4;
  58383. updatable?: boolean;
  58384. sourcePlane?: Plane;
  58385. }, scene?: Nullable<Scene>): Mesh;
  58386. /**
  58387. * Creates a ground mesh
  58388. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  58389. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  58390. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58391. * @param name defines the name of the mesh
  58392. * @param options defines the options used to create the mesh
  58393. * @param scene defines the hosting scene
  58394. * @returns the ground mesh
  58395. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  58396. */
  58397. static CreateGround(name: string, options: {
  58398. width?: number;
  58399. height?: number;
  58400. subdivisions?: number;
  58401. subdivisionsX?: number;
  58402. subdivisionsY?: number;
  58403. updatable?: boolean;
  58404. }, scene?: Nullable<Scene>): Mesh;
  58405. /**
  58406. * Creates a tiled ground mesh
  58407. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  58408. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  58409. * * 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
  58410. * * 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
  58411. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58412. * @param name defines the name of the mesh
  58413. * @param options defines the options used to create the mesh
  58414. * @param scene defines the hosting scene
  58415. * @returns the tiled ground mesh
  58416. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  58417. */
  58418. static CreateTiledGround(name: string, options: {
  58419. xmin: number;
  58420. zmin: number;
  58421. xmax: number;
  58422. zmax: number;
  58423. subdivisions?: {
  58424. w: number;
  58425. h: number;
  58426. };
  58427. precision?: {
  58428. w: number;
  58429. h: number;
  58430. };
  58431. updatable?: boolean;
  58432. }, scene?: Nullable<Scene>): Mesh;
  58433. /**
  58434. * Creates a ground mesh from a height map
  58435. * * The parameter `url` sets the URL of the height map image resource.
  58436. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  58437. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  58438. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  58439. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  58440. * * 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.
  58441. * * 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).
  58442. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  58443. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58444. * @param name defines the name of the mesh
  58445. * @param url defines the url to the height map
  58446. * @param options defines the options used to create the mesh
  58447. * @param scene defines the hosting scene
  58448. * @returns the ground mesh
  58449. * @see https://doc.babylonjs.com/babylon101/height_map
  58450. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  58451. */
  58452. static CreateGroundFromHeightMap(name: string, url: string, options: {
  58453. width?: number;
  58454. height?: number;
  58455. subdivisions?: number;
  58456. minHeight?: number;
  58457. maxHeight?: number;
  58458. colorFilter?: Color3;
  58459. alphaFilter?: number;
  58460. updatable?: boolean;
  58461. onReady?: (mesh: GroundMesh) => void;
  58462. }, scene?: Nullable<Scene>): GroundMesh;
  58463. /**
  58464. * Creates a polygon mesh
  58465. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  58466. * * 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
  58467. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  58468. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58469. * * 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)
  58470. * * Remember you can only change the shape positions, not their number when updating a polygon
  58471. * @param name defines the name of the mesh
  58472. * @param options defines the options used to create the mesh
  58473. * @param scene defines the hosting scene
  58474. * @param earcutInjection can be used to inject your own earcut reference
  58475. * @returns the polygon mesh
  58476. */
  58477. static CreatePolygon(name: string, options: {
  58478. shape: Vector3[];
  58479. holes?: Vector3[][];
  58480. depth?: number;
  58481. faceUV?: Vector4[];
  58482. faceColors?: Color4[];
  58483. updatable?: boolean;
  58484. sideOrientation?: number;
  58485. frontUVs?: Vector4;
  58486. backUVs?: Vector4;
  58487. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58488. /**
  58489. * Creates an extruded polygon mesh, with depth in the Y direction.
  58490. * * 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)
  58491. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58492. * @param name defines the name of the mesh
  58493. * @param options defines the options used to create the mesh
  58494. * @param scene defines the hosting scene
  58495. * @param earcutInjection can be used to inject your own earcut reference
  58496. * @returns the polygon mesh
  58497. */
  58498. static ExtrudePolygon(name: string, options: {
  58499. shape: Vector3[];
  58500. holes?: Vector3[][];
  58501. depth?: number;
  58502. faceUV?: Vector4[];
  58503. faceColors?: Color4[];
  58504. updatable?: boolean;
  58505. sideOrientation?: number;
  58506. frontUVs?: Vector4;
  58507. backUVs?: Vector4;
  58508. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58509. /**
  58510. * Creates a tube mesh.
  58511. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58512. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  58513. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  58514. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  58515. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  58516. * * 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)
  58517. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  58518. * * 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
  58519. * * 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
  58520. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58521. * * 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
  58522. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58523. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58524. * @param name defines the name of the mesh
  58525. * @param options defines the options used to create the mesh
  58526. * @param scene defines the hosting scene
  58527. * @returns the tube mesh
  58528. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58529. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  58530. */
  58531. static CreateTube(name: string, options: {
  58532. path: Vector3[];
  58533. radius?: number;
  58534. tessellation?: number;
  58535. radiusFunction?: {
  58536. (i: number, distance: number): number;
  58537. };
  58538. cap?: number;
  58539. arc?: number;
  58540. updatable?: boolean;
  58541. sideOrientation?: number;
  58542. frontUVs?: Vector4;
  58543. backUVs?: Vector4;
  58544. instance?: Mesh;
  58545. invertUV?: boolean;
  58546. }, scene?: Nullable<Scene>): Mesh;
  58547. /**
  58548. * Creates a polyhedron mesh
  58549. * * 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
  58550. * * The parameter `size` (positive float, default 1) sets the polygon size
  58551. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  58552. * * 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`
  58553. * * 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
  58554. * * 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)`)
  58555. * * 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
  58556. * * 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
  58557. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58558. * * 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
  58559. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58560. * @param name defines the name of the mesh
  58561. * @param options defines the options used to create the mesh
  58562. * @param scene defines the hosting scene
  58563. * @returns the polyhedron mesh
  58564. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  58565. */
  58566. static CreatePolyhedron(name: string, options: {
  58567. type?: number;
  58568. size?: number;
  58569. sizeX?: number;
  58570. sizeY?: number;
  58571. sizeZ?: number;
  58572. custom?: any;
  58573. faceUV?: Vector4[];
  58574. faceColors?: Color4[];
  58575. flat?: boolean;
  58576. updatable?: boolean;
  58577. sideOrientation?: number;
  58578. frontUVs?: Vector4;
  58579. backUVs?: Vector4;
  58580. }, scene?: Nullable<Scene>): Mesh;
  58581. /**
  58582. * Creates a decal mesh.
  58583. * 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
  58584. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  58585. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  58586. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  58587. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  58588. * @param name defines the name of the mesh
  58589. * @param sourceMesh defines the mesh where the decal must be applied
  58590. * @param options defines the options used to create the mesh
  58591. * @param scene defines the hosting scene
  58592. * @returns the decal mesh
  58593. * @see https://doc.babylonjs.com/how_to/decals
  58594. */
  58595. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  58596. position?: Vector3;
  58597. normal?: Vector3;
  58598. size?: Vector3;
  58599. angle?: number;
  58600. }): Mesh;
  58601. }
  58602. }
  58603. declare module BABYLON {
  58604. /**
  58605. * A simplifier interface for future simplification implementations
  58606. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  58607. */
  58608. export interface ISimplifier {
  58609. /**
  58610. * Simplification of a given mesh according to the given settings.
  58611. * Since this requires computation, it is assumed that the function runs async.
  58612. * @param settings The settings of the simplification, including quality and distance
  58613. * @param successCallback A callback that will be called after the mesh was simplified.
  58614. * @param errorCallback in case of an error, this callback will be called. optional.
  58615. */
  58616. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  58617. }
  58618. /**
  58619. * Expected simplification settings.
  58620. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  58621. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  58622. */
  58623. export interface ISimplificationSettings {
  58624. /**
  58625. * Gets or sets the expected quality
  58626. */
  58627. quality: number;
  58628. /**
  58629. * Gets or sets the distance when this optimized version should be used
  58630. */
  58631. distance: number;
  58632. /**
  58633. * Gets an already optimized mesh
  58634. */
  58635. optimizeMesh?: boolean;
  58636. }
  58637. /**
  58638. * Class used to specify simplification options
  58639. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  58640. */
  58641. export class SimplificationSettings implements ISimplificationSettings {
  58642. /** expected quality */
  58643. quality: number;
  58644. /** distance when this optimized version should be used */
  58645. distance: number;
  58646. /** already optimized mesh */
  58647. optimizeMesh?: boolean | undefined;
  58648. /**
  58649. * Creates a SimplificationSettings
  58650. * @param quality expected quality
  58651. * @param distance distance when this optimized version should be used
  58652. * @param optimizeMesh already optimized mesh
  58653. */
  58654. constructor(
  58655. /** expected quality */
  58656. quality: number,
  58657. /** distance when this optimized version should be used */
  58658. distance: number,
  58659. /** already optimized mesh */
  58660. optimizeMesh?: boolean | undefined);
  58661. }
  58662. /**
  58663. * Interface used to define a simplification task
  58664. */
  58665. export interface ISimplificationTask {
  58666. /**
  58667. * Array of settings
  58668. */
  58669. settings: Array<ISimplificationSettings>;
  58670. /**
  58671. * Simplification type
  58672. */
  58673. simplificationType: SimplificationType;
  58674. /**
  58675. * Mesh to simplify
  58676. */
  58677. mesh: Mesh;
  58678. /**
  58679. * Callback called on success
  58680. */
  58681. successCallback?: () => void;
  58682. /**
  58683. * Defines if parallel processing can be used
  58684. */
  58685. parallelProcessing: boolean;
  58686. }
  58687. /**
  58688. * Queue used to order the simplification tasks
  58689. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  58690. */
  58691. export class SimplificationQueue {
  58692. private _simplificationArray;
  58693. /**
  58694. * Gets a boolean indicating that the process is still running
  58695. */
  58696. running: boolean;
  58697. /**
  58698. * Creates a new queue
  58699. */
  58700. constructor();
  58701. /**
  58702. * Adds a new simplification task
  58703. * @param task defines a task to add
  58704. */
  58705. addTask(task: ISimplificationTask): void;
  58706. /**
  58707. * Execute next task
  58708. */
  58709. executeNext(): void;
  58710. /**
  58711. * Execute a simplification task
  58712. * @param task defines the task to run
  58713. */
  58714. runSimplification(task: ISimplificationTask): void;
  58715. private getSimplifier;
  58716. }
  58717. /**
  58718. * The implemented types of simplification
  58719. * At the moment only Quadratic Error Decimation is implemented
  58720. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  58721. */
  58722. export enum SimplificationType {
  58723. /** Quadratic error decimation */
  58724. QUADRATIC = 0
  58725. }
  58726. }
  58727. declare module BABYLON {
  58728. interface Scene {
  58729. /** @hidden (Backing field) */
  58730. _simplificationQueue: SimplificationQueue;
  58731. /**
  58732. * Gets or sets the simplification queue attached to the scene
  58733. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  58734. */
  58735. simplificationQueue: SimplificationQueue;
  58736. }
  58737. interface Mesh {
  58738. /**
  58739. * Simplify the mesh according to the given array of settings.
  58740. * Function will return immediately and will simplify async
  58741. * @param settings a collection of simplification settings
  58742. * @param parallelProcessing should all levels calculate parallel or one after the other
  58743. * @param simplificationType the type of simplification to run
  58744. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  58745. * @returns the current mesh
  58746. */
  58747. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  58748. }
  58749. /**
  58750. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  58751. * created in a scene
  58752. */
  58753. export class SimplicationQueueSceneComponent implements ISceneComponent {
  58754. /**
  58755. * The component name helpfull to identify the component in the list of scene components.
  58756. */
  58757. readonly name: string;
  58758. /**
  58759. * The scene the component belongs to.
  58760. */
  58761. scene: Scene;
  58762. /**
  58763. * Creates a new instance of the component for the given scene
  58764. * @param scene Defines the scene to register the component in
  58765. */
  58766. constructor(scene: Scene);
  58767. /**
  58768. * Registers the component in a given scene
  58769. */
  58770. register(): void;
  58771. /**
  58772. * Rebuilds the elements related to this component in case of
  58773. * context lost for instance.
  58774. */
  58775. rebuild(): void;
  58776. /**
  58777. * Disposes the component and the associated ressources
  58778. */
  58779. dispose(): void;
  58780. private _beforeCameraUpdate;
  58781. }
  58782. }
  58783. declare module BABYLON {
  58784. /**
  58785. * Navigation plugin interface to add navigation constrained by a navigation mesh
  58786. */
  58787. export interface INavigationEnginePlugin {
  58788. /**
  58789. * plugin name
  58790. */
  58791. name: string;
  58792. /**
  58793. * Creates a navigation mesh
  58794. * @param meshes array of all the geometry used to compute the navigatio mesh
  58795. * @param parameters bunch of parameters used to filter geometry
  58796. */
  58797. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  58798. /**
  58799. * Create a navigation mesh debug mesh
  58800. * @param scene is where the mesh will be added
  58801. * @returns debug display mesh
  58802. */
  58803. createDebugNavMesh(scene: Scene): Mesh;
  58804. /**
  58805. * Get a navigation mesh constrained position, closest to the parameter position
  58806. * @param position world position
  58807. * @returns the closest point to position constrained by the navigation mesh
  58808. */
  58809. getClosestPoint(position: Vector3): Vector3;
  58810. /**
  58811. * Get a navigation mesh constrained position, within a particular radius
  58812. * @param position world position
  58813. * @param maxRadius the maximum distance to the constrained world position
  58814. * @returns the closest point to position constrained by the navigation mesh
  58815. */
  58816. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  58817. /**
  58818. * Compute the final position from a segment made of destination-position
  58819. * @param position world position
  58820. * @param destination world position
  58821. * @returns the resulting point along the navmesh
  58822. */
  58823. moveAlong(position: Vector3, destination: Vector3): Vector3;
  58824. /**
  58825. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  58826. * @param start world position
  58827. * @param end world position
  58828. * @returns array containing world position composing the path
  58829. */
  58830. computePath(start: Vector3, end: Vector3): Vector3[];
  58831. /**
  58832. * If this plugin is supported
  58833. * @returns true if plugin is supported
  58834. */
  58835. isSupported(): boolean;
  58836. /**
  58837. * Create a new Crowd so you can add agents
  58838. * @param maxAgents the maximum agent count in the crowd
  58839. * @param maxAgentRadius the maximum radius an agent can have
  58840. * @param scene to attach the crowd to
  58841. * @returns the crowd you can add agents to
  58842. */
  58843. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  58844. /**
  58845. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  58846. * The queries will try to find a solution within those bounds
  58847. * default is (1,1,1)
  58848. * @param extent x,y,z value that define the extent around the queries point of reference
  58849. */
  58850. setDefaultQueryExtent(extent: Vector3): void;
  58851. /**
  58852. * Get the Bounding box extent specified by setDefaultQueryExtent
  58853. * @returns the box extent values
  58854. */
  58855. getDefaultQueryExtent(): Vector3;
  58856. /**
  58857. * Release all resources
  58858. */
  58859. dispose(): void;
  58860. }
  58861. /**
  58862. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  58863. */
  58864. export interface ICrowd {
  58865. /**
  58866. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  58867. * You can attach anything to that node. The node position is updated in the scene update tick.
  58868. * @param pos world position that will be constrained by the navigation mesh
  58869. * @param parameters agent parameters
  58870. * @param transform hooked to the agent that will be update by the scene
  58871. * @returns agent index
  58872. */
  58873. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  58874. /**
  58875. * Returns the agent position in world space
  58876. * @param index agent index returned by addAgent
  58877. * @returns world space position
  58878. */
  58879. getAgentPosition(index: number): Vector3;
  58880. /**
  58881. * Gets the agent velocity in world space
  58882. * @param index agent index returned by addAgent
  58883. * @returns world space velocity
  58884. */
  58885. getAgentVelocity(index: number): Vector3;
  58886. /**
  58887. * remove a particular agent previously created
  58888. * @param index agent index returned by addAgent
  58889. */
  58890. removeAgent(index: number): void;
  58891. /**
  58892. * get the list of all agents attached to this crowd
  58893. * @returns list of agent indices
  58894. */
  58895. getAgents(): number[];
  58896. /**
  58897. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  58898. * @param deltaTime in seconds
  58899. */
  58900. update(deltaTime: number): void;
  58901. /**
  58902. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  58903. * @param index agent index returned by addAgent
  58904. * @param destination targeted world position
  58905. */
  58906. agentGoto(index: number, destination: Vector3): void;
  58907. /**
  58908. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  58909. * The queries will try to find a solution within those bounds
  58910. * default is (1,1,1)
  58911. * @param extent x,y,z value that define the extent around the queries point of reference
  58912. */
  58913. setDefaultQueryExtent(extent: Vector3): void;
  58914. /**
  58915. * Get the Bounding box extent specified by setDefaultQueryExtent
  58916. * @returns the box extent values
  58917. */
  58918. getDefaultQueryExtent(): Vector3;
  58919. /**
  58920. * Release all resources
  58921. */
  58922. dispose(): void;
  58923. }
  58924. /**
  58925. * Configures an agent
  58926. */
  58927. export interface IAgentParameters {
  58928. /**
  58929. * Agent radius. [Limit: >= 0]
  58930. */
  58931. radius: number;
  58932. /**
  58933. * Agent height. [Limit: > 0]
  58934. */
  58935. height: number;
  58936. /**
  58937. * Maximum allowed acceleration. [Limit: >= 0]
  58938. */
  58939. maxAcceleration: number;
  58940. /**
  58941. * Maximum allowed speed. [Limit: >= 0]
  58942. */
  58943. maxSpeed: number;
  58944. /**
  58945. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  58946. */
  58947. collisionQueryRange: number;
  58948. /**
  58949. * The path visibility optimization range. [Limit: > 0]
  58950. */
  58951. pathOptimizationRange: number;
  58952. /**
  58953. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  58954. */
  58955. separationWeight: number;
  58956. }
  58957. /**
  58958. * Configures the navigation mesh creation
  58959. */
  58960. export interface INavMeshParameters {
  58961. /**
  58962. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  58963. */
  58964. cs: number;
  58965. /**
  58966. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  58967. */
  58968. ch: number;
  58969. /**
  58970. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  58971. */
  58972. walkableSlopeAngle: number;
  58973. /**
  58974. * Minimum floor to 'ceiling' height that will still allow the floor area to
  58975. * be considered walkable. [Limit: >= 3] [Units: vx]
  58976. */
  58977. walkableHeight: number;
  58978. /**
  58979. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  58980. */
  58981. walkableClimb: number;
  58982. /**
  58983. * The distance to erode/shrink the walkable area of the heightfield away from
  58984. * obstructions. [Limit: >=0] [Units: vx]
  58985. */
  58986. walkableRadius: number;
  58987. /**
  58988. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  58989. */
  58990. maxEdgeLen: number;
  58991. /**
  58992. * The maximum distance a simplfied contour's border edges should deviate
  58993. * the original raw contour. [Limit: >=0] [Units: vx]
  58994. */
  58995. maxSimplificationError: number;
  58996. /**
  58997. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  58998. */
  58999. minRegionArea: number;
  59000. /**
  59001. * Any regions with a span count smaller than this value will, if possible,
  59002. * be merged with larger regions. [Limit: >=0] [Units: vx]
  59003. */
  59004. mergeRegionArea: number;
  59005. /**
  59006. * The maximum number of vertices allowed for polygons generated during the
  59007. * contour to polygon conversion process. [Limit: >= 3]
  59008. */
  59009. maxVertsPerPoly: number;
  59010. /**
  59011. * Sets the sampling distance to use when generating the detail mesh.
  59012. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  59013. */
  59014. detailSampleDist: number;
  59015. /**
  59016. * The maximum distance the detail mesh surface should deviate from heightfield
  59017. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  59018. */
  59019. detailSampleMaxError: number;
  59020. }
  59021. }
  59022. declare module BABYLON {
  59023. /**
  59024. * RecastJS navigation plugin
  59025. */
  59026. export class RecastJSPlugin implements INavigationEnginePlugin {
  59027. /**
  59028. * Reference to the Recast library
  59029. */
  59030. bjsRECAST: any;
  59031. /**
  59032. * plugin name
  59033. */
  59034. name: string;
  59035. /**
  59036. * the first navmesh created. We might extend this to support multiple navmeshes
  59037. */
  59038. navMesh: any;
  59039. /**
  59040. * Initializes the recastJS plugin
  59041. * @param recastInjection can be used to inject your own recast reference
  59042. */
  59043. constructor(recastInjection?: any);
  59044. /**
  59045. * Creates a navigation mesh
  59046. * @param meshes array of all the geometry used to compute the navigatio mesh
  59047. * @param parameters bunch of parameters used to filter geometry
  59048. */
  59049. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  59050. /**
  59051. * Create a navigation mesh debug mesh
  59052. * @param scene is where the mesh will be added
  59053. * @returns debug display mesh
  59054. */
  59055. createDebugNavMesh(scene: Scene): Mesh;
  59056. /**
  59057. * Get a navigation mesh constrained position, closest to the parameter position
  59058. * @param position world position
  59059. * @returns the closest point to position constrained by the navigation mesh
  59060. */
  59061. getClosestPoint(position: Vector3): Vector3;
  59062. /**
  59063. * Get a navigation mesh constrained position, within a particular radius
  59064. * @param position world position
  59065. * @param maxRadius the maximum distance to the constrained world position
  59066. * @returns the closest point to position constrained by the navigation mesh
  59067. */
  59068. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  59069. /**
  59070. * Compute the final position from a segment made of destination-position
  59071. * @param position world position
  59072. * @param destination world position
  59073. * @returns the resulting point along the navmesh
  59074. */
  59075. moveAlong(position: Vector3, destination: Vector3): Vector3;
  59076. /**
  59077. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  59078. * @param start world position
  59079. * @param end world position
  59080. * @returns array containing world position composing the path
  59081. */
  59082. computePath(start: Vector3, end: Vector3): Vector3[];
  59083. /**
  59084. * Create a new Crowd so you can add agents
  59085. * @param maxAgents the maximum agent count in the crowd
  59086. * @param maxAgentRadius the maximum radius an agent can have
  59087. * @param scene to attach the crowd to
  59088. * @returns the crowd you can add agents to
  59089. */
  59090. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  59091. /**
  59092. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  59093. * The queries will try to find a solution within those bounds
  59094. * default is (1,1,1)
  59095. * @param extent x,y,z value that define the extent around the queries point of reference
  59096. */
  59097. setDefaultQueryExtent(extent: Vector3): void;
  59098. /**
  59099. * Get the Bounding box extent specified by setDefaultQueryExtent
  59100. * @returns the box extent values
  59101. */
  59102. getDefaultQueryExtent(): Vector3;
  59103. /**
  59104. * Disposes
  59105. */
  59106. dispose(): void;
  59107. /**
  59108. * If this plugin is supported
  59109. * @returns true if plugin is supported
  59110. */
  59111. isSupported(): boolean;
  59112. }
  59113. /**
  59114. * Recast detour crowd implementation
  59115. */
  59116. export class RecastJSCrowd implements ICrowd {
  59117. /**
  59118. * Recast/detour plugin
  59119. */
  59120. bjsRECASTPlugin: RecastJSPlugin;
  59121. /**
  59122. * Link to the detour crowd
  59123. */
  59124. recastCrowd: any;
  59125. /**
  59126. * One transform per agent
  59127. */
  59128. transforms: TransformNode[];
  59129. /**
  59130. * All agents created
  59131. */
  59132. agents: number[];
  59133. /**
  59134. * Link to the scene is kept to unregister the crowd from the scene
  59135. */
  59136. private _scene;
  59137. /**
  59138. * Observer for crowd updates
  59139. */
  59140. private _onBeforeAnimationsObserver;
  59141. /**
  59142. * Constructor
  59143. * @param plugin recastJS plugin
  59144. * @param maxAgents the maximum agent count in the crowd
  59145. * @param maxAgentRadius the maximum radius an agent can have
  59146. * @param scene to attach the crowd to
  59147. * @returns the crowd you can add agents to
  59148. */
  59149. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  59150. /**
  59151. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  59152. * You can attach anything to that node. The node position is updated in the scene update tick.
  59153. * @param pos world position that will be constrained by the navigation mesh
  59154. * @param parameters agent parameters
  59155. * @param transform hooked to the agent that will be update by the scene
  59156. * @returns agent index
  59157. */
  59158. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  59159. /**
  59160. * Returns the agent position in world space
  59161. * @param index agent index returned by addAgent
  59162. * @returns world space position
  59163. */
  59164. getAgentPosition(index: number): Vector3;
  59165. /**
  59166. * Returns the agent velocity in world space
  59167. * @param index agent index returned by addAgent
  59168. * @returns world space velocity
  59169. */
  59170. getAgentVelocity(index: number): Vector3;
  59171. /**
  59172. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  59173. * @param index agent index returned by addAgent
  59174. * @param destination targeted world position
  59175. */
  59176. agentGoto(index: number, destination: Vector3): void;
  59177. /**
  59178. * remove a particular agent previously created
  59179. * @param index agent index returned by addAgent
  59180. */
  59181. removeAgent(index: number): void;
  59182. /**
  59183. * get the list of all agents attached to this crowd
  59184. * @returns list of agent indices
  59185. */
  59186. getAgents(): number[];
  59187. /**
  59188. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  59189. * @param deltaTime in seconds
  59190. */
  59191. update(deltaTime: number): void;
  59192. /**
  59193. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  59194. * The queries will try to find a solution within those bounds
  59195. * default is (1,1,1)
  59196. * @param extent x,y,z value that define the extent around the queries point of reference
  59197. */
  59198. setDefaultQueryExtent(extent: Vector3): void;
  59199. /**
  59200. * Get the Bounding box extent specified by setDefaultQueryExtent
  59201. * @returns the box extent values
  59202. */
  59203. getDefaultQueryExtent(): Vector3;
  59204. /**
  59205. * Release all resources
  59206. */
  59207. dispose(): void;
  59208. }
  59209. }
  59210. declare module BABYLON {
  59211. /**
  59212. * Class used to enable access to IndexedDB
  59213. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  59214. */
  59215. export class Database implements IOfflineProvider {
  59216. private _callbackManifestChecked;
  59217. private _currentSceneUrl;
  59218. private _db;
  59219. private _enableSceneOffline;
  59220. private _enableTexturesOffline;
  59221. private _manifestVersionFound;
  59222. private _mustUpdateRessources;
  59223. private _hasReachedQuota;
  59224. private _isSupported;
  59225. private _idbFactory;
  59226. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  59227. private static IsUASupportingBlobStorage;
  59228. /**
  59229. * Gets a boolean indicating if Database storate is enabled (off by default)
  59230. */
  59231. static IDBStorageEnabled: boolean;
  59232. /**
  59233. * Gets a boolean indicating if scene must be saved in the database
  59234. */
  59235. readonly enableSceneOffline: boolean;
  59236. /**
  59237. * Gets a boolean indicating if textures must be saved in the database
  59238. */
  59239. readonly enableTexturesOffline: boolean;
  59240. /**
  59241. * Creates a new Database
  59242. * @param urlToScene defines the url to load the scene
  59243. * @param callbackManifestChecked defines the callback to use when manifest is checked
  59244. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  59245. */
  59246. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  59247. private static _ParseURL;
  59248. private static _ReturnFullUrlLocation;
  59249. private _checkManifestFile;
  59250. /**
  59251. * Open the database and make it available
  59252. * @param successCallback defines the callback to call on success
  59253. * @param errorCallback defines the callback to call on error
  59254. */
  59255. open(successCallback: () => void, errorCallback: () => void): void;
  59256. /**
  59257. * Loads an image from the database
  59258. * @param url defines the url to load from
  59259. * @param image defines the target DOM image
  59260. */
  59261. loadImage(url: string, image: HTMLImageElement): void;
  59262. private _loadImageFromDBAsync;
  59263. private _saveImageIntoDBAsync;
  59264. private _checkVersionFromDB;
  59265. private _loadVersionFromDBAsync;
  59266. private _saveVersionIntoDBAsync;
  59267. /**
  59268. * Loads a file from database
  59269. * @param url defines the URL to load from
  59270. * @param sceneLoaded defines a callback to call on success
  59271. * @param progressCallBack defines a callback to call when progress changed
  59272. * @param errorCallback defines a callback to call on error
  59273. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  59274. */
  59275. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  59276. private _loadFileAsync;
  59277. private _saveFileAsync;
  59278. /**
  59279. * Validates if xhr data is correct
  59280. * @param xhr defines the request to validate
  59281. * @param dataType defines the expected data type
  59282. * @returns true if data is correct
  59283. */
  59284. private static _ValidateXHRData;
  59285. }
  59286. }
  59287. declare module BABYLON {
  59288. /** @hidden */
  59289. export var gpuUpdateParticlesPixelShader: {
  59290. name: string;
  59291. shader: string;
  59292. };
  59293. }
  59294. declare module BABYLON {
  59295. /** @hidden */
  59296. export var gpuUpdateParticlesVertexShader: {
  59297. name: string;
  59298. shader: string;
  59299. };
  59300. }
  59301. declare module BABYLON {
  59302. /** @hidden */
  59303. export var clipPlaneFragmentDeclaration2: {
  59304. name: string;
  59305. shader: string;
  59306. };
  59307. }
  59308. declare module BABYLON {
  59309. /** @hidden */
  59310. export var gpuRenderParticlesPixelShader: {
  59311. name: string;
  59312. shader: string;
  59313. };
  59314. }
  59315. declare module BABYLON {
  59316. /** @hidden */
  59317. export var clipPlaneVertexDeclaration2: {
  59318. name: string;
  59319. shader: string;
  59320. };
  59321. }
  59322. declare module BABYLON {
  59323. /** @hidden */
  59324. export var gpuRenderParticlesVertexShader: {
  59325. name: string;
  59326. shader: string;
  59327. };
  59328. }
  59329. declare module BABYLON {
  59330. /**
  59331. * This represents a GPU particle system in Babylon
  59332. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  59333. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  59334. */
  59335. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  59336. /**
  59337. * The layer mask we are rendering the particles through.
  59338. */
  59339. layerMask: number;
  59340. private _capacity;
  59341. private _activeCount;
  59342. private _currentActiveCount;
  59343. private _accumulatedCount;
  59344. private _renderEffect;
  59345. private _updateEffect;
  59346. private _buffer0;
  59347. private _buffer1;
  59348. private _spriteBuffer;
  59349. private _updateVAO;
  59350. private _renderVAO;
  59351. private _targetIndex;
  59352. private _sourceBuffer;
  59353. private _targetBuffer;
  59354. private _engine;
  59355. private _currentRenderId;
  59356. private _started;
  59357. private _stopped;
  59358. private _timeDelta;
  59359. private _randomTexture;
  59360. private _randomTexture2;
  59361. private _attributesStrideSize;
  59362. private _updateEffectOptions;
  59363. private _randomTextureSize;
  59364. private _actualFrame;
  59365. private readonly _rawTextureWidth;
  59366. /**
  59367. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  59368. */
  59369. static readonly IsSupported: boolean;
  59370. /**
  59371. * An event triggered when the system is disposed.
  59372. */
  59373. onDisposeObservable: Observable<GPUParticleSystem>;
  59374. /**
  59375. * Gets the maximum number of particles active at the same time.
  59376. * @returns The max number of active particles.
  59377. */
  59378. getCapacity(): number;
  59379. /**
  59380. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  59381. * to override the particles.
  59382. */
  59383. forceDepthWrite: boolean;
  59384. /**
  59385. * Gets or set the number of active particles
  59386. */
  59387. activeParticleCount: number;
  59388. private _preWarmDone;
  59389. /**
  59390. * Is this system ready to be used/rendered
  59391. * @return true if the system is ready
  59392. */
  59393. isReady(): boolean;
  59394. /**
  59395. * Gets if the system has been started. (Note: this will still be true after stop is called)
  59396. * @returns True if it has been started, otherwise false.
  59397. */
  59398. isStarted(): boolean;
  59399. /**
  59400. * Starts the particle system and begins to emit
  59401. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  59402. */
  59403. start(delay?: number): void;
  59404. /**
  59405. * Stops the particle system.
  59406. */
  59407. stop(): void;
  59408. /**
  59409. * Remove all active particles
  59410. */
  59411. reset(): void;
  59412. /**
  59413. * Returns the string "GPUParticleSystem"
  59414. * @returns a string containing the class name
  59415. */
  59416. getClassName(): string;
  59417. private _colorGradientsTexture;
  59418. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  59419. /**
  59420. * Adds a new color gradient
  59421. * @param gradient defines the gradient to use (between 0 and 1)
  59422. * @param color1 defines the color to affect to the specified gradient
  59423. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  59424. * @returns the current particle system
  59425. */
  59426. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  59427. /**
  59428. * Remove a specific color gradient
  59429. * @param gradient defines the gradient to remove
  59430. * @returns the current particle system
  59431. */
  59432. removeColorGradient(gradient: number): GPUParticleSystem;
  59433. private _angularSpeedGradientsTexture;
  59434. private _sizeGradientsTexture;
  59435. private _velocityGradientsTexture;
  59436. private _limitVelocityGradientsTexture;
  59437. private _dragGradientsTexture;
  59438. private _addFactorGradient;
  59439. /**
  59440. * Adds a new size gradient
  59441. * @param gradient defines the gradient to use (between 0 and 1)
  59442. * @param factor defines the size factor to affect to the specified gradient
  59443. * @returns the current particle system
  59444. */
  59445. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  59446. /**
  59447. * Remove a specific size gradient
  59448. * @param gradient defines the gradient to remove
  59449. * @returns the current particle system
  59450. */
  59451. removeSizeGradient(gradient: number): GPUParticleSystem;
  59452. /**
  59453. * Adds a new angular speed gradient
  59454. * @param gradient defines the gradient to use (between 0 and 1)
  59455. * @param factor defines the angular speed to affect to the specified gradient
  59456. * @returns the current particle system
  59457. */
  59458. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  59459. /**
  59460. * Remove a specific angular speed gradient
  59461. * @param gradient defines the gradient to remove
  59462. * @returns the current particle system
  59463. */
  59464. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  59465. /**
  59466. * Adds a new velocity gradient
  59467. * @param gradient defines the gradient to use (between 0 and 1)
  59468. * @param factor defines the velocity to affect to the specified gradient
  59469. * @returns the current particle system
  59470. */
  59471. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  59472. /**
  59473. * Remove a specific velocity gradient
  59474. * @param gradient defines the gradient to remove
  59475. * @returns the current particle system
  59476. */
  59477. removeVelocityGradient(gradient: number): GPUParticleSystem;
  59478. /**
  59479. * Adds a new limit velocity gradient
  59480. * @param gradient defines the gradient to use (between 0 and 1)
  59481. * @param factor defines the limit velocity value to affect to the specified gradient
  59482. * @returns the current particle system
  59483. */
  59484. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  59485. /**
  59486. * Remove a specific limit velocity gradient
  59487. * @param gradient defines the gradient to remove
  59488. * @returns the current particle system
  59489. */
  59490. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  59491. /**
  59492. * Adds a new drag gradient
  59493. * @param gradient defines the gradient to use (between 0 and 1)
  59494. * @param factor defines the drag value to affect to the specified gradient
  59495. * @returns the current particle system
  59496. */
  59497. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  59498. /**
  59499. * Remove a specific drag gradient
  59500. * @param gradient defines the gradient to remove
  59501. * @returns the current particle system
  59502. */
  59503. removeDragGradient(gradient: number): GPUParticleSystem;
  59504. /**
  59505. * Not supported by GPUParticleSystem
  59506. * @param gradient defines the gradient to use (between 0 and 1)
  59507. * @param factor defines the emit rate value to affect to the specified gradient
  59508. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  59509. * @returns the current particle system
  59510. */
  59511. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  59512. /**
  59513. * Not supported by GPUParticleSystem
  59514. * @param gradient defines the gradient to remove
  59515. * @returns the current particle system
  59516. */
  59517. removeEmitRateGradient(gradient: number): IParticleSystem;
  59518. /**
  59519. * Not supported by GPUParticleSystem
  59520. * @param gradient defines the gradient to use (between 0 and 1)
  59521. * @param factor defines the start size value to affect to the specified gradient
  59522. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  59523. * @returns the current particle system
  59524. */
  59525. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  59526. /**
  59527. * Not supported by GPUParticleSystem
  59528. * @param gradient defines the gradient to remove
  59529. * @returns the current particle system
  59530. */
  59531. removeStartSizeGradient(gradient: number): IParticleSystem;
  59532. /**
  59533. * Not supported by GPUParticleSystem
  59534. * @param gradient defines the gradient to use (between 0 and 1)
  59535. * @param min defines the color remap minimal range
  59536. * @param max defines the color remap maximal range
  59537. * @returns the current particle system
  59538. */
  59539. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  59540. /**
  59541. * Not supported by GPUParticleSystem
  59542. * @param gradient defines the gradient to remove
  59543. * @returns the current particle system
  59544. */
  59545. removeColorRemapGradient(): IParticleSystem;
  59546. /**
  59547. * Not supported by GPUParticleSystem
  59548. * @param gradient defines the gradient to use (between 0 and 1)
  59549. * @param min defines the alpha remap minimal range
  59550. * @param max defines the alpha remap maximal range
  59551. * @returns the current particle system
  59552. */
  59553. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  59554. /**
  59555. * Not supported by GPUParticleSystem
  59556. * @param gradient defines the gradient to remove
  59557. * @returns the current particle system
  59558. */
  59559. removeAlphaRemapGradient(): IParticleSystem;
  59560. /**
  59561. * Not supported by GPUParticleSystem
  59562. * @param gradient defines the gradient to use (between 0 and 1)
  59563. * @param color defines the color to affect to the specified gradient
  59564. * @returns the current particle system
  59565. */
  59566. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  59567. /**
  59568. * Not supported by GPUParticleSystem
  59569. * @param gradient defines the gradient to remove
  59570. * @returns the current particle system
  59571. */
  59572. removeRampGradient(): IParticleSystem;
  59573. /**
  59574. * Not supported by GPUParticleSystem
  59575. * @returns the list of ramp gradients
  59576. */
  59577. getRampGradients(): Nullable<Array<Color3Gradient>>;
  59578. /**
  59579. * Not supported by GPUParticleSystem
  59580. * Gets or sets a boolean indicating that ramp gradients must be used
  59581. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  59582. */
  59583. useRampGradients: boolean;
  59584. /**
  59585. * Not supported by GPUParticleSystem
  59586. * @param gradient defines the gradient to use (between 0 and 1)
  59587. * @param factor defines the life time factor to affect to the specified gradient
  59588. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  59589. * @returns the current particle system
  59590. */
  59591. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  59592. /**
  59593. * Not supported by GPUParticleSystem
  59594. * @param gradient defines the gradient to remove
  59595. * @returns the current particle system
  59596. */
  59597. removeLifeTimeGradient(gradient: number): IParticleSystem;
  59598. /**
  59599. * Instantiates a GPU particle system.
  59600. * 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.
  59601. * @param name The name of the particle system
  59602. * @param options The options used to create the system
  59603. * @param scene The scene the particle system belongs to
  59604. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  59605. */
  59606. constructor(name: string, options: Partial<{
  59607. capacity: number;
  59608. randomTextureSize: number;
  59609. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  59610. protected _reset(): void;
  59611. private _createUpdateVAO;
  59612. private _createRenderVAO;
  59613. private _initialize;
  59614. /** @hidden */
  59615. _recreateUpdateEffect(): void;
  59616. /** @hidden */
  59617. _recreateRenderEffect(): void;
  59618. /**
  59619. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  59620. * @param preWarm defines if we are in the pre-warmimg phase
  59621. */
  59622. animate(preWarm?: boolean): void;
  59623. private _createFactorGradientTexture;
  59624. private _createSizeGradientTexture;
  59625. private _createAngularSpeedGradientTexture;
  59626. private _createVelocityGradientTexture;
  59627. private _createLimitVelocityGradientTexture;
  59628. private _createDragGradientTexture;
  59629. private _createColorGradientTexture;
  59630. /**
  59631. * Renders the particle system in its current state
  59632. * @param preWarm defines if the system should only update the particles but not render them
  59633. * @returns the current number of particles
  59634. */
  59635. render(preWarm?: boolean): number;
  59636. /**
  59637. * Rebuilds the particle system
  59638. */
  59639. rebuild(): void;
  59640. private _releaseBuffers;
  59641. private _releaseVAOs;
  59642. /**
  59643. * Disposes the particle system and free the associated resources
  59644. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  59645. */
  59646. dispose(disposeTexture?: boolean): void;
  59647. /**
  59648. * Clones the particle system.
  59649. * @param name The name of the cloned object
  59650. * @param newEmitter The new emitter to use
  59651. * @returns the cloned particle system
  59652. */
  59653. clone(name: string, newEmitter: any): GPUParticleSystem;
  59654. /**
  59655. * Serializes the particle system to a JSON object.
  59656. * @returns the JSON object
  59657. */
  59658. serialize(): any;
  59659. /**
  59660. * Parses a JSON object to create a GPU particle system.
  59661. * @param parsedParticleSystem The JSON object to parse
  59662. * @param scene The scene to create the particle system in
  59663. * @param rootUrl The root url to use to load external dependencies like texture
  59664. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  59665. * @returns the parsed GPU particle system
  59666. */
  59667. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  59668. }
  59669. }
  59670. declare module BABYLON {
  59671. /**
  59672. * Represents a set of particle systems working together to create a specific effect
  59673. */
  59674. export class ParticleSystemSet implements IDisposable {
  59675. /**
  59676. * Gets or sets base Assets URL
  59677. */
  59678. static BaseAssetsUrl: string;
  59679. private _emitterCreationOptions;
  59680. private _emitterNode;
  59681. /**
  59682. * Gets the particle system list
  59683. */
  59684. systems: IParticleSystem[];
  59685. /**
  59686. * Gets the emitter node used with this set
  59687. */
  59688. readonly emitterNode: Nullable<TransformNode>;
  59689. /**
  59690. * Creates a new emitter mesh as a sphere
  59691. * @param options defines the options used to create the sphere
  59692. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  59693. * @param scene defines the hosting scene
  59694. */
  59695. setEmitterAsSphere(options: {
  59696. diameter: number;
  59697. segments: number;
  59698. color: Color3;
  59699. }, renderingGroupId: number, scene: Scene): void;
  59700. /**
  59701. * Starts all particle systems of the set
  59702. * @param emitter defines an optional mesh to use as emitter for the particle systems
  59703. */
  59704. start(emitter?: AbstractMesh): void;
  59705. /**
  59706. * Release all associated resources
  59707. */
  59708. dispose(): void;
  59709. /**
  59710. * Serialize the set into a JSON compatible object
  59711. * @returns a JSON compatible representation of the set
  59712. */
  59713. serialize(): any;
  59714. /**
  59715. * Parse a new ParticleSystemSet from a serialized source
  59716. * @param data defines a JSON compatible representation of the set
  59717. * @param scene defines the hosting scene
  59718. * @param gpu defines if we want GPU particles or CPU particles
  59719. * @returns a new ParticleSystemSet
  59720. */
  59721. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  59722. }
  59723. }
  59724. declare module BABYLON {
  59725. /**
  59726. * This class is made for on one-liner static method to help creating particle system set.
  59727. */
  59728. export class ParticleHelper {
  59729. /**
  59730. * Gets or sets base Assets URL
  59731. */
  59732. static BaseAssetsUrl: string;
  59733. /**
  59734. * Create a default particle system that you can tweak
  59735. * @param emitter defines the emitter to use
  59736. * @param capacity defines the system capacity (default is 500 particles)
  59737. * @param scene defines the hosting scene
  59738. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  59739. * @returns the new Particle system
  59740. */
  59741. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  59742. /**
  59743. * This is the main static method (one-liner) of this helper to create different particle systems
  59744. * @param type This string represents the type to the particle system to create
  59745. * @param scene The scene where the particle system should live
  59746. * @param gpu If the system will use gpu
  59747. * @returns the ParticleSystemSet created
  59748. */
  59749. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  59750. /**
  59751. * Static function used to export a particle system to a ParticleSystemSet variable.
  59752. * Please note that the emitter shape is not exported
  59753. * @param systems defines the particle systems to export
  59754. * @returns the created particle system set
  59755. */
  59756. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  59757. }
  59758. }
  59759. declare module BABYLON {
  59760. interface Engine {
  59761. /**
  59762. * Create an effect to use with particle systems.
  59763. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  59764. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  59765. * @param uniformsNames defines a list of attribute names
  59766. * @param samplers defines an array of string used to represent textures
  59767. * @param defines defines the string containing the defines to use to compile the shaders
  59768. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  59769. * @param onCompiled defines a function to call when the effect creation is successful
  59770. * @param onError defines a function to call when the effect creation has failed
  59771. * @returns the new Effect
  59772. */
  59773. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  59774. }
  59775. interface Mesh {
  59776. /**
  59777. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  59778. * @returns an array of IParticleSystem
  59779. */
  59780. getEmittedParticleSystems(): IParticleSystem[];
  59781. /**
  59782. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  59783. * @returns an array of IParticleSystem
  59784. */
  59785. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  59786. }
  59787. /**
  59788. * @hidden
  59789. */
  59790. export var _IDoNeedToBeInTheBuild: number;
  59791. }
  59792. declare module BABYLON {
  59793. /** Defines the 4 color options */
  59794. export enum PointColor {
  59795. /** color value */
  59796. Color = 2,
  59797. /** uv value */
  59798. UV = 1,
  59799. /** random value */
  59800. Random = 0,
  59801. /** stated value */
  59802. Stated = 3
  59803. }
  59804. /**
  59805. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  59806. * As it is just a mesh, the PointCloudSystem has all the same properties as any other BJS mesh : not more, not less. It can be scaled, rotated, translated, enlighted, textured, moved, etc.
  59807. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  59808. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  59809. *
  59810. * Full documentation here : TO BE ENTERED
  59811. */
  59812. export class PointsCloudSystem implements IDisposable {
  59813. /**
  59814. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  59815. * Example : var p = SPS.particles[i];
  59816. */
  59817. particles: CloudPoint[];
  59818. /**
  59819. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  59820. */
  59821. nbParticles: number;
  59822. /**
  59823. * This a counter for your own usage. It's not set by any SPS functions.
  59824. */
  59825. counter: number;
  59826. /**
  59827. * The PCS name. This name is also given to the underlying mesh.
  59828. */
  59829. name: string;
  59830. /**
  59831. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  59832. */
  59833. mesh: Mesh;
  59834. /**
  59835. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  59836. * Please read :
  59837. */
  59838. vars: any;
  59839. /**
  59840. * @hidden
  59841. */
  59842. _size: number;
  59843. private _scene;
  59844. private _promises;
  59845. private _positions;
  59846. private _indices;
  59847. private _normals;
  59848. private _colors;
  59849. private _uvs;
  59850. private _indices32;
  59851. private _positions32;
  59852. private _colors32;
  59853. private _uvs32;
  59854. private _updatable;
  59855. private _isVisibilityBoxLocked;
  59856. private _alwaysVisible;
  59857. private _groups;
  59858. private _groupCounter;
  59859. private _computeParticleColor;
  59860. private _computeParticleTexture;
  59861. private _computeParticleRotation;
  59862. private _computeBoundingBox;
  59863. private _isReady;
  59864. /**
  59865. * Creates a PCS (Points Cloud System) object
  59866. * @param name (String) is the PCS name, this will be the underlying mesh name
  59867. * @param pointSize (number) is the size for each point
  59868. * @param scene (Scene) is the scene in which the PCS is added
  59869. * @param options defines the options of the PCS e.g.
  59870. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  59871. */
  59872. constructor(name: string, pointSize: number, scene: Scene, options?: {
  59873. updatable?: boolean;
  59874. });
  59875. /**
  59876. * Builds the PCS underlying mesh. Returns a standard Mesh.
  59877. * If no points were added to the PCS, the returned mesh is just a single point.
  59878. * @returns a promise for the created mesh
  59879. */
  59880. buildMeshAsync(): Promise<Mesh>;
  59881. /**
  59882. * @hidden
  59883. */
  59884. private _buildMesh;
  59885. private _addParticle;
  59886. private _randomUnitVector;
  59887. private _getColorIndicesForCoord;
  59888. private _setPointsColorOrUV;
  59889. private _colorFromTexture;
  59890. private _calculateDensity;
  59891. /**
  59892. * Adds points to the PCS in random positions within a unit sphere
  59893. * @param nb (positive integer) the number of particles to be created from this model
  59894. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  59895. * @returns the number of groups in the system
  59896. */
  59897. addPoints(nb: number, pointFunction?: any): number;
  59898. /**
  59899. * Adds points to the PCS from the surface of the model shape
  59900. * @param mesh is any Mesh object that will be used as a surface model for the points
  59901. * @param nb (positive integer) the number of particles to be created from this model
  59902. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  59903. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  59904. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  59905. * @returns the number of groups in the system
  59906. */
  59907. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  59908. /**
  59909. * Adds points to the PCS inside the model shape
  59910. * @param mesh is any Mesh object that will be used as a surface model for the points
  59911. * @param nb (positive integer) the number of particles to be created from this model
  59912. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  59913. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  59914. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  59915. * @returns the number of groups in the system
  59916. */
  59917. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  59918. /**
  59919. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  59920. * This method calls `updateParticle()` for each particle of the SPS.
  59921. * For an animated SPS, it is usually called within the render loop.
  59922. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  59923. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  59924. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  59925. * @returns the PCS.
  59926. */
  59927. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  59928. /**
  59929. * Disposes the PCS.
  59930. */
  59931. dispose(): void;
  59932. /**
  59933. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  59934. * doc :
  59935. * @returns the PCS.
  59936. */
  59937. refreshVisibleSize(): PointsCloudSystem;
  59938. /**
  59939. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  59940. * @param size the size (float) of the visibility box
  59941. * note : this doesn't lock the PCS mesh bounding box.
  59942. * doc :
  59943. */
  59944. setVisibilityBox(size: number): void;
  59945. /**
  59946. * Gets whether the PCS is always visible or not
  59947. * doc :
  59948. */
  59949. /**
  59950. * Sets the PCS as always visible or not
  59951. * doc :
  59952. */
  59953. isAlwaysVisible: boolean;
  59954. /**
  59955. * Tells to `setParticles()` to compute the particle rotations or not
  59956. * Default value : false. The PCS is faster when it's set to false
  59957. * Note : particle rotations are only applied to parent particles
  59958. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  59959. */
  59960. computeParticleRotation: boolean;
  59961. /**
  59962. * Tells to `setParticles()` to compute the particle colors or not.
  59963. * Default value : true. The PCS is faster when it's set to false.
  59964. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  59965. */
  59966. /**
  59967. * Gets if `setParticles()` computes the particle colors or not.
  59968. * Default value : false. The PCS is faster when it's set to false.
  59969. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  59970. */
  59971. computeParticleColor: boolean;
  59972. /**
  59973. * Gets if `setParticles()` computes the particle textures or not.
  59974. * Default value : false. The PCS is faster when it's set to false.
  59975. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  59976. */
  59977. computeParticleTexture: boolean;
  59978. /**
  59979. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  59980. */
  59981. /**
  59982. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  59983. */
  59984. computeBoundingBox: boolean;
  59985. /**
  59986. * This function does nothing. It may be overwritten to set all the particle first values.
  59987. * The PCS doesn't call this function, you may have to call it by your own.
  59988. * doc :
  59989. */
  59990. initParticles(): void;
  59991. /**
  59992. * This function does nothing. It may be overwritten to recycle a particle
  59993. * The PCS doesn't call this function, you can to call it
  59994. * doc :
  59995. * @param particle The particle to recycle
  59996. * @returns the recycled particle
  59997. */
  59998. recycleParticle(particle: CloudPoint): CloudPoint;
  59999. /**
  60000. * Updates a particle : this function should be overwritten by the user.
  60001. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  60002. * doc :
  60003. * @example : just set a particle position or velocity and recycle conditions
  60004. * @param particle The particle to update
  60005. * @returns the updated particle
  60006. */
  60007. updateParticle(particle: CloudPoint): CloudPoint;
  60008. /**
  60009. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  60010. * This does nothing and may be overwritten by the user.
  60011. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  60012. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  60013. * @param update the boolean update value actually passed to setParticles()
  60014. */
  60015. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  60016. /**
  60017. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  60018. * This will be passed three parameters.
  60019. * This does nothing and may be overwritten by the user.
  60020. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  60021. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  60022. * @param update the boolean update value actually passed to setParticles()
  60023. */
  60024. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  60025. }
  60026. }
  60027. declare module BABYLON {
  60028. /**
  60029. * Represents one particle of a points cloud system.
  60030. */
  60031. export class CloudPoint {
  60032. /**
  60033. * particle global index
  60034. */
  60035. idx: number;
  60036. /**
  60037. * The color of the particle
  60038. */
  60039. color: Nullable<Color4>;
  60040. /**
  60041. * The world space position of the particle.
  60042. */
  60043. position: Vector3;
  60044. /**
  60045. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  60046. */
  60047. rotation: Vector3;
  60048. /**
  60049. * The world space rotation quaternion of the particle.
  60050. */
  60051. rotationQuaternion: Nullable<Quaternion>;
  60052. /**
  60053. * The uv of the particle.
  60054. */
  60055. uv: Nullable<Vector2>;
  60056. /**
  60057. * The current speed of the particle.
  60058. */
  60059. velocity: Vector3;
  60060. /**
  60061. * The pivot point in the particle local space.
  60062. */
  60063. pivot: Vector3;
  60064. /**
  60065. * Must the particle be translated from its pivot point in its local space ?
  60066. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  60067. * Default : false
  60068. */
  60069. translateFromPivot: boolean;
  60070. /**
  60071. * Index of this particle in the global "positions" array (Internal use)
  60072. * @hidden
  60073. */
  60074. _pos: number;
  60075. /**
  60076. * @hidden Index of this particle in the global "indices" array (Internal use)
  60077. */
  60078. _ind: number;
  60079. /**
  60080. * Group this particle belongs to
  60081. */
  60082. _group: PointsGroup;
  60083. /**
  60084. * Group id of this particle
  60085. */
  60086. groupId: number;
  60087. /**
  60088. * Index of the particle in its group id (Internal use)
  60089. */
  60090. idxInGroup: number;
  60091. /**
  60092. * @hidden Particle BoundingInfo object (Internal use)
  60093. */
  60094. _boundingInfo: BoundingInfo;
  60095. /**
  60096. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  60097. */
  60098. _pcs: PointsCloudSystem;
  60099. /**
  60100. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  60101. */
  60102. _stillInvisible: boolean;
  60103. /**
  60104. * @hidden Last computed particle rotation matrix
  60105. */
  60106. _rotationMatrix: number[];
  60107. /**
  60108. * Parent particle Id, if any.
  60109. * Default null.
  60110. */
  60111. parentId: Nullable<number>;
  60112. /**
  60113. * @hidden Internal global position in the PCS.
  60114. */
  60115. _globalPosition: Vector3;
  60116. /**
  60117. * Creates a Point Cloud object.
  60118. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  60119. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  60120. * @param group (PointsGroup) is the group the particle belongs to
  60121. * @param groupId (integer) is the group identifier in the PCS.
  60122. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  60123. * @param pcs defines the PCS it is associated to
  60124. */
  60125. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  60126. /**
  60127. * get point size
  60128. */
  60129. /**
  60130. * Set point size
  60131. */
  60132. size: Vector3;
  60133. /**
  60134. * Legacy support, changed quaternion to rotationQuaternion
  60135. */
  60136. /**
  60137. * Legacy support, changed quaternion to rotationQuaternion
  60138. */
  60139. quaternion: Nullable<Quaternion>;
  60140. /**
  60141. * Returns a boolean. True if the particle intersects a mesh, else false
  60142. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  60143. * @param target is the object (point or mesh) what the intersection is computed against
  60144. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  60145. * @returns true if it intersects
  60146. */
  60147. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  60148. /**
  60149. * get the rotation matrix of the particle
  60150. * @hidden
  60151. */
  60152. getRotationMatrix(m: Matrix): void;
  60153. }
  60154. /**
  60155. * Represents a group of points in a points cloud system
  60156. * * PCS internal tool, don't use it manually.
  60157. */
  60158. export class PointsGroup {
  60159. /**
  60160. * The group id
  60161. * @hidden
  60162. */
  60163. groupID: number;
  60164. /**
  60165. * image data for group (internal use)
  60166. * @hidden
  60167. */
  60168. _groupImageData: Nullable<ArrayBufferView>;
  60169. /**
  60170. * Image Width (internal use)
  60171. * @hidden
  60172. */
  60173. _groupImgWidth: number;
  60174. /**
  60175. * Image Height (internal use)
  60176. * @hidden
  60177. */
  60178. _groupImgHeight: number;
  60179. /**
  60180. * Custom position function (internal use)
  60181. * @hidden
  60182. */
  60183. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  60184. /**
  60185. * density per facet for surface points
  60186. * @hidden
  60187. */
  60188. _groupDensity: number[];
  60189. /**
  60190. * Only when points are colored by texture carries pointer to texture list array
  60191. * @hidden
  60192. */
  60193. _textureNb: number;
  60194. /**
  60195. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  60196. * PCS internal tool, don't use it manually.
  60197. * @hidden
  60198. */
  60199. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  60200. }
  60201. }
  60202. declare module BABYLON {
  60203. interface Scene {
  60204. /** @hidden (Backing field) */
  60205. _physicsEngine: Nullable<IPhysicsEngine>;
  60206. /** @hidden */
  60207. _physicsTimeAccumulator: number;
  60208. /**
  60209. * Gets the current physics engine
  60210. * @returns a IPhysicsEngine or null if none attached
  60211. */
  60212. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  60213. /**
  60214. * Enables physics to the current scene
  60215. * @param gravity defines the scene's gravity for the physics engine
  60216. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  60217. * @return a boolean indicating if the physics engine was initialized
  60218. */
  60219. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  60220. /**
  60221. * Disables and disposes the physics engine associated with the scene
  60222. */
  60223. disablePhysicsEngine(): void;
  60224. /**
  60225. * Gets a boolean indicating if there is an active physics engine
  60226. * @returns a boolean indicating if there is an active physics engine
  60227. */
  60228. isPhysicsEnabled(): boolean;
  60229. /**
  60230. * Deletes a physics compound impostor
  60231. * @param compound defines the compound to delete
  60232. */
  60233. deleteCompoundImpostor(compound: any): void;
  60234. /**
  60235. * An event triggered when physic simulation is about to be run
  60236. */
  60237. onBeforePhysicsObservable: Observable<Scene>;
  60238. /**
  60239. * An event triggered when physic simulation has been done
  60240. */
  60241. onAfterPhysicsObservable: Observable<Scene>;
  60242. }
  60243. interface AbstractMesh {
  60244. /** @hidden */
  60245. _physicsImpostor: Nullable<PhysicsImpostor>;
  60246. /**
  60247. * Gets or sets impostor used for physic simulation
  60248. * @see http://doc.babylonjs.com/features/physics_engine
  60249. */
  60250. physicsImpostor: Nullable<PhysicsImpostor>;
  60251. /**
  60252. * Gets the current physics impostor
  60253. * @see http://doc.babylonjs.com/features/physics_engine
  60254. * @returns a physics impostor or null
  60255. */
  60256. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  60257. /** Apply a physic impulse to the mesh
  60258. * @param force defines the force to apply
  60259. * @param contactPoint defines where to apply the force
  60260. * @returns the current mesh
  60261. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  60262. */
  60263. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  60264. /**
  60265. * Creates a physic joint between two meshes
  60266. * @param otherMesh defines the other mesh to use
  60267. * @param pivot1 defines the pivot to use on this mesh
  60268. * @param pivot2 defines the pivot to use on the other mesh
  60269. * @param options defines additional options (can be plugin dependent)
  60270. * @returns the current mesh
  60271. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  60272. */
  60273. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  60274. /** @hidden */
  60275. _disposePhysicsObserver: Nullable<Observer<Node>>;
  60276. }
  60277. /**
  60278. * Defines the physics engine scene component responsible to manage a physics engine
  60279. */
  60280. export class PhysicsEngineSceneComponent implements ISceneComponent {
  60281. /**
  60282. * The component name helpful to identify the component in the list of scene components.
  60283. */
  60284. readonly name: string;
  60285. /**
  60286. * The scene the component belongs to.
  60287. */
  60288. scene: Scene;
  60289. /**
  60290. * Creates a new instance of the component for the given scene
  60291. * @param scene Defines the scene to register the component in
  60292. */
  60293. constructor(scene: Scene);
  60294. /**
  60295. * Registers the component in a given scene
  60296. */
  60297. register(): void;
  60298. /**
  60299. * Rebuilds the elements related to this component in case of
  60300. * context lost for instance.
  60301. */
  60302. rebuild(): void;
  60303. /**
  60304. * Disposes the component and the associated ressources
  60305. */
  60306. dispose(): void;
  60307. }
  60308. }
  60309. declare module BABYLON {
  60310. /**
  60311. * A helper for physics simulations
  60312. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60313. */
  60314. export class PhysicsHelper {
  60315. private _scene;
  60316. private _physicsEngine;
  60317. /**
  60318. * Initializes the Physics helper
  60319. * @param scene Babylon.js scene
  60320. */
  60321. constructor(scene: Scene);
  60322. /**
  60323. * Applies a radial explosion impulse
  60324. * @param origin the origin of the explosion
  60325. * @param radiusOrEventOptions the radius or the options of radial explosion
  60326. * @param strength the explosion strength
  60327. * @param falloff possible options: Constant & Linear. Defaults to Constant
  60328. * @returns A physics radial explosion event, or null
  60329. */
  60330. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  60331. /**
  60332. * Applies a radial explosion force
  60333. * @param origin the origin of the explosion
  60334. * @param radiusOrEventOptions the radius or the options of radial explosion
  60335. * @param strength the explosion strength
  60336. * @param falloff possible options: Constant & Linear. Defaults to Constant
  60337. * @returns A physics radial explosion event, or null
  60338. */
  60339. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  60340. /**
  60341. * Creates a gravitational field
  60342. * @param origin the origin of the explosion
  60343. * @param radiusOrEventOptions the radius or the options of radial explosion
  60344. * @param strength the explosion strength
  60345. * @param falloff possible options: Constant & Linear. Defaults to Constant
  60346. * @returns A physics gravitational field event, or null
  60347. */
  60348. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  60349. /**
  60350. * Creates a physics updraft event
  60351. * @param origin the origin of the updraft
  60352. * @param radiusOrEventOptions the radius or the options of the updraft
  60353. * @param strength the strength of the updraft
  60354. * @param height the height of the updraft
  60355. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  60356. * @returns A physics updraft event, or null
  60357. */
  60358. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  60359. /**
  60360. * Creates a physics vortex event
  60361. * @param origin the of the vortex
  60362. * @param radiusOrEventOptions the radius or the options of the vortex
  60363. * @param strength the strength of the vortex
  60364. * @param height the height of the vortex
  60365. * @returns a Physics vortex event, or null
  60366. * A physics vortex event or null
  60367. */
  60368. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  60369. }
  60370. /**
  60371. * Represents a physics radial explosion event
  60372. */
  60373. class PhysicsRadialExplosionEvent {
  60374. private _scene;
  60375. private _options;
  60376. private _sphere;
  60377. private _dataFetched;
  60378. /**
  60379. * Initializes a radial explosioin event
  60380. * @param _scene BabylonJS scene
  60381. * @param _options The options for the vortex event
  60382. */
  60383. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  60384. /**
  60385. * Returns the data related to the radial explosion event (sphere).
  60386. * @returns The radial explosion event data
  60387. */
  60388. getData(): PhysicsRadialExplosionEventData;
  60389. /**
  60390. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  60391. * @param impostor A physics imposter
  60392. * @param origin the origin of the explosion
  60393. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  60394. */
  60395. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  60396. /**
  60397. * Triggers affecterd impostors callbacks
  60398. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  60399. */
  60400. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  60401. /**
  60402. * Disposes the sphere.
  60403. * @param force Specifies if the sphere should be disposed by force
  60404. */
  60405. dispose(force?: boolean): void;
  60406. /*** Helpers ***/
  60407. private _prepareSphere;
  60408. private _intersectsWithSphere;
  60409. }
  60410. /**
  60411. * Represents a gravitational field event
  60412. */
  60413. class PhysicsGravitationalFieldEvent {
  60414. private _physicsHelper;
  60415. private _scene;
  60416. private _origin;
  60417. private _options;
  60418. private _tickCallback;
  60419. private _sphere;
  60420. private _dataFetched;
  60421. /**
  60422. * Initializes the physics gravitational field event
  60423. * @param _physicsHelper A physics helper
  60424. * @param _scene BabylonJS scene
  60425. * @param _origin The origin position of the gravitational field event
  60426. * @param _options The options for the vortex event
  60427. */
  60428. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  60429. /**
  60430. * Returns the data related to the gravitational field event (sphere).
  60431. * @returns A gravitational field event
  60432. */
  60433. getData(): PhysicsGravitationalFieldEventData;
  60434. /**
  60435. * Enables the gravitational field.
  60436. */
  60437. enable(): void;
  60438. /**
  60439. * Disables the gravitational field.
  60440. */
  60441. disable(): void;
  60442. /**
  60443. * Disposes the sphere.
  60444. * @param force The force to dispose from the gravitational field event
  60445. */
  60446. dispose(force?: boolean): void;
  60447. private _tick;
  60448. }
  60449. /**
  60450. * Represents a physics updraft event
  60451. */
  60452. class PhysicsUpdraftEvent {
  60453. private _scene;
  60454. private _origin;
  60455. private _options;
  60456. private _physicsEngine;
  60457. private _originTop;
  60458. private _originDirection;
  60459. private _tickCallback;
  60460. private _cylinder;
  60461. private _cylinderPosition;
  60462. private _dataFetched;
  60463. /**
  60464. * Initializes the physics updraft event
  60465. * @param _scene BabylonJS scene
  60466. * @param _origin The origin position of the updraft
  60467. * @param _options The options for the updraft event
  60468. */
  60469. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  60470. /**
  60471. * Returns the data related to the updraft event (cylinder).
  60472. * @returns A physics updraft event
  60473. */
  60474. getData(): PhysicsUpdraftEventData;
  60475. /**
  60476. * Enables the updraft.
  60477. */
  60478. enable(): void;
  60479. /**
  60480. * Disables the updraft.
  60481. */
  60482. disable(): void;
  60483. /**
  60484. * Disposes the cylinder.
  60485. * @param force Specifies if the updraft should be disposed by force
  60486. */
  60487. dispose(force?: boolean): void;
  60488. private getImpostorHitData;
  60489. private _tick;
  60490. /*** Helpers ***/
  60491. private _prepareCylinder;
  60492. private _intersectsWithCylinder;
  60493. }
  60494. /**
  60495. * Represents a physics vortex event
  60496. */
  60497. class PhysicsVortexEvent {
  60498. private _scene;
  60499. private _origin;
  60500. private _options;
  60501. private _physicsEngine;
  60502. private _originTop;
  60503. private _tickCallback;
  60504. private _cylinder;
  60505. private _cylinderPosition;
  60506. private _dataFetched;
  60507. /**
  60508. * Initializes the physics vortex event
  60509. * @param _scene The BabylonJS scene
  60510. * @param _origin The origin position of the vortex
  60511. * @param _options The options for the vortex event
  60512. */
  60513. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  60514. /**
  60515. * Returns the data related to the vortex event (cylinder).
  60516. * @returns The physics vortex event data
  60517. */
  60518. getData(): PhysicsVortexEventData;
  60519. /**
  60520. * Enables the vortex.
  60521. */
  60522. enable(): void;
  60523. /**
  60524. * Disables the cortex.
  60525. */
  60526. disable(): void;
  60527. /**
  60528. * Disposes the sphere.
  60529. * @param force
  60530. */
  60531. dispose(force?: boolean): void;
  60532. private getImpostorHitData;
  60533. private _tick;
  60534. /*** Helpers ***/
  60535. private _prepareCylinder;
  60536. private _intersectsWithCylinder;
  60537. }
  60538. /**
  60539. * Options fot the radial explosion event
  60540. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60541. */
  60542. export class PhysicsRadialExplosionEventOptions {
  60543. /**
  60544. * The radius of the sphere for the radial explosion.
  60545. */
  60546. radius: number;
  60547. /**
  60548. * The strenth of the explosion.
  60549. */
  60550. strength: number;
  60551. /**
  60552. * The strenght of the force in correspondence to the distance of the affected object
  60553. */
  60554. falloff: PhysicsRadialImpulseFalloff;
  60555. /**
  60556. * Sphere options for the radial explosion.
  60557. */
  60558. sphere: {
  60559. segments: number;
  60560. diameter: number;
  60561. };
  60562. /**
  60563. * Sphere options for the radial explosion.
  60564. */
  60565. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  60566. }
  60567. /**
  60568. * Options fot the updraft event
  60569. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60570. */
  60571. export class PhysicsUpdraftEventOptions {
  60572. /**
  60573. * The radius of the cylinder for the vortex
  60574. */
  60575. radius: number;
  60576. /**
  60577. * The strenth of the updraft.
  60578. */
  60579. strength: number;
  60580. /**
  60581. * The height of the cylinder for the updraft.
  60582. */
  60583. height: number;
  60584. /**
  60585. * The mode for the the updraft.
  60586. */
  60587. updraftMode: PhysicsUpdraftMode;
  60588. }
  60589. /**
  60590. * Options fot the vortex event
  60591. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60592. */
  60593. export class PhysicsVortexEventOptions {
  60594. /**
  60595. * The radius of the cylinder for the vortex
  60596. */
  60597. radius: number;
  60598. /**
  60599. * The strenth of the vortex.
  60600. */
  60601. strength: number;
  60602. /**
  60603. * The height of the cylinder for the vortex.
  60604. */
  60605. height: number;
  60606. /**
  60607. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  60608. */
  60609. centripetalForceThreshold: number;
  60610. /**
  60611. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  60612. */
  60613. centripetalForceMultiplier: number;
  60614. /**
  60615. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  60616. */
  60617. centrifugalForceMultiplier: number;
  60618. /**
  60619. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  60620. */
  60621. updraftForceMultiplier: number;
  60622. }
  60623. /**
  60624. * The strenght of the force in correspondence to the distance of the affected object
  60625. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60626. */
  60627. export enum PhysicsRadialImpulseFalloff {
  60628. /** Defines that impulse is constant in strength across it's whole radius */
  60629. Constant = 0,
  60630. /** Defines that impulse gets weaker if it's further from the origin */
  60631. Linear = 1
  60632. }
  60633. /**
  60634. * The strength of the force in correspondence to the distance of the affected object
  60635. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60636. */
  60637. export enum PhysicsUpdraftMode {
  60638. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  60639. Center = 0,
  60640. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  60641. Perpendicular = 1
  60642. }
  60643. /**
  60644. * Interface for a physics hit data
  60645. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60646. */
  60647. export interface PhysicsHitData {
  60648. /**
  60649. * The force applied at the contact point
  60650. */
  60651. force: Vector3;
  60652. /**
  60653. * The contact point
  60654. */
  60655. contactPoint: Vector3;
  60656. /**
  60657. * The distance from the origin to the contact point
  60658. */
  60659. distanceFromOrigin: number;
  60660. }
  60661. /**
  60662. * Interface for radial explosion event data
  60663. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60664. */
  60665. export interface PhysicsRadialExplosionEventData {
  60666. /**
  60667. * A sphere used for the radial explosion event
  60668. */
  60669. sphere: Mesh;
  60670. }
  60671. /**
  60672. * Interface for gravitational field event data
  60673. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60674. */
  60675. export interface PhysicsGravitationalFieldEventData {
  60676. /**
  60677. * A sphere mesh used for the gravitational field event
  60678. */
  60679. sphere: Mesh;
  60680. }
  60681. /**
  60682. * Interface for updraft event data
  60683. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60684. */
  60685. export interface PhysicsUpdraftEventData {
  60686. /**
  60687. * A cylinder used for the updraft event
  60688. */
  60689. cylinder: Mesh;
  60690. }
  60691. /**
  60692. * Interface for vortex event data
  60693. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60694. */
  60695. export interface PhysicsVortexEventData {
  60696. /**
  60697. * A cylinder used for the vortex event
  60698. */
  60699. cylinder: Mesh;
  60700. }
  60701. /**
  60702. * Interface for an affected physics impostor
  60703. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60704. */
  60705. export interface PhysicsAffectedImpostorWithData {
  60706. /**
  60707. * The impostor affected by the effect
  60708. */
  60709. impostor: PhysicsImpostor;
  60710. /**
  60711. * The data about the hit/horce from the explosion
  60712. */
  60713. hitData: PhysicsHitData;
  60714. }
  60715. }
  60716. declare module BABYLON {
  60717. /** @hidden */
  60718. export var blackAndWhitePixelShader: {
  60719. name: string;
  60720. shader: string;
  60721. };
  60722. }
  60723. declare module BABYLON {
  60724. /**
  60725. * Post process used to render in black and white
  60726. */
  60727. export class BlackAndWhitePostProcess extends PostProcess {
  60728. /**
  60729. * Linear about to convert he result to black and white (default: 1)
  60730. */
  60731. degree: number;
  60732. /**
  60733. * Creates a black and white post process
  60734. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  60735. * @param name The name of the effect.
  60736. * @param options The required width/height ratio to downsize to before computing the render pass.
  60737. * @param camera The camera to apply the render pass to.
  60738. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60739. * @param engine The engine which the post process will be applied. (default: current engine)
  60740. * @param reusable If the post process can be reused on the same frame. (default: false)
  60741. */
  60742. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  60743. }
  60744. }
  60745. declare module BABYLON {
  60746. /**
  60747. * This represents a set of one or more post processes in Babylon.
  60748. * A post process can be used to apply a shader to a texture after it is rendered.
  60749. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60750. */
  60751. export class PostProcessRenderEffect {
  60752. private _postProcesses;
  60753. private _getPostProcesses;
  60754. private _singleInstance;
  60755. private _cameras;
  60756. private _indicesForCamera;
  60757. /**
  60758. * Name of the effect
  60759. * @hidden
  60760. */
  60761. _name: string;
  60762. /**
  60763. * Instantiates a post process render effect.
  60764. * A post process can be used to apply a shader to a texture after it is rendered.
  60765. * @param engine The engine the effect is tied to
  60766. * @param name The name of the effect
  60767. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  60768. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  60769. */
  60770. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  60771. /**
  60772. * Checks if all the post processes in the effect are supported.
  60773. */
  60774. readonly isSupported: boolean;
  60775. /**
  60776. * Updates the current state of the effect
  60777. * @hidden
  60778. */
  60779. _update(): void;
  60780. /**
  60781. * Attaches the effect on cameras
  60782. * @param cameras The camera to attach to.
  60783. * @hidden
  60784. */
  60785. _attachCameras(cameras: Camera): void;
  60786. /**
  60787. * Attaches the effect on cameras
  60788. * @param cameras The camera to attach to.
  60789. * @hidden
  60790. */
  60791. _attachCameras(cameras: Camera[]): void;
  60792. /**
  60793. * Detaches the effect on cameras
  60794. * @param cameras The camera to detatch from.
  60795. * @hidden
  60796. */
  60797. _detachCameras(cameras: Camera): void;
  60798. /**
  60799. * Detatches the effect on cameras
  60800. * @param cameras The camera to detatch from.
  60801. * @hidden
  60802. */
  60803. _detachCameras(cameras: Camera[]): void;
  60804. /**
  60805. * Enables the effect on given cameras
  60806. * @param cameras The camera to enable.
  60807. * @hidden
  60808. */
  60809. _enable(cameras: Camera): void;
  60810. /**
  60811. * Enables the effect on given cameras
  60812. * @param cameras The camera to enable.
  60813. * @hidden
  60814. */
  60815. _enable(cameras: Nullable<Camera[]>): void;
  60816. /**
  60817. * Disables the effect on the given cameras
  60818. * @param cameras The camera to disable.
  60819. * @hidden
  60820. */
  60821. _disable(cameras: Camera): void;
  60822. /**
  60823. * Disables the effect on the given cameras
  60824. * @param cameras The camera to disable.
  60825. * @hidden
  60826. */
  60827. _disable(cameras: Nullable<Camera[]>): void;
  60828. /**
  60829. * Gets a list of the post processes contained in the effect.
  60830. * @param camera The camera to get the post processes on.
  60831. * @returns The list of the post processes in the effect.
  60832. */
  60833. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  60834. }
  60835. }
  60836. declare module BABYLON {
  60837. /** @hidden */
  60838. export var extractHighlightsPixelShader: {
  60839. name: string;
  60840. shader: string;
  60841. };
  60842. }
  60843. declare module BABYLON {
  60844. /**
  60845. * 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.
  60846. */
  60847. export class ExtractHighlightsPostProcess extends PostProcess {
  60848. /**
  60849. * The luminance threshold, pixels below this value will be set to black.
  60850. */
  60851. threshold: number;
  60852. /** @hidden */
  60853. _exposure: number;
  60854. /**
  60855. * Post process which has the input texture to be used when performing highlight extraction
  60856. * @hidden
  60857. */
  60858. _inputPostProcess: Nullable<PostProcess>;
  60859. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60860. }
  60861. }
  60862. declare module BABYLON {
  60863. /** @hidden */
  60864. export var bloomMergePixelShader: {
  60865. name: string;
  60866. shader: string;
  60867. };
  60868. }
  60869. declare module BABYLON {
  60870. /**
  60871. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  60872. */
  60873. export class BloomMergePostProcess extends PostProcess {
  60874. /** Weight of the bloom to be added to the original input. */
  60875. weight: number;
  60876. /**
  60877. * Creates a new instance of @see BloomMergePostProcess
  60878. * @param name The name of the effect.
  60879. * @param originalFromInput Post process which's input will be used for the merge.
  60880. * @param blurred Blurred highlights post process which's output will be used.
  60881. * @param weight Weight of the bloom to be added to the original input.
  60882. * @param options The required width/height ratio to downsize to before computing the render pass.
  60883. * @param camera The camera to apply the render pass to.
  60884. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60885. * @param engine The engine which the post process will be applied. (default: current engine)
  60886. * @param reusable If the post process can be reused on the same frame. (default: false)
  60887. * @param textureType Type of textures used when performing the post process. (default: 0)
  60888. * @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)
  60889. */
  60890. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  60891. /** Weight of the bloom to be added to the original input. */
  60892. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60893. }
  60894. }
  60895. declare module BABYLON {
  60896. /**
  60897. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  60898. */
  60899. export class BloomEffect extends PostProcessRenderEffect {
  60900. private bloomScale;
  60901. /**
  60902. * @hidden Internal
  60903. */
  60904. _effects: Array<PostProcess>;
  60905. /**
  60906. * @hidden Internal
  60907. */
  60908. _downscale: ExtractHighlightsPostProcess;
  60909. private _blurX;
  60910. private _blurY;
  60911. private _merge;
  60912. /**
  60913. * The luminance threshold to find bright areas of the image to bloom.
  60914. */
  60915. threshold: number;
  60916. /**
  60917. * The strength of the bloom.
  60918. */
  60919. weight: number;
  60920. /**
  60921. * Specifies the size of the bloom blur kernel, relative to the final output size
  60922. */
  60923. kernel: number;
  60924. /**
  60925. * Creates a new instance of @see BloomEffect
  60926. * @param scene The scene the effect belongs to.
  60927. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  60928. * @param bloomKernel The size of the kernel to be used when applying the blur.
  60929. * @param bloomWeight The the strength of bloom.
  60930. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  60931. * @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)
  60932. */
  60933. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  60934. /**
  60935. * Disposes each of the internal effects for a given camera.
  60936. * @param camera The camera to dispose the effect on.
  60937. */
  60938. disposeEffects(camera: Camera): void;
  60939. /**
  60940. * @hidden Internal
  60941. */
  60942. _updateEffects(): void;
  60943. /**
  60944. * Internal
  60945. * @returns if all the contained post processes are ready.
  60946. * @hidden
  60947. */
  60948. _isReady(): boolean;
  60949. }
  60950. }
  60951. declare module BABYLON {
  60952. /** @hidden */
  60953. export var chromaticAberrationPixelShader: {
  60954. name: string;
  60955. shader: string;
  60956. };
  60957. }
  60958. declare module BABYLON {
  60959. /**
  60960. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  60961. */
  60962. export class ChromaticAberrationPostProcess extends PostProcess {
  60963. /**
  60964. * The amount of seperation of rgb channels (default: 30)
  60965. */
  60966. aberrationAmount: number;
  60967. /**
  60968. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  60969. */
  60970. radialIntensity: number;
  60971. /**
  60972. * 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))
  60973. */
  60974. direction: Vector2;
  60975. /**
  60976. * 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))
  60977. */
  60978. centerPosition: Vector2;
  60979. /**
  60980. * Creates a new instance ChromaticAberrationPostProcess
  60981. * @param name The name of the effect.
  60982. * @param screenWidth The width of the screen to apply the effect on.
  60983. * @param screenHeight The height of the screen to apply the effect on.
  60984. * @param options The required width/height ratio to downsize to before computing the render pass.
  60985. * @param camera The camera to apply the render pass to.
  60986. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60987. * @param engine The engine which the post process will be applied. (default: current engine)
  60988. * @param reusable If the post process can be reused on the same frame. (default: false)
  60989. * @param textureType Type of textures used when performing the post process. (default: 0)
  60990. * @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)
  60991. */
  60992. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60993. }
  60994. }
  60995. declare module BABYLON {
  60996. /** @hidden */
  60997. export var circleOfConfusionPixelShader: {
  60998. name: string;
  60999. shader: string;
  61000. };
  61001. }
  61002. declare module BABYLON {
  61003. /**
  61004. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  61005. */
  61006. export class CircleOfConfusionPostProcess extends PostProcess {
  61007. /**
  61008. * 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.
  61009. */
  61010. lensSize: number;
  61011. /**
  61012. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  61013. */
  61014. fStop: number;
  61015. /**
  61016. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  61017. */
  61018. focusDistance: number;
  61019. /**
  61020. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  61021. */
  61022. focalLength: number;
  61023. private _depthTexture;
  61024. /**
  61025. * Creates a new instance CircleOfConfusionPostProcess
  61026. * @param name The name of the effect.
  61027. * @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.
  61028. * @param options The required width/height ratio to downsize to before computing the render pass.
  61029. * @param camera The camera to apply the render pass to.
  61030. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61031. * @param engine The engine which the post process will be applied. (default: current engine)
  61032. * @param reusable If the post process can be reused on the same frame. (default: false)
  61033. * @param textureType Type of textures used when performing the post process. (default: 0)
  61034. * @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)
  61035. */
  61036. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61037. /**
  61038. * 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.
  61039. */
  61040. depthTexture: RenderTargetTexture;
  61041. }
  61042. }
  61043. declare module BABYLON {
  61044. /** @hidden */
  61045. export var colorCorrectionPixelShader: {
  61046. name: string;
  61047. shader: string;
  61048. };
  61049. }
  61050. declare module BABYLON {
  61051. /**
  61052. *
  61053. * This post-process allows the modification of rendered colors by using
  61054. * a 'look-up table' (LUT). This effect is also called Color Grading.
  61055. *
  61056. * The object needs to be provided an url to a texture containing the color
  61057. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  61058. * Use an image editing software to tweak the LUT to match your needs.
  61059. *
  61060. * For an example of a color LUT, see here:
  61061. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  61062. * For explanations on color grading, see here:
  61063. * @see http://udn.epicgames.com/Three/ColorGrading.html
  61064. *
  61065. */
  61066. export class ColorCorrectionPostProcess extends PostProcess {
  61067. private _colorTableTexture;
  61068. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61069. }
  61070. }
  61071. declare module BABYLON {
  61072. /** @hidden */
  61073. export var convolutionPixelShader: {
  61074. name: string;
  61075. shader: string;
  61076. };
  61077. }
  61078. declare module BABYLON {
  61079. /**
  61080. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  61081. * input texture to perform effects such as edge detection or sharpening
  61082. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  61083. */
  61084. export class ConvolutionPostProcess extends PostProcess {
  61085. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  61086. kernel: number[];
  61087. /**
  61088. * Creates a new instance ConvolutionPostProcess
  61089. * @param name The name of the effect.
  61090. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  61091. * @param options The required width/height ratio to downsize to before computing the render pass.
  61092. * @param camera The camera to apply the render pass to.
  61093. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61094. * @param engine The engine which the post process will be applied. (default: current engine)
  61095. * @param reusable If the post process can be reused on the same frame. (default: false)
  61096. * @param textureType Type of textures used when performing the post process. (default: 0)
  61097. */
  61098. constructor(name: string,
  61099. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  61100. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  61101. /**
  61102. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61103. */
  61104. static EdgeDetect0Kernel: number[];
  61105. /**
  61106. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61107. */
  61108. static EdgeDetect1Kernel: number[];
  61109. /**
  61110. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61111. */
  61112. static EdgeDetect2Kernel: number[];
  61113. /**
  61114. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61115. */
  61116. static SharpenKernel: number[];
  61117. /**
  61118. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61119. */
  61120. static EmbossKernel: number[];
  61121. /**
  61122. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61123. */
  61124. static GaussianKernel: number[];
  61125. }
  61126. }
  61127. declare module BABYLON {
  61128. /**
  61129. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  61130. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  61131. * based on samples that have a large difference in distance than the center pixel.
  61132. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  61133. */
  61134. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  61135. direction: Vector2;
  61136. /**
  61137. * Creates a new instance CircleOfConfusionPostProcess
  61138. * @param name The name of the effect.
  61139. * @param scene The scene the effect belongs to.
  61140. * @param direction The direction the blur should be applied.
  61141. * @param kernel The size of the kernel used to blur.
  61142. * @param options The required width/height ratio to downsize to before computing the render pass.
  61143. * @param camera The camera to apply the render pass to.
  61144. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  61145. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  61146. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61147. * @param engine The engine which the post process will be applied. (default: current engine)
  61148. * @param reusable If the post process can be reused on the same frame. (default: false)
  61149. * @param textureType Type of textures used when performing the post process. (default: 0)
  61150. * @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)
  61151. */
  61152. 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);
  61153. }
  61154. }
  61155. declare module BABYLON {
  61156. /** @hidden */
  61157. export var depthOfFieldMergePixelShader: {
  61158. name: string;
  61159. shader: string;
  61160. };
  61161. }
  61162. declare module BABYLON {
  61163. /**
  61164. * Options to be set when merging outputs from the default pipeline.
  61165. */
  61166. export class DepthOfFieldMergePostProcessOptions {
  61167. /**
  61168. * The original image to merge on top of
  61169. */
  61170. originalFromInput: PostProcess;
  61171. /**
  61172. * Parameters to perform the merge of the depth of field effect
  61173. */
  61174. depthOfField?: {
  61175. circleOfConfusion: PostProcess;
  61176. blurSteps: Array<PostProcess>;
  61177. };
  61178. /**
  61179. * Parameters to perform the merge of bloom effect
  61180. */
  61181. bloom?: {
  61182. blurred: PostProcess;
  61183. weight: number;
  61184. };
  61185. }
  61186. /**
  61187. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  61188. */
  61189. export class DepthOfFieldMergePostProcess extends PostProcess {
  61190. private blurSteps;
  61191. /**
  61192. * Creates a new instance of DepthOfFieldMergePostProcess
  61193. * @param name The name of the effect.
  61194. * @param originalFromInput Post process which's input will be used for the merge.
  61195. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  61196. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  61197. * @param options The required width/height ratio to downsize to before computing the render pass.
  61198. * @param camera The camera to apply the render pass to.
  61199. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61200. * @param engine The engine which the post process will be applied. (default: current engine)
  61201. * @param reusable If the post process can be reused on the same frame. (default: false)
  61202. * @param textureType Type of textures used when performing the post process. (default: 0)
  61203. * @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)
  61204. */
  61205. 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);
  61206. /**
  61207. * Updates the effect with the current post process compile time values and recompiles the shader.
  61208. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  61209. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  61210. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  61211. * @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
  61212. * @param onCompiled Called when the shader has been compiled.
  61213. * @param onError Called if there is an error when compiling a shader.
  61214. */
  61215. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  61216. }
  61217. }
  61218. declare module BABYLON {
  61219. /**
  61220. * Specifies the level of max blur that should be applied when using the depth of field effect
  61221. */
  61222. export enum DepthOfFieldEffectBlurLevel {
  61223. /**
  61224. * Subtle blur
  61225. */
  61226. Low = 0,
  61227. /**
  61228. * Medium blur
  61229. */
  61230. Medium = 1,
  61231. /**
  61232. * Large blur
  61233. */
  61234. High = 2
  61235. }
  61236. /**
  61237. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  61238. */
  61239. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  61240. private _circleOfConfusion;
  61241. /**
  61242. * @hidden Internal, blurs from high to low
  61243. */
  61244. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  61245. private _depthOfFieldBlurY;
  61246. private _dofMerge;
  61247. /**
  61248. * @hidden Internal post processes in depth of field effect
  61249. */
  61250. _effects: Array<PostProcess>;
  61251. /**
  61252. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  61253. */
  61254. focalLength: number;
  61255. /**
  61256. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  61257. */
  61258. fStop: number;
  61259. /**
  61260. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  61261. */
  61262. focusDistance: number;
  61263. /**
  61264. * 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.
  61265. */
  61266. lensSize: number;
  61267. /**
  61268. * Creates a new instance DepthOfFieldEffect
  61269. * @param scene The scene the effect belongs to.
  61270. * @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.
  61271. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  61272. * @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)
  61273. */
  61274. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  61275. /**
  61276. * Get the current class name of the current effet
  61277. * @returns "DepthOfFieldEffect"
  61278. */
  61279. getClassName(): string;
  61280. /**
  61281. * 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.
  61282. */
  61283. depthTexture: RenderTargetTexture;
  61284. /**
  61285. * Disposes each of the internal effects for a given camera.
  61286. * @param camera The camera to dispose the effect on.
  61287. */
  61288. disposeEffects(camera: Camera): void;
  61289. /**
  61290. * @hidden Internal
  61291. */
  61292. _updateEffects(): void;
  61293. /**
  61294. * Internal
  61295. * @returns if all the contained post processes are ready.
  61296. * @hidden
  61297. */
  61298. _isReady(): boolean;
  61299. }
  61300. }
  61301. declare module BABYLON {
  61302. /** @hidden */
  61303. export var displayPassPixelShader: {
  61304. name: string;
  61305. shader: string;
  61306. };
  61307. }
  61308. declare module BABYLON {
  61309. /**
  61310. * DisplayPassPostProcess which produces an output the same as it's input
  61311. */
  61312. export class DisplayPassPostProcess extends PostProcess {
  61313. /**
  61314. * Creates the DisplayPassPostProcess
  61315. * @param name The name of the effect.
  61316. * @param options The required width/height ratio to downsize to before computing the render pass.
  61317. * @param camera The camera to apply the render pass to.
  61318. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61319. * @param engine The engine which the post process will be applied. (default: current engine)
  61320. * @param reusable If the post process can be reused on the same frame. (default: false)
  61321. */
  61322. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61323. }
  61324. }
  61325. declare module BABYLON {
  61326. /** @hidden */
  61327. export var filterPixelShader: {
  61328. name: string;
  61329. shader: string;
  61330. };
  61331. }
  61332. declare module BABYLON {
  61333. /**
  61334. * Applies a kernel filter to the image
  61335. */
  61336. export class FilterPostProcess extends PostProcess {
  61337. /** The matrix to be applied to the image */
  61338. kernelMatrix: Matrix;
  61339. /**
  61340. *
  61341. * @param name The name of the effect.
  61342. * @param kernelMatrix The matrix to be applied to the image
  61343. * @param options The required width/height ratio to downsize to before computing the render pass.
  61344. * @param camera The camera to apply the render pass to.
  61345. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61346. * @param engine The engine which the post process will be applied. (default: current engine)
  61347. * @param reusable If the post process can be reused on the same frame. (default: false)
  61348. */
  61349. constructor(name: string,
  61350. /** The matrix to be applied to the image */
  61351. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61352. }
  61353. }
  61354. declare module BABYLON {
  61355. /** @hidden */
  61356. export var fxaaPixelShader: {
  61357. name: string;
  61358. shader: string;
  61359. };
  61360. }
  61361. declare module BABYLON {
  61362. /** @hidden */
  61363. export var fxaaVertexShader: {
  61364. name: string;
  61365. shader: string;
  61366. };
  61367. }
  61368. declare module BABYLON {
  61369. /**
  61370. * Fxaa post process
  61371. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  61372. */
  61373. export class FxaaPostProcess extends PostProcess {
  61374. /** @hidden */
  61375. texelWidth: number;
  61376. /** @hidden */
  61377. texelHeight: number;
  61378. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  61379. private _getDefines;
  61380. }
  61381. }
  61382. declare module BABYLON {
  61383. /** @hidden */
  61384. export var grainPixelShader: {
  61385. name: string;
  61386. shader: string;
  61387. };
  61388. }
  61389. declare module BABYLON {
  61390. /**
  61391. * The GrainPostProcess adds noise to the image at mid luminance levels
  61392. */
  61393. export class GrainPostProcess extends PostProcess {
  61394. /**
  61395. * The intensity of the grain added (default: 30)
  61396. */
  61397. intensity: number;
  61398. /**
  61399. * If the grain should be randomized on every frame
  61400. */
  61401. animated: boolean;
  61402. /**
  61403. * Creates a new instance of @see GrainPostProcess
  61404. * @param name The name of the effect.
  61405. * @param options The required width/height ratio to downsize to before computing the render pass.
  61406. * @param camera The camera to apply the render pass to.
  61407. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61408. * @param engine The engine which the post process will be applied. (default: current engine)
  61409. * @param reusable If the post process can be reused on the same frame. (default: false)
  61410. * @param textureType Type of textures used when performing the post process. (default: 0)
  61411. * @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)
  61412. */
  61413. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61414. }
  61415. }
  61416. declare module BABYLON {
  61417. /** @hidden */
  61418. export var highlightsPixelShader: {
  61419. name: string;
  61420. shader: string;
  61421. };
  61422. }
  61423. declare module BABYLON {
  61424. /**
  61425. * Extracts highlights from the image
  61426. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  61427. */
  61428. export class HighlightsPostProcess extends PostProcess {
  61429. /**
  61430. * Extracts highlights from the image
  61431. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  61432. * @param name The name of the effect.
  61433. * @param options The required width/height ratio to downsize to before computing the render pass.
  61434. * @param camera The camera to apply the render pass to.
  61435. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61436. * @param engine The engine which the post process will be applied. (default: current engine)
  61437. * @param reusable If the post process can be reused on the same frame. (default: false)
  61438. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  61439. */
  61440. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  61441. }
  61442. }
  61443. declare module BABYLON {
  61444. /** @hidden */
  61445. export var mrtFragmentDeclaration: {
  61446. name: string;
  61447. shader: string;
  61448. };
  61449. }
  61450. declare module BABYLON {
  61451. /** @hidden */
  61452. export var geometryPixelShader: {
  61453. name: string;
  61454. shader: string;
  61455. };
  61456. }
  61457. declare module BABYLON {
  61458. /** @hidden */
  61459. export var geometryVertexShader: {
  61460. name: string;
  61461. shader: string;
  61462. };
  61463. }
  61464. declare module BABYLON {
  61465. /** @hidden */
  61466. interface ISavedTransformationMatrix {
  61467. world: Matrix;
  61468. viewProjection: Matrix;
  61469. }
  61470. /**
  61471. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  61472. */
  61473. export class GeometryBufferRenderer {
  61474. /**
  61475. * Constant used to retrieve the position texture index in the G-Buffer textures array
  61476. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  61477. */
  61478. static readonly POSITION_TEXTURE_TYPE: number;
  61479. /**
  61480. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  61481. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  61482. */
  61483. static readonly VELOCITY_TEXTURE_TYPE: number;
  61484. /**
  61485. * Dictionary used to store the previous transformation matrices of each rendered mesh
  61486. * in order to compute objects velocities when enableVelocity is set to "true"
  61487. * @hidden
  61488. */
  61489. _previousTransformationMatrices: {
  61490. [index: number]: ISavedTransformationMatrix;
  61491. };
  61492. /**
  61493. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  61494. * in order to compute objects velocities when enableVelocity is set to "true"
  61495. * @hidden
  61496. */
  61497. _previousBonesTransformationMatrices: {
  61498. [index: number]: Float32Array;
  61499. };
  61500. /**
  61501. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  61502. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  61503. */
  61504. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  61505. private _scene;
  61506. private _multiRenderTarget;
  61507. private _ratio;
  61508. private _enablePosition;
  61509. private _enableVelocity;
  61510. private _positionIndex;
  61511. private _velocityIndex;
  61512. protected _effect: Effect;
  61513. protected _cachedDefines: string;
  61514. /**
  61515. * Set the render list (meshes to be rendered) used in the G buffer.
  61516. */
  61517. renderList: Mesh[];
  61518. /**
  61519. * Gets wether or not G buffer are supported by the running hardware.
  61520. * This requires draw buffer supports
  61521. */
  61522. readonly isSupported: boolean;
  61523. /**
  61524. * Returns the index of the given texture type in the G-Buffer textures array
  61525. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  61526. * @returns the index of the given texture type in the G-Buffer textures array
  61527. */
  61528. getTextureIndex(textureType: number): number;
  61529. /**
  61530. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  61531. */
  61532. /**
  61533. * Sets whether or not objects positions are enabled for the G buffer.
  61534. */
  61535. enablePosition: boolean;
  61536. /**
  61537. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  61538. */
  61539. /**
  61540. * Sets wether or not objects velocities are enabled for the G buffer.
  61541. */
  61542. enableVelocity: boolean;
  61543. /**
  61544. * Gets the scene associated with the buffer.
  61545. */
  61546. readonly scene: Scene;
  61547. /**
  61548. * Gets the ratio used by the buffer during its creation.
  61549. * How big is the buffer related to the main canvas.
  61550. */
  61551. readonly ratio: number;
  61552. /** @hidden */
  61553. static _SceneComponentInitialization: (scene: Scene) => void;
  61554. /**
  61555. * Creates a new G Buffer for the scene
  61556. * @param scene The scene the buffer belongs to
  61557. * @param ratio How big is the buffer related to the main canvas.
  61558. */
  61559. constructor(scene: Scene, ratio?: number);
  61560. /**
  61561. * Checks wether everything is ready to render a submesh to the G buffer.
  61562. * @param subMesh the submesh to check readiness for
  61563. * @param useInstances is the mesh drawn using instance or not
  61564. * @returns true if ready otherwise false
  61565. */
  61566. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61567. /**
  61568. * Gets the current underlying G Buffer.
  61569. * @returns the buffer
  61570. */
  61571. getGBuffer(): MultiRenderTarget;
  61572. /**
  61573. * Gets the number of samples used to render the buffer (anti aliasing).
  61574. */
  61575. /**
  61576. * Sets the number of samples used to render the buffer (anti aliasing).
  61577. */
  61578. samples: number;
  61579. /**
  61580. * Disposes the renderer and frees up associated resources.
  61581. */
  61582. dispose(): void;
  61583. protected _createRenderTargets(): void;
  61584. private _copyBonesTransformationMatrices;
  61585. }
  61586. }
  61587. declare module BABYLON {
  61588. interface Scene {
  61589. /** @hidden (Backing field) */
  61590. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  61591. /**
  61592. * Gets or Sets the current geometry buffer associated to the scene.
  61593. */
  61594. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  61595. /**
  61596. * Enables a GeometryBufferRender and associates it with the scene
  61597. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  61598. * @returns the GeometryBufferRenderer
  61599. */
  61600. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  61601. /**
  61602. * Disables the GeometryBufferRender associated with the scene
  61603. */
  61604. disableGeometryBufferRenderer(): void;
  61605. }
  61606. /**
  61607. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  61608. * in several rendering techniques.
  61609. */
  61610. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  61611. /**
  61612. * The component name helpful to identify the component in the list of scene components.
  61613. */
  61614. readonly name: string;
  61615. /**
  61616. * The scene the component belongs to.
  61617. */
  61618. scene: Scene;
  61619. /**
  61620. * Creates a new instance of the component for the given scene
  61621. * @param scene Defines the scene to register the component in
  61622. */
  61623. constructor(scene: Scene);
  61624. /**
  61625. * Registers the component in a given scene
  61626. */
  61627. register(): void;
  61628. /**
  61629. * Rebuilds the elements related to this component in case of
  61630. * context lost for instance.
  61631. */
  61632. rebuild(): void;
  61633. /**
  61634. * Disposes the component and the associated ressources
  61635. */
  61636. dispose(): void;
  61637. private _gatherRenderTargets;
  61638. }
  61639. }
  61640. declare module BABYLON {
  61641. /** @hidden */
  61642. export var motionBlurPixelShader: {
  61643. name: string;
  61644. shader: string;
  61645. };
  61646. }
  61647. declare module BABYLON {
  61648. /**
  61649. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  61650. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  61651. * As an example, all you have to do is to create the post-process:
  61652. * var mb = new BABYLON.MotionBlurPostProcess(
  61653. * 'mb', // The name of the effect.
  61654. * scene, // The scene containing the objects to blur according to their velocity.
  61655. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  61656. * camera // The camera to apply the render pass to.
  61657. * );
  61658. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  61659. */
  61660. export class MotionBlurPostProcess extends PostProcess {
  61661. /**
  61662. * Defines how much the image is blurred by the movement. Default value is equal to 1
  61663. */
  61664. motionStrength: number;
  61665. /**
  61666. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  61667. */
  61668. /**
  61669. * Sets the number of iterations to be used for motion blur quality
  61670. */
  61671. motionBlurSamples: number;
  61672. private _motionBlurSamples;
  61673. private _geometryBufferRenderer;
  61674. /**
  61675. * Creates a new instance MotionBlurPostProcess
  61676. * @param name The name of the effect.
  61677. * @param scene The scene containing the objects to blur according to their velocity.
  61678. * @param options The required width/height ratio to downsize to before computing the render pass.
  61679. * @param camera The camera to apply the render pass to.
  61680. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61681. * @param engine The engine which the post process will be applied. (default: current engine)
  61682. * @param reusable If the post process can be reused on the same frame. (default: false)
  61683. * @param textureType Type of textures used when performing the post process. (default: 0)
  61684. * @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)
  61685. */
  61686. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61687. /**
  61688. * Excludes the given skinned mesh from computing bones velocities.
  61689. * 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.
  61690. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  61691. */
  61692. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  61693. /**
  61694. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  61695. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  61696. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  61697. */
  61698. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  61699. /**
  61700. * Disposes the post process.
  61701. * @param camera The camera to dispose the post process on.
  61702. */
  61703. dispose(camera?: Camera): void;
  61704. }
  61705. }
  61706. declare module BABYLON {
  61707. /** @hidden */
  61708. export var refractionPixelShader: {
  61709. name: string;
  61710. shader: string;
  61711. };
  61712. }
  61713. declare module BABYLON {
  61714. /**
  61715. * Post process which applies a refractin texture
  61716. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  61717. */
  61718. export class RefractionPostProcess extends PostProcess {
  61719. /** the base color of the refraction (used to taint the rendering) */
  61720. color: Color3;
  61721. /** simulated refraction depth */
  61722. depth: number;
  61723. /** the coefficient of the base color (0 to remove base color tainting) */
  61724. colorLevel: number;
  61725. private _refTexture;
  61726. private _ownRefractionTexture;
  61727. /**
  61728. * Gets or sets the refraction texture
  61729. * Please note that you are responsible for disposing the texture if you set it manually
  61730. */
  61731. refractionTexture: Texture;
  61732. /**
  61733. * Initializes the RefractionPostProcess
  61734. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  61735. * @param name The name of the effect.
  61736. * @param refractionTextureUrl Url of the refraction texture to use
  61737. * @param color the base color of the refraction (used to taint the rendering)
  61738. * @param depth simulated refraction depth
  61739. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  61740. * @param camera The camera to apply the render pass to.
  61741. * @param options The required width/height ratio to downsize to before computing the render pass.
  61742. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61743. * @param engine The engine which the post process will be applied. (default: current engine)
  61744. * @param reusable If the post process can be reused on the same frame. (default: false)
  61745. */
  61746. constructor(name: string, refractionTextureUrl: string,
  61747. /** the base color of the refraction (used to taint the rendering) */
  61748. color: Color3,
  61749. /** simulated refraction depth */
  61750. depth: number,
  61751. /** the coefficient of the base color (0 to remove base color tainting) */
  61752. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61753. /**
  61754. * Disposes of the post process
  61755. * @param camera Camera to dispose post process on
  61756. */
  61757. dispose(camera: Camera): void;
  61758. }
  61759. }
  61760. declare module BABYLON {
  61761. /** @hidden */
  61762. export var sharpenPixelShader: {
  61763. name: string;
  61764. shader: string;
  61765. };
  61766. }
  61767. declare module BABYLON {
  61768. /**
  61769. * The SharpenPostProcess applies a sharpen kernel to every pixel
  61770. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  61771. */
  61772. export class SharpenPostProcess extends PostProcess {
  61773. /**
  61774. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  61775. */
  61776. colorAmount: number;
  61777. /**
  61778. * How much sharpness should be applied (default: 0.3)
  61779. */
  61780. edgeAmount: number;
  61781. /**
  61782. * Creates a new instance ConvolutionPostProcess
  61783. * @param name The name of the effect.
  61784. * @param options The required width/height ratio to downsize to before computing the render pass.
  61785. * @param camera The camera to apply the render pass to.
  61786. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61787. * @param engine The engine which the post process will be applied. (default: current engine)
  61788. * @param reusable If the post process can be reused on the same frame. (default: false)
  61789. * @param textureType Type of textures used when performing the post process. (default: 0)
  61790. * @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)
  61791. */
  61792. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61793. }
  61794. }
  61795. declare module BABYLON {
  61796. /**
  61797. * PostProcessRenderPipeline
  61798. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  61799. */
  61800. export class PostProcessRenderPipeline {
  61801. private engine;
  61802. private _renderEffects;
  61803. private _renderEffectsForIsolatedPass;
  61804. /**
  61805. * List of inspectable custom properties (used by the Inspector)
  61806. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  61807. */
  61808. inspectableCustomProperties: IInspectable[];
  61809. /**
  61810. * @hidden
  61811. */
  61812. protected _cameras: Camera[];
  61813. /** @hidden */
  61814. _name: string;
  61815. /**
  61816. * Gets pipeline name
  61817. */
  61818. readonly name: string;
  61819. /** Gets the list of attached cameras */
  61820. readonly cameras: Camera[];
  61821. /**
  61822. * Initializes a PostProcessRenderPipeline
  61823. * @param engine engine to add the pipeline to
  61824. * @param name name of the pipeline
  61825. */
  61826. constructor(engine: Engine, name: string);
  61827. /**
  61828. * Gets the class name
  61829. * @returns "PostProcessRenderPipeline"
  61830. */
  61831. getClassName(): string;
  61832. /**
  61833. * If all the render effects in the pipeline are supported
  61834. */
  61835. readonly isSupported: boolean;
  61836. /**
  61837. * Adds an effect to the pipeline
  61838. * @param renderEffect the effect to add
  61839. */
  61840. addEffect(renderEffect: PostProcessRenderEffect): void;
  61841. /** @hidden */
  61842. _rebuild(): void;
  61843. /** @hidden */
  61844. _enableEffect(renderEffectName: string, cameras: Camera): void;
  61845. /** @hidden */
  61846. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  61847. /** @hidden */
  61848. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  61849. /** @hidden */
  61850. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  61851. /** @hidden */
  61852. _attachCameras(cameras: Camera, unique: boolean): void;
  61853. /** @hidden */
  61854. _attachCameras(cameras: Camera[], unique: boolean): void;
  61855. /** @hidden */
  61856. _detachCameras(cameras: Camera): void;
  61857. /** @hidden */
  61858. _detachCameras(cameras: Nullable<Camera[]>): void;
  61859. /** @hidden */
  61860. _update(): void;
  61861. /** @hidden */
  61862. _reset(): void;
  61863. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  61864. /**
  61865. * Disposes of the pipeline
  61866. */
  61867. dispose(): void;
  61868. }
  61869. }
  61870. declare module BABYLON {
  61871. /**
  61872. * PostProcessRenderPipelineManager class
  61873. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  61874. */
  61875. export class PostProcessRenderPipelineManager {
  61876. private _renderPipelines;
  61877. /**
  61878. * Initializes a PostProcessRenderPipelineManager
  61879. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  61880. */
  61881. constructor();
  61882. /**
  61883. * Gets the list of supported render pipelines
  61884. */
  61885. readonly supportedPipelines: PostProcessRenderPipeline[];
  61886. /**
  61887. * Adds a pipeline to the manager
  61888. * @param renderPipeline The pipeline to add
  61889. */
  61890. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  61891. /**
  61892. * Attaches a camera to the pipeline
  61893. * @param renderPipelineName The name of the pipeline to attach to
  61894. * @param cameras the camera to attach
  61895. * @param unique if the camera can be attached multiple times to the pipeline
  61896. */
  61897. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  61898. /**
  61899. * Detaches a camera from the pipeline
  61900. * @param renderPipelineName The name of the pipeline to detach from
  61901. * @param cameras the camera to detach
  61902. */
  61903. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  61904. /**
  61905. * Enables an effect by name on a pipeline
  61906. * @param renderPipelineName the name of the pipeline to enable the effect in
  61907. * @param renderEffectName the name of the effect to enable
  61908. * @param cameras the cameras that the effect should be enabled on
  61909. */
  61910. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  61911. /**
  61912. * Disables an effect by name on a pipeline
  61913. * @param renderPipelineName the name of the pipeline to disable the effect in
  61914. * @param renderEffectName the name of the effect to disable
  61915. * @param cameras the cameras that the effect should be disabled on
  61916. */
  61917. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  61918. /**
  61919. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  61920. */
  61921. update(): void;
  61922. /** @hidden */
  61923. _rebuild(): void;
  61924. /**
  61925. * Disposes of the manager and pipelines
  61926. */
  61927. dispose(): void;
  61928. }
  61929. }
  61930. declare module BABYLON {
  61931. interface Scene {
  61932. /** @hidden (Backing field) */
  61933. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  61934. /**
  61935. * Gets the postprocess render pipeline manager
  61936. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  61937. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  61938. */
  61939. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  61940. }
  61941. /**
  61942. * Defines the Render Pipeline scene component responsible to rendering pipelines
  61943. */
  61944. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  61945. /**
  61946. * The component name helpfull to identify the component in the list of scene components.
  61947. */
  61948. readonly name: string;
  61949. /**
  61950. * The scene the component belongs to.
  61951. */
  61952. scene: Scene;
  61953. /**
  61954. * Creates a new instance of the component for the given scene
  61955. * @param scene Defines the scene to register the component in
  61956. */
  61957. constructor(scene: Scene);
  61958. /**
  61959. * Registers the component in a given scene
  61960. */
  61961. register(): void;
  61962. /**
  61963. * Rebuilds the elements related to this component in case of
  61964. * context lost for instance.
  61965. */
  61966. rebuild(): void;
  61967. /**
  61968. * Disposes the component and the associated ressources
  61969. */
  61970. dispose(): void;
  61971. private _gatherRenderTargets;
  61972. }
  61973. }
  61974. declare module BABYLON {
  61975. /**
  61976. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  61977. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  61978. */
  61979. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  61980. private _scene;
  61981. private _camerasToBeAttached;
  61982. /**
  61983. * ID of the sharpen post process,
  61984. */
  61985. private readonly SharpenPostProcessId;
  61986. /**
  61987. * @ignore
  61988. * ID of the image processing post process;
  61989. */
  61990. readonly ImageProcessingPostProcessId: string;
  61991. /**
  61992. * @ignore
  61993. * ID of the Fast Approximate Anti-Aliasing post process;
  61994. */
  61995. readonly FxaaPostProcessId: string;
  61996. /**
  61997. * ID of the chromatic aberration post process,
  61998. */
  61999. private readonly ChromaticAberrationPostProcessId;
  62000. /**
  62001. * ID of the grain post process
  62002. */
  62003. private readonly GrainPostProcessId;
  62004. /**
  62005. * Sharpen post process which will apply a sharpen convolution to enhance edges
  62006. */
  62007. sharpen: SharpenPostProcess;
  62008. private _sharpenEffect;
  62009. private bloom;
  62010. /**
  62011. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  62012. */
  62013. depthOfField: DepthOfFieldEffect;
  62014. /**
  62015. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  62016. */
  62017. fxaa: FxaaPostProcess;
  62018. /**
  62019. * Image post processing pass used to perform operations such as tone mapping or color grading.
  62020. */
  62021. imageProcessing: ImageProcessingPostProcess;
  62022. /**
  62023. * Chromatic aberration post process which will shift rgb colors in the image
  62024. */
  62025. chromaticAberration: ChromaticAberrationPostProcess;
  62026. private _chromaticAberrationEffect;
  62027. /**
  62028. * Grain post process which add noise to the image
  62029. */
  62030. grain: GrainPostProcess;
  62031. private _grainEffect;
  62032. /**
  62033. * Glow post process which adds a glow to emissive areas of the image
  62034. */
  62035. private _glowLayer;
  62036. /**
  62037. * Animations which can be used to tweak settings over a period of time
  62038. */
  62039. animations: Animation[];
  62040. private _imageProcessingConfigurationObserver;
  62041. private _sharpenEnabled;
  62042. private _bloomEnabled;
  62043. private _depthOfFieldEnabled;
  62044. private _depthOfFieldBlurLevel;
  62045. private _fxaaEnabled;
  62046. private _imageProcessingEnabled;
  62047. private _defaultPipelineTextureType;
  62048. private _bloomScale;
  62049. private _chromaticAberrationEnabled;
  62050. private _grainEnabled;
  62051. private _buildAllowed;
  62052. /**
  62053. * Gets active scene
  62054. */
  62055. readonly scene: Scene;
  62056. /**
  62057. * Enable or disable the sharpen process from the pipeline
  62058. */
  62059. sharpenEnabled: boolean;
  62060. private _resizeObserver;
  62061. private _hardwareScaleLevel;
  62062. private _bloomKernel;
  62063. /**
  62064. * Specifies the size of the bloom blur kernel, relative to the final output size
  62065. */
  62066. bloomKernel: number;
  62067. /**
  62068. * Specifies the weight of the bloom in the final rendering
  62069. */
  62070. private _bloomWeight;
  62071. /**
  62072. * Specifies the luma threshold for the area that will be blurred by the bloom
  62073. */
  62074. private _bloomThreshold;
  62075. private _hdr;
  62076. /**
  62077. * The strength of the bloom.
  62078. */
  62079. bloomWeight: number;
  62080. /**
  62081. * The strength of the bloom.
  62082. */
  62083. bloomThreshold: number;
  62084. /**
  62085. * The scale of the bloom, lower value will provide better performance.
  62086. */
  62087. bloomScale: number;
  62088. /**
  62089. * Enable or disable the bloom from the pipeline
  62090. */
  62091. bloomEnabled: boolean;
  62092. private _rebuildBloom;
  62093. /**
  62094. * If the depth of field is enabled.
  62095. */
  62096. depthOfFieldEnabled: boolean;
  62097. /**
  62098. * Blur level of the depth of field effect. (Higher blur will effect performance)
  62099. */
  62100. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  62101. /**
  62102. * If the anti aliasing is enabled.
  62103. */
  62104. fxaaEnabled: boolean;
  62105. private _samples;
  62106. /**
  62107. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  62108. */
  62109. samples: number;
  62110. /**
  62111. * If image processing is enabled.
  62112. */
  62113. imageProcessingEnabled: boolean;
  62114. /**
  62115. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  62116. */
  62117. glowLayerEnabled: boolean;
  62118. /**
  62119. * Gets the glow layer (or null if not defined)
  62120. */
  62121. readonly glowLayer: Nullable<GlowLayer>;
  62122. /**
  62123. * Enable or disable the chromaticAberration process from the pipeline
  62124. */
  62125. chromaticAberrationEnabled: boolean;
  62126. /**
  62127. * Enable or disable the grain process from the pipeline
  62128. */
  62129. grainEnabled: boolean;
  62130. /**
  62131. * @constructor
  62132. * @param name - The rendering pipeline name (default: "")
  62133. * @param hdr - If high dynamic range textures should be used (default: true)
  62134. * @param scene - The scene linked to this pipeline (default: the last created scene)
  62135. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  62136. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  62137. */
  62138. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  62139. /**
  62140. * Get the class name
  62141. * @returns "DefaultRenderingPipeline"
  62142. */
  62143. getClassName(): string;
  62144. /**
  62145. * Force the compilation of the entire pipeline.
  62146. */
  62147. prepare(): void;
  62148. private _hasCleared;
  62149. private _prevPostProcess;
  62150. private _prevPrevPostProcess;
  62151. private _setAutoClearAndTextureSharing;
  62152. private _depthOfFieldSceneObserver;
  62153. private _buildPipeline;
  62154. private _disposePostProcesses;
  62155. /**
  62156. * Adds a camera to the pipeline
  62157. * @param camera the camera to be added
  62158. */
  62159. addCamera(camera: Camera): void;
  62160. /**
  62161. * Removes a camera from the pipeline
  62162. * @param camera the camera to remove
  62163. */
  62164. removeCamera(camera: Camera): void;
  62165. /**
  62166. * Dispose of the pipeline and stop all post processes
  62167. */
  62168. dispose(): void;
  62169. /**
  62170. * Serialize the rendering pipeline (Used when exporting)
  62171. * @returns the serialized object
  62172. */
  62173. serialize(): any;
  62174. /**
  62175. * Parse the serialized pipeline
  62176. * @param source Source pipeline.
  62177. * @param scene The scene to load the pipeline to.
  62178. * @param rootUrl The URL of the serialized pipeline.
  62179. * @returns An instantiated pipeline from the serialized object.
  62180. */
  62181. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  62182. }
  62183. }
  62184. declare module BABYLON {
  62185. /** @hidden */
  62186. export var lensHighlightsPixelShader: {
  62187. name: string;
  62188. shader: string;
  62189. };
  62190. }
  62191. declare module BABYLON {
  62192. /** @hidden */
  62193. export var depthOfFieldPixelShader: {
  62194. name: string;
  62195. shader: string;
  62196. };
  62197. }
  62198. declare module BABYLON {
  62199. /**
  62200. * BABYLON.JS Chromatic Aberration GLSL Shader
  62201. * Author: Olivier Guyot
  62202. * Separates very slightly R, G and B colors on the edges of the screen
  62203. * Inspired by Francois Tarlier & Martins Upitis
  62204. */
  62205. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  62206. /**
  62207. * @ignore
  62208. * The chromatic aberration PostProcess id in the pipeline
  62209. */
  62210. LensChromaticAberrationEffect: string;
  62211. /**
  62212. * @ignore
  62213. * The highlights enhancing PostProcess id in the pipeline
  62214. */
  62215. HighlightsEnhancingEffect: string;
  62216. /**
  62217. * @ignore
  62218. * The depth-of-field PostProcess id in the pipeline
  62219. */
  62220. LensDepthOfFieldEffect: string;
  62221. private _scene;
  62222. private _depthTexture;
  62223. private _grainTexture;
  62224. private _chromaticAberrationPostProcess;
  62225. private _highlightsPostProcess;
  62226. private _depthOfFieldPostProcess;
  62227. private _edgeBlur;
  62228. private _grainAmount;
  62229. private _chromaticAberration;
  62230. private _distortion;
  62231. private _highlightsGain;
  62232. private _highlightsThreshold;
  62233. private _dofDistance;
  62234. private _dofAperture;
  62235. private _dofDarken;
  62236. private _dofPentagon;
  62237. private _blurNoise;
  62238. /**
  62239. * @constructor
  62240. *
  62241. * Effect parameters are as follow:
  62242. * {
  62243. * chromatic_aberration: number; // from 0 to x (1 for realism)
  62244. * edge_blur: number; // from 0 to x (1 for realism)
  62245. * distortion: number; // from 0 to x (1 for realism)
  62246. * grain_amount: number; // from 0 to 1
  62247. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  62248. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  62249. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  62250. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  62251. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  62252. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  62253. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  62254. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  62255. * }
  62256. * Note: if an effect parameter is unset, effect is disabled
  62257. *
  62258. * @param name The rendering pipeline name
  62259. * @param parameters - An object containing all parameters (see above)
  62260. * @param scene The scene linked to this pipeline
  62261. * @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)
  62262. * @param cameras The array of cameras that the rendering pipeline will be attached to
  62263. */
  62264. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  62265. /**
  62266. * Get the class name
  62267. * @returns "LensRenderingPipeline"
  62268. */
  62269. getClassName(): string;
  62270. /**
  62271. * Gets associated scene
  62272. */
  62273. readonly scene: Scene;
  62274. /**
  62275. * Gets or sets the edge blur
  62276. */
  62277. edgeBlur: number;
  62278. /**
  62279. * Gets or sets the grain amount
  62280. */
  62281. grainAmount: number;
  62282. /**
  62283. * Gets or sets the chromatic aberration amount
  62284. */
  62285. chromaticAberration: number;
  62286. /**
  62287. * Gets or sets the depth of field aperture
  62288. */
  62289. dofAperture: number;
  62290. /**
  62291. * Gets or sets the edge distortion
  62292. */
  62293. edgeDistortion: number;
  62294. /**
  62295. * Gets or sets the depth of field distortion
  62296. */
  62297. dofDistortion: number;
  62298. /**
  62299. * Gets or sets the darken out of focus amount
  62300. */
  62301. darkenOutOfFocus: number;
  62302. /**
  62303. * Gets or sets a boolean indicating if blur noise is enabled
  62304. */
  62305. blurNoise: boolean;
  62306. /**
  62307. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  62308. */
  62309. pentagonBokeh: boolean;
  62310. /**
  62311. * Gets or sets the highlight grain amount
  62312. */
  62313. highlightsGain: number;
  62314. /**
  62315. * Gets or sets the highlight threshold
  62316. */
  62317. highlightsThreshold: number;
  62318. /**
  62319. * Sets the amount of blur at the edges
  62320. * @param amount blur amount
  62321. */
  62322. setEdgeBlur(amount: number): void;
  62323. /**
  62324. * Sets edge blur to 0
  62325. */
  62326. disableEdgeBlur(): void;
  62327. /**
  62328. * Sets the amout of grain
  62329. * @param amount Amount of grain
  62330. */
  62331. setGrainAmount(amount: number): void;
  62332. /**
  62333. * Set grain amount to 0
  62334. */
  62335. disableGrain(): void;
  62336. /**
  62337. * Sets the chromatic aberration amount
  62338. * @param amount amount of chromatic aberration
  62339. */
  62340. setChromaticAberration(amount: number): void;
  62341. /**
  62342. * Sets chromatic aberration amount to 0
  62343. */
  62344. disableChromaticAberration(): void;
  62345. /**
  62346. * Sets the EdgeDistortion amount
  62347. * @param amount amount of EdgeDistortion
  62348. */
  62349. setEdgeDistortion(amount: number): void;
  62350. /**
  62351. * Sets edge distortion to 0
  62352. */
  62353. disableEdgeDistortion(): void;
  62354. /**
  62355. * Sets the FocusDistance amount
  62356. * @param amount amount of FocusDistance
  62357. */
  62358. setFocusDistance(amount: number): void;
  62359. /**
  62360. * Disables depth of field
  62361. */
  62362. disableDepthOfField(): void;
  62363. /**
  62364. * Sets the Aperture amount
  62365. * @param amount amount of Aperture
  62366. */
  62367. setAperture(amount: number): void;
  62368. /**
  62369. * Sets the DarkenOutOfFocus amount
  62370. * @param amount amount of DarkenOutOfFocus
  62371. */
  62372. setDarkenOutOfFocus(amount: number): void;
  62373. private _pentagonBokehIsEnabled;
  62374. /**
  62375. * Creates a pentagon bokeh effect
  62376. */
  62377. enablePentagonBokeh(): void;
  62378. /**
  62379. * Disables the pentagon bokeh effect
  62380. */
  62381. disablePentagonBokeh(): void;
  62382. /**
  62383. * Enables noise blur
  62384. */
  62385. enableNoiseBlur(): void;
  62386. /**
  62387. * Disables noise blur
  62388. */
  62389. disableNoiseBlur(): void;
  62390. /**
  62391. * Sets the HighlightsGain amount
  62392. * @param amount amount of HighlightsGain
  62393. */
  62394. setHighlightsGain(amount: number): void;
  62395. /**
  62396. * Sets the HighlightsThreshold amount
  62397. * @param amount amount of HighlightsThreshold
  62398. */
  62399. setHighlightsThreshold(amount: number): void;
  62400. /**
  62401. * Disables highlights
  62402. */
  62403. disableHighlights(): void;
  62404. /**
  62405. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  62406. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  62407. */
  62408. dispose(disableDepthRender?: boolean): void;
  62409. private _createChromaticAberrationPostProcess;
  62410. private _createHighlightsPostProcess;
  62411. private _createDepthOfFieldPostProcess;
  62412. private _createGrainTexture;
  62413. }
  62414. }
  62415. declare module BABYLON {
  62416. /** @hidden */
  62417. export var ssao2PixelShader: {
  62418. name: string;
  62419. shader: string;
  62420. };
  62421. }
  62422. declare module BABYLON {
  62423. /** @hidden */
  62424. export var ssaoCombinePixelShader: {
  62425. name: string;
  62426. shader: string;
  62427. };
  62428. }
  62429. declare module BABYLON {
  62430. /**
  62431. * Render pipeline to produce ssao effect
  62432. */
  62433. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  62434. /**
  62435. * @ignore
  62436. * The PassPostProcess id in the pipeline that contains the original scene color
  62437. */
  62438. SSAOOriginalSceneColorEffect: string;
  62439. /**
  62440. * @ignore
  62441. * The SSAO PostProcess id in the pipeline
  62442. */
  62443. SSAORenderEffect: string;
  62444. /**
  62445. * @ignore
  62446. * The horizontal blur PostProcess id in the pipeline
  62447. */
  62448. SSAOBlurHRenderEffect: string;
  62449. /**
  62450. * @ignore
  62451. * The vertical blur PostProcess id in the pipeline
  62452. */
  62453. SSAOBlurVRenderEffect: string;
  62454. /**
  62455. * @ignore
  62456. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  62457. */
  62458. SSAOCombineRenderEffect: string;
  62459. /**
  62460. * The output strength of the SSAO post-process. Default value is 1.0.
  62461. */
  62462. totalStrength: number;
  62463. /**
  62464. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  62465. */
  62466. maxZ: number;
  62467. /**
  62468. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  62469. */
  62470. minZAspect: number;
  62471. private _samples;
  62472. /**
  62473. * Number of samples used for the SSAO calculations. Default value is 8
  62474. */
  62475. samples: number;
  62476. private _textureSamples;
  62477. /**
  62478. * Number of samples to use for antialiasing
  62479. */
  62480. textureSamples: number;
  62481. /**
  62482. * Ratio object used for SSAO ratio and blur ratio
  62483. */
  62484. private _ratio;
  62485. /**
  62486. * Dynamically generated sphere sampler.
  62487. */
  62488. private _sampleSphere;
  62489. /**
  62490. * Blur filter offsets
  62491. */
  62492. private _samplerOffsets;
  62493. private _expensiveBlur;
  62494. /**
  62495. * If bilateral blur should be used
  62496. */
  62497. expensiveBlur: boolean;
  62498. /**
  62499. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  62500. */
  62501. radius: number;
  62502. /**
  62503. * The base color of the SSAO post-process
  62504. * The final result is "base + ssao" between [0, 1]
  62505. */
  62506. base: number;
  62507. /**
  62508. * Support test.
  62509. */
  62510. static readonly IsSupported: boolean;
  62511. private _scene;
  62512. private _depthTexture;
  62513. private _normalTexture;
  62514. private _randomTexture;
  62515. private _originalColorPostProcess;
  62516. private _ssaoPostProcess;
  62517. private _blurHPostProcess;
  62518. private _blurVPostProcess;
  62519. private _ssaoCombinePostProcess;
  62520. /**
  62521. * Gets active scene
  62522. */
  62523. readonly scene: Scene;
  62524. /**
  62525. * @constructor
  62526. * @param name The rendering pipeline name
  62527. * @param scene The scene linked to this pipeline
  62528. * @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 }
  62529. * @param cameras The array of cameras that the rendering pipeline will be attached to
  62530. */
  62531. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  62532. /**
  62533. * Get the class name
  62534. * @returns "SSAO2RenderingPipeline"
  62535. */
  62536. getClassName(): string;
  62537. /**
  62538. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  62539. */
  62540. dispose(disableGeometryBufferRenderer?: boolean): void;
  62541. private _createBlurPostProcess;
  62542. /** @hidden */
  62543. _rebuild(): void;
  62544. private _bits;
  62545. private _radicalInverse_VdC;
  62546. private _hammersley;
  62547. private _hemisphereSample_uniform;
  62548. private _generateHemisphere;
  62549. private _createSSAOPostProcess;
  62550. private _createSSAOCombinePostProcess;
  62551. private _createRandomTexture;
  62552. /**
  62553. * Serialize the rendering pipeline (Used when exporting)
  62554. * @returns the serialized object
  62555. */
  62556. serialize(): any;
  62557. /**
  62558. * Parse the serialized pipeline
  62559. * @param source Source pipeline.
  62560. * @param scene The scene to load the pipeline to.
  62561. * @param rootUrl The URL of the serialized pipeline.
  62562. * @returns An instantiated pipeline from the serialized object.
  62563. */
  62564. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  62565. }
  62566. }
  62567. declare module BABYLON {
  62568. /** @hidden */
  62569. export var ssaoPixelShader: {
  62570. name: string;
  62571. shader: string;
  62572. };
  62573. }
  62574. declare module BABYLON {
  62575. /**
  62576. * Render pipeline to produce ssao effect
  62577. */
  62578. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  62579. /**
  62580. * @ignore
  62581. * The PassPostProcess id in the pipeline that contains the original scene color
  62582. */
  62583. SSAOOriginalSceneColorEffect: string;
  62584. /**
  62585. * @ignore
  62586. * The SSAO PostProcess id in the pipeline
  62587. */
  62588. SSAORenderEffect: string;
  62589. /**
  62590. * @ignore
  62591. * The horizontal blur PostProcess id in the pipeline
  62592. */
  62593. SSAOBlurHRenderEffect: string;
  62594. /**
  62595. * @ignore
  62596. * The vertical blur PostProcess id in the pipeline
  62597. */
  62598. SSAOBlurVRenderEffect: string;
  62599. /**
  62600. * @ignore
  62601. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  62602. */
  62603. SSAOCombineRenderEffect: string;
  62604. /**
  62605. * The output strength of the SSAO post-process. Default value is 1.0.
  62606. */
  62607. totalStrength: number;
  62608. /**
  62609. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  62610. */
  62611. radius: number;
  62612. /**
  62613. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  62614. * Must not be equal to fallOff and superior to fallOff.
  62615. * Default value is 0.0075
  62616. */
  62617. area: number;
  62618. /**
  62619. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  62620. * Must not be equal to area and inferior to area.
  62621. * Default value is 0.000001
  62622. */
  62623. fallOff: number;
  62624. /**
  62625. * The base color of the SSAO post-process
  62626. * The final result is "base + ssao" between [0, 1]
  62627. */
  62628. base: number;
  62629. private _scene;
  62630. private _depthTexture;
  62631. private _randomTexture;
  62632. private _originalColorPostProcess;
  62633. private _ssaoPostProcess;
  62634. private _blurHPostProcess;
  62635. private _blurVPostProcess;
  62636. private _ssaoCombinePostProcess;
  62637. private _firstUpdate;
  62638. /**
  62639. * Gets active scene
  62640. */
  62641. readonly scene: Scene;
  62642. /**
  62643. * @constructor
  62644. * @param name - The rendering pipeline name
  62645. * @param scene - The scene linked to this pipeline
  62646. * @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 }
  62647. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  62648. */
  62649. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  62650. /**
  62651. * Get the class name
  62652. * @returns "SSAORenderingPipeline"
  62653. */
  62654. getClassName(): string;
  62655. /**
  62656. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  62657. */
  62658. dispose(disableDepthRender?: boolean): void;
  62659. private _createBlurPostProcess;
  62660. /** @hidden */
  62661. _rebuild(): void;
  62662. private _createSSAOPostProcess;
  62663. private _createSSAOCombinePostProcess;
  62664. private _createRandomTexture;
  62665. }
  62666. }
  62667. declare module BABYLON {
  62668. /** @hidden */
  62669. export var standardPixelShader: {
  62670. name: string;
  62671. shader: string;
  62672. };
  62673. }
  62674. declare module BABYLON {
  62675. /**
  62676. * Standard rendering pipeline
  62677. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  62678. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  62679. */
  62680. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  62681. /**
  62682. * Public members
  62683. */
  62684. /**
  62685. * Post-process which contains the original scene color before the pipeline applies all the effects
  62686. */
  62687. originalPostProcess: Nullable<PostProcess>;
  62688. /**
  62689. * Post-process used to down scale an image x4
  62690. */
  62691. downSampleX4PostProcess: Nullable<PostProcess>;
  62692. /**
  62693. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  62694. */
  62695. brightPassPostProcess: Nullable<PostProcess>;
  62696. /**
  62697. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  62698. */
  62699. blurHPostProcesses: PostProcess[];
  62700. /**
  62701. * Post-process array storing all the vertical blur post-processes used by the pipeline
  62702. */
  62703. blurVPostProcesses: PostProcess[];
  62704. /**
  62705. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  62706. */
  62707. textureAdderPostProcess: Nullable<PostProcess>;
  62708. /**
  62709. * Post-process used to create volumetric lighting effect
  62710. */
  62711. volumetricLightPostProcess: Nullable<PostProcess>;
  62712. /**
  62713. * Post-process used to smooth the previous volumetric light post-process on the X axis
  62714. */
  62715. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  62716. /**
  62717. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  62718. */
  62719. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  62720. /**
  62721. * Post-process used to merge the volumetric light effect and the real scene color
  62722. */
  62723. volumetricLightMergePostProces: Nullable<PostProcess>;
  62724. /**
  62725. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  62726. */
  62727. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  62728. /**
  62729. * Base post-process used to calculate the average luminance of the final image for HDR
  62730. */
  62731. luminancePostProcess: Nullable<PostProcess>;
  62732. /**
  62733. * Post-processes used to create down sample post-processes in order to get
  62734. * the average luminance of the final image for HDR
  62735. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  62736. */
  62737. luminanceDownSamplePostProcesses: PostProcess[];
  62738. /**
  62739. * Post-process used to create a HDR effect (light adaptation)
  62740. */
  62741. hdrPostProcess: Nullable<PostProcess>;
  62742. /**
  62743. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  62744. */
  62745. textureAdderFinalPostProcess: Nullable<PostProcess>;
  62746. /**
  62747. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  62748. */
  62749. lensFlareFinalPostProcess: Nullable<PostProcess>;
  62750. /**
  62751. * Post-process used to merge the final HDR post-process and the real scene color
  62752. */
  62753. hdrFinalPostProcess: Nullable<PostProcess>;
  62754. /**
  62755. * Post-process used to create a lens flare effect
  62756. */
  62757. lensFlarePostProcess: Nullable<PostProcess>;
  62758. /**
  62759. * Post-process that merges the result of the lens flare post-process and the real scene color
  62760. */
  62761. lensFlareComposePostProcess: Nullable<PostProcess>;
  62762. /**
  62763. * Post-process used to create a motion blur effect
  62764. */
  62765. motionBlurPostProcess: Nullable<PostProcess>;
  62766. /**
  62767. * Post-process used to create a depth of field effect
  62768. */
  62769. depthOfFieldPostProcess: Nullable<PostProcess>;
  62770. /**
  62771. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  62772. */
  62773. fxaaPostProcess: Nullable<FxaaPostProcess>;
  62774. /**
  62775. * Represents the brightness threshold in order to configure the illuminated surfaces
  62776. */
  62777. brightThreshold: number;
  62778. /**
  62779. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  62780. */
  62781. blurWidth: number;
  62782. /**
  62783. * Sets if the blur for highlighted surfaces must be only horizontal
  62784. */
  62785. horizontalBlur: boolean;
  62786. /**
  62787. * Gets the overall exposure used by the pipeline
  62788. */
  62789. /**
  62790. * Sets the overall exposure used by the pipeline
  62791. */
  62792. exposure: number;
  62793. /**
  62794. * Texture used typically to simulate "dirty" on camera lens
  62795. */
  62796. lensTexture: Nullable<Texture>;
  62797. /**
  62798. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  62799. */
  62800. volumetricLightCoefficient: number;
  62801. /**
  62802. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  62803. */
  62804. volumetricLightPower: number;
  62805. /**
  62806. * Used the set the blur intensity to smooth the volumetric lights
  62807. */
  62808. volumetricLightBlurScale: number;
  62809. /**
  62810. * Light (spot or directional) used to generate the volumetric lights rays
  62811. * The source light must have a shadow generate so the pipeline can get its
  62812. * depth map
  62813. */
  62814. sourceLight: Nullable<SpotLight | DirectionalLight>;
  62815. /**
  62816. * For eye adaptation, represents the minimum luminance the eye can see
  62817. */
  62818. hdrMinimumLuminance: number;
  62819. /**
  62820. * For eye adaptation, represents the decrease luminance speed
  62821. */
  62822. hdrDecreaseRate: number;
  62823. /**
  62824. * For eye adaptation, represents the increase luminance speed
  62825. */
  62826. hdrIncreaseRate: number;
  62827. /**
  62828. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  62829. */
  62830. /**
  62831. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  62832. */
  62833. hdrAutoExposure: boolean;
  62834. /**
  62835. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  62836. */
  62837. lensColorTexture: Nullable<Texture>;
  62838. /**
  62839. * The overall strengh for the lens flare effect
  62840. */
  62841. lensFlareStrength: number;
  62842. /**
  62843. * Dispersion coefficient for lens flare ghosts
  62844. */
  62845. lensFlareGhostDispersal: number;
  62846. /**
  62847. * Main lens flare halo width
  62848. */
  62849. lensFlareHaloWidth: number;
  62850. /**
  62851. * Based on the lens distortion effect, defines how much the lens flare result
  62852. * is distorted
  62853. */
  62854. lensFlareDistortionStrength: number;
  62855. /**
  62856. * Configures the blur intensity used for for lens flare (halo)
  62857. */
  62858. lensFlareBlurWidth: number;
  62859. /**
  62860. * Lens star texture must be used to simulate rays on the flares and is available
  62861. * in the documentation
  62862. */
  62863. lensStarTexture: Nullable<Texture>;
  62864. /**
  62865. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  62866. * flare effect by taking account of the dirt texture
  62867. */
  62868. lensFlareDirtTexture: Nullable<Texture>;
  62869. /**
  62870. * Represents the focal length for the depth of field effect
  62871. */
  62872. depthOfFieldDistance: number;
  62873. /**
  62874. * Represents the blur intensity for the blurred part of the depth of field effect
  62875. */
  62876. depthOfFieldBlurWidth: number;
  62877. /**
  62878. * Gets how much the image is blurred by the movement while using the motion blur post-process
  62879. */
  62880. /**
  62881. * Sets how much the image is blurred by the movement while using the motion blur post-process
  62882. */
  62883. motionStrength: number;
  62884. /**
  62885. * Gets wether or not the motion blur post-process is object based or screen based.
  62886. */
  62887. /**
  62888. * Sets wether or not the motion blur post-process should be object based or screen based
  62889. */
  62890. objectBasedMotionBlur: boolean;
  62891. /**
  62892. * List of animations for the pipeline (IAnimatable implementation)
  62893. */
  62894. animations: Animation[];
  62895. /**
  62896. * Private members
  62897. */
  62898. private _scene;
  62899. private _currentDepthOfFieldSource;
  62900. private _basePostProcess;
  62901. private _fixedExposure;
  62902. private _currentExposure;
  62903. private _hdrAutoExposure;
  62904. private _hdrCurrentLuminance;
  62905. private _motionStrength;
  62906. private _isObjectBasedMotionBlur;
  62907. private _floatTextureType;
  62908. private _camerasToBeAttached;
  62909. private _ratio;
  62910. private _bloomEnabled;
  62911. private _depthOfFieldEnabled;
  62912. private _vlsEnabled;
  62913. private _lensFlareEnabled;
  62914. private _hdrEnabled;
  62915. private _motionBlurEnabled;
  62916. private _fxaaEnabled;
  62917. private _motionBlurSamples;
  62918. private _volumetricLightStepsCount;
  62919. private _samples;
  62920. /**
  62921. * @ignore
  62922. * Specifies if the bloom pipeline is enabled
  62923. */
  62924. BloomEnabled: boolean;
  62925. /**
  62926. * @ignore
  62927. * Specifies if the depth of field pipeline is enabed
  62928. */
  62929. DepthOfFieldEnabled: boolean;
  62930. /**
  62931. * @ignore
  62932. * Specifies if the lens flare pipeline is enabed
  62933. */
  62934. LensFlareEnabled: boolean;
  62935. /**
  62936. * @ignore
  62937. * Specifies if the HDR pipeline is enabled
  62938. */
  62939. HDREnabled: boolean;
  62940. /**
  62941. * @ignore
  62942. * Specifies if the volumetric lights scattering effect is enabled
  62943. */
  62944. VLSEnabled: boolean;
  62945. /**
  62946. * @ignore
  62947. * Specifies if the motion blur effect is enabled
  62948. */
  62949. MotionBlurEnabled: boolean;
  62950. /**
  62951. * Specifies if anti-aliasing is enabled
  62952. */
  62953. fxaaEnabled: boolean;
  62954. /**
  62955. * Specifies the number of steps used to calculate the volumetric lights
  62956. * Typically in interval [50, 200]
  62957. */
  62958. volumetricLightStepsCount: number;
  62959. /**
  62960. * Specifies the number of samples used for the motion blur effect
  62961. * Typically in interval [16, 64]
  62962. */
  62963. motionBlurSamples: number;
  62964. /**
  62965. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  62966. */
  62967. samples: number;
  62968. /**
  62969. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  62970. * @constructor
  62971. * @param name The rendering pipeline name
  62972. * @param scene The scene linked to this pipeline
  62973. * @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)
  62974. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  62975. * @param cameras The array of cameras that the rendering pipeline will be attached to
  62976. */
  62977. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  62978. private _buildPipeline;
  62979. private _createDownSampleX4PostProcess;
  62980. private _createBrightPassPostProcess;
  62981. private _createBlurPostProcesses;
  62982. private _createTextureAdderPostProcess;
  62983. private _createVolumetricLightPostProcess;
  62984. private _createLuminancePostProcesses;
  62985. private _createHdrPostProcess;
  62986. private _createLensFlarePostProcess;
  62987. private _createDepthOfFieldPostProcess;
  62988. private _createMotionBlurPostProcess;
  62989. private _getDepthTexture;
  62990. private _disposePostProcesses;
  62991. /**
  62992. * Dispose of the pipeline and stop all post processes
  62993. */
  62994. dispose(): void;
  62995. /**
  62996. * Serialize the rendering pipeline (Used when exporting)
  62997. * @returns the serialized object
  62998. */
  62999. serialize(): any;
  63000. /**
  63001. * Parse the serialized pipeline
  63002. * @param source Source pipeline.
  63003. * @param scene The scene to load the pipeline to.
  63004. * @param rootUrl The URL of the serialized pipeline.
  63005. * @returns An instantiated pipeline from the serialized object.
  63006. */
  63007. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  63008. /**
  63009. * Luminance steps
  63010. */
  63011. static LuminanceSteps: number;
  63012. }
  63013. }
  63014. declare module BABYLON {
  63015. /** @hidden */
  63016. export var tonemapPixelShader: {
  63017. name: string;
  63018. shader: string;
  63019. };
  63020. }
  63021. declare module BABYLON {
  63022. /** Defines operator used for tonemapping */
  63023. export enum TonemappingOperator {
  63024. /** Hable */
  63025. Hable = 0,
  63026. /** Reinhard */
  63027. Reinhard = 1,
  63028. /** HejiDawson */
  63029. HejiDawson = 2,
  63030. /** Photographic */
  63031. Photographic = 3
  63032. }
  63033. /**
  63034. * Defines a post process to apply tone mapping
  63035. */
  63036. export class TonemapPostProcess extends PostProcess {
  63037. private _operator;
  63038. /** Defines the required exposure adjustement */
  63039. exposureAdjustment: number;
  63040. /**
  63041. * Creates a new TonemapPostProcess
  63042. * @param name defines the name of the postprocess
  63043. * @param _operator defines the operator to use
  63044. * @param exposureAdjustment defines the required exposure adjustement
  63045. * @param camera defines the camera to use (can be null)
  63046. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  63047. * @param engine defines the hosting engine (can be ignore if camera is set)
  63048. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  63049. */
  63050. constructor(name: string, _operator: TonemappingOperator,
  63051. /** Defines the required exposure adjustement */
  63052. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  63053. }
  63054. }
  63055. declare module BABYLON {
  63056. /** @hidden */
  63057. export var depthVertexShader: {
  63058. name: string;
  63059. shader: string;
  63060. };
  63061. }
  63062. declare module BABYLON {
  63063. /** @hidden */
  63064. export var volumetricLightScatteringPixelShader: {
  63065. name: string;
  63066. shader: string;
  63067. };
  63068. }
  63069. declare module BABYLON {
  63070. /** @hidden */
  63071. export var volumetricLightScatteringPassVertexShader: {
  63072. name: string;
  63073. shader: string;
  63074. };
  63075. }
  63076. declare module BABYLON {
  63077. /** @hidden */
  63078. export var volumetricLightScatteringPassPixelShader: {
  63079. name: string;
  63080. shader: string;
  63081. };
  63082. }
  63083. declare module BABYLON {
  63084. /**
  63085. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  63086. */
  63087. export class VolumetricLightScatteringPostProcess extends PostProcess {
  63088. private _volumetricLightScatteringPass;
  63089. private _volumetricLightScatteringRTT;
  63090. private _viewPort;
  63091. private _screenCoordinates;
  63092. private _cachedDefines;
  63093. /**
  63094. * If not undefined, the mesh position is computed from the attached node position
  63095. */
  63096. attachedNode: {
  63097. position: Vector3;
  63098. };
  63099. /**
  63100. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  63101. */
  63102. customMeshPosition: Vector3;
  63103. /**
  63104. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  63105. */
  63106. useCustomMeshPosition: boolean;
  63107. /**
  63108. * If the post-process should inverse the light scattering direction
  63109. */
  63110. invert: boolean;
  63111. /**
  63112. * The internal mesh used by the post-process
  63113. */
  63114. mesh: Mesh;
  63115. /**
  63116. * @hidden
  63117. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  63118. */
  63119. useDiffuseColor: boolean;
  63120. /**
  63121. * Array containing the excluded meshes not rendered in the internal pass
  63122. */
  63123. excludedMeshes: AbstractMesh[];
  63124. /**
  63125. * Controls the overall intensity of the post-process
  63126. */
  63127. exposure: number;
  63128. /**
  63129. * Dissipates each sample's contribution in range [0, 1]
  63130. */
  63131. decay: number;
  63132. /**
  63133. * Controls the overall intensity of each sample
  63134. */
  63135. weight: number;
  63136. /**
  63137. * Controls the density of each sample
  63138. */
  63139. density: number;
  63140. /**
  63141. * @constructor
  63142. * @param name The post-process name
  63143. * @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)
  63144. * @param camera The camera that the post-process will be attached to
  63145. * @param mesh The mesh used to create the light scattering
  63146. * @param samples The post-process quality, default 100
  63147. * @param samplingModeThe post-process filtering mode
  63148. * @param engine The babylon engine
  63149. * @param reusable If the post-process is reusable
  63150. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  63151. */
  63152. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  63153. /**
  63154. * Returns the string "VolumetricLightScatteringPostProcess"
  63155. * @returns "VolumetricLightScatteringPostProcess"
  63156. */
  63157. getClassName(): string;
  63158. private _isReady;
  63159. /**
  63160. * Sets the new light position for light scattering effect
  63161. * @param position The new custom light position
  63162. */
  63163. setCustomMeshPosition(position: Vector3): void;
  63164. /**
  63165. * Returns the light position for light scattering effect
  63166. * @return Vector3 The custom light position
  63167. */
  63168. getCustomMeshPosition(): Vector3;
  63169. /**
  63170. * Disposes the internal assets and detaches the post-process from the camera
  63171. */
  63172. dispose(camera: Camera): void;
  63173. /**
  63174. * Returns the render target texture used by the post-process
  63175. * @return the render target texture used by the post-process
  63176. */
  63177. getPass(): RenderTargetTexture;
  63178. private _meshExcluded;
  63179. private _createPass;
  63180. private _updateMeshScreenCoordinates;
  63181. /**
  63182. * Creates a default mesh for the Volumeric Light Scattering post-process
  63183. * @param name The mesh name
  63184. * @param scene The scene where to create the mesh
  63185. * @return the default mesh
  63186. */
  63187. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  63188. }
  63189. }
  63190. declare module BABYLON {
  63191. interface Scene {
  63192. /** @hidden (Backing field) */
  63193. _boundingBoxRenderer: BoundingBoxRenderer;
  63194. /** @hidden (Backing field) */
  63195. _forceShowBoundingBoxes: boolean;
  63196. /**
  63197. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  63198. */
  63199. forceShowBoundingBoxes: boolean;
  63200. /**
  63201. * Gets the bounding box renderer associated with the scene
  63202. * @returns a BoundingBoxRenderer
  63203. */
  63204. getBoundingBoxRenderer(): BoundingBoxRenderer;
  63205. }
  63206. interface AbstractMesh {
  63207. /** @hidden (Backing field) */
  63208. _showBoundingBox: boolean;
  63209. /**
  63210. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  63211. */
  63212. showBoundingBox: boolean;
  63213. }
  63214. /**
  63215. * Component responsible of rendering the bounding box of the meshes in a scene.
  63216. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  63217. */
  63218. export class BoundingBoxRenderer implements ISceneComponent {
  63219. /**
  63220. * The component name helpfull to identify the component in the list of scene components.
  63221. */
  63222. readonly name: string;
  63223. /**
  63224. * The scene the component belongs to.
  63225. */
  63226. scene: Scene;
  63227. /**
  63228. * Color of the bounding box lines placed in front of an object
  63229. */
  63230. frontColor: Color3;
  63231. /**
  63232. * Color of the bounding box lines placed behind an object
  63233. */
  63234. backColor: Color3;
  63235. /**
  63236. * Defines if the renderer should show the back lines or not
  63237. */
  63238. showBackLines: boolean;
  63239. /**
  63240. * @hidden
  63241. */
  63242. renderList: SmartArray<BoundingBox>;
  63243. private _colorShader;
  63244. private _vertexBuffers;
  63245. private _indexBuffer;
  63246. private _fillIndexBuffer;
  63247. private _fillIndexData;
  63248. /**
  63249. * Instantiates a new bounding box renderer in a scene.
  63250. * @param scene the scene the renderer renders in
  63251. */
  63252. constructor(scene: Scene);
  63253. /**
  63254. * Registers the component in a given scene
  63255. */
  63256. register(): void;
  63257. private _evaluateSubMesh;
  63258. private _activeMesh;
  63259. private _prepareRessources;
  63260. private _createIndexBuffer;
  63261. /**
  63262. * Rebuilds the elements related to this component in case of
  63263. * context lost for instance.
  63264. */
  63265. rebuild(): void;
  63266. /**
  63267. * @hidden
  63268. */
  63269. reset(): void;
  63270. /**
  63271. * Render the bounding boxes of a specific rendering group
  63272. * @param renderingGroupId defines the rendering group to render
  63273. */
  63274. render(renderingGroupId: number): void;
  63275. /**
  63276. * In case of occlusion queries, we can render the occlusion bounding box through this method
  63277. * @param mesh Define the mesh to render the occlusion bounding box for
  63278. */
  63279. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  63280. /**
  63281. * Dispose and release the resources attached to this renderer.
  63282. */
  63283. dispose(): void;
  63284. }
  63285. }
  63286. declare module BABYLON {
  63287. /** @hidden */
  63288. export var depthPixelShader: {
  63289. name: string;
  63290. shader: string;
  63291. };
  63292. }
  63293. declare module BABYLON {
  63294. /**
  63295. * This represents a depth renderer in Babylon.
  63296. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  63297. */
  63298. export class DepthRenderer {
  63299. private _scene;
  63300. private _depthMap;
  63301. private _effect;
  63302. private readonly _storeNonLinearDepth;
  63303. private readonly _clearColor;
  63304. /** Get if the depth renderer is using packed depth or not */
  63305. readonly isPacked: boolean;
  63306. private _cachedDefines;
  63307. private _camera;
  63308. /**
  63309. * Specifiess that the depth renderer will only be used within
  63310. * the camera it is created for.
  63311. * This can help forcing its rendering during the camera processing.
  63312. */
  63313. useOnlyInActiveCamera: boolean;
  63314. /** @hidden */
  63315. static _SceneComponentInitialization: (scene: Scene) => void;
  63316. /**
  63317. * Instantiates a depth renderer
  63318. * @param scene The scene the renderer belongs to
  63319. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  63320. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  63321. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  63322. */
  63323. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  63324. /**
  63325. * Creates the depth rendering effect and checks if the effect is ready.
  63326. * @param subMesh The submesh to be used to render the depth map of
  63327. * @param useInstances If multiple world instances should be used
  63328. * @returns if the depth renderer is ready to render the depth map
  63329. */
  63330. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63331. /**
  63332. * Gets the texture which the depth map will be written to.
  63333. * @returns The depth map texture
  63334. */
  63335. getDepthMap(): RenderTargetTexture;
  63336. /**
  63337. * Disposes of the depth renderer.
  63338. */
  63339. dispose(): void;
  63340. }
  63341. }
  63342. declare module BABYLON {
  63343. interface Scene {
  63344. /** @hidden (Backing field) */
  63345. _depthRenderer: {
  63346. [id: string]: DepthRenderer;
  63347. };
  63348. /**
  63349. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  63350. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  63351. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  63352. * @returns the created depth renderer
  63353. */
  63354. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  63355. /**
  63356. * Disables a depth renderer for a given camera
  63357. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  63358. */
  63359. disableDepthRenderer(camera?: Nullable<Camera>): void;
  63360. }
  63361. /**
  63362. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  63363. * in several rendering techniques.
  63364. */
  63365. export class DepthRendererSceneComponent implements ISceneComponent {
  63366. /**
  63367. * The component name helpfull to identify the component in the list of scene components.
  63368. */
  63369. readonly name: string;
  63370. /**
  63371. * The scene the component belongs to.
  63372. */
  63373. scene: Scene;
  63374. /**
  63375. * Creates a new instance of the component for the given scene
  63376. * @param scene Defines the scene to register the component in
  63377. */
  63378. constructor(scene: Scene);
  63379. /**
  63380. * Registers the component in a given scene
  63381. */
  63382. register(): void;
  63383. /**
  63384. * Rebuilds the elements related to this component in case of
  63385. * context lost for instance.
  63386. */
  63387. rebuild(): void;
  63388. /**
  63389. * Disposes the component and the associated ressources
  63390. */
  63391. dispose(): void;
  63392. private _gatherRenderTargets;
  63393. private _gatherActiveCameraRenderTargets;
  63394. }
  63395. }
  63396. declare module BABYLON {
  63397. /** @hidden */
  63398. export var outlinePixelShader: {
  63399. name: string;
  63400. shader: string;
  63401. };
  63402. }
  63403. declare module BABYLON {
  63404. /** @hidden */
  63405. export var outlineVertexShader: {
  63406. name: string;
  63407. shader: string;
  63408. };
  63409. }
  63410. declare module BABYLON {
  63411. interface Scene {
  63412. /** @hidden */
  63413. _outlineRenderer: OutlineRenderer;
  63414. /**
  63415. * Gets the outline renderer associated with the scene
  63416. * @returns a OutlineRenderer
  63417. */
  63418. getOutlineRenderer(): OutlineRenderer;
  63419. }
  63420. interface AbstractMesh {
  63421. /** @hidden (Backing field) */
  63422. _renderOutline: boolean;
  63423. /**
  63424. * Gets or sets a boolean indicating if the outline must be rendered as well
  63425. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  63426. */
  63427. renderOutline: boolean;
  63428. /** @hidden (Backing field) */
  63429. _renderOverlay: boolean;
  63430. /**
  63431. * Gets or sets a boolean indicating if the overlay must be rendered as well
  63432. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  63433. */
  63434. renderOverlay: boolean;
  63435. }
  63436. /**
  63437. * This class is responsible to draw bothe outline/overlay of meshes.
  63438. * It should not be used directly but through the available method on mesh.
  63439. */
  63440. export class OutlineRenderer implements ISceneComponent {
  63441. /**
  63442. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  63443. */
  63444. private static _StencilReference;
  63445. /**
  63446. * The name of the component. Each component must have a unique name.
  63447. */
  63448. name: string;
  63449. /**
  63450. * The scene the component belongs to.
  63451. */
  63452. scene: Scene;
  63453. /**
  63454. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  63455. */
  63456. zOffset: number;
  63457. private _engine;
  63458. private _effect;
  63459. private _cachedDefines;
  63460. private _savedDepthWrite;
  63461. /**
  63462. * Instantiates a new outline renderer. (There could be only one per scene).
  63463. * @param scene Defines the scene it belongs to
  63464. */
  63465. constructor(scene: Scene);
  63466. /**
  63467. * Register the component to one instance of a scene.
  63468. */
  63469. register(): void;
  63470. /**
  63471. * Rebuilds the elements related to this component in case of
  63472. * context lost for instance.
  63473. */
  63474. rebuild(): void;
  63475. /**
  63476. * Disposes the component and the associated ressources.
  63477. */
  63478. dispose(): void;
  63479. /**
  63480. * Renders the outline in the canvas.
  63481. * @param subMesh Defines the sumesh to render
  63482. * @param batch Defines the batch of meshes in case of instances
  63483. * @param useOverlay Defines if the rendering is for the overlay or the outline
  63484. */
  63485. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  63486. /**
  63487. * Returns whether or not the outline renderer is ready for a given submesh.
  63488. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  63489. * @param subMesh Defines the submesh to check readyness for
  63490. * @param useInstances Defines wheter wee are trying to render instances or not
  63491. * @returns true if ready otherwise false
  63492. */
  63493. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63494. private _beforeRenderingMesh;
  63495. private _afterRenderingMesh;
  63496. }
  63497. }
  63498. declare module BABYLON {
  63499. /**
  63500. * Class used to manage multiple sprites of different sizes on the same spritesheet
  63501. * @see http://doc.babylonjs.com/babylon101/sprites
  63502. */
  63503. export class SpritePackedManager extends SpriteManager {
  63504. /** defines the packed manager's name */
  63505. name: string;
  63506. /**
  63507. * Creates a new sprite manager from a packed sprite sheet
  63508. * @param name defines the manager's name
  63509. * @param imgUrl defines the sprite sheet url
  63510. * @param capacity defines the maximum allowed number of sprites
  63511. * @param scene defines the hosting scene
  63512. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  63513. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  63514. * @param samplingMode defines the smapling mode to use with spritesheet
  63515. * @param fromPacked set to true; do not alter
  63516. */
  63517. constructor(
  63518. /** defines the packed manager's name */
  63519. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  63520. }
  63521. }
  63522. declare module BABYLON {
  63523. /**
  63524. * Defines the list of states available for a task inside a AssetsManager
  63525. */
  63526. export enum AssetTaskState {
  63527. /**
  63528. * Initialization
  63529. */
  63530. INIT = 0,
  63531. /**
  63532. * Running
  63533. */
  63534. RUNNING = 1,
  63535. /**
  63536. * Done
  63537. */
  63538. DONE = 2,
  63539. /**
  63540. * Error
  63541. */
  63542. ERROR = 3
  63543. }
  63544. /**
  63545. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  63546. */
  63547. export abstract class AbstractAssetTask {
  63548. /**
  63549. * Task name
  63550. */ name: string;
  63551. /**
  63552. * Callback called when the task is successful
  63553. */
  63554. onSuccess: (task: any) => void;
  63555. /**
  63556. * Callback called when the task is not successful
  63557. */
  63558. onError: (task: any, message?: string, exception?: any) => void;
  63559. /**
  63560. * Creates a new AssetsManager
  63561. * @param name defines the name of the task
  63562. */
  63563. constructor(
  63564. /**
  63565. * Task name
  63566. */ name: string);
  63567. private _isCompleted;
  63568. private _taskState;
  63569. private _errorObject;
  63570. /**
  63571. * Get if the task is completed
  63572. */
  63573. readonly isCompleted: boolean;
  63574. /**
  63575. * Gets the current state of the task
  63576. */
  63577. readonly taskState: AssetTaskState;
  63578. /**
  63579. * Gets the current error object (if task is in error)
  63580. */
  63581. readonly errorObject: {
  63582. message?: string;
  63583. exception?: any;
  63584. };
  63585. /**
  63586. * Internal only
  63587. * @hidden
  63588. */
  63589. _setErrorObject(message?: string, exception?: any): void;
  63590. /**
  63591. * Execute the current task
  63592. * @param scene defines the scene where you want your assets to be loaded
  63593. * @param onSuccess is a callback called when the task is successfully executed
  63594. * @param onError is a callback called if an error occurs
  63595. */
  63596. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63597. /**
  63598. * Execute the current task
  63599. * @param scene defines the scene where you want your assets to be loaded
  63600. * @param onSuccess is a callback called when the task is successfully executed
  63601. * @param onError is a callback called if an error occurs
  63602. */
  63603. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63604. /**
  63605. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  63606. * This can be used with failed tasks that have the reason for failure fixed.
  63607. */
  63608. reset(): void;
  63609. private onErrorCallback;
  63610. private onDoneCallback;
  63611. }
  63612. /**
  63613. * Define the interface used by progress events raised during assets loading
  63614. */
  63615. export interface IAssetsProgressEvent {
  63616. /**
  63617. * Defines the number of remaining tasks to process
  63618. */
  63619. remainingCount: number;
  63620. /**
  63621. * Defines the total number of tasks
  63622. */
  63623. totalCount: number;
  63624. /**
  63625. * Defines the task that was just processed
  63626. */
  63627. task: AbstractAssetTask;
  63628. }
  63629. /**
  63630. * Class used to share progress information about assets loading
  63631. */
  63632. export class AssetsProgressEvent implements IAssetsProgressEvent {
  63633. /**
  63634. * Defines the number of remaining tasks to process
  63635. */
  63636. remainingCount: number;
  63637. /**
  63638. * Defines the total number of tasks
  63639. */
  63640. totalCount: number;
  63641. /**
  63642. * Defines the task that was just processed
  63643. */
  63644. task: AbstractAssetTask;
  63645. /**
  63646. * Creates a AssetsProgressEvent
  63647. * @param remainingCount defines the number of remaining tasks to process
  63648. * @param totalCount defines the total number of tasks
  63649. * @param task defines the task that was just processed
  63650. */
  63651. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  63652. }
  63653. /**
  63654. * Define a task used by AssetsManager to load meshes
  63655. */
  63656. export class MeshAssetTask extends AbstractAssetTask {
  63657. /**
  63658. * Defines the name of the task
  63659. */
  63660. name: string;
  63661. /**
  63662. * Defines the list of mesh's names you want to load
  63663. */
  63664. meshesNames: any;
  63665. /**
  63666. * Defines the root url to use as a base to load your meshes and associated resources
  63667. */
  63668. rootUrl: string;
  63669. /**
  63670. * Defines the filename of the scene to load from
  63671. */
  63672. sceneFilename: string;
  63673. /**
  63674. * Gets the list of loaded meshes
  63675. */
  63676. loadedMeshes: Array<AbstractMesh>;
  63677. /**
  63678. * Gets the list of loaded particle systems
  63679. */
  63680. loadedParticleSystems: Array<IParticleSystem>;
  63681. /**
  63682. * Gets the list of loaded skeletons
  63683. */
  63684. loadedSkeletons: Array<Skeleton>;
  63685. /**
  63686. * Gets the list of loaded animation groups
  63687. */
  63688. loadedAnimationGroups: Array<AnimationGroup>;
  63689. /**
  63690. * Callback called when the task is successful
  63691. */
  63692. onSuccess: (task: MeshAssetTask) => void;
  63693. /**
  63694. * Callback called when the task is successful
  63695. */
  63696. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  63697. /**
  63698. * Creates a new MeshAssetTask
  63699. * @param name defines the name of the task
  63700. * @param meshesNames defines the list of mesh's names you want to load
  63701. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  63702. * @param sceneFilename defines the filename of the scene to load from
  63703. */
  63704. constructor(
  63705. /**
  63706. * Defines the name of the task
  63707. */
  63708. name: string,
  63709. /**
  63710. * Defines the list of mesh's names you want to load
  63711. */
  63712. meshesNames: any,
  63713. /**
  63714. * Defines the root url to use as a base to load your meshes and associated resources
  63715. */
  63716. rootUrl: string,
  63717. /**
  63718. * Defines the filename of the scene to load from
  63719. */
  63720. sceneFilename: string);
  63721. /**
  63722. * Execute the current task
  63723. * @param scene defines the scene where you want your assets to be loaded
  63724. * @param onSuccess is a callback called when the task is successfully executed
  63725. * @param onError is a callback called if an error occurs
  63726. */
  63727. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63728. }
  63729. /**
  63730. * Define a task used by AssetsManager to load text content
  63731. */
  63732. export class TextFileAssetTask extends AbstractAssetTask {
  63733. /**
  63734. * Defines the name of the task
  63735. */
  63736. name: string;
  63737. /**
  63738. * Defines the location of the file to load
  63739. */
  63740. url: string;
  63741. /**
  63742. * Gets the loaded text string
  63743. */
  63744. text: string;
  63745. /**
  63746. * Callback called when the task is successful
  63747. */
  63748. onSuccess: (task: TextFileAssetTask) => void;
  63749. /**
  63750. * Callback called when the task is successful
  63751. */
  63752. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  63753. /**
  63754. * Creates a new TextFileAssetTask object
  63755. * @param name defines the name of the task
  63756. * @param url defines the location of the file to load
  63757. */
  63758. constructor(
  63759. /**
  63760. * Defines the name of the task
  63761. */
  63762. name: string,
  63763. /**
  63764. * Defines the location of the file to load
  63765. */
  63766. url: string);
  63767. /**
  63768. * Execute the current task
  63769. * @param scene defines the scene where you want your assets to be loaded
  63770. * @param onSuccess is a callback called when the task is successfully executed
  63771. * @param onError is a callback called if an error occurs
  63772. */
  63773. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63774. }
  63775. /**
  63776. * Define a task used by AssetsManager to load binary data
  63777. */
  63778. export class BinaryFileAssetTask extends AbstractAssetTask {
  63779. /**
  63780. * Defines the name of the task
  63781. */
  63782. name: string;
  63783. /**
  63784. * Defines the location of the file to load
  63785. */
  63786. url: string;
  63787. /**
  63788. * Gets the lodaded data (as an array buffer)
  63789. */
  63790. data: ArrayBuffer;
  63791. /**
  63792. * Callback called when the task is successful
  63793. */
  63794. onSuccess: (task: BinaryFileAssetTask) => void;
  63795. /**
  63796. * Callback called when the task is successful
  63797. */
  63798. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  63799. /**
  63800. * Creates a new BinaryFileAssetTask object
  63801. * @param name defines the name of the new task
  63802. * @param url defines the location of the file to load
  63803. */
  63804. constructor(
  63805. /**
  63806. * Defines the name of the task
  63807. */
  63808. name: string,
  63809. /**
  63810. * Defines the location of the file to load
  63811. */
  63812. url: string);
  63813. /**
  63814. * Execute the current task
  63815. * @param scene defines the scene where you want your assets to be loaded
  63816. * @param onSuccess is a callback called when the task is successfully executed
  63817. * @param onError is a callback called if an error occurs
  63818. */
  63819. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63820. }
  63821. /**
  63822. * Define a task used by AssetsManager to load images
  63823. */
  63824. export class ImageAssetTask extends AbstractAssetTask {
  63825. /**
  63826. * Defines the name of the task
  63827. */
  63828. name: string;
  63829. /**
  63830. * Defines the location of the image to load
  63831. */
  63832. url: string;
  63833. /**
  63834. * Gets the loaded images
  63835. */
  63836. image: HTMLImageElement;
  63837. /**
  63838. * Callback called when the task is successful
  63839. */
  63840. onSuccess: (task: ImageAssetTask) => void;
  63841. /**
  63842. * Callback called when the task is successful
  63843. */
  63844. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  63845. /**
  63846. * Creates a new ImageAssetTask
  63847. * @param name defines the name of the task
  63848. * @param url defines the location of the image to load
  63849. */
  63850. constructor(
  63851. /**
  63852. * Defines the name of the task
  63853. */
  63854. name: string,
  63855. /**
  63856. * Defines the location of the image to load
  63857. */
  63858. url: string);
  63859. /**
  63860. * Execute the current task
  63861. * @param scene defines the scene where you want your assets to be loaded
  63862. * @param onSuccess is a callback called when the task is successfully executed
  63863. * @param onError is a callback called if an error occurs
  63864. */
  63865. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63866. }
  63867. /**
  63868. * Defines the interface used by texture loading tasks
  63869. */
  63870. export interface ITextureAssetTask<TEX extends BaseTexture> {
  63871. /**
  63872. * Gets the loaded texture
  63873. */
  63874. texture: TEX;
  63875. }
  63876. /**
  63877. * Define a task used by AssetsManager to load 2D textures
  63878. */
  63879. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  63880. /**
  63881. * Defines the name of the task
  63882. */
  63883. name: string;
  63884. /**
  63885. * Defines the location of the file to load
  63886. */
  63887. url: string;
  63888. /**
  63889. * Defines if mipmap should not be generated (default is false)
  63890. */
  63891. noMipmap?: boolean | undefined;
  63892. /**
  63893. * Defines if texture must be inverted on Y axis (default is false)
  63894. */
  63895. invertY?: boolean | undefined;
  63896. /**
  63897. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  63898. */
  63899. samplingMode: number;
  63900. /**
  63901. * Gets the loaded texture
  63902. */
  63903. texture: Texture;
  63904. /**
  63905. * Callback called when the task is successful
  63906. */
  63907. onSuccess: (task: TextureAssetTask) => void;
  63908. /**
  63909. * Callback called when the task is successful
  63910. */
  63911. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  63912. /**
  63913. * Creates a new TextureAssetTask object
  63914. * @param name defines the name of the task
  63915. * @param url defines the location of the file to load
  63916. * @param noMipmap defines if mipmap should not be generated (default is false)
  63917. * @param invertY defines if texture must be inverted on Y axis (default is false)
  63918. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  63919. */
  63920. constructor(
  63921. /**
  63922. * Defines the name of the task
  63923. */
  63924. name: string,
  63925. /**
  63926. * Defines the location of the file to load
  63927. */
  63928. url: string,
  63929. /**
  63930. * Defines if mipmap should not be generated (default is false)
  63931. */
  63932. noMipmap?: boolean | undefined,
  63933. /**
  63934. * Defines if texture must be inverted on Y axis (default is false)
  63935. */
  63936. invertY?: boolean | undefined,
  63937. /**
  63938. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  63939. */
  63940. samplingMode?: number);
  63941. /**
  63942. * Execute the current task
  63943. * @param scene defines the scene where you want your assets to be loaded
  63944. * @param onSuccess is a callback called when the task is successfully executed
  63945. * @param onError is a callback called if an error occurs
  63946. */
  63947. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63948. }
  63949. /**
  63950. * Define a task used by AssetsManager to load cube textures
  63951. */
  63952. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  63953. /**
  63954. * Defines the name of the task
  63955. */
  63956. name: string;
  63957. /**
  63958. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  63959. */
  63960. url: string;
  63961. /**
  63962. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  63963. */
  63964. extensions?: string[] | undefined;
  63965. /**
  63966. * Defines if mipmaps should not be generated (default is false)
  63967. */
  63968. noMipmap?: boolean | undefined;
  63969. /**
  63970. * Defines the explicit list of files (undefined by default)
  63971. */
  63972. files?: string[] | undefined;
  63973. /**
  63974. * Gets the loaded texture
  63975. */
  63976. texture: CubeTexture;
  63977. /**
  63978. * Callback called when the task is successful
  63979. */
  63980. onSuccess: (task: CubeTextureAssetTask) => void;
  63981. /**
  63982. * Callback called when the task is successful
  63983. */
  63984. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  63985. /**
  63986. * Creates a new CubeTextureAssetTask
  63987. * @param name defines the name of the task
  63988. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  63989. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  63990. * @param noMipmap defines if mipmaps should not be generated (default is false)
  63991. * @param files defines the explicit list of files (undefined by default)
  63992. */
  63993. constructor(
  63994. /**
  63995. * Defines the name of the task
  63996. */
  63997. name: string,
  63998. /**
  63999. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  64000. */
  64001. url: string,
  64002. /**
  64003. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  64004. */
  64005. extensions?: string[] | undefined,
  64006. /**
  64007. * Defines if mipmaps should not be generated (default is false)
  64008. */
  64009. noMipmap?: boolean | undefined,
  64010. /**
  64011. * Defines the explicit list of files (undefined by default)
  64012. */
  64013. files?: string[] | undefined);
  64014. /**
  64015. * Execute the current task
  64016. * @param scene defines the scene where you want your assets to be loaded
  64017. * @param onSuccess is a callback called when the task is successfully executed
  64018. * @param onError is a callback called if an error occurs
  64019. */
  64020. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64021. }
  64022. /**
  64023. * Define a task used by AssetsManager to load HDR cube textures
  64024. */
  64025. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  64026. /**
  64027. * Defines the name of the task
  64028. */
  64029. name: string;
  64030. /**
  64031. * Defines the location of the file to load
  64032. */
  64033. url: string;
  64034. /**
  64035. * Defines the desired size (the more it increases the longer the generation will be)
  64036. */
  64037. size: number;
  64038. /**
  64039. * Defines if mipmaps should not be generated (default is false)
  64040. */
  64041. noMipmap: boolean;
  64042. /**
  64043. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  64044. */
  64045. generateHarmonics: boolean;
  64046. /**
  64047. * 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)
  64048. */
  64049. gammaSpace: boolean;
  64050. /**
  64051. * Internal Use Only
  64052. */
  64053. reserved: boolean;
  64054. /**
  64055. * Gets the loaded texture
  64056. */
  64057. texture: HDRCubeTexture;
  64058. /**
  64059. * Callback called when the task is successful
  64060. */
  64061. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  64062. /**
  64063. * Callback called when the task is successful
  64064. */
  64065. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  64066. /**
  64067. * Creates a new HDRCubeTextureAssetTask object
  64068. * @param name defines the name of the task
  64069. * @param url defines the location of the file to load
  64070. * @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.
  64071. * @param noMipmap defines if mipmaps should not be generated (default is false)
  64072. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  64073. * @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)
  64074. * @param reserved Internal use only
  64075. */
  64076. constructor(
  64077. /**
  64078. * Defines the name of the task
  64079. */
  64080. name: string,
  64081. /**
  64082. * Defines the location of the file to load
  64083. */
  64084. url: string,
  64085. /**
  64086. * Defines the desired size (the more it increases the longer the generation will be)
  64087. */
  64088. size: number,
  64089. /**
  64090. * Defines if mipmaps should not be generated (default is false)
  64091. */
  64092. noMipmap?: boolean,
  64093. /**
  64094. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  64095. */
  64096. generateHarmonics?: boolean,
  64097. /**
  64098. * 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)
  64099. */
  64100. gammaSpace?: boolean,
  64101. /**
  64102. * Internal Use Only
  64103. */
  64104. reserved?: boolean);
  64105. /**
  64106. * Execute the current task
  64107. * @param scene defines the scene where you want your assets to be loaded
  64108. * @param onSuccess is a callback called when the task is successfully executed
  64109. * @param onError is a callback called if an error occurs
  64110. */
  64111. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64112. }
  64113. /**
  64114. * Define a task used by AssetsManager to load Equirectangular cube textures
  64115. */
  64116. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  64117. /**
  64118. * Defines the name of the task
  64119. */
  64120. name: string;
  64121. /**
  64122. * Defines the location of the file to load
  64123. */
  64124. url: string;
  64125. /**
  64126. * Defines the desired size (the more it increases the longer the generation will be)
  64127. */
  64128. size: number;
  64129. /**
  64130. * Defines if mipmaps should not be generated (default is false)
  64131. */
  64132. noMipmap: boolean;
  64133. /**
  64134. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  64135. * but the standard material would require them in Gamma space) (default is true)
  64136. */
  64137. gammaSpace: boolean;
  64138. /**
  64139. * Gets the loaded texture
  64140. */
  64141. texture: EquiRectangularCubeTexture;
  64142. /**
  64143. * Callback called when the task is successful
  64144. */
  64145. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  64146. /**
  64147. * Callback called when the task is successful
  64148. */
  64149. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  64150. /**
  64151. * Creates a new EquiRectangularCubeTextureAssetTask object
  64152. * @param name defines the name of the task
  64153. * @param url defines the location of the file to load
  64154. * @param size defines the desired size (the more it increases the longer the generation will be)
  64155. * If the size is omitted this implies you are using a preprocessed cubemap.
  64156. * @param noMipmap defines if mipmaps should not be generated (default is false)
  64157. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  64158. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  64159. * (default is true)
  64160. */
  64161. constructor(
  64162. /**
  64163. * Defines the name of the task
  64164. */
  64165. name: string,
  64166. /**
  64167. * Defines the location of the file to load
  64168. */
  64169. url: string,
  64170. /**
  64171. * Defines the desired size (the more it increases the longer the generation will be)
  64172. */
  64173. size: number,
  64174. /**
  64175. * Defines if mipmaps should not be generated (default is false)
  64176. */
  64177. noMipmap?: boolean,
  64178. /**
  64179. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  64180. * but the standard material would require them in Gamma space) (default is true)
  64181. */
  64182. gammaSpace?: boolean);
  64183. /**
  64184. * Execute the current task
  64185. * @param scene defines the scene where you want your assets to be loaded
  64186. * @param onSuccess is a callback called when the task is successfully executed
  64187. * @param onError is a callback called if an error occurs
  64188. */
  64189. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64190. }
  64191. /**
  64192. * This class can be used to easily import assets into a scene
  64193. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  64194. */
  64195. export class AssetsManager {
  64196. private _scene;
  64197. private _isLoading;
  64198. protected _tasks: AbstractAssetTask[];
  64199. protected _waitingTasksCount: number;
  64200. protected _totalTasksCount: number;
  64201. /**
  64202. * Callback called when all tasks are processed
  64203. */
  64204. onFinish: (tasks: AbstractAssetTask[]) => void;
  64205. /**
  64206. * Callback called when a task is successful
  64207. */
  64208. onTaskSuccess: (task: AbstractAssetTask) => void;
  64209. /**
  64210. * Callback called when a task had an error
  64211. */
  64212. onTaskError: (task: AbstractAssetTask) => void;
  64213. /**
  64214. * Callback called when a task is done (whatever the result is)
  64215. */
  64216. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  64217. /**
  64218. * Observable called when all tasks are processed
  64219. */
  64220. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  64221. /**
  64222. * Observable called when a task had an error
  64223. */
  64224. onTaskErrorObservable: Observable<AbstractAssetTask>;
  64225. /**
  64226. * Observable called when all tasks were executed
  64227. */
  64228. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  64229. /**
  64230. * Observable called when a task is done (whatever the result is)
  64231. */
  64232. onProgressObservable: Observable<IAssetsProgressEvent>;
  64233. /**
  64234. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  64235. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  64236. */
  64237. useDefaultLoadingScreen: boolean;
  64238. /**
  64239. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  64240. * when all assets have been downloaded.
  64241. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  64242. */
  64243. autoHideLoadingUI: boolean;
  64244. /**
  64245. * Creates a new AssetsManager
  64246. * @param scene defines the scene to work on
  64247. */
  64248. constructor(scene: Scene);
  64249. /**
  64250. * Add a MeshAssetTask to the list of active tasks
  64251. * @param taskName defines the name of the new task
  64252. * @param meshesNames defines the name of meshes to load
  64253. * @param rootUrl defines the root url to use to locate files
  64254. * @param sceneFilename defines the filename of the scene file
  64255. * @returns a new MeshAssetTask object
  64256. */
  64257. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  64258. /**
  64259. * Add a TextFileAssetTask to the list of active tasks
  64260. * @param taskName defines the name of the new task
  64261. * @param url defines the url of the file to load
  64262. * @returns a new TextFileAssetTask object
  64263. */
  64264. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  64265. /**
  64266. * Add a BinaryFileAssetTask to the list of active tasks
  64267. * @param taskName defines the name of the new task
  64268. * @param url defines the url of the file to load
  64269. * @returns a new BinaryFileAssetTask object
  64270. */
  64271. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  64272. /**
  64273. * Add a ImageAssetTask to the list of active tasks
  64274. * @param taskName defines the name of the new task
  64275. * @param url defines the url of the file to load
  64276. * @returns a new ImageAssetTask object
  64277. */
  64278. addImageTask(taskName: string, url: string): ImageAssetTask;
  64279. /**
  64280. * Add a TextureAssetTask to the list of active tasks
  64281. * @param taskName defines the name of the new task
  64282. * @param url defines the url of the file to load
  64283. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  64284. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  64285. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  64286. * @returns a new TextureAssetTask object
  64287. */
  64288. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  64289. /**
  64290. * Add a CubeTextureAssetTask to the list of active tasks
  64291. * @param taskName defines the name of the new task
  64292. * @param url defines the url of the file to load
  64293. * @param extensions defines the extension to use to load the cube map (can be null)
  64294. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  64295. * @param files defines the list of files to load (can be null)
  64296. * @returns a new CubeTextureAssetTask object
  64297. */
  64298. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  64299. /**
  64300. *
  64301. * Add a HDRCubeTextureAssetTask to the list of active tasks
  64302. * @param taskName defines the name of the new task
  64303. * @param url defines the url of the file to load
  64304. * @param size defines the size you want for the cubemap (can be null)
  64305. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  64306. * @param generateHarmonics defines if you want to automatically generate (true by default)
  64307. * @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)
  64308. * @param reserved Internal use only
  64309. * @returns a new HDRCubeTextureAssetTask object
  64310. */
  64311. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  64312. /**
  64313. *
  64314. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  64315. * @param taskName defines the name of the new task
  64316. * @param url defines the url of the file to load
  64317. * @param size defines the size you want for the cubemap (can be null)
  64318. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  64319. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  64320. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  64321. * @returns a new EquiRectangularCubeTextureAssetTask object
  64322. */
  64323. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  64324. /**
  64325. * Remove a task from the assets manager.
  64326. * @param task the task to remove
  64327. */
  64328. removeTask(task: AbstractAssetTask): void;
  64329. private _decreaseWaitingTasksCount;
  64330. private _runTask;
  64331. /**
  64332. * Reset the AssetsManager and remove all tasks
  64333. * @return the current instance of the AssetsManager
  64334. */
  64335. reset(): AssetsManager;
  64336. /**
  64337. * Start the loading process
  64338. * @return the current instance of the AssetsManager
  64339. */
  64340. load(): AssetsManager;
  64341. /**
  64342. * Start the loading process as an async operation
  64343. * @return a promise returning the list of failed tasks
  64344. */
  64345. loadAsync(): Promise<void>;
  64346. }
  64347. }
  64348. declare module BABYLON {
  64349. /**
  64350. * Wrapper class for promise with external resolve and reject.
  64351. */
  64352. export class Deferred<T> {
  64353. /**
  64354. * The promise associated with this deferred object.
  64355. */
  64356. readonly promise: Promise<T>;
  64357. private _resolve;
  64358. private _reject;
  64359. /**
  64360. * The resolve method of the promise associated with this deferred object.
  64361. */
  64362. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  64363. /**
  64364. * The reject method of the promise associated with this deferred object.
  64365. */
  64366. readonly reject: (reason?: any) => void;
  64367. /**
  64368. * Constructor for this deferred object.
  64369. */
  64370. constructor();
  64371. }
  64372. }
  64373. declare module BABYLON {
  64374. /**
  64375. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  64376. */
  64377. export class MeshExploder {
  64378. private _centerMesh;
  64379. private _meshes;
  64380. private _meshesOrigins;
  64381. private _toCenterVectors;
  64382. private _scaledDirection;
  64383. private _newPosition;
  64384. private _centerPosition;
  64385. /**
  64386. * Explodes meshes from a center mesh.
  64387. * @param meshes The meshes to explode.
  64388. * @param centerMesh The mesh to be center of explosion.
  64389. */
  64390. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  64391. private _setCenterMesh;
  64392. /**
  64393. * Get class name
  64394. * @returns "MeshExploder"
  64395. */
  64396. getClassName(): string;
  64397. /**
  64398. * "Exploded meshes"
  64399. * @returns Array of meshes with the centerMesh at index 0.
  64400. */
  64401. getMeshes(): Array<Mesh>;
  64402. /**
  64403. * Explodes meshes giving a specific direction
  64404. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  64405. */
  64406. explode(direction?: number): void;
  64407. }
  64408. }
  64409. declare module BABYLON {
  64410. /**
  64411. * Class used to help managing file picking and drag'n'drop
  64412. */
  64413. export class FilesInput {
  64414. /**
  64415. * List of files ready to be loaded
  64416. */
  64417. static readonly FilesToLoad: {
  64418. [key: string]: File;
  64419. };
  64420. /**
  64421. * Callback called when a file is processed
  64422. */
  64423. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  64424. private _engine;
  64425. private _currentScene;
  64426. private _sceneLoadedCallback;
  64427. private _progressCallback;
  64428. private _additionalRenderLoopLogicCallback;
  64429. private _textureLoadingCallback;
  64430. private _startingProcessingFilesCallback;
  64431. private _onReloadCallback;
  64432. private _errorCallback;
  64433. private _elementToMonitor;
  64434. private _sceneFileToLoad;
  64435. private _filesToLoad;
  64436. /**
  64437. * Creates a new FilesInput
  64438. * @param engine defines the rendering engine
  64439. * @param scene defines the hosting scene
  64440. * @param sceneLoadedCallback callback called when scene is loaded
  64441. * @param progressCallback callback called to track progress
  64442. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  64443. * @param textureLoadingCallback callback called when a texture is loading
  64444. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  64445. * @param onReloadCallback callback called when a reload is requested
  64446. * @param errorCallback callback call if an error occurs
  64447. */
  64448. 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);
  64449. private _dragEnterHandler;
  64450. private _dragOverHandler;
  64451. private _dropHandler;
  64452. /**
  64453. * Calls this function to listen to drag'n'drop events on a specific DOM element
  64454. * @param elementToMonitor defines the DOM element to track
  64455. */
  64456. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  64457. /**
  64458. * Release all associated resources
  64459. */
  64460. dispose(): void;
  64461. private renderFunction;
  64462. private drag;
  64463. private drop;
  64464. private _traverseFolder;
  64465. private _processFiles;
  64466. /**
  64467. * Load files from a drop event
  64468. * @param event defines the drop event to use as source
  64469. */
  64470. loadFiles(event: any): void;
  64471. private _processReload;
  64472. /**
  64473. * Reload the current scene from the loaded files
  64474. */
  64475. reload(): void;
  64476. }
  64477. }
  64478. declare module BABYLON {
  64479. /**
  64480. * Defines the root class used to create scene optimization to use with SceneOptimizer
  64481. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64482. */
  64483. export class SceneOptimization {
  64484. /**
  64485. * Defines the priority of this optimization (0 by default which means first in the list)
  64486. */
  64487. priority: number;
  64488. /**
  64489. * Gets a string describing the action executed by the current optimization
  64490. * @returns description string
  64491. */
  64492. getDescription(): string;
  64493. /**
  64494. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64495. * @param scene defines the current scene where to apply this optimization
  64496. * @param optimizer defines the current optimizer
  64497. * @returns true if everything that can be done was applied
  64498. */
  64499. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64500. /**
  64501. * Creates the SceneOptimization object
  64502. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  64503. * @param desc defines the description associated with the optimization
  64504. */
  64505. constructor(
  64506. /**
  64507. * Defines the priority of this optimization (0 by default which means first in the list)
  64508. */
  64509. priority?: number);
  64510. }
  64511. /**
  64512. * Defines an optimization used to reduce the size of render target textures
  64513. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64514. */
  64515. export class TextureOptimization extends SceneOptimization {
  64516. /**
  64517. * Defines the priority of this optimization (0 by default which means first in the list)
  64518. */
  64519. priority: number;
  64520. /**
  64521. * 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
  64522. */
  64523. maximumSize: number;
  64524. /**
  64525. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  64526. */
  64527. step: number;
  64528. /**
  64529. * Gets a string describing the action executed by the current optimization
  64530. * @returns description string
  64531. */
  64532. getDescription(): string;
  64533. /**
  64534. * Creates the TextureOptimization object
  64535. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  64536. * @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
  64537. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  64538. */
  64539. constructor(
  64540. /**
  64541. * Defines the priority of this optimization (0 by default which means first in the list)
  64542. */
  64543. priority?: number,
  64544. /**
  64545. * 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
  64546. */
  64547. maximumSize?: number,
  64548. /**
  64549. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  64550. */
  64551. step?: number);
  64552. /**
  64553. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64554. * @param scene defines the current scene where to apply this optimization
  64555. * @param optimizer defines the current optimizer
  64556. * @returns true if everything that can be done was applied
  64557. */
  64558. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64559. }
  64560. /**
  64561. * Defines an optimization used to increase or decrease the rendering resolution
  64562. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64563. */
  64564. export class HardwareScalingOptimization extends SceneOptimization {
  64565. /**
  64566. * Defines the priority of this optimization (0 by default which means first in the list)
  64567. */
  64568. priority: number;
  64569. /**
  64570. * Defines the maximum scale to use (2 by default)
  64571. */
  64572. maximumScale: number;
  64573. /**
  64574. * Defines the step to use between two passes (0.5 by default)
  64575. */
  64576. step: number;
  64577. private _currentScale;
  64578. private _directionOffset;
  64579. /**
  64580. * Gets a string describing the action executed by the current optimization
  64581. * @return description string
  64582. */
  64583. getDescription(): string;
  64584. /**
  64585. * Creates the HardwareScalingOptimization object
  64586. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  64587. * @param maximumScale defines the maximum scale to use (2 by default)
  64588. * @param step defines the step to use between two passes (0.5 by default)
  64589. */
  64590. constructor(
  64591. /**
  64592. * Defines the priority of this optimization (0 by default which means first in the list)
  64593. */
  64594. priority?: number,
  64595. /**
  64596. * Defines the maximum scale to use (2 by default)
  64597. */
  64598. maximumScale?: number,
  64599. /**
  64600. * Defines the step to use between two passes (0.5 by default)
  64601. */
  64602. step?: number);
  64603. /**
  64604. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64605. * @param scene defines the current scene where to apply this optimization
  64606. * @param optimizer defines the current optimizer
  64607. * @returns true if everything that can be done was applied
  64608. */
  64609. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64610. }
  64611. /**
  64612. * Defines an optimization used to remove shadows
  64613. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64614. */
  64615. export class ShadowsOptimization extends SceneOptimization {
  64616. /**
  64617. * Gets a string describing the action executed by the current optimization
  64618. * @return description string
  64619. */
  64620. getDescription(): string;
  64621. /**
  64622. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64623. * @param scene defines the current scene where to apply this optimization
  64624. * @param optimizer defines the current optimizer
  64625. * @returns true if everything that can be done was applied
  64626. */
  64627. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64628. }
  64629. /**
  64630. * Defines an optimization used to turn post-processes off
  64631. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64632. */
  64633. export class PostProcessesOptimization extends SceneOptimization {
  64634. /**
  64635. * Gets a string describing the action executed by the current optimization
  64636. * @return description string
  64637. */
  64638. getDescription(): string;
  64639. /**
  64640. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64641. * @param scene defines the current scene where to apply this optimization
  64642. * @param optimizer defines the current optimizer
  64643. * @returns true if everything that can be done was applied
  64644. */
  64645. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64646. }
  64647. /**
  64648. * Defines an optimization used to turn lens flares off
  64649. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64650. */
  64651. export class LensFlaresOptimization extends SceneOptimization {
  64652. /**
  64653. * Gets a string describing the action executed by the current optimization
  64654. * @return description string
  64655. */
  64656. getDescription(): string;
  64657. /**
  64658. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64659. * @param scene defines the current scene where to apply this optimization
  64660. * @param optimizer defines the current optimizer
  64661. * @returns true if everything that can be done was applied
  64662. */
  64663. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64664. }
  64665. /**
  64666. * Defines an optimization based on user defined callback.
  64667. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64668. */
  64669. export class CustomOptimization extends SceneOptimization {
  64670. /**
  64671. * Callback called to apply the custom optimization.
  64672. */
  64673. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  64674. /**
  64675. * Callback called to get custom description
  64676. */
  64677. onGetDescription: () => string;
  64678. /**
  64679. * Gets a string describing the action executed by the current optimization
  64680. * @returns description string
  64681. */
  64682. getDescription(): string;
  64683. /**
  64684. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64685. * @param scene defines the current scene where to apply this optimization
  64686. * @param optimizer defines the current optimizer
  64687. * @returns true if everything that can be done was applied
  64688. */
  64689. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64690. }
  64691. /**
  64692. * Defines an optimization used to turn particles off
  64693. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64694. */
  64695. export class ParticlesOptimization extends SceneOptimization {
  64696. /**
  64697. * Gets a string describing the action executed by the current optimization
  64698. * @return description string
  64699. */
  64700. getDescription(): string;
  64701. /**
  64702. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64703. * @param scene defines the current scene where to apply this optimization
  64704. * @param optimizer defines the current optimizer
  64705. * @returns true if everything that can be done was applied
  64706. */
  64707. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64708. }
  64709. /**
  64710. * Defines an optimization used to turn render targets off
  64711. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64712. */
  64713. export class RenderTargetsOptimization extends SceneOptimization {
  64714. /**
  64715. * Gets a string describing the action executed by the current optimization
  64716. * @return description string
  64717. */
  64718. getDescription(): string;
  64719. /**
  64720. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64721. * @param scene defines the current scene where to apply this optimization
  64722. * @param optimizer defines the current optimizer
  64723. * @returns true if everything that can be done was applied
  64724. */
  64725. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64726. }
  64727. /**
  64728. * Defines an optimization used to merge meshes with compatible materials
  64729. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64730. */
  64731. export class MergeMeshesOptimization extends SceneOptimization {
  64732. private static _UpdateSelectionTree;
  64733. /**
  64734. * Gets or sets a boolean which defines if optimization octree has to be updated
  64735. */
  64736. /**
  64737. * Gets or sets a boolean which defines if optimization octree has to be updated
  64738. */
  64739. static UpdateSelectionTree: boolean;
  64740. /**
  64741. * Gets a string describing the action executed by the current optimization
  64742. * @return description string
  64743. */
  64744. getDescription(): string;
  64745. private _canBeMerged;
  64746. /**
  64747. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64748. * @param scene defines the current scene where to apply this optimization
  64749. * @param optimizer defines the current optimizer
  64750. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  64751. * @returns true if everything that can be done was applied
  64752. */
  64753. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  64754. }
  64755. /**
  64756. * Defines a list of options used by SceneOptimizer
  64757. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64758. */
  64759. export class SceneOptimizerOptions {
  64760. /**
  64761. * Defines the target frame rate to reach (60 by default)
  64762. */
  64763. targetFrameRate: number;
  64764. /**
  64765. * Defines the interval between two checkes (2000ms by default)
  64766. */
  64767. trackerDuration: number;
  64768. /**
  64769. * Gets the list of optimizations to apply
  64770. */
  64771. optimizations: SceneOptimization[];
  64772. /**
  64773. * Creates a new list of options used by SceneOptimizer
  64774. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  64775. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  64776. */
  64777. constructor(
  64778. /**
  64779. * Defines the target frame rate to reach (60 by default)
  64780. */
  64781. targetFrameRate?: number,
  64782. /**
  64783. * Defines the interval between two checkes (2000ms by default)
  64784. */
  64785. trackerDuration?: number);
  64786. /**
  64787. * Add a new optimization
  64788. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  64789. * @returns the current SceneOptimizerOptions
  64790. */
  64791. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  64792. /**
  64793. * Add a new custom optimization
  64794. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  64795. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  64796. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  64797. * @returns the current SceneOptimizerOptions
  64798. */
  64799. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  64800. /**
  64801. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  64802. * @param targetFrameRate defines the target frame rate (60 by default)
  64803. * @returns a SceneOptimizerOptions object
  64804. */
  64805. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  64806. /**
  64807. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  64808. * @param targetFrameRate defines the target frame rate (60 by default)
  64809. * @returns a SceneOptimizerOptions object
  64810. */
  64811. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  64812. /**
  64813. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  64814. * @param targetFrameRate defines the target frame rate (60 by default)
  64815. * @returns a SceneOptimizerOptions object
  64816. */
  64817. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  64818. }
  64819. /**
  64820. * Class used to run optimizations in order to reach a target frame rate
  64821. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64822. */
  64823. export class SceneOptimizer implements IDisposable {
  64824. private _isRunning;
  64825. private _options;
  64826. private _scene;
  64827. private _currentPriorityLevel;
  64828. private _targetFrameRate;
  64829. private _trackerDuration;
  64830. private _currentFrameRate;
  64831. private _sceneDisposeObserver;
  64832. private _improvementMode;
  64833. /**
  64834. * Defines an observable called when the optimizer reaches the target frame rate
  64835. */
  64836. onSuccessObservable: Observable<SceneOptimizer>;
  64837. /**
  64838. * Defines an observable called when the optimizer enables an optimization
  64839. */
  64840. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  64841. /**
  64842. * Defines an observable called when the optimizer is not able to reach the target frame rate
  64843. */
  64844. onFailureObservable: Observable<SceneOptimizer>;
  64845. /**
  64846. * Gets a boolean indicating if the optimizer is in improvement mode
  64847. */
  64848. readonly isInImprovementMode: boolean;
  64849. /**
  64850. * Gets the current priority level (0 at start)
  64851. */
  64852. readonly currentPriorityLevel: number;
  64853. /**
  64854. * Gets the current frame rate checked by the SceneOptimizer
  64855. */
  64856. readonly currentFrameRate: number;
  64857. /**
  64858. * Gets or sets the current target frame rate (60 by default)
  64859. */
  64860. /**
  64861. * Gets or sets the current target frame rate (60 by default)
  64862. */
  64863. targetFrameRate: number;
  64864. /**
  64865. * Gets or sets the current interval between two checks (every 2000ms by default)
  64866. */
  64867. /**
  64868. * Gets or sets the current interval between two checks (every 2000ms by default)
  64869. */
  64870. trackerDuration: number;
  64871. /**
  64872. * Gets the list of active optimizations
  64873. */
  64874. readonly optimizations: SceneOptimization[];
  64875. /**
  64876. * Creates a new SceneOptimizer
  64877. * @param scene defines the scene to work on
  64878. * @param options defines the options to use with the SceneOptimizer
  64879. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  64880. * @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)
  64881. */
  64882. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  64883. /**
  64884. * Stops the current optimizer
  64885. */
  64886. stop(): void;
  64887. /**
  64888. * Reset the optimizer to initial step (current priority level = 0)
  64889. */
  64890. reset(): void;
  64891. /**
  64892. * Start the optimizer. By default it will try to reach a specific framerate
  64893. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  64894. */
  64895. start(): void;
  64896. private _checkCurrentState;
  64897. /**
  64898. * Release all resources
  64899. */
  64900. dispose(): void;
  64901. /**
  64902. * Helper function to create a SceneOptimizer with one single line of code
  64903. * @param scene defines the scene to work on
  64904. * @param options defines the options to use with the SceneOptimizer
  64905. * @param onSuccess defines a callback to call on success
  64906. * @param onFailure defines a callback to call on failure
  64907. * @returns the new SceneOptimizer object
  64908. */
  64909. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  64910. }
  64911. }
  64912. declare module BABYLON {
  64913. /**
  64914. * Class used to serialize a scene into a string
  64915. */
  64916. export class SceneSerializer {
  64917. /**
  64918. * Clear cache used by a previous serialization
  64919. */
  64920. static ClearCache(): void;
  64921. /**
  64922. * Serialize a scene into a JSON compatible object
  64923. * @param scene defines the scene to serialize
  64924. * @returns a JSON compatible object
  64925. */
  64926. static Serialize(scene: Scene): any;
  64927. /**
  64928. * Serialize a mesh into a JSON compatible object
  64929. * @param toSerialize defines the mesh to serialize
  64930. * @param withParents defines if parents must be serialized as well
  64931. * @param withChildren defines if children must be serialized as well
  64932. * @returns a JSON compatible object
  64933. */
  64934. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  64935. }
  64936. }
  64937. declare module BABYLON {
  64938. /**
  64939. * Class used to host texture specific utilities
  64940. */
  64941. export class TextureTools {
  64942. /**
  64943. * Uses the GPU to create a copy texture rescaled at a given size
  64944. * @param texture Texture to copy from
  64945. * @param width defines the desired width
  64946. * @param height defines the desired height
  64947. * @param useBilinearMode defines if bilinear mode has to be used
  64948. * @return the generated texture
  64949. */
  64950. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  64951. }
  64952. }
  64953. declare module BABYLON {
  64954. /**
  64955. * This represents the different options available for the video capture.
  64956. */
  64957. export interface VideoRecorderOptions {
  64958. /** Defines the mime type of the video. */
  64959. mimeType: string;
  64960. /** Defines the FPS the video should be recorded at. */
  64961. fps: number;
  64962. /** Defines the chunk size for the recording data. */
  64963. recordChunckSize: number;
  64964. /** The audio tracks to attach to the recording. */
  64965. audioTracks?: MediaStreamTrack[];
  64966. }
  64967. /**
  64968. * This can help with recording videos from BabylonJS.
  64969. * This is based on the available WebRTC functionalities of the browser.
  64970. *
  64971. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  64972. */
  64973. export class VideoRecorder {
  64974. private static readonly _defaultOptions;
  64975. /**
  64976. * Returns whether or not the VideoRecorder is available in your browser.
  64977. * @param engine Defines the Babylon Engine.
  64978. * @returns true if supported otherwise false.
  64979. */
  64980. static IsSupported(engine: Engine): boolean;
  64981. private readonly _options;
  64982. private _canvas;
  64983. private _mediaRecorder;
  64984. private _recordedChunks;
  64985. private _fileName;
  64986. private _resolve;
  64987. private _reject;
  64988. /**
  64989. * True when a recording is already in progress.
  64990. */
  64991. readonly isRecording: boolean;
  64992. /**
  64993. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  64994. * @param engine Defines the BabylonJS Engine you wish to record.
  64995. * @param options Defines options that can be used to customize the capture.
  64996. */
  64997. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  64998. /**
  64999. * Stops the current recording before the default capture timeout passed in the startRecording function.
  65000. */
  65001. stopRecording(): void;
  65002. /**
  65003. * Starts recording the canvas for a max duration specified in parameters.
  65004. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  65005. * If null no automatic download will start and you can rely on the promise to get the data back.
  65006. * @param maxDuration Defines the maximum recording time in seconds.
  65007. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  65008. * @return A promise callback at the end of the recording with the video data in Blob.
  65009. */
  65010. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  65011. /**
  65012. * Releases internal resources used during the recording.
  65013. */
  65014. dispose(): void;
  65015. private _handleDataAvailable;
  65016. private _handleError;
  65017. private _handleStop;
  65018. }
  65019. }
  65020. declare module BABYLON {
  65021. /**
  65022. * Class containing a set of static utilities functions for screenshots
  65023. */
  65024. export class ScreenshotTools {
  65025. /**
  65026. * Captures a screenshot of the current rendering
  65027. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  65028. * @param engine defines the rendering engine
  65029. * @param camera defines the source camera
  65030. * @param size This parameter can be set to a single number or to an object with the
  65031. * following (optional) properties: precision, width, height. If a single number is passed,
  65032. * it will be used for both width and height. If an object is passed, the screenshot size
  65033. * will be derived from the parameters. The precision property is a multiplier allowing
  65034. * rendering at a higher or lower resolution
  65035. * @param successCallback defines the callback receives a single parameter which contains the
  65036. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  65037. * src parameter of an <img> to display it
  65038. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  65039. * Check your browser for supported MIME types
  65040. */
  65041. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  65042. /**
  65043. * Captures a screenshot of the current rendering
  65044. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  65045. * @param engine defines the rendering engine
  65046. * @param camera defines the source camera
  65047. * @param size This parameter can be set to a single number or to an object with the
  65048. * following (optional) properties: precision, width, height. If a single number is passed,
  65049. * it will be used for both width and height. If an object is passed, the screenshot size
  65050. * will be derived from the parameters. The precision property is a multiplier allowing
  65051. * rendering at a higher or lower resolution
  65052. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  65053. * Check your browser for supported MIME types
  65054. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  65055. * to the src parameter of an <img> to display it
  65056. */
  65057. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  65058. /**
  65059. * Generates an image screenshot from the specified camera.
  65060. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  65061. * @param engine The engine to use for rendering
  65062. * @param camera The camera to use for rendering
  65063. * @param size This parameter can be set to a single number or to an object with the
  65064. * following (optional) properties: precision, width, height. If a single number is passed,
  65065. * it will be used for both width and height. If an object is passed, the screenshot size
  65066. * will be derived from the parameters. The precision property is a multiplier allowing
  65067. * rendering at a higher or lower resolution
  65068. * @param successCallback The callback receives a single parameter which contains the
  65069. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  65070. * src parameter of an <img> to display it
  65071. * @param mimeType The MIME type of the screenshot image (default: image/png).
  65072. * Check your browser for supported MIME types
  65073. * @param samples Texture samples (default: 1)
  65074. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  65075. * @param fileName A name for for the downloaded file.
  65076. */
  65077. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  65078. /**
  65079. * Generates an image screenshot from the specified camera.
  65080. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  65081. * @param engine The engine to use for rendering
  65082. * @param camera The camera to use for rendering
  65083. * @param size This parameter can be set to a single number or to an object with the
  65084. * following (optional) properties: precision, width, height. If a single number is passed,
  65085. * it will be used for both width and height. If an object is passed, the screenshot size
  65086. * will be derived from the parameters. The precision property is a multiplier allowing
  65087. * rendering at a higher or lower resolution
  65088. * @param mimeType The MIME type of the screenshot image (default: image/png).
  65089. * Check your browser for supported MIME types
  65090. * @param samples Texture samples (default: 1)
  65091. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  65092. * @param fileName A name for for the downloaded file.
  65093. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  65094. * to the src parameter of an <img> to display it
  65095. */
  65096. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  65097. /**
  65098. * Gets height and width for screenshot size
  65099. * @private
  65100. */
  65101. private static _getScreenshotSize;
  65102. }
  65103. }
  65104. declare module BABYLON {
  65105. /**
  65106. * Interface for a data buffer
  65107. */
  65108. export interface IDataBuffer {
  65109. /**
  65110. * Reads bytes from the data buffer.
  65111. * @param byteOffset The byte offset to read
  65112. * @param byteLength The byte length to read
  65113. * @returns A promise that resolves when the bytes are read
  65114. */
  65115. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  65116. /**
  65117. * The byte length of the buffer.
  65118. */
  65119. readonly byteLength: number;
  65120. }
  65121. /**
  65122. * Utility class for reading from a data buffer
  65123. */
  65124. export class DataReader {
  65125. /**
  65126. * The data buffer associated with this data reader.
  65127. */
  65128. readonly buffer: IDataBuffer;
  65129. /**
  65130. * The current byte offset from the beginning of the data buffer.
  65131. */
  65132. byteOffset: number;
  65133. private _dataView;
  65134. private _dataByteOffset;
  65135. /**
  65136. * Constructor
  65137. * @param buffer The buffer to read
  65138. */
  65139. constructor(buffer: IDataBuffer);
  65140. /**
  65141. * Loads the given byte length.
  65142. * @param byteLength The byte length to load
  65143. * @returns A promise that resolves when the load is complete
  65144. */
  65145. loadAsync(byteLength: number): Promise<void>;
  65146. /**
  65147. * Read a unsigned 32-bit integer from the currently loaded data range.
  65148. * @returns The 32-bit integer read
  65149. */
  65150. readUint32(): number;
  65151. /**
  65152. * Read a byte array from the currently loaded data range.
  65153. * @param byteLength The byte length to read
  65154. * @returns The byte array read
  65155. */
  65156. readUint8Array(byteLength: number): Uint8Array;
  65157. /**
  65158. * Read a string from the currently loaded data range.
  65159. * @param byteLength The byte length to read
  65160. * @returns The string read
  65161. */
  65162. readString(byteLength: number): string;
  65163. /**
  65164. * Skips the given byte length the currently loaded data range.
  65165. * @param byteLength The byte length to skip
  65166. */
  65167. skipBytes(byteLength: number): void;
  65168. }
  65169. }
  65170. declare module BABYLON {
  65171. /**
  65172. * A cursor which tracks a point on a path
  65173. */
  65174. export class PathCursor {
  65175. private path;
  65176. /**
  65177. * Stores path cursor callbacks for when an onchange event is triggered
  65178. */
  65179. private _onchange;
  65180. /**
  65181. * The value of the path cursor
  65182. */
  65183. value: number;
  65184. /**
  65185. * The animation array of the path cursor
  65186. */
  65187. animations: Animation[];
  65188. /**
  65189. * Initializes the path cursor
  65190. * @param path The path to track
  65191. */
  65192. constructor(path: Path2);
  65193. /**
  65194. * Gets the cursor point on the path
  65195. * @returns A point on the path cursor at the cursor location
  65196. */
  65197. getPoint(): Vector3;
  65198. /**
  65199. * Moves the cursor ahead by the step amount
  65200. * @param step The amount to move the cursor forward
  65201. * @returns This path cursor
  65202. */
  65203. moveAhead(step?: number): PathCursor;
  65204. /**
  65205. * Moves the cursor behind by the step amount
  65206. * @param step The amount to move the cursor back
  65207. * @returns This path cursor
  65208. */
  65209. moveBack(step?: number): PathCursor;
  65210. /**
  65211. * Moves the cursor by the step amount
  65212. * If the step amount is greater than one, an exception is thrown
  65213. * @param step The amount to move the cursor
  65214. * @returns This path cursor
  65215. */
  65216. move(step: number): PathCursor;
  65217. /**
  65218. * Ensures that the value is limited between zero and one
  65219. * @returns This path cursor
  65220. */
  65221. private ensureLimits;
  65222. /**
  65223. * Runs onchange callbacks on change (used by the animation engine)
  65224. * @returns This path cursor
  65225. */
  65226. private raiseOnChange;
  65227. /**
  65228. * Executes a function on change
  65229. * @param f A path cursor onchange callback
  65230. * @returns This path cursor
  65231. */
  65232. onchange(f: (cursor: PathCursor) => void): PathCursor;
  65233. }
  65234. }
  65235. declare module BABYLON {
  65236. /** @hidden */
  65237. export var blurPixelShader: {
  65238. name: string;
  65239. shader: string;
  65240. };
  65241. }
  65242. declare module BABYLON {
  65243. /** @hidden */
  65244. export var pointCloudVertexDeclaration: {
  65245. name: string;
  65246. shader: string;
  65247. };
  65248. }
  65249. // Mixins
  65250. interface Window {
  65251. mozIndexedDB: IDBFactory;
  65252. webkitIndexedDB: IDBFactory;
  65253. msIndexedDB: IDBFactory;
  65254. webkitURL: typeof URL;
  65255. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  65256. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  65257. WebGLRenderingContext: WebGLRenderingContext;
  65258. MSGesture: MSGesture;
  65259. CANNON: any;
  65260. AudioContext: AudioContext;
  65261. webkitAudioContext: AudioContext;
  65262. PointerEvent: any;
  65263. Math: Math;
  65264. Uint8Array: Uint8ArrayConstructor;
  65265. Float32Array: Float32ArrayConstructor;
  65266. mozURL: typeof URL;
  65267. msURL: typeof URL;
  65268. VRFrameData: any; // WebVR, from specs 1.1
  65269. DracoDecoderModule: any;
  65270. setImmediate(handler: (...args: any[]) => void): number;
  65271. }
  65272. interface HTMLCanvasElement {
  65273. requestPointerLock(): void;
  65274. msRequestPointerLock?(): void;
  65275. mozRequestPointerLock?(): void;
  65276. webkitRequestPointerLock?(): void;
  65277. /** Track wether a record is in progress */
  65278. isRecording: boolean;
  65279. /** Capture Stream method defined by some browsers */
  65280. captureStream(fps?: number): MediaStream;
  65281. }
  65282. interface CanvasRenderingContext2D {
  65283. msImageSmoothingEnabled: boolean;
  65284. }
  65285. interface MouseEvent {
  65286. mozMovementX: number;
  65287. mozMovementY: number;
  65288. webkitMovementX: number;
  65289. webkitMovementY: number;
  65290. msMovementX: number;
  65291. msMovementY: number;
  65292. }
  65293. interface Navigator {
  65294. mozGetVRDevices: (any: any) => any;
  65295. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  65296. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  65297. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  65298. webkitGetGamepads(): Gamepad[];
  65299. msGetGamepads(): Gamepad[];
  65300. webkitGamepads(): Gamepad[];
  65301. }
  65302. interface HTMLVideoElement {
  65303. mozSrcObject: any;
  65304. }
  65305. interface Math {
  65306. fround(x: number): number;
  65307. imul(a: number, b: number): number;
  65308. }
  65309. interface WebGLRenderingContext {
  65310. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  65311. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  65312. vertexAttribDivisor(index: number, divisor: number): void;
  65313. createVertexArray(): any;
  65314. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  65315. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  65316. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  65317. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  65318. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  65319. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  65320. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  65321. // Queries
  65322. createQuery(): WebGLQuery;
  65323. deleteQuery(query: WebGLQuery): void;
  65324. beginQuery(target: number, query: WebGLQuery): void;
  65325. endQuery(target: number): void;
  65326. getQueryParameter(query: WebGLQuery, pname: number): any;
  65327. getQuery(target: number, pname: number): any;
  65328. MAX_SAMPLES: number;
  65329. RGBA8: number;
  65330. READ_FRAMEBUFFER: number;
  65331. DRAW_FRAMEBUFFER: number;
  65332. UNIFORM_BUFFER: number;
  65333. HALF_FLOAT_OES: number;
  65334. RGBA16F: number;
  65335. RGBA32F: number;
  65336. R32F: number;
  65337. RG32F: number;
  65338. RGB32F: number;
  65339. R16F: number;
  65340. RG16F: number;
  65341. RGB16F: number;
  65342. RED: number;
  65343. RG: number;
  65344. R8: number;
  65345. RG8: number;
  65346. UNSIGNED_INT_24_8: number;
  65347. DEPTH24_STENCIL8: number;
  65348. MIN: number;
  65349. MAX: number;
  65350. /* Multiple Render Targets */
  65351. drawBuffers(buffers: number[]): void;
  65352. readBuffer(src: number): void;
  65353. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  65354. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  65355. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  65356. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  65357. // Occlusion Query
  65358. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  65359. ANY_SAMPLES_PASSED: number;
  65360. QUERY_RESULT_AVAILABLE: number;
  65361. QUERY_RESULT: number;
  65362. }
  65363. interface WebGLProgram {
  65364. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  65365. }
  65366. interface EXT_disjoint_timer_query {
  65367. QUERY_COUNTER_BITS_EXT: number;
  65368. TIME_ELAPSED_EXT: number;
  65369. TIMESTAMP_EXT: number;
  65370. GPU_DISJOINT_EXT: number;
  65371. QUERY_RESULT_EXT: number;
  65372. QUERY_RESULT_AVAILABLE_EXT: number;
  65373. queryCounterEXT(query: WebGLQuery, target: number): void;
  65374. createQueryEXT(): WebGLQuery;
  65375. beginQueryEXT(target: number, query: WebGLQuery): void;
  65376. endQueryEXT(target: number): void;
  65377. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  65378. deleteQueryEXT(query: WebGLQuery): void;
  65379. }
  65380. interface WebGLUniformLocation {
  65381. _currentState: any;
  65382. }
  65383. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  65384. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  65385. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  65386. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  65387. interface WebGLRenderingContext {
  65388. readonly RASTERIZER_DISCARD: number;
  65389. readonly DEPTH_COMPONENT24: number;
  65390. readonly TEXTURE_3D: number;
  65391. readonly TEXTURE_2D_ARRAY: number;
  65392. readonly TEXTURE_COMPARE_FUNC: number;
  65393. readonly TEXTURE_COMPARE_MODE: number;
  65394. readonly COMPARE_REF_TO_TEXTURE: number;
  65395. readonly TEXTURE_WRAP_R: number;
  65396. readonly HALF_FLOAT: number;
  65397. readonly RGB8: number;
  65398. readonly RED_INTEGER: number;
  65399. readonly RG_INTEGER: number;
  65400. readonly RGB_INTEGER: number;
  65401. readonly RGBA_INTEGER: number;
  65402. readonly R8_SNORM: number;
  65403. readonly RG8_SNORM: number;
  65404. readonly RGB8_SNORM: number;
  65405. readonly RGBA8_SNORM: number;
  65406. readonly R8I: number;
  65407. readonly RG8I: number;
  65408. readonly RGB8I: number;
  65409. readonly RGBA8I: number;
  65410. readonly R8UI: number;
  65411. readonly RG8UI: number;
  65412. readonly RGB8UI: number;
  65413. readonly RGBA8UI: number;
  65414. readonly R16I: number;
  65415. readonly RG16I: number;
  65416. readonly RGB16I: number;
  65417. readonly RGBA16I: number;
  65418. readonly R16UI: number;
  65419. readonly RG16UI: number;
  65420. readonly RGB16UI: number;
  65421. readonly RGBA16UI: number;
  65422. readonly R32I: number;
  65423. readonly RG32I: number;
  65424. readonly RGB32I: number;
  65425. readonly RGBA32I: number;
  65426. readonly R32UI: number;
  65427. readonly RG32UI: number;
  65428. readonly RGB32UI: number;
  65429. readonly RGBA32UI: number;
  65430. readonly RGB10_A2UI: number;
  65431. readonly R11F_G11F_B10F: number;
  65432. readonly RGB9_E5: number;
  65433. readonly RGB10_A2: number;
  65434. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  65435. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  65436. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  65437. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  65438. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  65439. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  65440. 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;
  65441. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  65442. readonly TRANSFORM_FEEDBACK: number;
  65443. readonly INTERLEAVED_ATTRIBS: number;
  65444. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  65445. createTransformFeedback(): WebGLTransformFeedback;
  65446. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  65447. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  65448. beginTransformFeedback(primitiveMode: number): void;
  65449. endTransformFeedback(): void;
  65450. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  65451. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  65452. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  65453. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  65454. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  65455. }
  65456. interface ImageBitmap {
  65457. readonly width: number;
  65458. readonly height: number;
  65459. close(): void;
  65460. }
  65461. interface WebGLQuery extends WebGLObject {
  65462. }
  65463. declare var WebGLQuery: {
  65464. prototype: WebGLQuery;
  65465. new(): WebGLQuery;
  65466. };
  65467. interface WebGLSampler extends WebGLObject {
  65468. }
  65469. declare var WebGLSampler: {
  65470. prototype: WebGLSampler;
  65471. new(): WebGLSampler;
  65472. };
  65473. interface WebGLSync extends WebGLObject {
  65474. }
  65475. declare var WebGLSync: {
  65476. prototype: WebGLSync;
  65477. new(): WebGLSync;
  65478. };
  65479. interface WebGLTransformFeedback extends WebGLObject {
  65480. }
  65481. declare var WebGLTransformFeedback: {
  65482. prototype: WebGLTransformFeedback;
  65483. new(): WebGLTransformFeedback;
  65484. };
  65485. interface WebGLVertexArrayObject extends WebGLObject {
  65486. }
  65487. declare var WebGLVertexArrayObject: {
  65488. prototype: WebGLVertexArrayObject;
  65489. new(): WebGLVertexArrayObject;
  65490. };
  65491. // Type definitions for WebVR API
  65492. // Project: https://w3c.github.io/webvr/
  65493. // Definitions by: six a <https://github.com/lostfictions>
  65494. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  65495. interface VRDisplay extends EventTarget {
  65496. /**
  65497. * Dictionary of capabilities describing the VRDisplay.
  65498. */
  65499. readonly capabilities: VRDisplayCapabilities;
  65500. /**
  65501. * z-depth defining the far plane of the eye view frustum
  65502. * enables mapping of values in the render target depth
  65503. * attachment to scene coordinates. Initially set to 10000.0.
  65504. */
  65505. depthFar: number;
  65506. /**
  65507. * z-depth defining the near plane of the eye view frustum
  65508. * enables mapping of values in the render target depth
  65509. * attachment to scene coordinates. Initially set to 0.01.
  65510. */
  65511. depthNear: number;
  65512. /**
  65513. * An identifier for this distinct VRDisplay. Used as an
  65514. * association point in the Gamepad API.
  65515. */
  65516. readonly displayId: number;
  65517. /**
  65518. * A display name, a user-readable name identifying it.
  65519. */
  65520. readonly displayName: string;
  65521. readonly isConnected: boolean;
  65522. readonly isPresenting: boolean;
  65523. /**
  65524. * If this VRDisplay supports room-scale experiences, the optional
  65525. * stage attribute contains details on the room-scale parameters.
  65526. */
  65527. readonly stageParameters: VRStageParameters | null;
  65528. /**
  65529. * Passing the value returned by `requestAnimationFrame` to
  65530. * `cancelAnimationFrame` will unregister the callback.
  65531. * @param handle Define the hanle of the request to cancel
  65532. */
  65533. cancelAnimationFrame(handle: number): void;
  65534. /**
  65535. * Stops presenting to the VRDisplay.
  65536. * @returns a promise to know when it stopped
  65537. */
  65538. exitPresent(): Promise<void>;
  65539. /**
  65540. * Return the current VREyeParameters for the given eye.
  65541. * @param whichEye Define the eye we want the parameter for
  65542. * @returns the eye parameters
  65543. */
  65544. getEyeParameters(whichEye: string): VREyeParameters;
  65545. /**
  65546. * Populates the passed VRFrameData with the information required to render
  65547. * the current frame.
  65548. * @param frameData Define the data structure to populate
  65549. * @returns true if ok otherwise false
  65550. */
  65551. getFrameData(frameData: VRFrameData): boolean;
  65552. /**
  65553. * Get the layers currently being presented.
  65554. * @returns the list of VR layers
  65555. */
  65556. getLayers(): VRLayer[];
  65557. /**
  65558. * Return a VRPose containing the future predicted pose of the VRDisplay
  65559. * when the current frame will be presented. The value returned will not
  65560. * change until JavaScript has returned control to the browser.
  65561. *
  65562. * The VRPose will contain the position, orientation, velocity,
  65563. * and acceleration of each of these properties.
  65564. * @returns the pose object
  65565. */
  65566. getPose(): VRPose;
  65567. /**
  65568. * Return the current instantaneous pose of the VRDisplay, with no
  65569. * prediction applied.
  65570. * @returns the current instantaneous pose
  65571. */
  65572. getImmediatePose(): VRPose;
  65573. /**
  65574. * The callback passed to `requestAnimationFrame` will be called
  65575. * any time a new frame should be rendered. When the VRDisplay is
  65576. * presenting the callback will be called at the native refresh
  65577. * rate of the HMD. When not presenting this function acts
  65578. * identically to how window.requestAnimationFrame acts. Content should
  65579. * make no assumptions of frame rate or vsync behavior as the HMD runs
  65580. * asynchronously from other displays and at differing refresh rates.
  65581. * @param callback Define the eaction to run next frame
  65582. * @returns the request handle it
  65583. */
  65584. requestAnimationFrame(callback: FrameRequestCallback): number;
  65585. /**
  65586. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  65587. * Repeat calls while already presenting will update the VRLayers being displayed.
  65588. * @param layers Define the list of layer to present
  65589. * @returns a promise to know when the request has been fulfilled
  65590. */
  65591. requestPresent(layers: VRLayer[]): Promise<void>;
  65592. /**
  65593. * Reset the pose for this display, treating its current position and
  65594. * orientation as the "origin/zero" values. VRPose.position,
  65595. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  65596. * updated when calling resetPose(). This should be called in only
  65597. * sitting-space experiences.
  65598. */
  65599. resetPose(): void;
  65600. /**
  65601. * The VRLayer provided to the VRDisplay will be captured and presented
  65602. * in the HMD. Calling this function has the same effect on the source
  65603. * canvas as any other operation that uses its source image, and canvases
  65604. * created without preserveDrawingBuffer set to true will be cleared.
  65605. * @param pose Define the pose to submit
  65606. */
  65607. submitFrame(pose?: VRPose): void;
  65608. }
  65609. declare var VRDisplay: {
  65610. prototype: VRDisplay;
  65611. new(): VRDisplay;
  65612. };
  65613. interface VRLayer {
  65614. leftBounds?: number[] | Float32Array | null;
  65615. rightBounds?: number[] | Float32Array | null;
  65616. source?: HTMLCanvasElement | null;
  65617. }
  65618. interface VRDisplayCapabilities {
  65619. readonly canPresent: boolean;
  65620. readonly hasExternalDisplay: boolean;
  65621. readonly hasOrientation: boolean;
  65622. readonly hasPosition: boolean;
  65623. readonly maxLayers: number;
  65624. }
  65625. interface VREyeParameters {
  65626. /** @deprecated */
  65627. readonly fieldOfView: VRFieldOfView;
  65628. readonly offset: Float32Array;
  65629. readonly renderHeight: number;
  65630. readonly renderWidth: number;
  65631. }
  65632. interface VRFieldOfView {
  65633. readonly downDegrees: number;
  65634. readonly leftDegrees: number;
  65635. readonly rightDegrees: number;
  65636. readonly upDegrees: number;
  65637. }
  65638. interface VRFrameData {
  65639. readonly leftProjectionMatrix: Float32Array;
  65640. readonly leftViewMatrix: Float32Array;
  65641. readonly pose: VRPose;
  65642. readonly rightProjectionMatrix: Float32Array;
  65643. readonly rightViewMatrix: Float32Array;
  65644. readonly timestamp: number;
  65645. }
  65646. interface VRPose {
  65647. readonly angularAcceleration: Float32Array | null;
  65648. readonly angularVelocity: Float32Array | null;
  65649. readonly linearAcceleration: Float32Array | null;
  65650. readonly linearVelocity: Float32Array | null;
  65651. readonly orientation: Float32Array | null;
  65652. readonly position: Float32Array | null;
  65653. readonly timestamp: number;
  65654. }
  65655. interface VRStageParameters {
  65656. sittingToStandingTransform?: Float32Array;
  65657. sizeX?: number;
  65658. sizeY?: number;
  65659. }
  65660. interface Navigator {
  65661. getVRDisplays(): Promise<VRDisplay[]>;
  65662. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  65663. }
  65664. interface Window {
  65665. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  65666. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  65667. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  65668. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  65669. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  65670. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  65671. }
  65672. interface Gamepad {
  65673. readonly displayId: number;
  65674. }
  65675. type XRSessionMode =
  65676. | "inline"
  65677. | "immersive-vr"
  65678. | "immersive-ar";
  65679. type XRReferenceSpaceType =
  65680. | "viewer"
  65681. | "local"
  65682. | "local-floor"
  65683. | "bounded-floor"
  65684. | "unbounded";
  65685. type XREnvironmentBlendMode =
  65686. | "opaque"
  65687. | "additive"
  65688. | "alpha-blend";
  65689. type XRVisibilityState =
  65690. | "visible"
  65691. | "visible-blurred"
  65692. | "hidden";
  65693. type XRHandedness =
  65694. | "none"
  65695. | "left"
  65696. | "right";
  65697. type XRTargetRayMode =
  65698. | "gaze"
  65699. | "tracked-pointer"
  65700. | "screen";
  65701. type XREye =
  65702. | "none"
  65703. | "left"
  65704. | "right";
  65705. interface XRSpace extends EventTarget {
  65706. }
  65707. interface XRRenderState {
  65708. depthNear?: number;
  65709. depthFar?: number;
  65710. inlineVerticalFieldOfView?: number;
  65711. baseLayer?: XRWebGLLayer;
  65712. }
  65713. interface XRInputSource {
  65714. handedness: XRHandedness;
  65715. targetRayMode: XRTargetRayMode;
  65716. targetRaySpace: XRSpace;
  65717. gripSpace: XRSpace | undefined;
  65718. gamepad: Gamepad | undefined;
  65719. profiles: Array<string>;
  65720. }
  65721. interface XRSession {
  65722. addEventListener: Function;
  65723. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  65724. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  65725. requestAnimationFrame: Function;
  65726. end(): Promise<void>;
  65727. renderState: XRRenderState;
  65728. inputSources: Array<XRInputSource>;
  65729. }
  65730. interface XRReferenceSpace extends XRSpace {
  65731. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  65732. onreset: any;
  65733. }
  65734. interface XRFrame {
  65735. session: XRSession;
  65736. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  65737. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  65738. }
  65739. interface XRViewerPose extends XRPose {
  65740. views: Array<XRView>;
  65741. }
  65742. interface XRPose {
  65743. transform: XRRigidTransform;
  65744. emulatedPosition: boolean;
  65745. }
  65746. interface XRWebGLLayerOptions {
  65747. antialias ?: boolean;
  65748. depth ?: boolean;
  65749. stencil ?: boolean;
  65750. alpha ?: boolean;
  65751. multiview ?: boolean;
  65752. framebufferScaleFactor ?: number;
  65753. }
  65754. declare var XRWebGLLayer: {
  65755. prototype: XRWebGLLayer;
  65756. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  65757. };
  65758. interface XRWebGLLayer {
  65759. framebuffer: WebGLFramebuffer;
  65760. framebufferWidth: number;
  65761. framebufferHeight: number;
  65762. getViewport: Function;
  65763. }
  65764. interface XRRigidTransform {
  65765. position: DOMPointReadOnly;
  65766. orientation: DOMPointReadOnly;
  65767. matrix: Float32Array;
  65768. inverse: XRRigidTransform;
  65769. }
  65770. interface XRView {
  65771. eye: XREye;
  65772. projectionMatrix: Float32Array;
  65773. transform: XRRigidTransform;
  65774. }
  65775. interface XRInputSourceChangeEvent {
  65776. session: XRSession;
  65777. removed: Array<XRInputSource>;
  65778. added: Array<XRInputSource>;
  65779. }
  65780. /**
  65781. * @ignore
  65782. */
  65783. declare module BABYLON.GLTF2.Exporter {
  65784. }
  65785. /**
  65786. * @ignore
  65787. */
  65788. declare module BABYLON.GLTF1 {
  65789. }
  65790. declare module BABYLON.GUI {
  65791. /**
  65792. * Class used to specific a value and its associated unit
  65793. */
  65794. export class ValueAndUnit {
  65795. /** defines the unit to store */
  65796. unit: number;
  65797. /** defines a boolean indicating if the value can be negative */
  65798. negativeValueAllowed: boolean;
  65799. private _value;
  65800. private _originalUnit;
  65801. /**
  65802. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  65803. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  65804. */
  65805. ignoreAdaptiveScaling: boolean;
  65806. /**
  65807. * Creates a new ValueAndUnit
  65808. * @param value defines the value to store
  65809. * @param unit defines the unit to store
  65810. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  65811. */
  65812. constructor(value: number,
  65813. /** defines the unit to store */
  65814. unit?: number,
  65815. /** defines a boolean indicating if the value can be negative */
  65816. negativeValueAllowed?: boolean);
  65817. /** Gets a boolean indicating if the value is a percentage */
  65818. readonly isPercentage: boolean;
  65819. /** Gets a boolean indicating if the value is store as pixel */
  65820. readonly isPixel: boolean;
  65821. /** Gets direct internal value */
  65822. readonly internalValue: number;
  65823. /**
  65824. * Gets value as pixel
  65825. * @param host defines the root host
  65826. * @param refValue defines the reference value for percentages
  65827. * @returns the value as pixel
  65828. */
  65829. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  65830. /**
  65831. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  65832. * @param value defines the value to store
  65833. * @param unit defines the unit to store
  65834. * @returns the current ValueAndUnit
  65835. */
  65836. updateInPlace(value: number, unit?: number): ValueAndUnit;
  65837. /**
  65838. * Gets the value accordingly to its unit
  65839. * @param host defines the root host
  65840. * @returns the value
  65841. */
  65842. getValue(host: AdvancedDynamicTexture): number;
  65843. /**
  65844. * Gets a string representation of the value
  65845. * @param host defines the root host
  65846. * @param decimals defines an optional number of decimals to display
  65847. * @returns a string
  65848. */
  65849. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  65850. /**
  65851. * Store a value parsed from a string
  65852. * @param source defines the source string
  65853. * @returns true if the value was successfully parsed
  65854. */
  65855. fromString(source: string | number): boolean;
  65856. private static _Regex;
  65857. private static _UNITMODE_PERCENTAGE;
  65858. private static _UNITMODE_PIXEL;
  65859. /** UNITMODE_PERCENTAGE */
  65860. static readonly UNITMODE_PERCENTAGE: number;
  65861. /** UNITMODE_PIXEL */
  65862. static readonly UNITMODE_PIXEL: number;
  65863. }
  65864. }
  65865. declare module BABYLON.GUI {
  65866. /**
  65867. * Define a style used by control to automatically setup properties based on a template.
  65868. * Only support font related properties so far
  65869. */
  65870. export class Style implements BABYLON.IDisposable {
  65871. private _fontFamily;
  65872. private _fontStyle;
  65873. private _fontWeight;
  65874. /** @hidden */
  65875. _host: AdvancedDynamicTexture;
  65876. /** @hidden */
  65877. _fontSize: ValueAndUnit;
  65878. /**
  65879. * BABYLON.Observable raised when the style values are changed
  65880. */
  65881. onChangedObservable: BABYLON.Observable<Style>;
  65882. /**
  65883. * Creates a new style object
  65884. * @param host defines the AdvancedDynamicTexture which hosts this style
  65885. */
  65886. constructor(host: AdvancedDynamicTexture);
  65887. /**
  65888. * Gets or sets the font size
  65889. */
  65890. fontSize: string | number;
  65891. /**
  65892. * Gets or sets the font family
  65893. */
  65894. fontFamily: string;
  65895. /**
  65896. * Gets or sets the font style
  65897. */
  65898. fontStyle: string;
  65899. /** Gets or sets font weight */
  65900. fontWeight: string;
  65901. /** Dispose all associated resources */
  65902. dispose(): void;
  65903. }
  65904. }
  65905. declare module BABYLON.GUI {
  65906. /**
  65907. * Class used to transport BABYLON.Vector2 information for pointer events
  65908. */
  65909. export class Vector2WithInfo extends BABYLON.Vector2 {
  65910. /** defines the current mouse button index */
  65911. buttonIndex: number;
  65912. /**
  65913. * Creates a new Vector2WithInfo
  65914. * @param source defines the vector2 data to transport
  65915. * @param buttonIndex defines the current mouse button index
  65916. */
  65917. constructor(source: BABYLON.Vector2,
  65918. /** defines the current mouse button index */
  65919. buttonIndex?: number);
  65920. }
  65921. /** Class used to provide 2D matrix features */
  65922. export class Matrix2D {
  65923. /** Gets the internal array of 6 floats used to store matrix data */
  65924. m: Float32Array;
  65925. /**
  65926. * Creates a new matrix
  65927. * @param m00 defines value for (0, 0)
  65928. * @param m01 defines value for (0, 1)
  65929. * @param m10 defines value for (1, 0)
  65930. * @param m11 defines value for (1, 1)
  65931. * @param m20 defines value for (2, 0)
  65932. * @param m21 defines value for (2, 1)
  65933. */
  65934. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  65935. /**
  65936. * Fills the matrix from direct values
  65937. * @param m00 defines value for (0, 0)
  65938. * @param m01 defines value for (0, 1)
  65939. * @param m10 defines value for (1, 0)
  65940. * @param m11 defines value for (1, 1)
  65941. * @param m20 defines value for (2, 0)
  65942. * @param m21 defines value for (2, 1)
  65943. * @returns the current modified matrix
  65944. */
  65945. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  65946. /**
  65947. * Gets matrix determinant
  65948. * @returns the determinant
  65949. */
  65950. determinant(): number;
  65951. /**
  65952. * Inverses the matrix and stores it in a target matrix
  65953. * @param result defines the target matrix
  65954. * @returns the current matrix
  65955. */
  65956. invertToRef(result: Matrix2D): Matrix2D;
  65957. /**
  65958. * Multiplies the current matrix with another one
  65959. * @param other defines the second operand
  65960. * @param result defines the target matrix
  65961. * @returns the current matrix
  65962. */
  65963. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  65964. /**
  65965. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  65966. * @param x defines the x coordinate to transform
  65967. * @param y defines the x coordinate to transform
  65968. * @param result defines the target vector2
  65969. * @returns the current matrix
  65970. */
  65971. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  65972. /**
  65973. * Creates an identity matrix
  65974. * @returns a new matrix
  65975. */
  65976. static Identity(): Matrix2D;
  65977. /**
  65978. * Creates a translation matrix and stores it in a target matrix
  65979. * @param x defines the x coordinate of the translation
  65980. * @param y defines the y coordinate of the translation
  65981. * @param result defines the target matrix
  65982. */
  65983. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  65984. /**
  65985. * Creates a scaling matrix and stores it in a target matrix
  65986. * @param x defines the x coordinate of the scaling
  65987. * @param y defines the y coordinate of the scaling
  65988. * @param result defines the target matrix
  65989. */
  65990. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  65991. /**
  65992. * Creates a rotation matrix and stores it in a target matrix
  65993. * @param angle defines the rotation angle
  65994. * @param result defines the target matrix
  65995. */
  65996. static RotationToRef(angle: number, result: Matrix2D): void;
  65997. private static _TempPreTranslationMatrix;
  65998. private static _TempPostTranslationMatrix;
  65999. private static _TempRotationMatrix;
  66000. private static _TempScalingMatrix;
  66001. private static _TempCompose0;
  66002. private static _TempCompose1;
  66003. private static _TempCompose2;
  66004. /**
  66005. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  66006. * @param tx defines the x coordinate of the translation
  66007. * @param ty defines the y coordinate of the translation
  66008. * @param angle defines the rotation angle
  66009. * @param scaleX defines the x coordinate of the scaling
  66010. * @param scaleY defines the y coordinate of the scaling
  66011. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  66012. * @param result defines the target matrix
  66013. */
  66014. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  66015. }
  66016. }
  66017. declare module BABYLON.GUI {
  66018. /**
  66019. * Class used to store 2D control sizes
  66020. */
  66021. export class Measure {
  66022. /** defines left coordinate */
  66023. left: number;
  66024. /** defines top coordinate */
  66025. top: number;
  66026. /** defines width dimension */
  66027. width: number;
  66028. /** defines height dimension */
  66029. height: number;
  66030. /**
  66031. * Creates a new measure
  66032. * @param left defines left coordinate
  66033. * @param top defines top coordinate
  66034. * @param width defines width dimension
  66035. * @param height defines height dimension
  66036. */
  66037. constructor(
  66038. /** defines left coordinate */
  66039. left: number,
  66040. /** defines top coordinate */
  66041. top: number,
  66042. /** defines width dimension */
  66043. width: number,
  66044. /** defines height dimension */
  66045. height: number);
  66046. /**
  66047. * Copy from another measure
  66048. * @param other defines the other measure to copy from
  66049. */
  66050. copyFrom(other: Measure): void;
  66051. /**
  66052. * Copy from a group of 4 floats
  66053. * @param left defines left coordinate
  66054. * @param top defines top coordinate
  66055. * @param width defines width dimension
  66056. * @param height defines height dimension
  66057. */
  66058. copyFromFloats(left: number, top: number, width: number, height: number): void;
  66059. /**
  66060. * Computes the axis aligned bounding box measure for two given measures
  66061. * @param a Input measure
  66062. * @param b Input measure
  66063. * @param result the resulting bounding measure
  66064. */
  66065. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  66066. /**
  66067. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  66068. * @param transform the matrix to transform the measure before computing the AABB
  66069. * @param result the resulting AABB
  66070. */
  66071. transformToRef(transform: Matrix2D, result: Measure): void;
  66072. /**
  66073. * Check equality between this measure and another one
  66074. * @param other defines the other measures
  66075. * @returns true if both measures are equals
  66076. */
  66077. isEqualsTo(other: Measure): boolean;
  66078. /**
  66079. * Creates an empty measure
  66080. * @returns a new measure
  66081. */
  66082. static Empty(): Measure;
  66083. }
  66084. }
  66085. declare module BABYLON.GUI {
  66086. /**
  66087. * Interface used to define a control that can receive focus
  66088. */
  66089. export interface IFocusableControl {
  66090. /**
  66091. * Function called when the control receives the focus
  66092. */
  66093. onFocus(): void;
  66094. /**
  66095. * Function called when the control loses the focus
  66096. */
  66097. onBlur(): void;
  66098. /**
  66099. * Function called to let the control handle keyboard events
  66100. * @param evt defines the current keyboard event
  66101. */
  66102. processKeyboard(evt: KeyboardEvent): void;
  66103. /**
  66104. * Function called to get the list of controls that should not steal the focus from this control
  66105. * @returns an array of controls
  66106. */
  66107. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  66108. }
  66109. /**
  66110. * Class used to create texture to support 2D GUI elements
  66111. * @see http://doc.babylonjs.com/how_to/gui
  66112. */
  66113. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  66114. private _isDirty;
  66115. private _renderObserver;
  66116. private _resizeObserver;
  66117. private _preKeyboardObserver;
  66118. private _pointerMoveObserver;
  66119. private _pointerObserver;
  66120. private _canvasPointerOutObserver;
  66121. private _background;
  66122. /** @hidden */
  66123. _rootContainer: Container;
  66124. /** @hidden */
  66125. _lastPickedControl: Control;
  66126. /** @hidden */
  66127. _lastControlOver: {
  66128. [pointerId: number]: Control;
  66129. };
  66130. /** @hidden */
  66131. _lastControlDown: {
  66132. [pointerId: number]: Control;
  66133. };
  66134. /** @hidden */
  66135. _capturingControl: {
  66136. [pointerId: number]: Control;
  66137. };
  66138. /** @hidden */
  66139. _shouldBlockPointer: boolean;
  66140. /** @hidden */
  66141. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  66142. /** @hidden */
  66143. _linkedControls: Control[];
  66144. private _isFullscreen;
  66145. private _fullscreenViewport;
  66146. private _idealWidth;
  66147. private _idealHeight;
  66148. private _useSmallestIdeal;
  66149. private _renderAtIdealSize;
  66150. private _focusedControl;
  66151. private _blockNextFocusCheck;
  66152. private _renderScale;
  66153. private _rootElement;
  66154. private _cursorChanged;
  66155. /**
  66156. * Define type to string to ensure compatibility across browsers
  66157. * Safari doesn't support DataTransfer constructor
  66158. */
  66159. private _clipboardData;
  66160. /**
  66161. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  66162. */
  66163. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  66164. /**
  66165. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  66166. */
  66167. onControlPickedObservable: BABYLON.Observable<Control>;
  66168. /**
  66169. * BABYLON.Observable event triggered before layout is evaluated
  66170. */
  66171. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  66172. /**
  66173. * BABYLON.Observable event triggered after the layout was evaluated
  66174. */
  66175. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  66176. /**
  66177. * BABYLON.Observable event triggered before the texture is rendered
  66178. */
  66179. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  66180. /**
  66181. * BABYLON.Observable event triggered after the texture was rendered
  66182. */
  66183. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  66184. /**
  66185. * Gets or sets a boolean defining if alpha is stored as premultiplied
  66186. */
  66187. premulAlpha: boolean;
  66188. /**
  66189. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  66190. * Useful when you want more antialiasing
  66191. */
  66192. renderScale: number;
  66193. /** Gets or sets the background color */
  66194. background: string;
  66195. /**
  66196. * Gets or sets the ideal width used to design controls.
  66197. * The GUI will then rescale everything accordingly
  66198. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  66199. */
  66200. idealWidth: number;
  66201. /**
  66202. * Gets or sets the ideal height used to design controls.
  66203. * The GUI will then rescale everything accordingly
  66204. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  66205. */
  66206. idealHeight: number;
  66207. /**
  66208. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  66209. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  66210. */
  66211. useSmallestIdeal: boolean;
  66212. /**
  66213. * Gets or sets a boolean indicating if adaptive scaling must be used
  66214. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  66215. */
  66216. renderAtIdealSize: boolean;
  66217. /**
  66218. * Gets the underlying layer used to render the texture when in fullscreen mode
  66219. */
  66220. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  66221. /**
  66222. * Gets the root container control
  66223. */
  66224. readonly rootContainer: Container;
  66225. /**
  66226. * Returns an array containing the root container.
  66227. * This is mostly used to let the Inspector introspects the ADT
  66228. * @returns an array containing the rootContainer
  66229. */
  66230. getChildren(): Array<Container>;
  66231. /**
  66232. * Will return all controls that are inside this texture
  66233. * @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
  66234. * @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
  66235. * @return all child controls
  66236. */
  66237. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  66238. /**
  66239. * Gets or sets the current focused control
  66240. */
  66241. focusedControl: BABYLON.Nullable<IFocusableControl>;
  66242. /**
  66243. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  66244. */
  66245. isForeground: boolean;
  66246. /**
  66247. * Gets or set information about clipboardData
  66248. */
  66249. clipboardData: string;
  66250. /**
  66251. * Creates a new AdvancedDynamicTexture
  66252. * @param name defines the name of the texture
  66253. * @param width defines the width of the texture
  66254. * @param height defines the height of the texture
  66255. * @param scene defines the hosting scene
  66256. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  66257. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  66258. */
  66259. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  66260. /**
  66261. * Get the current class name of the texture useful for serialization or dynamic coding.
  66262. * @returns "AdvancedDynamicTexture"
  66263. */
  66264. getClassName(): string;
  66265. /**
  66266. * Function used to execute a function on all controls
  66267. * @param func defines the function to execute
  66268. * @param container defines the container where controls belong. If null the root container will be used
  66269. */
  66270. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  66271. private _useInvalidateRectOptimization;
  66272. /**
  66273. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  66274. */
  66275. useInvalidateRectOptimization: boolean;
  66276. private _invalidatedRectangle;
  66277. /**
  66278. * Invalidates a rectangle area on the gui texture
  66279. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  66280. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  66281. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  66282. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  66283. */
  66284. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  66285. /**
  66286. * Marks the texture as dirty forcing a complete update
  66287. */
  66288. markAsDirty(): void;
  66289. /**
  66290. * Helper function used to create a new style
  66291. * @returns a new style
  66292. * @see http://doc.babylonjs.com/how_to/gui#styles
  66293. */
  66294. createStyle(): Style;
  66295. /**
  66296. * Adds a new control to the root container
  66297. * @param control defines the control to add
  66298. * @returns the current texture
  66299. */
  66300. addControl(control: Control): AdvancedDynamicTexture;
  66301. /**
  66302. * Removes a control from the root container
  66303. * @param control defines the control to remove
  66304. * @returns the current texture
  66305. */
  66306. removeControl(control: Control): AdvancedDynamicTexture;
  66307. /**
  66308. * Release all resources
  66309. */
  66310. dispose(): void;
  66311. private _onResize;
  66312. /** @hidden */
  66313. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  66314. /**
  66315. * Get screen coordinates for a vector3
  66316. * @param position defines the position to project
  66317. * @param worldMatrix defines the world matrix to use
  66318. * @returns the projected position
  66319. */
  66320. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  66321. private _checkUpdate;
  66322. private _clearMeasure;
  66323. private _render;
  66324. /** @hidden */
  66325. _changeCursor(cursor: string): void;
  66326. /** @hidden */
  66327. _registerLastControlDown(control: Control, pointerId: number): void;
  66328. private _doPicking;
  66329. /** @hidden */
  66330. _cleanControlAfterRemovalFromList(list: {
  66331. [pointerId: number]: Control;
  66332. }, control: Control): void;
  66333. /** @hidden */
  66334. _cleanControlAfterRemoval(control: Control): void;
  66335. /** Attach to all scene events required to support pointer events */
  66336. attach(): void;
  66337. /** @hidden */
  66338. private onClipboardCopy;
  66339. /** @hidden */
  66340. private onClipboardCut;
  66341. /** @hidden */
  66342. private onClipboardPaste;
  66343. /**
  66344. * Register the clipboard Events onto the canvas
  66345. */
  66346. registerClipboardEvents(): void;
  66347. /**
  66348. * Unregister the clipboard Events from the canvas
  66349. */
  66350. unRegisterClipboardEvents(): void;
  66351. /**
  66352. * Connect the texture to a hosting mesh to enable interactions
  66353. * @param mesh defines the mesh to attach to
  66354. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  66355. */
  66356. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  66357. /**
  66358. * Move the focus to a specific control
  66359. * @param control defines the control which will receive the focus
  66360. */
  66361. moveFocusToControl(control: IFocusableControl): void;
  66362. private _manageFocus;
  66363. private _attachToOnPointerOut;
  66364. /**
  66365. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  66366. * @param mesh defines the mesh which will receive the texture
  66367. * @param width defines the texture width (1024 by default)
  66368. * @param height defines the texture height (1024 by default)
  66369. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  66370. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  66371. * @returns a new AdvancedDynamicTexture
  66372. */
  66373. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  66374. /**
  66375. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  66376. * In this mode the texture will rely on a layer for its rendering.
  66377. * This allows it to be treated like any other layer.
  66378. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  66379. * LayerMask is set through advancedTexture.layer.layerMask
  66380. * @param name defines name for the texture
  66381. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  66382. * @param scene defines the hsoting scene
  66383. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  66384. * @returns a new AdvancedDynamicTexture
  66385. */
  66386. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  66387. }
  66388. }
  66389. declare module BABYLON.GUI {
  66390. /**
  66391. * Root class used for all 2D controls
  66392. * @see http://doc.babylonjs.com/how_to/gui#controls
  66393. */
  66394. export class Control {
  66395. /** defines the name of the control */
  66396. name?: string | undefined;
  66397. /**
  66398. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  66399. */
  66400. static AllowAlphaInheritance: boolean;
  66401. private _alpha;
  66402. private _alphaSet;
  66403. private _zIndex;
  66404. /** @hidden */
  66405. _host: AdvancedDynamicTexture;
  66406. /** Gets or sets the control parent */
  66407. parent: BABYLON.Nullable<Container>;
  66408. /** @hidden */
  66409. _currentMeasure: Measure;
  66410. private _fontFamily;
  66411. private _fontStyle;
  66412. private _fontWeight;
  66413. private _fontSize;
  66414. private _font;
  66415. /** @hidden */
  66416. _width: ValueAndUnit;
  66417. /** @hidden */
  66418. _height: ValueAndUnit;
  66419. /** @hidden */
  66420. protected _fontOffset: {
  66421. ascent: number;
  66422. height: number;
  66423. descent: number;
  66424. };
  66425. private _color;
  66426. private _style;
  66427. private _styleObserver;
  66428. /** @hidden */
  66429. protected _horizontalAlignment: number;
  66430. /** @hidden */
  66431. protected _verticalAlignment: number;
  66432. /** @hidden */
  66433. protected _isDirty: boolean;
  66434. /** @hidden */
  66435. protected _wasDirty: boolean;
  66436. /** @hidden */
  66437. _tempParentMeasure: Measure;
  66438. /** @hidden */
  66439. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  66440. /** @hidden */
  66441. protected _cachedParentMeasure: Measure;
  66442. private _paddingLeft;
  66443. private _paddingRight;
  66444. private _paddingTop;
  66445. private _paddingBottom;
  66446. /** @hidden */
  66447. _left: ValueAndUnit;
  66448. /** @hidden */
  66449. _top: ValueAndUnit;
  66450. private _scaleX;
  66451. private _scaleY;
  66452. private _rotation;
  66453. private _transformCenterX;
  66454. private _transformCenterY;
  66455. /** @hidden */
  66456. _transformMatrix: Matrix2D;
  66457. /** @hidden */
  66458. protected _invertTransformMatrix: Matrix2D;
  66459. /** @hidden */
  66460. protected _transformedPosition: BABYLON.Vector2;
  66461. private _isMatrixDirty;
  66462. private _cachedOffsetX;
  66463. private _cachedOffsetY;
  66464. private _isVisible;
  66465. private _isHighlighted;
  66466. /** @hidden */
  66467. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  66468. private _fontSet;
  66469. private _dummyVector2;
  66470. private _downCount;
  66471. private _enterCount;
  66472. private _doNotRender;
  66473. private _downPointerIds;
  66474. protected _isEnabled: boolean;
  66475. protected _disabledColor: string;
  66476. /** @hidden */
  66477. protected _rebuildLayout: boolean;
  66478. /** @hidden */
  66479. _isClipped: boolean;
  66480. /** @hidden */
  66481. _automaticSize: boolean;
  66482. /** @hidden */
  66483. _tag: any;
  66484. /**
  66485. * 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
  66486. */
  66487. uniqueId: number;
  66488. /**
  66489. * Gets or sets an object used to store user defined information for the node
  66490. */
  66491. metadata: any;
  66492. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  66493. isHitTestVisible: boolean;
  66494. /** Gets or sets a boolean indicating if the control can block pointer events */
  66495. isPointerBlocker: boolean;
  66496. /** Gets or sets a boolean indicating if the control can be focusable */
  66497. isFocusInvisible: boolean;
  66498. /**
  66499. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  66500. * 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
  66501. */
  66502. clipChildren: boolean;
  66503. /**
  66504. * Gets or sets a boolean indicating that control content must be clipped
  66505. * 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
  66506. */
  66507. clipContent: boolean;
  66508. /**
  66509. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  66510. */
  66511. useBitmapCache: boolean;
  66512. private _cacheData;
  66513. private _shadowOffsetX;
  66514. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  66515. shadowOffsetX: number;
  66516. private _shadowOffsetY;
  66517. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  66518. shadowOffsetY: number;
  66519. private _shadowBlur;
  66520. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  66521. shadowBlur: number;
  66522. private _shadowColor;
  66523. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  66524. shadowColor: string;
  66525. /** Gets or sets the cursor to use when the control is hovered */
  66526. hoverCursor: string;
  66527. /** @hidden */
  66528. protected _linkOffsetX: ValueAndUnit;
  66529. /** @hidden */
  66530. protected _linkOffsetY: ValueAndUnit;
  66531. /** Gets the control type name */
  66532. readonly typeName: string;
  66533. /**
  66534. * Get the current class name of the control.
  66535. * @returns current class name
  66536. */
  66537. getClassName(): string;
  66538. /**
  66539. * An event triggered when the pointer move over the control.
  66540. */
  66541. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  66542. /**
  66543. * An event triggered when the pointer move out of the control.
  66544. */
  66545. onPointerOutObservable: BABYLON.Observable<Control>;
  66546. /**
  66547. * An event triggered when the pointer taps the control
  66548. */
  66549. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  66550. /**
  66551. * An event triggered when pointer up
  66552. */
  66553. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  66554. /**
  66555. * An event triggered when a control is clicked on
  66556. */
  66557. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  66558. /**
  66559. * An event triggered when pointer enters the control
  66560. */
  66561. onPointerEnterObservable: BABYLON.Observable<Control>;
  66562. /**
  66563. * An event triggered when the control is marked as dirty
  66564. */
  66565. onDirtyObservable: BABYLON.Observable<Control>;
  66566. /**
  66567. * An event triggered before drawing the control
  66568. */
  66569. onBeforeDrawObservable: BABYLON.Observable<Control>;
  66570. /**
  66571. * An event triggered after the control was drawn
  66572. */
  66573. onAfterDrawObservable: BABYLON.Observable<Control>;
  66574. /**
  66575. * Get the hosting AdvancedDynamicTexture
  66576. */
  66577. readonly host: AdvancedDynamicTexture;
  66578. /** Gets or set information about font offsets (used to render and align text) */
  66579. fontOffset: {
  66580. ascent: number;
  66581. height: number;
  66582. descent: number;
  66583. };
  66584. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  66585. alpha: number;
  66586. /**
  66587. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  66588. */
  66589. isHighlighted: boolean;
  66590. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  66591. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  66592. */
  66593. scaleX: number;
  66594. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  66595. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  66596. */
  66597. scaleY: number;
  66598. /** Gets or sets the rotation angle (0 by default)
  66599. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  66600. */
  66601. rotation: number;
  66602. /** Gets or sets the transformation center on Y axis (0 by default)
  66603. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  66604. */
  66605. transformCenterY: number;
  66606. /** Gets or sets the transformation center on X axis (0 by default)
  66607. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  66608. */
  66609. transformCenterX: number;
  66610. /**
  66611. * Gets or sets the horizontal alignment
  66612. * @see http://doc.babylonjs.com/how_to/gui#alignments
  66613. */
  66614. horizontalAlignment: number;
  66615. /**
  66616. * Gets or sets the vertical alignment
  66617. * @see http://doc.babylonjs.com/how_to/gui#alignments
  66618. */
  66619. verticalAlignment: number;
  66620. /**
  66621. * Gets or sets control width
  66622. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  66623. */
  66624. width: string | number;
  66625. /**
  66626. * Gets or sets the control width in pixel
  66627. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  66628. */
  66629. widthInPixels: number;
  66630. /**
  66631. * Gets or sets control height
  66632. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  66633. */
  66634. height: string | number;
  66635. /**
  66636. * Gets or sets control height in pixel
  66637. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  66638. */
  66639. heightInPixels: number;
  66640. /** Gets or set font family */
  66641. fontFamily: string;
  66642. /** Gets or sets font style */
  66643. fontStyle: string;
  66644. /** Gets or sets font weight */
  66645. fontWeight: string;
  66646. /**
  66647. * Gets or sets style
  66648. * @see http://doc.babylonjs.com/how_to/gui#styles
  66649. */
  66650. style: BABYLON.Nullable<Style>;
  66651. /** @hidden */
  66652. readonly _isFontSizeInPercentage: boolean;
  66653. /** Gets or sets font size in pixels */
  66654. fontSizeInPixels: number;
  66655. /** Gets or sets font size */
  66656. fontSize: string | number;
  66657. /** Gets or sets foreground color */
  66658. color: string;
  66659. /** Gets or sets z index which is used to reorder controls on the z axis */
  66660. zIndex: number;
  66661. /** Gets or sets a boolean indicating if the control can be rendered */
  66662. notRenderable: boolean;
  66663. /** Gets or sets a boolean indicating if the control is visible */
  66664. isVisible: boolean;
  66665. /** Gets a boolean indicating that the control needs to update its rendering */
  66666. readonly isDirty: boolean;
  66667. /**
  66668. * Gets the current linked mesh (or null if none)
  66669. */
  66670. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  66671. /**
  66672. * Gets or sets a value indicating the padding to use on the left of the control
  66673. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  66674. */
  66675. paddingLeft: string | number;
  66676. /**
  66677. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  66678. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  66679. */
  66680. paddingLeftInPixels: number;
  66681. /**
  66682. * Gets or sets a value indicating the padding to use on the right of the control
  66683. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  66684. */
  66685. paddingRight: string | number;
  66686. /**
  66687. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  66688. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  66689. */
  66690. paddingRightInPixels: number;
  66691. /**
  66692. * Gets or sets a value indicating the padding to use on the top of the control
  66693. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  66694. */
  66695. paddingTop: string | number;
  66696. /**
  66697. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  66698. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  66699. */
  66700. paddingTopInPixels: number;
  66701. /**
  66702. * Gets or sets a value indicating the padding to use on the bottom of the control
  66703. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  66704. */
  66705. paddingBottom: string | number;
  66706. /**
  66707. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  66708. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  66709. */
  66710. paddingBottomInPixels: number;
  66711. /**
  66712. * Gets or sets a value indicating the left coordinate of the control
  66713. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  66714. */
  66715. left: string | number;
  66716. /**
  66717. * Gets or sets a value indicating the left coordinate in pixels of the control
  66718. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  66719. */
  66720. leftInPixels: number;
  66721. /**
  66722. * Gets or sets a value indicating the top coordinate of the control
  66723. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  66724. */
  66725. top: string | number;
  66726. /**
  66727. * Gets or sets a value indicating the top coordinate in pixels of the control
  66728. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  66729. */
  66730. topInPixels: number;
  66731. /**
  66732. * Gets or sets a value indicating the offset on X axis to the linked mesh
  66733. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  66734. */
  66735. linkOffsetX: string | number;
  66736. /**
  66737. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  66738. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  66739. */
  66740. linkOffsetXInPixels: number;
  66741. /**
  66742. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  66743. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  66744. */
  66745. linkOffsetY: string | number;
  66746. /**
  66747. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  66748. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  66749. */
  66750. linkOffsetYInPixels: number;
  66751. /** Gets the center coordinate on X axis */
  66752. readonly centerX: number;
  66753. /** Gets the center coordinate on Y axis */
  66754. readonly centerY: number;
  66755. /** Gets or sets if control is Enabled*/
  66756. isEnabled: boolean;
  66757. /** Gets or sets background color of control if it's disabled*/
  66758. disabledColor: string;
  66759. /**
  66760. * Creates a new control
  66761. * @param name defines the name of the control
  66762. */
  66763. constructor(
  66764. /** defines the name of the control */
  66765. name?: string | undefined);
  66766. /** @hidden */
  66767. protected _getTypeName(): string;
  66768. /**
  66769. * Gets the first ascendant in the hierarchy of the given type
  66770. * @param className defines the required type
  66771. * @returns the ascendant or null if not found
  66772. */
  66773. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  66774. /** @hidden */
  66775. _resetFontCache(): void;
  66776. /**
  66777. * Determines if a container is an ascendant of the current control
  66778. * @param container defines the container to look for
  66779. * @returns true if the container is one of the ascendant of the control
  66780. */
  66781. isAscendant(container: Control): boolean;
  66782. /**
  66783. * Gets coordinates in local control space
  66784. * @param globalCoordinates defines the coordinates to transform
  66785. * @returns the new coordinates in local space
  66786. */
  66787. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  66788. /**
  66789. * Gets coordinates in local control space
  66790. * @param globalCoordinates defines the coordinates to transform
  66791. * @param result defines the target vector2 where to store the result
  66792. * @returns the current control
  66793. */
  66794. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  66795. /**
  66796. * Gets coordinates in parent local control space
  66797. * @param globalCoordinates defines the coordinates to transform
  66798. * @returns the new coordinates in parent local space
  66799. */
  66800. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  66801. /**
  66802. * Move the current control to a vector3 position projected onto the screen.
  66803. * @param position defines the target position
  66804. * @param scene defines the hosting scene
  66805. */
  66806. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  66807. /**
  66808. * Will store all controls that have this control as ascendant in a given array
  66809. * @param results defines the array where to store the descendants
  66810. * @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
  66811. * @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
  66812. */
  66813. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  66814. /**
  66815. * Will return all controls that have this control as ascendant
  66816. * @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
  66817. * @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
  66818. * @return all child controls
  66819. */
  66820. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  66821. /**
  66822. * Link current control with a target mesh
  66823. * @param mesh defines the mesh to link with
  66824. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  66825. */
  66826. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  66827. /** @hidden */
  66828. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  66829. /** @hidden */
  66830. _offsetLeft(offset: number): void;
  66831. /** @hidden */
  66832. _offsetTop(offset: number): void;
  66833. /** @hidden */
  66834. _markMatrixAsDirty(): void;
  66835. /** @hidden */
  66836. _flagDescendantsAsMatrixDirty(): void;
  66837. /** @hidden */
  66838. _intersectsRect(rect: Measure): boolean;
  66839. /** @hidden */
  66840. protected invalidateRect(): void;
  66841. /** @hidden */
  66842. _markAsDirty(force?: boolean): void;
  66843. /** @hidden */
  66844. _markAllAsDirty(): void;
  66845. /** @hidden */
  66846. _link(host: AdvancedDynamicTexture): void;
  66847. /** @hidden */
  66848. protected _transform(context?: CanvasRenderingContext2D): void;
  66849. /** @hidden */
  66850. _renderHighlight(context: CanvasRenderingContext2D): void;
  66851. /** @hidden */
  66852. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  66853. /** @hidden */
  66854. protected _applyStates(context: CanvasRenderingContext2D): void;
  66855. /** @hidden */
  66856. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  66857. /** @hidden */
  66858. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66859. protected _evaluateClippingState(parentMeasure: Measure): void;
  66860. /** @hidden */
  66861. _measure(): void;
  66862. /** @hidden */
  66863. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66864. /** @hidden */
  66865. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66866. /** @hidden */
  66867. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66868. /** @hidden */
  66869. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  66870. private static _ClipMeasure;
  66871. private _tmpMeasureA;
  66872. private _clip;
  66873. /** @hidden */
  66874. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  66875. /** @hidden */
  66876. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  66877. /**
  66878. * Tests if a given coordinates belong to the current control
  66879. * @param x defines x coordinate to test
  66880. * @param y defines y coordinate to test
  66881. * @returns true if the coordinates are inside the control
  66882. */
  66883. contains(x: number, y: number): boolean;
  66884. /** @hidden */
  66885. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  66886. /** @hidden */
  66887. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  66888. /** @hidden */
  66889. _onPointerEnter(target: Control): boolean;
  66890. /** @hidden */
  66891. _onPointerOut(target: Control, force?: boolean): void;
  66892. /** @hidden */
  66893. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  66894. /** @hidden */
  66895. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  66896. /** @hidden */
  66897. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  66898. /** @hidden */
  66899. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  66900. private _prepareFont;
  66901. /** Releases associated resources */
  66902. dispose(): void;
  66903. private static _HORIZONTAL_ALIGNMENT_LEFT;
  66904. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  66905. private static _HORIZONTAL_ALIGNMENT_CENTER;
  66906. private static _VERTICAL_ALIGNMENT_TOP;
  66907. private static _VERTICAL_ALIGNMENT_BOTTOM;
  66908. private static _VERTICAL_ALIGNMENT_CENTER;
  66909. /** HORIZONTAL_ALIGNMENT_LEFT */
  66910. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  66911. /** HORIZONTAL_ALIGNMENT_RIGHT */
  66912. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  66913. /** HORIZONTAL_ALIGNMENT_CENTER */
  66914. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  66915. /** VERTICAL_ALIGNMENT_TOP */
  66916. static readonly VERTICAL_ALIGNMENT_TOP: number;
  66917. /** VERTICAL_ALIGNMENT_BOTTOM */
  66918. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  66919. /** VERTICAL_ALIGNMENT_CENTER */
  66920. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  66921. private static _FontHeightSizes;
  66922. /** @hidden */
  66923. static _GetFontOffset(font: string): {
  66924. ascent: number;
  66925. height: number;
  66926. descent: number;
  66927. };
  66928. /**
  66929. * Creates a stack panel that can be used to render headers
  66930. * @param control defines the control to associate with the header
  66931. * @param text defines the text of the header
  66932. * @param size defines the size of the header
  66933. * @param options defines options used to configure the header
  66934. * @returns a new StackPanel
  66935. * @ignore
  66936. * @hidden
  66937. */
  66938. static AddHeader: (control: Control, text: string, size: string | number, options: {
  66939. isHorizontal: boolean;
  66940. controlFirst: boolean;
  66941. }) => any;
  66942. /** @hidden */
  66943. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  66944. }
  66945. }
  66946. declare module BABYLON.GUI {
  66947. /**
  66948. * Root class for 2D containers
  66949. * @see http://doc.babylonjs.com/how_to/gui#containers
  66950. */
  66951. export class Container extends Control {
  66952. name?: string | undefined;
  66953. /** @hidden */
  66954. protected _children: Control[];
  66955. /** @hidden */
  66956. protected _measureForChildren: Measure;
  66957. /** @hidden */
  66958. protected _background: string;
  66959. /** @hidden */
  66960. protected _adaptWidthToChildren: boolean;
  66961. /** @hidden */
  66962. protected _adaptHeightToChildren: boolean;
  66963. /**
  66964. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  66965. */
  66966. logLayoutCycleErrors: boolean;
  66967. /**
  66968. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  66969. */
  66970. maxLayoutCycle: number;
  66971. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  66972. adaptHeightToChildren: boolean;
  66973. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  66974. adaptWidthToChildren: boolean;
  66975. /** Gets or sets background color */
  66976. background: string;
  66977. /** Gets the list of children */
  66978. readonly children: Control[];
  66979. /**
  66980. * Creates a new Container
  66981. * @param name defines the name of the container
  66982. */
  66983. constructor(name?: string | undefined);
  66984. protected _getTypeName(): string;
  66985. _flagDescendantsAsMatrixDirty(): void;
  66986. /**
  66987. * Gets a child using its name
  66988. * @param name defines the child name to look for
  66989. * @returns the child control if found
  66990. */
  66991. getChildByName(name: string): BABYLON.Nullable<Control>;
  66992. /**
  66993. * Gets a child using its type and its name
  66994. * @param name defines the child name to look for
  66995. * @param type defines the child type to look for
  66996. * @returns the child control if found
  66997. */
  66998. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  66999. /**
  67000. * Search for a specific control in children
  67001. * @param control defines the control to look for
  67002. * @returns true if the control is in child list
  67003. */
  67004. containsControl(control: Control): boolean;
  67005. /**
  67006. * Adds a new control to the current container
  67007. * @param control defines the control to add
  67008. * @returns the current container
  67009. */
  67010. addControl(control: BABYLON.Nullable<Control>): Container;
  67011. /**
  67012. * Removes all controls from the current container
  67013. * @returns the current container
  67014. */
  67015. clearControls(): Container;
  67016. /**
  67017. * Removes a control from the current container
  67018. * @param control defines the control to remove
  67019. * @returns the current container
  67020. */
  67021. removeControl(control: Control): Container;
  67022. /** @hidden */
  67023. _reOrderControl(control: Control): void;
  67024. /** @hidden */
  67025. _offsetLeft(offset: number): void;
  67026. /** @hidden */
  67027. _offsetTop(offset: number): void;
  67028. /** @hidden */
  67029. _markAllAsDirty(): void;
  67030. /** @hidden */
  67031. protected _localDraw(context: CanvasRenderingContext2D): void;
  67032. /** @hidden */
  67033. _link(host: AdvancedDynamicTexture): void;
  67034. /** @hidden */
  67035. protected _beforeLayout(): void;
  67036. /** @hidden */
  67037. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67038. /** @hidden */
  67039. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  67040. protected _postMeasure(): void;
  67041. /** @hidden */
  67042. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  67043. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  67044. /** @hidden */
  67045. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  67046. /** @hidden */
  67047. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67048. /** Releases associated resources */
  67049. dispose(): void;
  67050. }
  67051. }
  67052. declare module BABYLON.GUI {
  67053. /** Class used to create rectangle container */
  67054. export class Rectangle extends Container {
  67055. name?: string | undefined;
  67056. private _thickness;
  67057. private _cornerRadius;
  67058. /** Gets or sets border thickness */
  67059. thickness: number;
  67060. /** Gets or sets the corner radius angle */
  67061. cornerRadius: number;
  67062. /**
  67063. * Creates a new Rectangle
  67064. * @param name defines the control name
  67065. */
  67066. constructor(name?: string | undefined);
  67067. protected _getTypeName(): string;
  67068. protected _localDraw(context: CanvasRenderingContext2D): void;
  67069. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67070. private _drawRoundedRect;
  67071. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  67072. }
  67073. }
  67074. declare module BABYLON.GUI {
  67075. /**
  67076. * Enum that determines the text-wrapping mode to use.
  67077. */
  67078. export enum TextWrapping {
  67079. /**
  67080. * Clip the text when it's larger than Control.width; this is the default mode.
  67081. */
  67082. Clip = 0,
  67083. /**
  67084. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  67085. */
  67086. WordWrap = 1,
  67087. /**
  67088. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  67089. */
  67090. Ellipsis = 2
  67091. }
  67092. /**
  67093. * Class used to create text block control
  67094. */
  67095. export class TextBlock extends Control {
  67096. /**
  67097. * Defines the name of the control
  67098. */
  67099. name?: string | undefined;
  67100. private _text;
  67101. private _textWrapping;
  67102. private _textHorizontalAlignment;
  67103. private _textVerticalAlignment;
  67104. private _lines;
  67105. private _resizeToFit;
  67106. private _lineSpacing;
  67107. private _outlineWidth;
  67108. private _outlineColor;
  67109. /**
  67110. * An event triggered after the text is changed
  67111. */
  67112. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  67113. /**
  67114. * An event triggered after the text was broken up into lines
  67115. */
  67116. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  67117. /**
  67118. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  67119. */
  67120. readonly lines: any[];
  67121. /**
  67122. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  67123. */
  67124. /**
  67125. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  67126. */
  67127. resizeToFit: boolean;
  67128. /**
  67129. * Gets or sets a boolean indicating if text must be wrapped
  67130. */
  67131. /**
  67132. * Gets or sets a boolean indicating if text must be wrapped
  67133. */
  67134. textWrapping: TextWrapping | boolean;
  67135. /**
  67136. * Gets or sets text to display
  67137. */
  67138. /**
  67139. * Gets or sets text to display
  67140. */
  67141. text: string;
  67142. /**
  67143. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  67144. */
  67145. /**
  67146. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  67147. */
  67148. textHorizontalAlignment: number;
  67149. /**
  67150. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  67151. */
  67152. /**
  67153. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  67154. */
  67155. textVerticalAlignment: number;
  67156. /**
  67157. * Gets or sets line spacing value
  67158. */
  67159. /**
  67160. * Gets or sets line spacing value
  67161. */
  67162. lineSpacing: string | number;
  67163. /**
  67164. * Gets or sets outlineWidth of the text to display
  67165. */
  67166. /**
  67167. * Gets or sets outlineWidth of the text to display
  67168. */
  67169. outlineWidth: number;
  67170. /**
  67171. * Gets or sets outlineColor of the text to display
  67172. */
  67173. /**
  67174. * Gets or sets outlineColor of the text to display
  67175. */
  67176. outlineColor: string;
  67177. /**
  67178. * Creates a new TextBlock object
  67179. * @param name defines the name of the control
  67180. * @param text defines the text to display (emptry string by default)
  67181. */
  67182. constructor(
  67183. /**
  67184. * Defines the name of the control
  67185. */
  67186. name?: string | undefined, text?: string);
  67187. protected _getTypeName(): string;
  67188. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67189. private _drawText;
  67190. /** @hidden */
  67191. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  67192. protected _applyStates(context: CanvasRenderingContext2D): void;
  67193. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  67194. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  67195. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  67196. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  67197. protected _renderLines(context: CanvasRenderingContext2D): void;
  67198. /**
  67199. * Given a width constraint applied on the text block, find the expected height
  67200. * @returns expected height
  67201. */
  67202. computeExpectedHeight(): number;
  67203. dispose(): void;
  67204. }
  67205. }
  67206. declare module BABYLON.GUI {
  67207. /**
  67208. * Class used to create 2D images
  67209. */
  67210. export class Image extends Control {
  67211. name?: string | undefined;
  67212. private _workingCanvas;
  67213. private _domImage;
  67214. private _imageWidth;
  67215. private _imageHeight;
  67216. private _loaded;
  67217. private _stretch;
  67218. private _source;
  67219. private _autoScale;
  67220. private _sourceLeft;
  67221. private _sourceTop;
  67222. private _sourceWidth;
  67223. private _sourceHeight;
  67224. private _cellWidth;
  67225. private _cellHeight;
  67226. private _cellId;
  67227. private _populateNinePatchSlicesFromImage;
  67228. private _sliceLeft;
  67229. private _sliceRight;
  67230. private _sliceTop;
  67231. private _sliceBottom;
  67232. private _detectPointerOnOpaqueOnly;
  67233. /**
  67234. * BABYLON.Observable notified when the content is loaded
  67235. */
  67236. onImageLoadedObservable: BABYLON.Observable<Image>;
  67237. /**
  67238. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  67239. */
  67240. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  67241. /**
  67242. * Gets a boolean indicating that the content is loaded
  67243. */
  67244. readonly isLoaded: boolean;
  67245. /**
  67246. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  67247. */
  67248. populateNinePatchSlicesFromImage: boolean;
  67249. /**
  67250. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  67251. * Beware using this as this will comsume more memory as the image has to be stored twice
  67252. */
  67253. detectPointerOnOpaqueOnly: boolean;
  67254. /**
  67255. * Gets or sets the left value for slicing (9-patch)
  67256. */
  67257. sliceLeft: number;
  67258. /**
  67259. * Gets or sets the right value for slicing (9-patch)
  67260. */
  67261. sliceRight: number;
  67262. /**
  67263. * Gets or sets the top value for slicing (9-patch)
  67264. */
  67265. sliceTop: number;
  67266. /**
  67267. * Gets or sets the bottom value for slicing (9-patch)
  67268. */
  67269. sliceBottom: number;
  67270. /**
  67271. * Gets or sets the left coordinate in the source image
  67272. */
  67273. sourceLeft: number;
  67274. /**
  67275. * Gets or sets the top coordinate in the source image
  67276. */
  67277. sourceTop: number;
  67278. /**
  67279. * Gets or sets the width to capture in the source image
  67280. */
  67281. sourceWidth: number;
  67282. /**
  67283. * Gets or sets the height to capture in the source image
  67284. */
  67285. sourceHeight: number;
  67286. /**
  67287. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  67288. * @see http://doc.babylonjs.com/how_to/gui#image
  67289. */
  67290. autoScale: boolean;
  67291. /** Gets or sets the streching mode used by the image */
  67292. stretch: number;
  67293. /** @hidden */
  67294. _rotate90(n: number): Image;
  67295. /**
  67296. * Gets or sets the internal DOM image used to render the control
  67297. */
  67298. domImage: HTMLImageElement;
  67299. private _onImageLoaded;
  67300. private _extractNinePatchSliceDataFromImage;
  67301. /**
  67302. * Gets or sets image source url
  67303. */
  67304. source: BABYLON.Nullable<string>;
  67305. /**
  67306. * Checks for svg document with icon id present
  67307. */
  67308. private _svgCheck;
  67309. /**
  67310. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  67311. * given external svg file and icon id
  67312. */
  67313. private _getSVGAttribs;
  67314. /**
  67315. * Gets or sets the cell width to use when animation sheet is enabled
  67316. * @see http://doc.babylonjs.com/how_to/gui#image
  67317. */
  67318. cellWidth: number;
  67319. /**
  67320. * Gets or sets the cell height to use when animation sheet is enabled
  67321. * @see http://doc.babylonjs.com/how_to/gui#image
  67322. */
  67323. cellHeight: number;
  67324. /**
  67325. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  67326. * @see http://doc.babylonjs.com/how_to/gui#image
  67327. */
  67328. cellId: number;
  67329. /**
  67330. * Creates a new Image
  67331. * @param name defines the control name
  67332. * @param url defines the image url
  67333. */
  67334. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  67335. /**
  67336. * Tests if a given coordinates belong to the current control
  67337. * @param x defines x coordinate to test
  67338. * @param y defines y coordinate to test
  67339. * @returns true if the coordinates are inside the control
  67340. */
  67341. contains(x: number, y: number): boolean;
  67342. protected _getTypeName(): string;
  67343. /** Force the control to synchronize with its content */
  67344. synchronizeSizeWithContent(): void;
  67345. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67346. private _prepareWorkingCanvasForOpaqueDetection;
  67347. private _drawImage;
  67348. _draw(context: CanvasRenderingContext2D): void;
  67349. private _renderCornerPatch;
  67350. private _renderNinePatch;
  67351. dispose(): void;
  67352. /** STRETCH_NONE */
  67353. static readonly STRETCH_NONE: number;
  67354. /** STRETCH_FILL */
  67355. static readonly STRETCH_FILL: number;
  67356. /** STRETCH_UNIFORM */
  67357. static readonly STRETCH_UNIFORM: number;
  67358. /** STRETCH_EXTEND */
  67359. static readonly STRETCH_EXTEND: number;
  67360. /** NINE_PATCH */
  67361. static readonly STRETCH_NINE_PATCH: number;
  67362. }
  67363. }
  67364. declare module BABYLON.GUI {
  67365. /**
  67366. * Class used to create 2D buttons
  67367. */
  67368. export class Button extends Rectangle {
  67369. name?: string | undefined;
  67370. /**
  67371. * Function called to generate a pointer enter animation
  67372. */
  67373. pointerEnterAnimation: () => void;
  67374. /**
  67375. * Function called to generate a pointer out animation
  67376. */
  67377. pointerOutAnimation: () => void;
  67378. /**
  67379. * Function called to generate a pointer down animation
  67380. */
  67381. pointerDownAnimation: () => void;
  67382. /**
  67383. * Function called to generate a pointer up animation
  67384. */
  67385. pointerUpAnimation: () => void;
  67386. /**
  67387. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  67388. */
  67389. delegatePickingToChildren: boolean;
  67390. private _image;
  67391. /**
  67392. * Returns the image part of the button (if any)
  67393. */
  67394. readonly image: BABYLON.Nullable<Image>;
  67395. private _textBlock;
  67396. /**
  67397. * Returns the image part of the button (if any)
  67398. */
  67399. readonly textBlock: BABYLON.Nullable<TextBlock>;
  67400. /**
  67401. * Creates a new Button
  67402. * @param name defines the name of the button
  67403. */
  67404. constructor(name?: string | undefined);
  67405. protected _getTypeName(): string;
  67406. /** @hidden */
  67407. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  67408. /** @hidden */
  67409. _onPointerEnter(target: Control): boolean;
  67410. /** @hidden */
  67411. _onPointerOut(target: Control, force?: boolean): void;
  67412. /** @hidden */
  67413. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  67414. /** @hidden */
  67415. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  67416. /**
  67417. * Creates a new button made with an image and a text
  67418. * @param name defines the name of the button
  67419. * @param text defines the text of the button
  67420. * @param imageUrl defines the url of the image
  67421. * @returns a new Button
  67422. */
  67423. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  67424. /**
  67425. * Creates a new button made with an image
  67426. * @param name defines the name of the button
  67427. * @param imageUrl defines the url of the image
  67428. * @returns a new Button
  67429. */
  67430. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  67431. /**
  67432. * Creates a new button made with a text
  67433. * @param name defines the name of the button
  67434. * @param text defines the text of the button
  67435. * @returns a new Button
  67436. */
  67437. static CreateSimpleButton(name: string, text: string): Button;
  67438. /**
  67439. * Creates a new button made with an image and a centered text
  67440. * @param name defines the name of the button
  67441. * @param text defines the text of the button
  67442. * @param imageUrl defines the url of the image
  67443. * @returns a new Button
  67444. */
  67445. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  67446. }
  67447. }
  67448. declare module BABYLON.GUI {
  67449. /**
  67450. * Class used to create a 2D stack panel container
  67451. */
  67452. export class StackPanel extends Container {
  67453. name?: string | undefined;
  67454. private _isVertical;
  67455. private _manualWidth;
  67456. private _manualHeight;
  67457. private _doNotTrackManualChanges;
  67458. /**
  67459. * Gets or sets a boolean indicating that layou warnings should be ignored
  67460. */
  67461. ignoreLayoutWarnings: boolean;
  67462. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  67463. isVertical: boolean;
  67464. /**
  67465. * Gets or sets panel width.
  67466. * This value should not be set when in horizontal mode as it will be computed automatically
  67467. */
  67468. width: string | number;
  67469. /**
  67470. * Gets or sets panel height.
  67471. * This value should not be set when in vertical mode as it will be computed automatically
  67472. */
  67473. height: string | number;
  67474. /**
  67475. * Creates a new StackPanel
  67476. * @param name defines control name
  67477. */
  67478. constructor(name?: string | undefined);
  67479. protected _getTypeName(): string;
  67480. /** @hidden */
  67481. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67482. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67483. protected _postMeasure(): void;
  67484. }
  67485. }
  67486. declare module BABYLON.GUI {
  67487. /**
  67488. * Class used to represent a 2D checkbox
  67489. */
  67490. export class Checkbox extends Control {
  67491. name?: string | undefined;
  67492. private _isChecked;
  67493. private _background;
  67494. private _checkSizeRatio;
  67495. private _thickness;
  67496. /** Gets or sets border thickness */
  67497. thickness: number;
  67498. /**
  67499. * BABYLON.Observable raised when isChecked property changes
  67500. */
  67501. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  67502. /** Gets or sets a value indicating the ratio between overall size and check size */
  67503. checkSizeRatio: number;
  67504. /** Gets or sets background color */
  67505. background: string;
  67506. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  67507. isChecked: boolean;
  67508. /**
  67509. * Creates a new CheckBox
  67510. * @param name defines the control name
  67511. */
  67512. constructor(name?: string | undefined);
  67513. protected _getTypeName(): string;
  67514. /** @hidden */
  67515. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  67516. /** @hidden */
  67517. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  67518. /**
  67519. * Utility function to easily create a checkbox with a header
  67520. * @param title defines the label to use for the header
  67521. * @param onValueChanged defines the callback to call when value changes
  67522. * @returns a StackPanel containing the checkbox and a textBlock
  67523. */
  67524. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  67525. }
  67526. }
  67527. declare module BABYLON.GUI {
  67528. /**
  67529. * Class used to store key control properties
  67530. */
  67531. export class KeyPropertySet {
  67532. /** Width */
  67533. width?: string;
  67534. /** Height */
  67535. height?: string;
  67536. /** Left padding */
  67537. paddingLeft?: string;
  67538. /** Right padding */
  67539. paddingRight?: string;
  67540. /** Top padding */
  67541. paddingTop?: string;
  67542. /** Bottom padding */
  67543. paddingBottom?: string;
  67544. /** Foreground color */
  67545. color?: string;
  67546. /** Background color */
  67547. background?: string;
  67548. }
  67549. /**
  67550. * Class used to create virtual keyboard
  67551. */
  67552. export class VirtualKeyboard extends StackPanel {
  67553. /** BABYLON.Observable raised when a key is pressed */
  67554. onKeyPressObservable: BABYLON.Observable<string>;
  67555. /** Gets or sets default key button width */
  67556. defaultButtonWidth: string;
  67557. /** Gets or sets default key button height */
  67558. defaultButtonHeight: string;
  67559. /** Gets or sets default key button left padding */
  67560. defaultButtonPaddingLeft: string;
  67561. /** Gets or sets default key button right padding */
  67562. defaultButtonPaddingRight: string;
  67563. /** Gets or sets default key button top padding */
  67564. defaultButtonPaddingTop: string;
  67565. /** Gets or sets default key button bottom padding */
  67566. defaultButtonPaddingBottom: string;
  67567. /** Gets or sets default key button foreground color */
  67568. defaultButtonColor: string;
  67569. /** Gets or sets default key button background color */
  67570. defaultButtonBackground: string;
  67571. /** Gets or sets shift button foreground color */
  67572. shiftButtonColor: string;
  67573. /** Gets or sets shift button thickness*/
  67574. selectedShiftThickness: number;
  67575. /** Gets shift key state */
  67576. shiftState: number;
  67577. protected _getTypeName(): string;
  67578. private _createKey;
  67579. /**
  67580. * Adds a new row of keys
  67581. * @param keys defines the list of keys to add
  67582. * @param propertySets defines the associated property sets
  67583. */
  67584. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  67585. /**
  67586. * Set the shift key to a specific state
  67587. * @param shiftState defines the new shift state
  67588. */
  67589. applyShiftState(shiftState: number): void;
  67590. private _currentlyConnectedInputText;
  67591. private _connectedInputTexts;
  67592. private _onKeyPressObserver;
  67593. /** Gets the input text control currently attached to the keyboard */
  67594. readonly connectedInputText: BABYLON.Nullable<InputText>;
  67595. /**
  67596. * Connects the keyboard with an input text control
  67597. *
  67598. * @param input defines the target control
  67599. */
  67600. connect(input: InputText): void;
  67601. /**
  67602. * Disconnects the keyboard from connected InputText controls
  67603. *
  67604. * @param input optionally defines a target control, otherwise all are disconnected
  67605. */
  67606. disconnect(input?: InputText): void;
  67607. private _removeConnectedInputObservables;
  67608. /**
  67609. * Release all resources
  67610. */
  67611. dispose(): void;
  67612. /**
  67613. * Creates a new keyboard using a default layout
  67614. *
  67615. * @param name defines control name
  67616. * @returns a new VirtualKeyboard
  67617. */
  67618. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  67619. }
  67620. }
  67621. declare module BABYLON.GUI {
  67622. /**
  67623. * Class used to create input text control
  67624. */
  67625. export class InputText extends Control implements IFocusableControl {
  67626. name?: string | undefined;
  67627. private _text;
  67628. private _placeholderText;
  67629. private _background;
  67630. private _focusedBackground;
  67631. private _focusedColor;
  67632. private _placeholderColor;
  67633. private _thickness;
  67634. private _margin;
  67635. private _autoStretchWidth;
  67636. private _maxWidth;
  67637. private _isFocused;
  67638. private _blinkTimeout;
  67639. private _blinkIsEven;
  67640. private _cursorOffset;
  67641. private _scrollLeft;
  67642. private _textWidth;
  67643. private _clickedCoordinate;
  67644. private _deadKey;
  67645. private _addKey;
  67646. private _currentKey;
  67647. private _isTextHighlightOn;
  67648. private _textHighlightColor;
  67649. private _highligherOpacity;
  67650. private _highlightedText;
  67651. private _startHighlightIndex;
  67652. private _endHighlightIndex;
  67653. private _cursorIndex;
  67654. private _onFocusSelectAll;
  67655. private _isPointerDown;
  67656. private _onClipboardObserver;
  67657. private _onPointerDblTapObserver;
  67658. /** @hidden */
  67659. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  67660. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  67661. promptMessage: string;
  67662. /** Force disable prompt on mobile device */
  67663. disableMobilePrompt: boolean;
  67664. /** BABYLON.Observable raised when the text changes */
  67665. onTextChangedObservable: BABYLON.Observable<InputText>;
  67666. /** BABYLON.Observable raised just before an entered character is to be added */
  67667. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  67668. /** BABYLON.Observable raised when the control gets the focus */
  67669. onFocusObservable: BABYLON.Observable<InputText>;
  67670. /** BABYLON.Observable raised when the control loses the focus */
  67671. onBlurObservable: BABYLON.Observable<InputText>;
  67672. /**Observable raised when the text is highlighted */
  67673. onTextHighlightObservable: BABYLON.Observable<InputText>;
  67674. /**Observable raised when copy event is triggered */
  67675. onTextCopyObservable: BABYLON.Observable<InputText>;
  67676. /** BABYLON.Observable raised when cut event is triggered */
  67677. onTextCutObservable: BABYLON.Observable<InputText>;
  67678. /** BABYLON.Observable raised when paste event is triggered */
  67679. onTextPasteObservable: BABYLON.Observable<InputText>;
  67680. /** BABYLON.Observable raised when a key event was processed */
  67681. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  67682. /** Gets or sets the maximum width allowed by the control */
  67683. maxWidth: string | number;
  67684. /** Gets the maximum width allowed by the control in pixels */
  67685. readonly maxWidthInPixels: number;
  67686. /** Gets or sets the text highlighter transparency; default: 0.4 */
  67687. highligherOpacity: number;
  67688. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  67689. onFocusSelectAll: boolean;
  67690. /** Gets or sets the text hightlight color */
  67691. textHighlightColor: string;
  67692. /** Gets or sets control margin */
  67693. margin: string;
  67694. /** Gets control margin in pixels */
  67695. readonly marginInPixels: number;
  67696. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  67697. autoStretchWidth: boolean;
  67698. /** Gets or sets border thickness */
  67699. thickness: number;
  67700. /** Gets or sets the background color when focused */
  67701. focusedBackground: string;
  67702. /** Gets or sets the background color when focused */
  67703. focusedColor: string;
  67704. /** Gets or sets the background color */
  67705. background: string;
  67706. /** Gets or sets the placeholder color */
  67707. placeholderColor: string;
  67708. /** Gets or sets the text displayed when the control is empty */
  67709. placeholderText: string;
  67710. /** Gets or sets the dead key flag */
  67711. deadKey: boolean;
  67712. /** Gets or sets the highlight text */
  67713. highlightedText: string;
  67714. /** Gets or sets if the current key should be added */
  67715. addKey: boolean;
  67716. /** Gets or sets the value of the current key being entered */
  67717. currentKey: string;
  67718. /** Gets or sets the text displayed in the control */
  67719. text: string;
  67720. /** Gets or sets control width */
  67721. width: string | number;
  67722. /**
  67723. * Creates a new InputText
  67724. * @param name defines the control name
  67725. * @param text defines the text of the control
  67726. */
  67727. constructor(name?: string | undefined, text?: string);
  67728. /** @hidden */
  67729. onBlur(): void;
  67730. /** @hidden */
  67731. onFocus(): void;
  67732. protected _getTypeName(): string;
  67733. /**
  67734. * Function called to get the list of controls that should not steal the focus from this control
  67735. * @returns an array of controls
  67736. */
  67737. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  67738. /** @hidden */
  67739. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  67740. /** @hidden */
  67741. private _updateValueFromCursorIndex;
  67742. /** @hidden */
  67743. private _processDblClick;
  67744. /** @hidden */
  67745. private _selectAllText;
  67746. /**
  67747. * Handles the keyboard event
  67748. * @param evt Defines the KeyboardEvent
  67749. */
  67750. processKeyboard(evt: KeyboardEvent): void;
  67751. /** @hidden */
  67752. private _onCopyText;
  67753. /** @hidden */
  67754. private _onCutText;
  67755. /** @hidden */
  67756. private _onPasteText;
  67757. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  67758. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  67759. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  67760. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  67761. protected _beforeRenderText(text: string): string;
  67762. dispose(): void;
  67763. }
  67764. }
  67765. declare module BABYLON.GUI {
  67766. /**
  67767. * Class used to create a 2D grid container
  67768. */
  67769. export class Grid extends Container {
  67770. name?: string | undefined;
  67771. private _rowDefinitions;
  67772. private _columnDefinitions;
  67773. private _cells;
  67774. private _childControls;
  67775. /**
  67776. * Gets the number of columns
  67777. */
  67778. readonly columnCount: number;
  67779. /**
  67780. * Gets the number of rows
  67781. */
  67782. readonly rowCount: number;
  67783. /** Gets the list of children */
  67784. readonly children: Control[];
  67785. /** Gets the list of cells (e.g. the containers) */
  67786. readonly cells: {
  67787. [key: string]: Container;
  67788. };
  67789. /**
  67790. * Gets the definition of a specific row
  67791. * @param index defines the index of the row
  67792. * @returns the row definition
  67793. */
  67794. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  67795. /**
  67796. * Gets the definition of a specific column
  67797. * @param index defines the index of the column
  67798. * @returns the column definition
  67799. */
  67800. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  67801. /**
  67802. * Adds a new row to the grid
  67803. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  67804. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  67805. * @returns the current grid
  67806. */
  67807. addRowDefinition(height: number, isPixel?: boolean): Grid;
  67808. /**
  67809. * Adds a new column to the grid
  67810. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  67811. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  67812. * @returns the current grid
  67813. */
  67814. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  67815. /**
  67816. * Update a row definition
  67817. * @param index defines the index of the row to update
  67818. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  67819. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  67820. * @returns the current grid
  67821. */
  67822. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  67823. /**
  67824. * Update a column definition
  67825. * @param index defines the index of the column to update
  67826. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  67827. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  67828. * @returns the current grid
  67829. */
  67830. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  67831. /**
  67832. * Gets the list of children stored in a specific cell
  67833. * @param row defines the row to check
  67834. * @param column defines the column to check
  67835. * @returns the list of controls
  67836. */
  67837. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  67838. /**
  67839. * Gets a string representing the child cell info (row x column)
  67840. * @param child defines the control to get info from
  67841. * @returns a string containing the child cell info (row x column)
  67842. */
  67843. getChildCellInfo(child: Control): string;
  67844. private _removeCell;
  67845. private _offsetCell;
  67846. /**
  67847. * Remove a column definition at specified index
  67848. * @param index defines the index of the column to remove
  67849. * @returns the current grid
  67850. */
  67851. removeColumnDefinition(index: number): Grid;
  67852. /**
  67853. * Remove a row definition at specified index
  67854. * @param index defines the index of the row to remove
  67855. * @returns the current grid
  67856. */
  67857. removeRowDefinition(index: number): Grid;
  67858. /**
  67859. * Adds a new control to the current grid
  67860. * @param control defines the control to add
  67861. * @param row defines the row where to add the control (0 by default)
  67862. * @param column defines the column where to add the control (0 by default)
  67863. * @returns the current grid
  67864. */
  67865. addControl(control: Control, row?: number, column?: number): Grid;
  67866. /**
  67867. * Removes a control from the current container
  67868. * @param control defines the control to remove
  67869. * @returns the current container
  67870. */
  67871. removeControl(control: Control): Container;
  67872. /**
  67873. * Creates a new Grid
  67874. * @param name defines control name
  67875. */
  67876. constructor(name?: string | undefined);
  67877. protected _getTypeName(): string;
  67878. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  67879. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67880. _flagDescendantsAsMatrixDirty(): void;
  67881. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  67882. /** Releases associated resources */
  67883. dispose(): void;
  67884. }
  67885. }
  67886. declare module BABYLON.GUI {
  67887. /** Class used to create color pickers */
  67888. export class ColorPicker extends Control {
  67889. name?: string | undefined;
  67890. private static _Epsilon;
  67891. private _colorWheelCanvas;
  67892. private _value;
  67893. private _tmpColor;
  67894. private _pointerStartedOnSquare;
  67895. private _pointerStartedOnWheel;
  67896. private _squareLeft;
  67897. private _squareTop;
  67898. private _squareSize;
  67899. private _h;
  67900. private _s;
  67901. private _v;
  67902. private _lastPointerDownID;
  67903. /**
  67904. * BABYLON.Observable raised when the value changes
  67905. */
  67906. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  67907. /** Gets or sets the color of the color picker */
  67908. value: BABYLON.Color3;
  67909. /**
  67910. * Gets or sets control width
  67911. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67912. */
  67913. width: string | number;
  67914. /**
  67915. * Gets or sets control height
  67916. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67917. */
  67918. /** Gets or sets control height */
  67919. height: string | number;
  67920. /** Gets or sets control size */
  67921. size: string | number;
  67922. /**
  67923. * Creates a new ColorPicker
  67924. * @param name defines the control name
  67925. */
  67926. constructor(name?: string | undefined);
  67927. protected _getTypeName(): string;
  67928. /** @hidden */
  67929. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67930. private _updateSquareProps;
  67931. private _drawGradientSquare;
  67932. private _drawCircle;
  67933. private _createColorWheelCanvas;
  67934. /** @hidden */
  67935. _draw(context: CanvasRenderingContext2D): void;
  67936. private _pointerIsDown;
  67937. private _updateValueFromPointer;
  67938. private _isPointOnSquare;
  67939. private _isPointOnWheel;
  67940. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  67941. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  67942. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  67943. /**
  67944. * This function expands the color picker by creating a color picker dialog with manual
  67945. * color value input and the ability to save colors into an array to be used later in
  67946. * subsequent launches of the dialogue.
  67947. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  67948. * @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.
  67949. * @returns picked color as a hex string and the saved colors array as hex strings.
  67950. */
  67951. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  67952. pickerWidth?: string;
  67953. pickerHeight?: string;
  67954. headerHeight?: string;
  67955. lastColor?: string;
  67956. swatchLimit?: number;
  67957. numSwatchesPerLine?: number;
  67958. savedColors?: Array<string>;
  67959. }): Promise<{
  67960. savedColors?: string[];
  67961. pickedColor: string;
  67962. }>;
  67963. }
  67964. }
  67965. declare module BABYLON.GUI {
  67966. /** Class used to create 2D ellipse containers */
  67967. export class Ellipse extends Container {
  67968. name?: string | undefined;
  67969. private _thickness;
  67970. /** Gets or sets border thickness */
  67971. thickness: number;
  67972. /**
  67973. * Creates a new Ellipse
  67974. * @param name defines the control name
  67975. */
  67976. constructor(name?: string | undefined);
  67977. protected _getTypeName(): string;
  67978. protected _localDraw(context: CanvasRenderingContext2D): void;
  67979. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67980. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  67981. }
  67982. }
  67983. declare module BABYLON.GUI {
  67984. /**
  67985. * Class used to create a password control
  67986. */
  67987. export class InputPassword extends InputText {
  67988. protected _beforeRenderText(text: string): string;
  67989. }
  67990. }
  67991. declare module BABYLON.GUI {
  67992. /** Class used to render 2D lines */
  67993. export class Line extends Control {
  67994. name?: string | undefined;
  67995. private _lineWidth;
  67996. private _x1;
  67997. private _y1;
  67998. private _x2;
  67999. private _y2;
  68000. private _dash;
  68001. private _connectedControl;
  68002. private _connectedControlDirtyObserver;
  68003. /** Gets or sets the dash pattern */
  68004. dash: Array<number>;
  68005. /** Gets or sets the control connected with the line end */
  68006. connectedControl: Control;
  68007. /** Gets or sets start coordinates on X axis */
  68008. x1: string | number;
  68009. /** Gets or sets start coordinates on Y axis */
  68010. y1: string | number;
  68011. /** Gets or sets end coordinates on X axis */
  68012. x2: string | number;
  68013. /** Gets or sets end coordinates on Y axis */
  68014. y2: string | number;
  68015. /** Gets or sets line width */
  68016. lineWidth: number;
  68017. /** Gets or sets horizontal alignment */
  68018. horizontalAlignment: number;
  68019. /** Gets or sets vertical alignment */
  68020. verticalAlignment: number;
  68021. private readonly _effectiveX2;
  68022. private readonly _effectiveY2;
  68023. /**
  68024. * Creates a new Line
  68025. * @param name defines the control name
  68026. */
  68027. constructor(name?: string | undefined);
  68028. protected _getTypeName(): string;
  68029. _draw(context: CanvasRenderingContext2D): void;
  68030. _measure(): void;
  68031. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68032. /**
  68033. * Move one end of the line given 3D cartesian coordinates.
  68034. * @param position Targeted world position
  68035. * @param scene BABYLON.Scene
  68036. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  68037. */
  68038. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  68039. /**
  68040. * Move one end of the line to a position in screen absolute space.
  68041. * @param projectedPosition Position in screen absolute space (X, Y)
  68042. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  68043. */
  68044. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  68045. }
  68046. }
  68047. declare module BABYLON.GUI {
  68048. /**
  68049. * Class used to store a point for a MultiLine object.
  68050. * The point can be pure 2D coordinates, a mesh or a control
  68051. */
  68052. export class MultiLinePoint {
  68053. private _multiLine;
  68054. private _x;
  68055. private _y;
  68056. private _control;
  68057. private _mesh;
  68058. private _controlObserver;
  68059. private _meshObserver;
  68060. /** @hidden */
  68061. _point: BABYLON.Vector2;
  68062. /**
  68063. * Creates a new MultiLinePoint
  68064. * @param multiLine defines the source MultiLine object
  68065. */
  68066. constructor(multiLine: MultiLine);
  68067. /** Gets or sets x coordinate */
  68068. x: string | number;
  68069. /** Gets or sets y coordinate */
  68070. y: string | number;
  68071. /** Gets or sets the control associated with this point */
  68072. control: BABYLON.Nullable<Control>;
  68073. /** Gets or sets the mesh associated with this point */
  68074. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  68075. /** Resets links */
  68076. resetLinks(): void;
  68077. /**
  68078. * Gets a translation vector
  68079. * @returns the translation vector
  68080. */
  68081. translate(): BABYLON.Vector2;
  68082. private _translatePoint;
  68083. /** Release associated resources */
  68084. dispose(): void;
  68085. }
  68086. }
  68087. declare module BABYLON.GUI {
  68088. /**
  68089. * Class used to create multi line control
  68090. */
  68091. export class MultiLine extends Control {
  68092. name?: string | undefined;
  68093. private _lineWidth;
  68094. private _dash;
  68095. private _points;
  68096. private _minX;
  68097. private _minY;
  68098. private _maxX;
  68099. private _maxY;
  68100. /**
  68101. * Creates a new MultiLine
  68102. * @param name defines the control name
  68103. */
  68104. constructor(name?: string | undefined);
  68105. /** Gets or sets dash pattern */
  68106. dash: Array<number>;
  68107. /**
  68108. * Gets point stored at specified index
  68109. * @param index defines the index to look for
  68110. * @returns the requested point if found
  68111. */
  68112. getAt(index: number): MultiLinePoint;
  68113. /** Function called when a point is updated */
  68114. onPointUpdate: () => void;
  68115. /**
  68116. * Adds new points to the point collection
  68117. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  68118. * @returns the list of created MultiLinePoint
  68119. */
  68120. add(...items: (AbstractMesh | Control | {
  68121. x: string | number;
  68122. y: string | number;
  68123. })[]): MultiLinePoint[];
  68124. /**
  68125. * Adds a new point to the point collection
  68126. * @param item defines the item (mesh, control or 2d coordiantes) to add
  68127. * @returns the created MultiLinePoint
  68128. */
  68129. push(item?: (AbstractMesh | Control | {
  68130. x: string | number;
  68131. y: string | number;
  68132. })): MultiLinePoint;
  68133. /**
  68134. * Remove a specific value or point from the active point collection
  68135. * @param value defines the value or point to remove
  68136. */
  68137. remove(value: number | MultiLinePoint): void;
  68138. /**
  68139. * Resets this object to initial state (no point)
  68140. */
  68141. reset(): void;
  68142. /**
  68143. * Resets all links
  68144. */
  68145. resetLinks(): void;
  68146. /** Gets or sets line width */
  68147. lineWidth: number;
  68148. horizontalAlignment: number;
  68149. verticalAlignment: number;
  68150. protected _getTypeName(): string;
  68151. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  68152. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68153. _measure(): void;
  68154. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68155. dispose(): void;
  68156. }
  68157. }
  68158. declare module BABYLON.GUI {
  68159. /**
  68160. * Class used to create radio button controls
  68161. */
  68162. export class RadioButton extends Control {
  68163. name?: string | undefined;
  68164. private _isChecked;
  68165. private _background;
  68166. private _checkSizeRatio;
  68167. private _thickness;
  68168. /** Gets or sets border thickness */
  68169. thickness: number;
  68170. /** Gets or sets group name */
  68171. group: string;
  68172. /** BABYLON.Observable raised when isChecked is changed */
  68173. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  68174. /** Gets or sets a value indicating the ratio between overall size and check size */
  68175. checkSizeRatio: number;
  68176. /** Gets or sets background color */
  68177. background: string;
  68178. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  68179. isChecked: boolean;
  68180. /**
  68181. * Creates a new RadioButton
  68182. * @param name defines the control name
  68183. */
  68184. constructor(name?: string | undefined);
  68185. protected _getTypeName(): string;
  68186. _draw(context: CanvasRenderingContext2D): void;
  68187. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  68188. /**
  68189. * Utility function to easily create a radio button with a header
  68190. * @param title defines the label to use for the header
  68191. * @param group defines the group to use for the radio button
  68192. * @param isChecked defines the initial state of the radio button
  68193. * @param onValueChanged defines the callback to call when value changes
  68194. * @returns a StackPanel containing the radio button and a textBlock
  68195. */
  68196. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  68197. }
  68198. }
  68199. declare module BABYLON.GUI {
  68200. /**
  68201. * Class used to create slider controls
  68202. */
  68203. export class BaseSlider extends Control {
  68204. name?: string | undefined;
  68205. protected _thumbWidth: ValueAndUnit;
  68206. private _minimum;
  68207. private _maximum;
  68208. private _value;
  68209. private _isVertical;
  68210. protected _barOffset: ValueAndUnit;
  68211. private _isThumbClamped;
  68212. protected _displayThumb: boolean;
  68213. private _step;
  68214. private _lastPointerDownID;
  68215. protected _effectiveBarOffset: number;
  68216. protected _renderLeft: number;
  68217. protected _renderTop: number;
  68218. protected _renderWidth: number;
  68219. protected _renderHeight: number;
  68220. protected _backgroundBoxLength: number;
  68221. protected _backgroundBoxThickness: number;
  68222. protected _effectiveThumbThickness: number;
  68223. /** BABYLON.Observable raised when the sldier value changes */
  68224. onValueChangedObservable: BABYLON.Observable<number>;
  68225. /** Gets or sets a boolean indicating if the thumb must be rendered */
  68226. displayThumb: boolean;
  68227. /** Gets or sets a step to apply to values (0 by default) */
  68228. step: number;
  68229. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  68230. barOffset: string | number;
  68231. /** Gets main bar offset in pixels*/
  68232. readonly barOffsetInPixels: number;
  68233. /** Gets or sets thumb width */
  68234. thumbWidth: string | number;
  68235. /** Gets thumb width in pixels */
  68236. readonly thumbWidthInPixels: number;
  68237. /** Gets or sets minimum value */
  68238. minimum: number;
  68239. /** Gets or sets maximum value */
  68240. maximum: number;
  68241. /** Gets or sets current value */
  68242. value: number;
  68243. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  68244. isVertical: boolean;
  68245. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  68246. isThumbClamped: boolean;
  68247. /**
  68248. * Creates a new BaseSlider
  68249. * @param name defines the control name
  68250. */
  68251. constructor(name?: string | undefined);
  68252. protected _getTypeName(): string;
  68253. protected _getThumbPosition(): number;
  68254. protected _getThumbThickness(type: string): number;
  68255. protected _prepareRenderingData(type: string): void;
  68256. private _pointerIsDown;
  68257. /** @hidden */
  68258. protected _updateValueFromPointer(x: number, y: number): void;
  68259. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  68260. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  68261. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  68262. }
  68263. }
  68264. declare module BABYLON.GUI {
  68265. /**
  68266. * Class used to create slider controls
  68267. */
  68268. export class Slider extends BaseSlider {
  68269. name?: string | undefined;
  68270. private _background;
  68271. private _borderColor;
  68272. private _isThumbCircle;
  68273. protected _displayValueBar: boolean;
  68274. /** Gets or sets a boolean indicating if the value bar must be rendered */
  68275. displayValueBar: boolean;
  68276. /** Gets or sets border color */
  68277. borderColor: string;
  68278. /** Gets or sets background color */
  68279. background: string;
  68280. /** Gets or sets a boolean indicating if the thumb should be round or square */
  68281. isThumbCircle: boolean;
  68282. /**
  68283. * Creates a new Slider
  68284. * @param name defines the control name
  68285. */
  68286. constructor(name?: string | undefined);
  68287. protected _getTypeName(): string;
  68288. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  68289. }
  68290. }
  68291. declare module BABYLON.GUI {
  68292. /** Class used to create a RadioGroup
  68293. * which contains groups of radio buttons
  68294. */
  68295. export class SelectorGroup {
  68296. /** name of SelectorGroup */
  68297. name: string;
  68298. private _groupPanel;
  68299. private _selectors;
  68300. private _groupHeader;
  68301. /**
  68302. * Creates a new SelectorGroup
  68303. * @param name of group, used as a group heading
  68304. */
  68305. constructor(
  68306. /** name of SelectorGroup */
  68307. name: string);
  68308. /** Gets the groupPanel of the SelectorGroup */
  68309. readonly groupPanel: StackPanel;
  68310. /** Gets the selectors array */
  68311. readonly selectors: StackPanel[];
  68312. /** Gets and sets the group header */
  68313. header: string;
  68314. /** @hidden */
  68315. private _addGroupHeader;
  68316. /** @hidden*/
  68317. _getSelector(selectorNb: number): StackPanel | undefined;
  68318. /** Removes the selector at the given position
  68319. * @param selectorNb the position of the selector within the group
  68320. */
  68321. removeSelector(selectorNb: number): void;
  68322. }
  68323. /** Class used to create a CheckboxGroup
  68324. * which contains groups of checkbox buttons
  68325. */
  68326. export class CheckboxGroup extends SelectorGroup {
  68327. /** Adds a checkbox as a control
  68328. * @param text is the label for the selector
  68329. * @param func is the function called when the Selector is checked
  68330. * @param checked is true when Selector is checked
  68331. */
  68332. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  68333. /** @hidden */
  68334. _setSelectorLabel(selectorNb: number, label: string): void;
  68335. /** @hidden */
  68336. _setSelectorLabelColor(selectorNb: number, color: string): void;
  68337. /** @hidden */
  68338. _setSelectorButtonColor(selectorNb: number, color: string): void;
  68339. /** @hidden */
  68340. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  68341. }
  68342. /** Class used to create a RadioGroup
  68343. * which contains groups of radio buttons
  68344. */
  68345. export class RadioGroup extends SelectorGroup {
  68346. private _selectNb;
  68347. /** Adds a radio button as a control
  68348. * @param label is the label for the selector
  68349. * @param func is the function called when the Selector is checked
  68350. * @param checked is true when Selector is checked
  68351. */
  68352. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  68353. /** @hidden */
  68354. _setSelectorLabel(selectorNb: number, label: string): void;
  68355. /** @hidden */
  68356. _setSelectorLabelColor(selectorNb: number, color: string): void;
  68357. /** @hidden */
  68358. _setSelectorButtonColor(selectorNb: number, color: string): void;
  68359. /** @hidden */
  68360. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  68361. }
  68362. /** Class used to create a SliderGroup
  68363. * which contains groups of slider buttons
  68364. */
  68365. export class SliderGroup extends SelectorGroup {
  68366. /**
  68367. * Adds a slider to the SelectorGroup
  68368. * @param label is the label for the SliderBar
  68369. * @param func is the function called when the Slider moves
  68370. * @param unit is a string describing the units used, eg degrees or metres
  68371. * @param min is the minimum value for the Slider
  68372. * @param max is the maximum value for the Slider
  68373. * @param value is the start value for the Slider between min and max
  68374. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  68375. */
  68376. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  68377. /** @hidden */
  68378. _setSelectorLabel(selectorNb: number, label: string): void;
  68379. /** @hidden */
  68380. _setSelectorLabelColor(selectorNb: number, color: string): void;
  68381. /** @hidden */
  68382. _setSelectorButtonColor(selectorNb: number, color: string): void;
  68383. /** @hidden */
  68384. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  68385. }
  68386. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  68387. * @see http://doc.babylonjs.com/how_to/selector
  68388. */
  68389. export class SelectionPanel extends Rectangle {
  68390. /** name of SelectionPanel */
  68391. name: string;
  68392. /** an array of SelectionGroups */
  68393. groups: SelectorGroup[];
  68394. private _panel;
  68395. private _buttonColor;
  68396. private _buttonBackground;
  68397. private _headerColor;
  68398. private _barColor;
  68399. private _barHeight;
  68400. private _spacerHeight;
  68401. private _labelColor;
  68402. private _groups;
  68403. private _bars;
  68404. /**
  68405. * Creates a new SelectionPanel
  68406. * @param name of SelectionPanel
  68407. * @param groups is an array of SelectionGroups
  68408. */
  68409. constructor(
  68410. /** name of SelectionPanel */
  68411. name: string,
  68412. /** an array of SelectionGroups */
  68413. groups?: SelectorGroup[]);
  68414. protected _getTypeName(): string;
  68415. /** Gets or sets the headerColor */
  68416. headerColor: string;
  68417. private _setHeaderColor;
  68418. /** Gets or sets the button color */
  68419. buttonColor: string;
  68420. private _setbuttonColor;
  68421. /** Gets or sets the label color */
  68422. labelColor: string;
  68423. private _setLabelColor;
  68424. /** Gets or sets the button background */
  68425. buttonBackground: string;
  68426. private _setButtonBackground;
  68427. /** Gets or sets the color of separator bar */
  68428. barColor: string;
  68429. private _setBarColor;
  68430. /** Gets or sets the height of separator bar */
  68431. barHeight: string;
  68432. private _setBarHeight;
  68433. /** Gets or sets the height of spacers*/
  68434. spacerHeight: string;
  68435. private _setSpacerHeight;
  68436. /** Adds a bar between groups */
  68437. private _addSpacer;
  68438. /** Add a group to the selection panel
  68439. * @param group is the selector group to add
  68440. */
  68441. addGroup(group: SelectorGroup): void;
  68442. /** Remove the group from the given position
  68443. * @param groupNb is the position of the group in the list
  68444. */
  68445. removeGroup(groupNb: number): void;
  68446. /** Change a group header label
  68447. * @param label is the new group header label
  68448. * @param groupNb is the number of the group to relabel
  68449. * */
  68450. setHeaderName(label: string, groupNb: number): void;
  68451. /** Change selector label to the one given
  68452. * @param label is the new selector label
  68453. * @param groupNb is the number of the groupcontaining the selector
  68454. * @param selectorNb is the number of the selector within a group to relabel
  68455. * */
  68456. relabel(label: string, groupNb: number, selectorNb: number): void;
  68457. /** For a given group position remove the selector at the given position
  68458. * @param groupNb is the number of the group to remove the selector from
  68459. * @param selectorNb is the number of the selector within the group
  68460. */
  68461. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  68462. /** For a given group position of correct type add a checkbox button
  68463. * @param groupNb is the number of the group to remove the selector from
  68464. * @param label is the label for the selector
  68465. * @param func is the function called when the Selector is checked
  68466. * @param checked is true when Selector is checked
  68467. */
  68468. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  68469. /** For a given group position of correct type add a radio button
  68470. * @param groupNb is the number of the group to remove the selector from
  68471. * @param label is the label for the selector
  68472. * @param func is the function called when the Selector is checked
  68473. * @param checked is true when Selector is checked
  68474. */
  68475. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  68476. /**
  68477. * For a given slider group add a slider
  68478. * @param groupNb is the number of the group to add the slider to
  68479. * @param label is the label for the Slider
  68480. * @param func is the function called when the Slider moves
  68481. * @param unit is a string describing the units used, eg degrees or metres
  68482. * @param min is the minimum value for the Slider
  68483. * @param max is the maximum value for the Slider
  68484. * @param value is the start value for the Slider between min and max
  68485. * @param onVal is the function used to format the value displayed, eg radians to degrees
  68486. */
  68487. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  68488. }
  68489. }
  68490. declare module BABYLON.GUI {
  68491. /**
  68492. * Class used to hold a the container for ScrollViewer
  68493. * @hidden
  68494. */
  68495. export class _ScrollViewerWindow extends Container {
  68496. parentClientWidth: number;
  68497. parentClientHeight: number;
  68498. /**
  68499. * Creates a new ScrollViewerWindow
  68500. * @param name of ScrollViewerWindow
  68501. */
  68502. constructor(name?: string);
  68503. protected _getTypeName(): string;
  68504. /** @hidden */
  68505. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68506. protected _postMeasure(): void;
  68507. }
  68508. }
  68509. declare module BABYLON.GUI {
  68510. /**
  68511. * Class used to create slider controls
  68512. */
  68513. export class ScrollBar extends BaseSlider {
  68514. name?: string | undefined;
  68515. private _background;
  68516. private _borderColor;
  68517. private _tempMeasure;
  68518. /** Gets or sets border color */
  68519. borderColor: string;
  68520. /** Gets or sets background color */
  68521. background: string;
  68522. /**
  68523. * Creates a new Slider
  68524. * @param name defines the control name
  68525. */
  68526. constructor(name?: string | undefined);
  68527. protected _getTypeName(): string;
  68528. protected _getThumbThickness(): number;
  68529. _draw(context: CanvasRenderingContext2D): void;
  68530. private _first;
  68531. private _originX;
  68532. private _originY;
  68533. /** @hidden */
  68534. protected _updateValueFromPointer(x: number, y: number): void;
  68535. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  68536. }
  68537. }
  68538. declare module BABYLON.GUI {
  68539. /**
  68540. * Class used to create slider controls
  68541. */
  68542. export class ImageScrollBar extends BaseSlider {
  68543. name?: string | undefined;
  68544. private _backgroundBaseImage;
  68545. private _backgroundImage;
  68546. private _thumbImage;
  68547. private _thumbBaseImage;
  68548. private _thumbLength;
  68549. private _thumbHeight;
  68550. private _barImageHeight;
  68551. private _tempMeasure;
  68552. /**
  68553. * Gets or sets the image used to render the background for horizontal bar
  68554. */
  68555. backgroundImage: Image;
  68556. /**
  68557. * Gets or sets the image used to render the thumb
  68558. */
  68559. thumbImage: Image;
  68560. /**
  68561. * Gets or sets the length of the thumb
  68562. */
  68563. thumbLength: number;
  68564. /**
  68565. * Gets or sets the height of the thumb
  68566. */
  68567. thumbHeight: number;
  68568. /**
  68569. * Gets or sets the height of the bar image
  68570. */
  68571. barImageHeight: number;
  68572. /**
  68573. * Creates a new ImageScrollBar
  68574. * @param name defines the control name
  68575. */
  68576. constructor(name?: string | undefined);
  68577. protected _getTypeName(): string;
  68578. protected _getThumbThickness(): number;
  68579. _draw(context: CanvasRenderingContext2D): void;
  68580. private _first;
  68581. private _originX;
  68582. private _originY;
  68583. /** @hidden */
  68584. protected _updateValueFromPointer(x: number, y: number): void;
  68585. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  68586. }
  68587. }
  68588. declare module BABYLON.GUI {
  68589. /**
  68590. * Class used to hold a viewer window and sliders in a grid
  68591. */
  68592. export class ScrollViewer extends Rectangle {
  68593. private _grid;
  68594. private _horizontalBarSpace;
  68595. private _verticalBarSpace;
  68596. private _dragSpace;
  68597. private _horizontalBar;
  68598. private _verticalBar;
  68599. private _barColor;
  68600. private _barBackground;
  68601. private _barImage;
  68602. private _barBackgroundImage;
  68603. private _barSize;
  68604. private _endLeft;
  68605. private _endTop;
  68606. private _window;
  68607. private _pointerIsOver;
  68608. private _wheelPrecision;
  68609. private _onPointerObserver;
  68610. private _clientWidth;
  68611. private _clientHeight;
  68612. private _useImageBar;
  68613. private _thumbLength;
  68614. private _thumbHeight;
  68615. private _barImageHeight;
  68616. /**
  68617. * Gets the horizontal scrollbar
  68618. */
  68619. readonly horizontalBar: ScrollBar | ImageScrollBar;
  68620. /**
  68621. * Gets the vertical scrollbar
  68622. */
  68623. readonly verticalBar: ScrollBar | ImageScrollBar;
  68624. /**
  68625. * Adds a new control to the current container
  68626. * @param control defines the control to add
  68627. * @returns the current container
  68628. */
  68629. addControl(control: BABYLON.Nullable<Control>): Container;
  68630. /**
  68631. * Removes a control from the current container
  68632. * @param control defines the control to remove
  68633. * @returns the current container
  68634. */
  68635. removeControl(control: Control): Container;
  68636. /** Gets the list of children */
  68637. readonly children: Control[];
  68638. _flagDescendantsAsMatrixDirty(): void;
  68639. /**
  68640. * Creates a new ScrollViewer
  68641. * @param name of ScrollViewer
  68642. */
  68643. constructor(name?: string, isImageBased?: boolean);
  68644. /** Reset the scroll viewer window to initial size */
  68645. resetWindow(): void;
  68646. protected _getTypeName(): string;
  68647. private _buildClientSizes;
  68648. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68649. protected _postMeasure(): void;
  68650. /**
  68651. * Gets or sets the mouse wheel precision
  68652. * from 0 to 1 with a default value of 0.05
  68653. * */
  68654. wheelPrecision: number;
  68655. /** Gets or sets the scroll bar container background color */
  68656. scrollBackground: string;
  68657. /** Gets or sets the bar color */
  68658. barColor: string;
  68659. /** Gets or sets the bar image */
  68660. thumbImage: Image;
  68661. /** Gets or sets the size of the bar */
  68662. barSize: number;
  68663. /** Gets or sets the length of the thumb */
  68664. thumbLength: number;
  68665. /** Gets or sets the height of the thumb */
  68666. thumbHeight: number;
  68667. /** Gets or sets the height of the bar image */
  68668. barImageHeight: number;
  68669. /** Gets or sets the bar background */
  68670. barBackground: string;
  68671. /** Gets or sets the bar background image */
  68672. barImage: Image;
  68673. /** @hidden */
  68674. private _updateScroller;
  68675. _link(host: AdvancedDynamicTexture): void;
  68676. /** @hidden */
  68677. private _addBar;
  68678. /** @hidden */
  68679. private _attachWheel;
  68680. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  68681. /** Releases associated resources */
  68682. dispose(): void;
  68683. }
  68684. }
  68685. declare module BABYLON.GUI {
  68686. /** Class used to render a grid */
  68687. export class DisplayGrid extends Control {
  68688. name?: string | undefined;
  68689. private _cellWidth;
  68690. private _cellHeight;
  68691. private _minorLineTickness;
  68692. private _minorLineColor;
  68693. private _majorLineTickness;
  68694. private _majorLineColor;
  68695. private _majorLineFrequency;
  68696. private _background;
  68697. private _displayMajorLines;
  68698. private _displayMinorLines;
  68699. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  68700. displayMinorLines: boolean;
  68701. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  68702. displayMajorLines: boolean;
  68703. /** Gets or sets background color (Black by default) */
  68704. background: string;
  68705. /** Gets or sets the width of each cell (20 by default) */
  68706. cellWidth: number;
  68707. /** Gets or sets the height of each cell (20 by default) */
  68708. cellHeight: number;
  68709. /** Gets or sets the tickness of minor lines (1 by default) */
  68710. minorLineTickness: number;
  68711. /** Gets or sets the color of minor lines (DarkGray by default) */
  68712. minorLineColor: string;
  68713. /** Gets or sets the tickness of major lines (2 by default) */
  68714. majorLineTickness: number;
  68715. /** Gets or sets the color of major lines (White by default) */
  68716. majorLineColor: string;
  68717. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  68718. majorLineFrequency: number;
  68719. /**
  68720. * Creates a new GridDisplayRectangle
  68721. * @param name defines the control name
  68722. */
  68723. constructor(name?: string | undefined);
  68724. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  68725. protected _getTypeName(): string;
  68726. }
  68727. }
  68728. declare module BABYLON.GUI {
  68729. /**
  68730. * Class used to create slider controls based on images
  68731. */
  68732. export class ImageBasedSlider extends BaseSlider {
  68733. name?: string | undefined;
  68734. private _backgroundImage;
  68735. private _thumbImage;
  68736. private _valueBarImage;
  68737. private _tempMeasure;
  68738. displayThumb: boolean;
  68739. /**
  68740. * Gets or sets the image used to render the background
  68741. */
  68742. backgroundImage: Image;
  68743. /**
  68744. * Gets or sets the image used to render the value bar
  68745. */
  68746. valueBarImage: Image;
  68747. /**
  68748. * Gets or sets the image used to render the thumb
  68749. */
  68750. thumbImage: Image;
  68751. /**
  68752. * Creates a new ImageBasedSlider
  68753. * @param name defines the control name
  68754. */
  68755. constructor(name?: string | undefined);
  68756. protected _getTypeName(): string;
  68757. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  68758. }
  68759. }
  68760. declare module BABYLON.GUI {
  68761. /**
  68762. * Forcing an export so that this code will execute
  68763. * @hidden
  68764. */
  68765. const name = "Statics";
  68766. }
  68767. declare module BABYLON.GUI {
  68768. /**
  68769. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  68770. */
  68771. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  68772. /**
  68773. * Define the instrumented AdvancedDynamicTexture.
  68774. */
  68775. texture: AdvancedDynamicTexture;
  68776. private _captureRenderTime;
  68777. private _renderTime;
  68778. private _captureLayoutTime;
  68779. private _layoutTime;
  68780. private _onBeginRenderObserver;
  68781. private _onEndRenderObserver;
  68782. private _onBeginLayoutObserver;
  68783. private _onEndLayoutObserver;
  68784. /**
  68785. * Gets the perf counter used to capture render time
  68786. */
  68787. readonly renderTimeCounter: BABYLON.PerfCounter;
  68788. /**
  68789. * Gets the perf counter used to capture layout time
  68790. */
  68791. readonly layoutTimeCounter: BABYLON.PerfCounter;
  68792. /**
  68793. * Enable or disable the render time capture
  68794. */
  68795. captureRenderTime: boolean;
  68796. /**
  68797. * Enable or disable the layout time capture
  68798. */
  68799. captureLayoutTime: boolean;
  68800. /**
  68801. * Instantiates a new advanced dynamic texture instrumentation.
  68802. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  68803. * @param texture Defines the AdvancedDynamicTexture to instrument
  68804. */
  68805. constructor(
  68806. /**
  68807. * Define the instrumented AdvancedDynamicTexture.
  68808. */
  68809. texture: AdvancedDynamicTexture);
  68810. /**
  68811. * Dispose and release associated resources.
  68812. */
  68813. dispose(): void;
  68814. }
  68815. }
  68816. declare module BABYLON.GUI {
  68817. /**
  68818. * Class used to load GUI via XML.
  68819. */
  68820. export class XmlLoader {
  68821. private _nodes;
  68822. private _nodeTypes;
  68823. private _isLoaded;
  68824. private _objectAttributes;
  68825. private _parentClass;
  68826. /**
  68827. * Create a new xml loader
  68828. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  68829. */
  68830. constructor(parentClass?: null);
  68831. private _getChainElement;
  68832. private _getClassAttribute;
  68833. private _createGuiElement;
  68834. private _parseGrid;
  68835. private _parseElement;
  68836. private _prepareSourceElement;
  68837. private _parseElementsFromSource;
  68838. private _parseXml;
  68839. /**
  68840. * Gets if the loading has finished.
  68841. * @returns whether the loading has finished or not
  68842. */
  68843. isLoaded(): boolean;
  68844. /**
  68845. * Gets a loaded node / control by id.
  68846. * @param id the Controls id set in the xml
  68847. * @returns element of type Control
  68848. */
  68849. getNodeById(id: string): any;
  68850. /**
  68851. * Gets all loaded nodes / controls
  68852. * @returns Array of controls
  68853. */
  68854. getNodes(): any;
  68855. /**
  68856. * Initiates the xml layout loading
  68857. * @param xmlFile defines the xml layout to load
  68858. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  68859. * @param callback defines the callback called on layout load.
  68860. */
  68861. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  68862. }
  68863. }
  68864. declare module BABYLON.GUI {
  68865. /**
  68866. * Class used to create containers for controls
  68867. */
  68868. export class Container3D extends Control3D {
  68869. private _blockLayout;
  68870. /**
  68871. * Gets the list of child controls
  68872. */
  68873. protected _children: Control3D[];
  68874. /**
  68875. * Gets the list of child controls
  68876. */
  68877. readonly children: Array<Control3D>;
  68878. /**
  68879. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  68880. * This is helpful to optimize layout operation when adding multiple children in a row
  68881. */
  68882. blockLayout: boolean;
  68883. /**
  68884. * Creates a new container
  68885. * @param name defines the container name
  68886. */
  68887. constructor(name?: string);
  68888. /**
  68889. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  68890. * @returns the current container
  68891. */
  68892. updateLayout(): Container3D;
  68893. /**
  68894. * Gets a boolean indicating if the given control is in the children of this control
  68895. * @param control defines the control to check
  68896. * @returns true if the control is in the child list
  68897. */
  68898. containsControl(control: Control3D): boolean;
  68899. /**
  68900. * Adds a control to the children of this control
  68901. * @param control defines the control to add
  68902. * @returns the current container
  68903. */
  68904. addControl(control: Control3D): Container3D;
  68905. /**
  68906. * This function will be called everytime a new control is added
  68907. */
  68908. protected _arrangeChildren(): void;
  68909. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  68910. /**
  68911. * Removes a control from the children of this control
  68912. * @param control defines the control to remove
  68913. * @returns the current container
  68914. */
  68915. removeControl(control: Control3D): Container3D;
  68916. protected _getTypeName(): string;
  68917. /**
  68918. * Releases all associated resources
  68919. */
  68920. dispose(): void;
  68921. /** Control rotation will remain unchanged */
  68922. static readonly UNSET_ORIENTATION: number;
  68923. /** Control will rotate to make it look at sphere central axis */
  68924. static readonly FACEORIGIN_ORIENTATION: number;
  68925. /** Control will rotate to make it look back at sphere central axis */
  68926. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  68927. /** Control will rotate to look at z axis (0, 0, 1) */
  68928. static readonly FACEFORWARD_ORIENTATION: number;
  68929. /** Control will rotate to look at negative z axis (0, 0, -1) */
  68930. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  68931. }
  68932. }
  68933. declare module BABYLON.GUI {
  68934. /**
  68935. * Class used to manage 3D user interface
  68936. * @see http://doc.babylonjs.com/how_to/gui3d
  68937. */
  68938. export class GUI3DManager implements BABYLON.IDisposable {
  68939. private _scene;
  68940. private _sceneDisposeObserver;
  68941. private _utilityLayer;
  68942. private _rootContainer;
  68943. private _pointerObserver;
  68944. private _pointerOutObserver;
  68945. /** @hidden */
  68946. _lastPickedControl: Control3D;
  68947. /** @hidden */
  68948. _lastControlOver: {
  68949. [pointerId: number]: Control3D;
  68950. };
  68951. /** @hidden */
  68952. _lastControlDown: {
  68953. [pointerId: number]: Control3D;
  68954. };
  68955. /**
  68956. * BABYLON.Observable raised when the point picked by the pointer events changed
  68957. */
  68958. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  68959. /** @hidden */
  68960. _sharedMaterials: {
  68961. [key: string]: BABYLON.Material;
  68962. };
  68963. /** Gets the hosting scene */
  68964. readonly scene: BABYLON.Scene;
  68965. /** Gets associated utility layer */
  68966. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  68967. /**
  68968. * Creates a new GUI3DManager
  68969. * @param scene
  68970. */
  68971. constructor(scene?: BABYLON.Scene);
  68972. private _handlePointerOut;
  68973. private _doPicking;
  68974. /**
  68975. * Gets the root container
  68976. */
  68977. readonly rootContainer: Container3D;
  68978. /**
  68979. * Gets a boolean indicating if the given control is in the root child list
  68980. * @param control defines the control to check
  68981. * @returns true if the control is in the root child list
  68982. */
  68983. containsControl(control: Control3D): boolean;
  68984. /**
  68985. * Adds a control to the root child list
  68986. * @param control defines the control to add
  68987. * @returns the current manager
  68988. */
  68989. addControl(control: Control3D): GUI3DManager;
  68990. /**
  68991. * Removes a control from the root child list
  68992. * @param control defines the control to remove
  68993. * @returns the current container
  68994. */
  68995. removeControl(control: Control3D): GUI3DManager;
  68996. /**
  68997. * Releases all associated resources
  68998. */
  68999. dispose(): void;
  69000. }
  69001. }
  69002. declare module BABYLON.GUI {
  69003. /**
  69004. * Class used to transport BABYLON.Vector3 information for pointer events
  69005. */
  69006. export class Vector3WithInfo extends BABYLON.Vector3 {
  69007. /** defines the current mouse button index */
  69008. buttonIndex: number;
  69009. /**
  69010. * Creates a new Vector3WithInfo
  69011. * @param source defines the vector3 data to transport
  69012. * @param buttonIndex defines the current mouse button index
  69013. */
  69014. constructor(source: BABYLON.Vector3,
  69015. /** defines the current mouse button index */
  69016. buttonIndex?: number);
  69017. }
  69018. }
  69019. declare module BABYLON.GUI {
  69020. /**
  69021. * Class used as base class for controls
  69022. */
  69023. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  69024. /** Defines the control name */
  69025. name?: string | undefined;
  69026. /** @hidden */
  69027. _host: GUI3DManager;
  69028. private _node;
  69029. private _downCount;
  69030. private _enterCount;
  69031. private _downPointerIds;
  69032. private _isVisible;
  69033. /** Gets or sets the control position in world space */
  69034. position: BABYLON.Vector3;
  69035. /** Gets or sets the control scaling in world space */
  69036. scaling: BABYLON.Vector3;
  69037. /** Callback used to start pointer enter animation */
  69038. pointerEnterAnimation: () => void;
  69039. /** Callback used to start pointer out animation */
  69040. pointerOutAnimation: () => void;
  69041. /** Callback used to start pointer down animation */
  69042. pointerDownAnimation: () => void;
  69043. /** Callback used to start pointer up animation */
  69044. pointerUpAnimation: () => void;
  69045. /**
  69046. * An event triggered when the pointer move over the control
  69047. */
  69048. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  69049. /**
  69050. * An event triggered when the pointer move out of the control
  69051. */
  69052. onPointerOutObservable: BABYLON.Observable<Control3D>;
  69053. /**
  69054. * An event triggered when the pointer taps the control
  69055. */
  69056. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  69057. /**
  69058. * An event triggered when pointer is up
  69059. */
  69060. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  69061. /**
  69062. * An event triggered when a control is clicked on (with a mouse)
  69063. */
  69064. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  69065. /**
  69066. * An event triggered when pointer enters the control
  69067. */
  69068. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  69069. /**
  69070. * Gets or sets the parent container
  69071. */
  69072. parent: BABYLON.Nullable<Container3D>;
  69073. private _behaviors;
  69074. /**
  69075. * Gets the list of attached behaviors
  69076. * @see http://doc.babylonjs.com/features/behaviour
  69077. */
  69078. readonly behaviors: BABYLON.Behavior<Control3D>[];
  69079. /**
  69080. * Attach a behavior to the control
  69081. * @see http://doc.babylonjs.com/features/behaviour
  69082. * @param behavior defines the behavior to attach
  69083. * @returns the current control
  69084. */
  69085. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  69086. /**
  69087. * Remove an attached behavior
  69088. * @see http://doc.babylonjs.com/features/behaviour
  69089. * @param behavior defines the behavior to attach
  69090. * @returns the current control
  69091. */
  69092. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  69093. /**
  69094. * Gets an attached behavior by name
  69095. * @param name defines the name of the behavior to look for
  69096. * @see http://doc.babylonjs.com/features/behaviour
  69097. * @returns null if behavior was not found else the requested behavior
  69098. */
  69099. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  69100. /** Gets or sets a boolean indicating if the control is visible */
  69101. isVisible: boolean;
  69102. /**
  69103. * Creates a new control
  69104. * @param name defines the control name
  69105. */
  69106. constructor(
  69107. /** Defines the control name */
  69108. name?: string | undefined);
  69109. /**
  69110. * Gets a string representing the class name
  69111. */
  69112. readonly typeName: string;
  69113. /**
  69114. * Get the current class name of the control.
  69115. * @returns current class name
  69116. */
  69117. getClassName(): string;
  69118. protected _getTypeName(): string;
  69119. /**
  69120. * Gets the transform node used by this control
  69121. */
  69122. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  69123. /**
  69124. * Gets the mesh used to render this control
  69125. */
  69126. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  69127. /**
  69128. * Link the control as child of the given node
  69129. * @param node defines the node to link to. Use null to unlink the control
  69130. * @returns the current control
  69131. */
  69132. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  69133. /** @hidden **/
  69134. _prepareNode(scene: BABYLON.Scene): void;
  69135. /**
  69136. * Node creation.
  69137. * Can be overriden by children
  69138. * @param scene defines the scene where the node must be attached
  69139. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  69140. */
  69141. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  69142. /**
  69143. * Affect a material to the given mesh
  69144. * @param mesh defines the mesh which will represent the control
  69145. */
  69146. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  69147. /** @hidden */
  69148. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  69149. /** @hidden */
  69150. _onPointerEnter(target: Control3D): boolean;
  69151. /** @hidden */
  69152. _onPointerOut(target: Control3D): void;
  69153. /** @hidden */
  69154. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  69155. /** @hidden */
  69156. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  69157. /** @hidden */
  69158. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  69159. /** @hidden */
  69160. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  69161. /** @hidden */
  69162. _disposeNode(): void;
  69163. /**
  69164. * Releases all associated resources
  69165. */
  69166. dispose(): void;
  69167. }
  69168. }
  69169. declare module BABYLON.GUI {
  69170. /**
  69171. * Class used as a root to all buttons
  69172. */
  69173. export class AbstractButton3D extends Control3D {
  69174. /**
  69175. * Creates a new button
  69176. * @param name defines the control name
  69177. */
  69178. constructor(name?: string);
  69179. protected _getTypeName(): string;
  69180. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  69181. }
  69182. }
  69183. declare module BABYLON.GUI {
  69184. /**
  69185. * Class used to create a button in 3D
  69186. */
  69187. export class Button3D extends AbstractButton3D {
  69188. /** @hidden */
  69189. protected _currentMaterial: BABYLON.Material;
  69190. private _facadeTexture;
  69191. private _content;
  69192. private _contentResolution;
  69193. private _contentScaleRatio;
  69194. /**
  69195. * Gets or sets the texture resolution used to render content (512 by default)
  69196. */
  69197. contentResolution: BABYLON.int;
  69198. /**
  69199. * Gets or sets the texture scale ratio used to render content (2 by default)
  69200. */
  69201. contentScaleRatio: number;
  69202. protected _disposeFacadeTexture(): void;
  69203. protected _resetContent(): void;
  69204. /**
  69205. * Creates a new button
  69206. * @param name defines the control name
  69207. */
  69208. constructor(name?: string);
  69209. /**
  69210. * Gets or sets the GUI 2D content used to display the button's facade
  69211. */
  69212. content: Control;
  69213. /**
  69214. * Apply the facade texture (created from the content property).
  69215. * This function can be overloaded by child classes
  69216. * @param facadeTexture defines the AdvancedDynamicTexture to use
  69217. */
  69218. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  69219. protected _getTypeName(): string;
  69220. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  69221. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  69222. /**
  69223. * Releases all associated resources
  69224. */
  69225. dispose(): void;
  69226. }
  69227. }
  69228. declare module BABYLON.GUI {
  69229. /**
  69230. * Abstract class used to create a container panel deployed on the surface of a volume
  69231. */
  69232. export abstract class VolumeBasedPanel extends Container3D {
  69233. private _columns;
  69234. private _rows;
  69235. private _rowThenColum;
  69236. private _orientation;
  69237. protected _cellWidth: number;
  69238. protected _cellHeight: number;
  69239. /**
  69240. * Gets or sets the distance between elements
  69241. */
  69242. margin: number;
  69243. /**
  69244. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  69245. * | Value | Type | Description |
  69246. * | ----- | ----------------------------------- | ----------- |
  69247. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  69248. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  69249. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  69250. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  69251. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  69252. */
  69253. orientation: number;
  69254. /**
  69255. * Gets or sets the number of columns requested (10 by default).
  69256. * The panel will automatically compute the number of rows based on number of child controls.
  69257. */
  69258. columns: BABYLON.int;
  69259. /**
  69260. * Gets or sets a the number of rows requested.
  69261. * The panel will automatically compute the number of columns based on number of child controls.
  69262. */
  69263. rows: BABYLON.int;
  69264. /**
  69265. * Creates new VolumeBasedPanel
  69266. */
  69267. constructor();
  69268. protected _arrangeChildren(): void;
  69269. /** Child classes must implement this function to provide correct control positioning */
  69270. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  69271. /** Child classes can implement this function to provide additional processing */
  69272. protected _finalProcessing(): void;
  69273. }
  69274. }
  69275. declare module BABYLON.GUI {
  69276. /**
  69277. * Class used to create a container panel deployed on the surface of a cylinder
  69278. */
  69279. export class CylinderPanel extends VolumeBasedPanel {
  69280. private _radius;
  69281. /**
  69282. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  69283. */
  69284. radius: BABYLON.float;
  69285. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  69286. private _cylindricalMapping;
  69287. }
  69288. }
  69289. declare module BABYLON.GUI {
  69290. /** @hidden */
  69291. export var fluentVertexShader: {
  69292. name: string;
  69293. shader: string;
  69294. };
  69295. }
  69296. declare module BABYLON.GUI {
  69297. /** @hidden */
  69298. export var fluentPixelShader: {
  69299. name: string;
  69300. shader: string;
  69301. };
  69302. }
  69303. declare module BABYLON.GUI {
  69304. /** @hidden */
  69305. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  69306. INNERGLOW: boolean;
  69307. BORDER: boolean;
  69308. HOVERLIGHT: boolean;
  69309. TEXTURE: boolean;
  69310. constructor();
  69311. }
  69312. /**
  69313. * Class used to render controls with fluent desgin
  69314. */
  69315. export class FluentMaterial extends BABYLON.PushMaterial {
  69316. /**
  69317. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  69318. */
  69319. innerGlowColorIntensity: number;
  69320. /**
  69321. * Gets or sets the inner glow color (white by default)
  69322. */
  69323. innerGlowColor: BABYLON.Color3;
  69324. /**
  69325. * Gets or sets alpha value (default is 1.0)
  69326. */
  69327. alpha: number;
  69328. /**
  69329. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  69330. */
  69331. albedoColor: BABYLON.Color3;
  69332. /**
  69333. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  69334. */
  69335. renderBorders: boolean;
  69336. /**
  69337. * Gets or sets border width (default is 0.5)
  69338. */
  69339. borderWidth: number;
  69340. /**
  69341. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  69342. */
  69343. edgeSmoothingValue: number;
  69344. /**
  69345. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  69346. */
  69347. borderMinValue: number;
  69348. /**
  69349. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  69350. */
  69351. renderHoverLight: boolean;
  69352. /**
  69353. * Gets or sets the radius used to render the hover light (default is 1.0)
  69354. */
  69355. hoverRadius: number;
  69356. /**
  69357. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  69358. */
  69359. hoverColor: BABYLON.Color4;
  69360. /**
  69361. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  69362. */
  69363. hoverPosition: BABYLON.Vector3;
  69364. private _albedoTexture;
  69365. /** Gets or sets the texture to use for albedo color */
  69366. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  69367. /**
  69368. * Creates a new Fluent material
  69369. * @param name defines the name of the material
  69370. * @param scene defines the hosting scene
  69371. */
  69372. constructor(name: string, scene: BABYLON.Scene);
  69373. needAlphaBlending(): boolean;
  69374. needAlphaTesting(): boolean;
  69375. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69376. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69377. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69378. getActiveTextures(): BABYLON.BaseTexture[];
  69379. hasTexture(texture: BABYLON.BaseTexture): boolean;
  69380. dispose(forceDisposeEffect?: boolean): void;
  69381. clone(name: string): FluentMaterial;
  69382. serialize(): any;
  69383. getClassName(): string;
  69384. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  69385. }
  69386. }
  69387. declare module BABYLON.GUI {
  69388. /**
  69389. * Class used to create a holographic button in 3D
  69390. */
  69391. export class HolographicButton extends Button3D {
  69392. private _backPlate;
  69393. private _textPlate;
  69394. private _frontPlate;
  69395. private _text;
  69396. private _imageUrl;
  69397. private _shareMaterials;
  69398. private _frontMaterial;
  69399. private _backMaterial;
  69400. private _plateMaterial;
  69401. private _pickedPointObserver;
  69402. private _tooltipFade;
  69403. private _tooltipTextBlock;
  69404. private _tooltipTexture;
  69405. private _tooltipMesh;
  69406. private _tooltipHoverObserver;
  69407. private _tooltipOutObserver;
  69408. private _disposeTooltip;
  69409. /**
  69410. * Rendering ground id of all the mesh in the button
  69411. */
  69412. renderingGroupId: number;
  69413. /**
  69414. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  69415. */
  69416. tooltipText: BABYLON.Nullable<string>;
  69417. /**
  69418. * Gets or sets text for the button
  69419. */
  69420. text: string;
  69421. /**
  69422. * Gets or sets the image url for the button
  69423. */
  69424. imageUrl: string;
  69425. /**
  69426. * Gets the back material used by this button
  69427. */
  69428. readonly backMaterial: FluentMaterial;
  69429. /**
  69430. * Gets the front material used by this button
  69431. */
  69432. readonly frontMaterial: FluentMaterial;
  69433. /**
  69434. * Gets the plate material used by this button
  69435. */
  69436. readonly plateMaterial: BABYLON.StandardMaterial;
  69437. /**
  69438. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  69439. */
  69440. readonly shareMaterials: boolean;
  69441. /**
  69442. * Creates a new button
  69443. * @param name defines the control name
  69444. */
  69445. constructor(name?: string, shareMaterials?: boolean);
  69446. protected _getTypeName(): string;
  69447. private _rebuildContent;
  69448. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  69449. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  69450. private _createBackMaterial;
  69451. private _createFrontMaterial;
  69452. private _createPlateMaterial;
  69453. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  69454. /**
  69455. * Releases all associated resources
  69456. */
  69457. dispose(): void;
  69458. }
  69459. }
  69460. declare module BABYLON.GUI {
  69461. /**
  69462. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  69463. */
  69464. export class MeshButton3D extends Button3D {
  69465. /** @hidden */
  69466. protected _currentMesh: BABYLON.Mesh;
  69467. /**
  69468. * Creates a new 3D button based on a mesh
  69469. * @param mesh mesh to become a 3D button
  69470. * @param name defines the control name
  69471. */
  69472. constructor(mesh: BABYLON.Mesh, name?: string);
  69473. protected _getTypeName(): string;
  69474. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  69475. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  69476. }
  69477. }
  69478. declare module BABYLON.GUI {
  69479. /**
  69480. * Class used to create a container panel deployed on the surface of a plane
  69481. */
  69482. export class PlanePanel extends VolumeBasedPanel {
  69483. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  69484. }
  69485. }
  69486. declare module BABYLON.GUI {
  69487. /**
  69488. * Class used to create a container panel where items get randomized planar mapping
  69489. */
  69490. export class ScatterPanel extends VolumeBasedPanel {
  69491. private _iteration;
  69492. /**
  69493. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  69494. */
  69495. iteration: BABYLON.float;
  69496. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  69497. private _scatterMapping;
  69498. protected _finalProcessing(): void;
  69499. }
  69500. }
  69501. declare module BABYLON.GUI {
  69502. /**
  69503. * Class used to create a container panel deployed on the surface of a sphere
  69504. */
  69505. export class SpherePanel extends VolumeBasedPanel {
  69506. private _radius;
  69507. /**
  69508. * Gets or sets the radius of the sphere where to project controls (5 by default)
  69509. */
  69510. radius: BABYLON.float;
  69511. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  69512. private _sphericalMapping;
  69513. }
  69514. }
  69515. declare module BABYLON.GUI {
  69516. /**
  69517. * Class used to create a stack panel in 3D on XY plane
  69518. */
  69519. export class StackPanel3D extends Container3D {
  69520. private _isVertical;
  69521. /**
  69522. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  69523. */
  69524. isVertical: boolean;
  69525. /**
  69526. * Gets or sets the distance between elements
  69527. */
  69528. margin: number;
  69529. /**
  69530. * Creates new StackPanel
  69531. * @param isVertical
  69532. */
  69533. constructor(isVertical?: boolean);
  69534. protected _arrangeChildren(): void;
  69535. }
  69536. }
  69537. declare module BABYLON {
  69538. /**
  69539. * Mode that determines the coordinate system to use.
  69540. */
  69541. export enum GLTFLoaderCoordinateSystemMode {
  69542. /**
  69543. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  69544. */
  69545. AUTO = 0,
  69546. /**
  69547. * Sets the useRightHandedSystem flag on the scene.
  69548. */
  69549. FORCE_RIGHT_HANDED = 1
  69550. }
  69551. /**
  69552. * Mode that determines what animations will start.
  69553. */
  69554. export enum GLTFLoaderAnimationStartMode {
  69555. /**
  69556. * No animation will start.
  69557. */
  69558. NONE = 0,
  69559. /**
  69560. * The first animation will start.
  69561. */
  69562. FIRST = 1,
  69563. /**
  69564. * All animations will start.
  69565. */
  69566. ALL = 2
  69567. }
  69568. /**
  69569. * Interface that contains the data for the glTF asset.
  69570. */
  69571. export interface IGLTFLoaderData {
  69572. /**
  69573. * The object that represents the glTF JSON.
  69574. */
  69575. json: Object;
  69576. /**
  69577. * The BIN chunk of a binary glTF.
  69578. */
  69579. bin: Nullable<IDataBuffer>;
  69580. }
  69581. /**
  69582. * Interface for extending the loader.
  69583. */
  69584. export interface IGLTFLoaderExtension {
  69585. /**
  69586. * The name of this extension.
  69587. */
  69588. readonly name: string;
  69589. /**
  69590. * Defines whether this extension is enabled.
  69591. */
  69592. enabled: boolean;
  69593. /**
  69594. * Defines the order of this extension.
  69595. * The loader sorts the extensions using these values when loading.
  69596. */
  69597. order?: number;
  69598. }
  69599. /**
  69600. * Loader state.
  69601. */
  69602. export enum GLTFLoaderState {
  69603. /**
  69604. * The asset is loading.
  69605. */
  69606. LOADING = 0,
  69607. /**
  69608. * The asset is ready for rendering.
  69609. */
  69610. READY = 1,
  69611. /**
  69612. * The asset is completely loaded.
  69613. */
  69614. COMPLETE = 2
  69615. }
  69616. /** @hidden */
  69617. export interface IGLTFLoader extends IDisposable {
  69618. readonly state: Nullable<GLTFLoaderState>;
  69619. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  69620. meshes: AbstractMesh[];
  69621. particleSystems: IParticleSystem[];
  69622. skeletons: Skeleton[];
  69623. animationGroups: AnimationGroup[];
  69624. }>;
  69625. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  69626. }
  69627. /**
  69628. * File loader for loading glTF files into a scene.
  69629. */
  69630. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  69631. /** @hidden */
  69632. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  69633. /** @hidden */
  69634. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  69635. /**
  69636. * Raised when the asset has been parsed
  69637. */
  69638. onParsedObservable: Observable<IGLTFLoaderData>;
  69639. private _onParsedObserver;
  69640. /**
  69641. * Raised when the asset has been parsed
  69642. */
  69643. onParsed: (loaderData: IGLTFLoaderData) => void;
  69644. /**
  69645. * 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.
  69646. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  69647. * Defaults to true.
  69648. * @hidden
  69649. */
  69650. static IncrementalLoading: boolean;
  69651. /**
  69652. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  69653. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  69654. * @hidden
  69655. */
  69656. static HomogeneousCoordinates: boolean;
  69657. /**
  69658. * The coordinate system mode. Defaults to AUTO.
  69659. */
  69660. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  69661. /**
  69662. * The animation start mode. Defaults to FIRST.
  69663. */
  69664. animationStartMode: GLTFLoaderAnimationStartMode;
  69665. /**
  69666. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  69667. */
  69668. compileMaterials: boolean;
  69669. /**
  69670. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  69671. */
  69672. useClipPlane: boolean;
  69673. /**
  69674. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  69675. */
  69676. compileShadowGenerators: boolean;
  69677. /**
  69678. * Defines if the Alpha blended materials are only applied as coverage.
  69679. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  69680. * If true, no extra effects are applied to transparent pixels.
  69681. */
  69682. transparencyAsCoverage: boolean;
  69683. /**
  69684. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  69685. * Enabling will disable offline support and glTF validator.
  69686. * Defaults to false.
  69687. */
  69688. useRangeRequests: boolean;
  69689. /**
  69690. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  69691. */
  69692. createInstances: boolean;
  69693. /**
  69694. * Function called before loading a url referenced by the asset.
  69695. */
  69696. preprocessUrlAsync: (url: string) => Promise<string>;
  69697. /**
  69698. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  69699. */
  69700. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  69701. private _onMeshLoadedObserver;
  69702. /**
  69703. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  69704. */
  69705. onMeshLoaded: (mesh: AbstractMesh) => void;
  69706. /**
  69707. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  69708. */
  69709. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  69710. private _onTextureLoadedObserver;
  69711. /**
  69712. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  69713. */
  69714. onTextureLoaded: (texture: BaseTexture) => void;
  69715. /**
  69716. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  69717. */
  69718. readonly onMaterialLoadedObservable: Observable<Material>;
  69719. private _onMaterialLoadedObserver;
  69720. /**
  69721. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  69722. */
  69723. onMaterialLoaded: (material: Material) => void;
  69724. /**
  69725. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  69726. */
  69727. readonly onCameraLoadedObservable: Observable<Camera>;
  69728. private _onCameraLoadedObserver;
  69729. /**
  69730. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  69731. */
  69732. onCameraLoaded: (camera: Camera) => void;
  69733. /**
  69734. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  69735. * For assets with LODs, raised when all of the LODs are complete.
  69736. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  69737. */
  69738. readonly onCompleteObservable: Observable<void>;
  69739. private _onCompleteObserver;
  69740. /**
  69741. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  69742. * For assets with LODs, raised when all of the LODs are complete.
  69743. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  69744. */
  69745. onComplete: () => void;
  69746. /**
  69747. * Observable raised when an error occurs.
  69748. */
  69749. readonly onErrorObservable: Observable<any>;
  69750. private _onErrorObserver;
  69751. /**
  69752. * Callback raised when an error occurs.
  69753. */
  69754. onError: (reason: any) => void;
  69755. /**
  69756. * Observable raised after the loader is disposed.
  69757. */
  69758. readonly onDisposeObservable: Observable<void>;
  69759. private _onDisposeObserver;
  69760. /**
  69761. * Callback raised after the loader is disposed.
  69762. */
  69763. onDispose: () => void;
  69764. /**
  69765. * Observable raised after a loader extension is created.
  69766. * Set additional options for a loader extension in this event.
  69767. */
  69768. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  69769. private _onExtensionLoadedObserver;
  69770. /**
  69771. * Callback raised after a loader extension is created.
  69772. */
  69773. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  69774. /**
  69775. * Defines if the loader logging is enabled.
  69776. */
  69777. loggingEnabled: boolean;
  69778. /**
  69779. * Defines if the loader should capture performance counters.
  69780. */
  69781. capturePerformanceCounters: boolean;
  69782. /**
  69783. * Defines if the loader should validate the asset.
  69784. */
  69785. validate: boolean;
  69786. /**
  69787. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  69788. */
  69789. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  69790. private _onValidatedObserver;
  69791. /**
  69792. * Callback raised after a loader extension is created.
  69793. */
  69794. onValidated: (results: BABYLON.GLTF2.IGLTFValidationResults) => void;
  69795. private _loader;
  69796. /**
  69797. * Name of the loader ("gltf")
  69798. */
  69799. name: string;
  69800. /** @hidden */
  69801. extensions: ISceneLoaderPluginExtensions;
  69802. /**
  69803. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  69804. */
  69805. dispose(): void;
  69806. /** @hidden */
  69807. _clear(): void;
  69808. /** @hidden */
  69809. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  69810. /** @hidden */
  69811. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  69812. /** @hidden */
  69813. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  69814. meshes: AbstractMesh[];
  69815. particleSystems: IParticleSystem[];
  69816. skeletons: Skeleton[];
  69817. animationGroups: AnimationGroup[];
  69818. }>;
  69819. /** @hidden */
  69820. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  69821. /** @hidden */
  69822. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  69823. /** @hidden */
  69824. canDirectLoad(data: string): boolean;
  69825. /** @hidden */
  69826. directLoad(scene: Scene, data: string): any;
  69827. /**
  69828. * The callback that allows custom handling of the root url based on the response url.
  69829. * @param rootUrl the original root url
  69830. * @param responseURL the response url if available
  69831. * @returns the new root url
  69832. */
  69833. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  69834. /** @hidden */
  69835. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  69836. /**
  69837. * The loader state or null if the loader is not active.
  69838. */
  69839. readonly loaderState: Nullable<GLTFLoaderState>;
  69840. /**
  69841. * Returns a promise that resolves when the asset is completely loaded.
  69842. * @returns a promise that resolves when the asset is completely loaded.
  69843. */
  69844. whenCompleteAsync(): Promise<void>;
  69845. private _validateAsync;
  69846. private _getLoader;
  69847. private _parseJson;
  69848. private _unpackBinaryAsync;
  69849. private _unpackBinaryV1Async;
  69850. private _unpackBinaryV2Async;
  69851. private static _parseVersion;
  69852. private static _compareVersion;
  69853. private static readonly _logSpaces;
  69854. private _logIndentLevel;
  69855. private _loggingEnabled;
  69856. /** @hidden */
  69857. _log: (message: string) => void;
  69858. /** @hidden */
  69859. _logOpen(message: string): void;
  69860. /** @hidden */
  69861. _logClose(): void;
  69862. private _logEnabled;
  69863. private _logDisabled;
  69864. private _capturePerformanceCounters;
  69865. /** @hidden */
  69866. _startPerformanceCounter: (counterName: string) => void;
  69867. /** @hidden */
  69868. _endPerformanceCounter: (counterName: string) => void;
  69869. private _startPerformanceCounterEnabled;
  69870. private _startPerformanceCounterDisabled;
  69871. private _endPerformanceCounterEnabled;
  69872. private _endPerformanceCounterDisabled;
  69873. }
  69874. }
  69875. declare module BABYLON.GLTF1 {
  69876. /**
  69877. * Enums
  69878. * @hidden
  69879. */
  69880. export enum EComponentType {
  69881. BYTE = 5120,
  69882. UNSIGNED_BYTE = 5121,
  69883. SHORT = 5122,
  69884. UNSIGNED_SHORT = 5123,
  69885. FLOAT = 5126
  69886. }
  69887. /** @hidden */
  69888. export enum EShaderType {
  69889. FRAGMENT = 35632,
  69890. VERTEX = 35633
  69891. }
  69892. /** @hidden */
  69893. export enum EParameterType {
  69894. BYTE = 5120,
  69895. UNSIGNED_BYTE = 5121,
  69896. SHORT = 5122,
  69897. UNSIGNED_SHORT = 5123,
  69898. INT = 5124,
  69899. UNSIGNED_INT = 5125,
  69900. FLOAT = 5126,
  69901. FLOAT_VEC2 = 35664,
  69902. FLOAT_VEC3 = 35665,
  69903. FLOAT_VEC4 = 35666,
  69904. INT_VEC2 = 35667,
  69905. INT_VEC3 = 35668,
  69906. INT_VEC4 = 35669,
  69907. BOOL = 35670,
  69908. BOOL_VEC2 = 35671,
  69909. BOOL_VEC3 = 35672,
  69910. BOOL_VEC4 = 35673,
  69911. FLOAT_MAT2 = 35674,
  69912. FLOAT_MAT3 = 35675,
  69913. FLOAT_MAT4 = 35676,
  69914. SAMPLER_2D = 35678
  69915. }
  69916. /** @hidden */
  69917. export enum ETextureWrapMode {
  69918. CLAMP_TO_EDGE = 33071,
  69919. MIRRORED_REPEAT = 33648,
  69920. REPEAT = 10497
  69921. }
  69922. /** @hidden */
  69923. export enum ETextureFilterType {
  69924. NEAREST = 9728,
  69925. LINEAR = 9728,
  69926. NEAREST_MIPMAP_NEAREST = 9984,
  69927. LINEAR_MIPMAP_NEAREST = 9985,
  69928. NEAREST_MIPMAP_LINEAR = 9986,
  69929. LINEAR_MIPMAP_LINEAR = 9987
  69930. }
  69931. /** @hidden */
  69932. export enum ETextureFormat {
  69933. ALPHA = 6406,
  69934. RGB = 6407,
  69935. RGBA = 6408,
  69936. LUMINANCE = 6409,
  69937. LUMINANCE_ALPHA = 6410
  69938. }
  69939. /** @hidden */
  69940. export enum ECullingType {
  69941. FRONT = 1028,
  69942. BACK = 1029,
  69943. FRONT_AND_BACK = 1032
  69944. }
  69945. /** @hidden */
  69946. export enum EBlendingFunction {
  69947. ZERO = 0,
  69948. ONE = 1,
  69949. SRC_COLOR = 768,
  69950. ONE_MINUS_SRC_COLOR = 769,
  69951. DST_COLOR = 774,
  69952. ONE_MINUS_DST_COLOR = 775,
  69953. SRC_ALPHA = 770,
  69954. ONE_MINUS_SRC_ALPHA = 771,
  69955. DST_ALPHA = 772,
  69956. ONE_MINUS_DST_ALPHA = 773,
  69957. CONSTANT_COLOR = 32769,
  69958. ONE_MINUS_CONSTANT_COLOR = 32770,
  69959. CONSTANT_ALPHA = 32771,
  69960. ONE_MINUS_CONSTANT_ALPHA = 32772,
  69961. SRC_ALPHA_SATURATE = 776
  69962. }
  69963. /** @hidden */
  69964. export interface IGLTFProperty {
  69965. extensions?: {
  69966. [key: string]: any;
  69967. };
  69968. extras?: Object;
  69969. }
  69970. /** @hidden */
  69971. export interface IGLTFChildRootProperty extends IGLTFProperty {
  69972. name?: string;
  69973. }
  69974. /** @hidden */
  69975. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  69976. bufferView: string;
  69977. byteOffset: number;
  69978. byteStride: number;
  69979. count: number;
  69980. type: string;
  69981. componentType: EComponentType;
  69982. max?: number[];
  69983. min?: number[];
  69984. name?: string;
  69985. }
  69986. /** @hidden */
  69987. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  69988. buffer: string;
  69989. byteOffset: number;
  69990. byteLength: number;
  69991. byteStride: number;
  69992. target?: number;
  69993. }
  69994. /** @hidden */
  69995. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  69996. uri: string;
  69997. byteLength?: number;
  69998. type?: string;
  69999. }
  70000. /** @hidden */
  70001. export interface IGLTFShader extends IGLTFChildRootProperty {
  70002. uri: string;
  70003. type: EShaderType;
  70004. }
  70005. /** @hidden */
  70006. export interface IGLTFProgram extends IGLTFChildRootProperty {
  70007. attributes: string[];
  70008. fragmentShader: string;
  70009. vertexShader: string;
  70010. }
  70011. /** @hidden */
  70012. export interface IGLTFTechniqueParameter {
  70013. type: number;
  70014. count?: number;
  70015. semantic?: string;
  70016. node?: string;
  70017. value?: number | boolean | string | Array<any>;
  70018. source?: string;
  70019. babylonValue?: any;
  70020. }
  70021. /** @hidden */
  70022. export interface IGLTFTechniqueCommonProfile {
  70023. lightingModel: string;
  70024. texcoordBindings: Object;
  70025. parameters?: Array<any>;
  70026. }
  70027. /** @hidden */
  70028. export interface IGLTFTechniqueStatesFunctions {
  70029. blendColor?: number[];
  70030. blendEquationSeparate?: number[];
  70031. blendFuncSeparate?: number[];
  70032. colorMask: boolean[];
  70033. cullFace: number[];
  70034. }
  70035. /** @hidden */
  70036. export interface IGLTFTechniqueStates {
  70037. enable: number[];
  70038. functions: IGLTFTechniqueStatesFunctions;
  70039. }
  70040. /** @hidden */
  70041. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  70042. parameters: {
  70043. [key: string]: IGLTFTechniqueParameter;
  70044. };
  70045. program: string;
  70046. attributes: {
  70047. [key: string]: string;
  70048. };
  70049. uniforms: {
  70050. [key: string]: string;
  70051. };
  70052. states: IGLTFTechniqueStates;
  70053. }
  70054. /** @hidden */
  70055. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  70056. technique?: string;
  70057. values: string[];
  70058. }
  70059. /** @hidden */
  70060. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  70061. attributes: {
  70062. [key: string]: string;
  70063. };
  70064. indices: string;
  70065. material: string;
  70066. mode?: number;
  70067. }
  70068. /** @hidden */
  70069. export interface IGLTFMesh extends IGLTFChildRootProperty {
  70070. primitives: IGLTFMeshPrimitive[];
  70071. }
  70072. /** @hidden */
  70073. export interface IGLTFImage extends IGLTFChildRootProperty {
  70074. uri: string;
  70075. }
  70076. /** @hidden */
  70077. export interface IGLTFSampler extends IGLTFChildRootProperty {
  70078. magFilter?: number;
  70079. minFilter?: number;
  70080. wrapS?: number;
  70081. wrapT?: number;
  70082. }
  70083. /** @hidden */
  70084. export interface IGLTFTexture extends IGLTFChildRootProperty {
  70085. sampler: string;
  70086. source: string;
  70087. format?: ETextureFormat;
  70088. internalFormat?: ETextureFormat;
  70089. target?: number;
  70090. type?: number;
  70091. babylonTexture?: Texture;
  70092. }
  70093. /** @hidden */
  70094. export interface IGLTFAmbienLight {
  70095. color?: number[];
  70096. }
  70097. /** @hidden */
  70098. export interface IGLTFDirectionalLight {
  70099. color?: number[];
  70100. }
  70101. /** @hidden */
  70102. export interface IGLTFPointLight {
  70103. color?: number[];
  70104. constantAttenuation?: number;
  70105. linearAttenuation?: number;
  70106. quadraticAttenuation?: number;
  70107. }
  70108. /** @hidden */
  70109. export interface IGLTFSpotLight {
  70110. color?: number[];
  70111. constantAttenuation?: number;
  70112. fallOfAngle?: number;
  70113. fallOffExponent?: number;
  70114. linearAttenuation?: number;
  70115. quadraticAttenuation?: number;
  70116. }
  70117. /** @hidden */
  70118. export interface IGLTFLight extends IGLTFChildRootProperty {
  70119. type: string;
  70120. }
  70121. /** @hidden */
  70122. export interface IGLTFCameraOrthographic {
  70123. xmag: number;
  70124. ymag: number;
  70125. zfar: number;
  70126. znear: number;
  70127. }
  70128. /** @hidden */
  70129. export interface IGLTFCameraPerspective {
  70130. aspectRatio: number;
  70131. yfov: number;
  70132. zfar: number;
  70133. znear: number;
  70134. }
  70135. /** @hidden */
  70136. export interface IGLTFCamera extends IGLTFChildRootProperty {
  70137. type: string;
  70138. }
  70139. /** @hidden */
  70140. export interface IGLTFAnimationChannelTarget {
  70141. id: string;
  70142. path: string;
  70143. }
  70144. /** @hidden */
  70145. export interface IGLTFAnimationChannel {
  70146. sampler: string;
  70147. target: IGLTFAnimationChannelTarget;
  70148. }
  70149. /** @hidden */
  70150. export interface IGLTFAnimationSampler {
  70151. input: string;
  70152. output: string;
  70153. interpolation?: string;
  70154. }
  70155. /** @hidden */
  70156. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  70157. channels?: IGLTFAnimationChannel[];
  70158. parameters?: {
  70159. [key: string]: string;
  70160. };
  70161. samplers?: {
  70162. [key: string]: IGLTFAnimationSampler;
  70163. };
  70164. }
  70165. /** @hidden */
  70166. export interface IGLTFNodeInstanceSkin {
  70167. skeletons: string[];
  70168. skin: string;
  70169. meshes: string[];
  70170. }
  70171. /** @hidden */
  70172. export interface IGLTFSkins extends IGLTFChildRootProperty {
  70173. bindShapeMatrix: number[];
  70174. inverseBindMatrices: string;
  70175. jointNames: string[];
  70176. babylonSkeleton?: Skeleton;
  70177. }
  70178. /** @hidden */
  70179. export interface IGLTFNode extends IGLTFChildRootProperty {
  70180. camera?: string;
  70181. children: string[];
  70182. skin?: string;
  70183. jointName?: string;
  70184. light?: string;
  70185. matrix: number[];
  70186. mesh?: string;
  70187. meshes?: string[];
  70188. rotation?: number[];
  70189. scale?: number[];
  70190. translation?: number[];
  70191. babylonNode?: Node;
  70192. }
  70193. /** @hidden */
  70194. export interface IGLTFScene extends IGLTFChildRootProperty {
  70195. nodes: string[];
  70196. }
  70197. /** @hidden */
  70198. export interface IGLTFRuntime {
  70199. extensions: {
  70200. [key: string]: any;
  70201. };
  70202. accessors: {
  70203. [key: string]: IGLTFAccessor;
  70204. };
  70205. buffers: {
  70206. [key: string]: IGLTFBuffer;
  70207. };
  70208. bufferViews: {
  70209. [key: string]: IGLTFBufferView;
  70210. };
  70211. meshes: {
  70212. [key: string]: IGLTFMesh;
  70213. };
  70214. lights: {
  70215. [key: string]: IGLTFLight;
  70216. };
  70217. cameras: {
  70218. [key: string]: IGLTFCamera;
  70219. };
  70220. nodes: {
  70221. [key: string]: IGLTFNode;
  70222. };
  70223. images: {
  70224. [key: string]: IGLTFImage;
  70225. };
  70226. textures: {
  70227. [key: string]: IGLTFTexture;
  70228. };
  70229. shaders: {
  70230. [key: string]: IGLTFShader;
  70231. };
  70232. programs: {
  70233. [key: string]: IGLTFProgram;
  70234. };
  70235. samplers: {
  70236. [key: string]: IGLTFSampler;
  70237. };
  70238. techniques: {
  70239. [key: string]: IGLTFTechnique;
  70240. };
  70241. materials: {
  70242. [key: string]: IGLTFMaterial;
  70243. };
  70244. animations: {
  70245. [key: string]: IGLTFAnimation;
  70246. };
  70247. skins: {
  70248. [key: string]: IGLTFSkins;
  70249. };
  70250. currentScene?: Object;
  70251. scenes: {
  70252. [key: string]: IGLTFScene;
  70253. };
  70254. extensionsUsed: string[];
  70255. extensionsRequired?: string[];
  70256. buffersCount: number;
  70257. shaderscount: number;
  70258. scene: Scene;
  70259. rootUrl: string;
  70260. loadedBufferCount: number;
  70261. loadedBufferViews: {
  70262. [name: string]: ArrayBufferView;
  70263. };
  70264. loadedShaderCount: number;
  70265. importOnlyMeshes: boolean;
  70266. importMeshesNames?: string[];
  70267. dummyNodes: Node[];
  70268. }
  70269. /** @hidden */
  70270. export interface INodeToRoot {
  70271. bone: Bone;
  70272. node: IGLTFNode;
  70273. id: string;
  70274. }
  70275. /** @hidden */
  70276. export interface IJointNode {
  70277. node: IGLTFNode;
  70278. id: string;
  70279. }
  70280. }
  70281. declare module BABYLON.GLTF1 {
  70282. /**
  70283. * Utils functions for GLTF
  70284. * @hidden
  70285. */
  70286. export class GLTFUtils {
  70287. /**
  70288. * Sets the given "parameter" matrix
  70289. * @param scene: the Scene object
  70290. * @param source: the source node where to pick the matrix
  70291. * @param parameter: the GLTF technique parameter
  70292. * @param uniformName: the name of the shader's uniform
  70293. * @param shaderMaterial: the shader material
  70294. */
  70295. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  70296. /**
  70297. * Sets the given "parameter" matrix
  70298. * @param shaderMaterial: the shader material
  70299. * @param uniform: the name of the shader's uniform
  70300. * @param value: the value of the uniform
  70301. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  70302. */
  70303. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  70304. /**
  70305. * Returns the wrap mode of the texture
  70306. * @param mode: the mode value
  70307. */
  70308. static GetWrapMode(mode: number): number;
  70309. /**
  70310. * Returns the byte stride giving an accessor
  70311. * @param accessor: the GLTF accessor objet
  70312. */
  70313. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  70314. /**
  70315. * Returns the texture filter mode giving a mode value
  70316. * @param mode: the filter mode value
  70317. */
  70318. static GetTextureFilterMode(mode: number): ETextureFilterType;
  70319. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  70320. /**
  70321. * Returns a buffer from its accessor
  70322. * @param gltfRuntime: the GLTF runtime
  70323. * @param accessor: the GLTF accessor
  70324. */
  70325. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  70326. /**
  70327. * Decodes a buffer view into a string
  70328. * @param view: the buffer view
  70329. */
  70330. static DecodeBufferToText(view: ArrayBufferView): string;
  70331. /**
  70332. * Returns the default material of gltf. Related to
  70333. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  70334. * @param scene: the Babylon.js scene
  70335. */
  70336. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  70337. private static _DefaultMaterial;
  70338. }
  70339. }
  70340. declare module BABYLON.GLTF1 {
  70341. /**
  70342. * Implementation of the base glTF spec
  70343. * @hidden
  70344. */
  70345. export class GLTFLoaderBase {
  70346. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  70347. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  70348. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  70349. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  70350. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  70351. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  70352. }
  70353. /**
  70354. * glTF V1 Loader
  70355. * @hidden
  70356. */
  70357. export class GLTFLoader implements IGLTFLoader {
  70358. static Extensions: {
  70359. [name: string]: GLTFLoaderExtension;
  70360. };
  70361. static RegisterExtension(extension: GLTFLoaderExtension): void;
  70362. state: Nullable<GLTFLoaderState>;
  70363. dispose(): void;
  70364. private _importMeshAsync;
  70365. /**
  70366. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  70367. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  70368. * @param scene the scene the meshes should be added to
  70369. * @param data gltf data containing information of the meshes in a loaded file
  70370. * @param rootUrl root url to load from
  70371. * @param onProgress event that fires when loading progress has occured
  70372. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  70373. */
  70374. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  70375. meshes: AbstractMesh[];
  70376. particleSystems: IParticleSystem[];
  70377. skeletons: Skeleton[];
  70378. animationGroups: AnimationGroup[];
  70379. }>;
  70380. private _loadAsync;
  70381. /**
  70382. * Imports all objects from a loaded gltf file and adds them to the scene
  70383. * @param scene the scene the objects should be added to
  70384. * @param data gltf data containing information of the meshes in a loaded file
  70385. * @param rootUrl root url to load from
  70386. * @param onProgress event that fires when loading progress has occured
  70387. * @returns a promise which completes when objects have been loaded to the scene
  70388. */
  70389. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  70390. private _loadShadersAsync;
  70391. private _loadBuffersAsync;
  70392. private _createNodes;
  70393. }
  70394. /** @hidden */
  70395. export abstract class GLTFLoaderExtension {
  70396. private _name;
  70397. constructor(name: string);
  70398. readonly name: string;
  70399. /**
  70400. * Defines an override for loading the runtime
  70401. * Return true to stop further extensions from loading the runtime
  70402. */
  70403. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  70404. /**
  70405. * Defines an onverride for creating gltf runtime
  70406. * Return true to stop further extensions from creating the runtime
  70407. */
  70408. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  70409. /**
  70410. * Defines an override for loading buffers
  70411. * Return true to stop further extensions from loading this buffer
  70412. */
  70413. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  70414. /**
  70415. * Defines an override for loading texture buffers
  70416. * Return true to stop further extensions from loading this texture data
  70417. */
  70418. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  70419. /**
  70420. * Defines an override for creating textures
  70421. * Return true to stop further extensions from loading this texture
  70422. */
  70423. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  70424. /**
  70425. * Defines an override for loading shader strings
  70426. * Return true to stop further extensions from loading this shader data
  70427. */
  70428. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  70429. /**
  70430. * Defines an override for loading materials
  70431. * Return true to stop further extensions from loading this material
  70432. */
  70433. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  70434. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  70435. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  70436. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  70437. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  70438. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  70439. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  70440. private static LoadTextureBufferAsync;
  70441. private static CreateTextureAsync;
  70442. private static ApplyExtensions;
  70443. }
  70444. }
  70445. declare module BABYLON.GLTF1 {
  70446. /** @hidden */
  70447. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  70448. private _bin;
  70449. constructor();
  70450. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  70451. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  70452. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  70453. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  70454. }
  70455. }
  70456. declare module BABYLON.GLTF1 {
  70457. /** @hidden */
  70458. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  70459. constructor();
  70460. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  70461. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  70462. private _loadTexture;
  70463. }
  70464. }
  70465. declare module BABYLON.GLTF2.Loader {
  70466. /**
  70467. * Loader interface with an index field.
  70468. */
  70469. export interface IArrayItem {
  70470. /**
  70471. * The index of this item in the array.
  70472. */
  70473. index: number;
  70474. }
  70475. /**
  70476. * Loader interface with additional members.
  70477. */
  70478. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  70479. /** @hidden */
  70480. _data?: Promise<ArrayBufferView>;
  70481. /** @hidden */
  70482. _babylonVertexBuffer?: Promise<VertexBuffer>;
  70483. }
  70484. /**
  70485. * Loader interface with additional members.
  70486. */
  70487. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  70488. }
  70489. /** @hidden */
  70490. export interface _IAnimationSamplerData {
  70491. input: Float32Array;
  70492. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  70493. output: Float32Array;
  70494. }
  70495. /**
  70496. * Loader interface with additional members.
  70497. */
  70498. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  70499. /** @hidden */
  70500. _data?: Promise<_IAnimationSamplerData>;
  70501. }
  70502. /**
  70503. * Loader interface with additional members.
  70504. */
  70505. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  70506. channels: IAnimationChannel[];
  70507. samplers: IAnimationSampler[];
  70508. /** @hidden */
  70509. _babylonAnimationGroup?: AnimationGroup;
  70510. }
  70511. /**
  70512. * Loader interface with additional members.
  70513. */
  70514. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  70515. /** @hidden */
  70516. _data?: Promise<ArrayBufferView>;
  70517. }
  70518. /**
  70519. * Loader interface with additional members.
  70520. */
  70521. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  70522. /** @hidden */
  70523. _data?: Promise<ArrayBufferView>;
  70524. /** @hidden */
  70525. _babylonBuffer?: Promise<Buffer>;
  70526. }
  70527. /**
  70528. * Loader interface with additional members.
  70529. */
  70530. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  70531. }
  70532. /**
  70533. * Loader interface with additional members.
  70534. */
  70535. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  70536. /** @hidden */
  70537. _data?: Promise<ArrayBufferView>;
  70538. }
  70539. /**
  70540. * Loader interface with additional members.
  70541. */
  70542. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  70543. }
  70544. /**
  70545. * Loader interface with additional members.
  70546. */
  70547. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  70548. }
  70549. /**
  70550. * Loader interface with additional members.
  70551. */
  70552. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  70553. baseColorTexture?: ITextureInfo;
  70554. metallicRoughnessTexture?: ITextureInfo;
  70555. }
  70556. /**
  70557. * Loader interface with additional members.
  70558. */
  70559. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  70560. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  70561. normalTexture?: IMaterialNormalTextureInfo;
  70562. occlusionTexture?: IMaterialOcclusionTextureInfo;
  70563. emissiveTexture?: ITextureInfo;
  70564. /** @hidden */
  70565. _data?: {
  70566. [babylonDrawMode: number]: {
  70567. babylonMaterial: Material;
  70568. babylonMeshes: AbstractMesh[];
  70569. promise: Promise<void>;
  70570. };
  70571. };
  70572. }
  70573. /**
  70574. * Loader interface with additional members.
  70575. */
  70576. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  70577. primitives: IMeshPrimitive[];
  70578. }
  70579. /**
  70580. * Loader interface with additional members.
  70581. */
  70582. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  70583. /** @hidden */
  70584. _instanceData?: {
  70585. babylonSourceMesh: Mesh;
  70586. promise: Promise<any>;
  70587. };
  70588. }
  70589. /**
  70590. * Loader interface with additional members.
  70591. */
  70592. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  70593. /**
  70594. * The parent glTF node.
  70595. */
  70596. parent?: INode;
  70597. /** @hidden */
  70598. _babylonTransformNode?: TransformNode;
  70599. /** @hidden */
  70600. _primitiveBabylonMeshes?: AbstractMesh[];
  70601. /** @hidden */
  70602. _babylonBones?: Bone[];
  70603. /** @hidden */
  70604. _numMorphTargets?: number;
  70605. }
  70606. /** @hidden */
  70607. export interface _ISamplerData {
  70608. noMipMaps: boolean;
  70609. samplingMode: number;
  70610. wrapU: number;
  70611. wrapV: number;
  70612. }
  70613. /**
  70614. * Loader interface with additional members.
  70615. */
  70616. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  70617. /** @hidden */
  70618. _data?: _ISamplerData;
  70619. }
  70620. /**
  70621. * Loader interface with additional members.
  70622. */
  70623. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  70624. }
  70625. /**
  70626. * Loader interface with additional members.
  70627. */
  70628. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  70629. /** @hidden */
  70630. _data?: {
  70631. babylonSkeleton: Skeleton;
  70632. promise: Promise<void>;
  70633. };
  70634. }
  70635. /**
  70636. * Loader interface with additional members.
  70637. */
  70638. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  70639. }
  70640. /**
  70641. * Loader interface with additional members.
  70642. */
  70643. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  70644. }
  70645. /**
  70646. * Loader interface with additional members.
  70647. */
  70648. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  70649. accessors?: IAccessor[];
  70650. animations?: IAnimation[];
  70651. buffers?: IBuffer[];
  70652. bufferViews?: IBufferView[];
  70653. cameras?: ICamera[];
  70654. images?: IImage[];
  70655. materials?: IMaterial[];
  70656. meshes?: IMesh[];
  70657. nodes?: INode[];
  70658. samplers?: ISampler[];
  70659. scenes?: IScene[];
  70660. skins?: ISkin[];
  70661. textures?: ITexture[];
  70662. }
  70663. }
  70664. declare module BABYLON.GLTF2 {
  70665. /**
  70666. * Interface for a glTF loader extension.
  70667. */
  70668. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  70669. /**
  70670. * Called after the loader state changes to LOADING.
  70671. */
  70672. onLoading?(): void;
  70673. /**
  70674. * Called after the loader state changes to READY.
  70675. */
  70676. onReady?(): void;
  70677. /**
  70678. * Define this method to modify the default behavior when loading scenes.
  70679. * @param context The context when loading the asset
  70680. * @param scene The glTF scene property
  70681. * @returns A promise that resolves when the load is complete or null if not handled
  70682. */
  70683. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  70684. /**
  70685. * Define this method to modify the default behavior when loading nodes.
  70686. * @param context The context when loading the asset
  70687. * @param node The glTF node property
  70688. * @param assign A function called synchronously after parsing the glTF properties
  70689. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  70690. */
  70691. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  70692. /**
  70693. * Define this method to modify the default behavior when loading cameras.
  70694. * @param context The context when loading the asset
  70695. * @param camera The glTF camera property
  70696. * @param assign A function called synchronously after parsing the glTF properties
  70697. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  70698. */
  70699. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  70700. /**
  70701. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  70702. * @param context The context when loading the asset
  70703. * @param primitive The glTF mesh primitive property
  70704. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  70705. */
  70706. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  70707. /**
  70708. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  70709. * @param context The context when loading the asset
  70710. * @param name The mesh name when loading the asset
  70711. * @param node The glTF node when loading the asset
  70712. * @param mesh The glTF mesh when loading the asset
  70713. * @param primitive The glTF mesh primitive property
  70714. * @param assign A function called synchronously after parsing the glTF properties
  70715. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  70716. */
  70717. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  70718. /**
  70719. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  70720. * @param context The context when loading the asset
  70721. * @param material The glTF material property
  70722. * @param assign A function called synchronously after parsing the glTF properties
  70723. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  70724. */
  70725. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  70726. /**
  70727. * Define this method to modify the default behavior when creating materials.
  70728. * @param context The context when loading the asset
  70729. * @param material The glTF material property
  70730. * @param babylonDrawMode The draw mode for the Babylon material
  70731. * @returns The Babylon material or null if not handled
  70732. */
  70733. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  70734. /**
  70735. * Define this method to modify the default behavior when loading material properties.
  70736. * @param context The context when loading the asset
  70737. * @param material The glTF material property
  70738. * @param babylonMaterial The Babylon material
  70739. * @returns A promise that resolves when the load is complete or null if not handled
  70740. */
  70741. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  70742. /**
  70743. * Define this method to modify the default behavior when loading texture infos.
  70744. * @param context The context when loading the asset
  70745. * @param textureInfo The glTF texture info property
  70746. * @param assign A function called synchronously after parsing the glTF properties
  70747. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  70748. */
  70749. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  70750. /**
  70751. * Define this method to modify the default behavior when loading animations.
  70752. * @param context The context when loading the asset
  70753. * @param animation The glTF animation property
  70754. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  70755. */
  70756. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  70757. /**
  70758. * @hidden Define this method to modify the default behavior when loading skins.
  70759. * @param context The context when loading the asset
  70760. * @param node The glTF node property
  70761. * @param skin The glTF skin property
  70762. * @returns A promise that resolves when the load is complete or null if not handled
  70763. */
  70764. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  70765. /**
  70766. * @hidden Define this method to modify the default behavior when loading uris.
  70767. * @param context The context when loading the asset
  70768. * @param property The glTF property associated with the uri
  70769. * @param uri The uri to load
  70770. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  70771. */
  70772. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  70773. /**
  70774. * Define this method to modify the default behavior when loading buffer views.
  70775. * @param context The context when loading the asset
  70776. * @param bufferView The glTF buffer view property
  70777. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  70778. */
  70779. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  70780. /**
  70781. * Define this method to modify the default behavior when loading buffers.
  70782. * @param context The context when loading the asset
  70783. * @param buffer The glTF buffer property
  70784. * @param byteOffset The byte offset to load
  70785. * @param byteLength The byte length to load
  70786. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  70787. */
  70788. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  70789. }
  70790. }
  70791. declare module BABYLON.GLTF2 {
  70792. /**
  70793. * Helper class for working with arrays when loading the glTF asset
  70794. */
  70795. export class ArrayItem {
  70796. /**
  70797. * Gets an item from the given array.
  70798. * @param context The context when loading the asset
  70799. * @param array The array to get the item from
  70800. * @param index The index to the array
  70801. * @returns The array item
  70802. */
  70803. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  70804. /**
  70805. * Assign an `index` field to each item of the given array.
  70806. * @param array The array of items
  70807. */
  70808. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  70809. }
  70810. /**
  70811. * The glTF 2.0 loader
  70812. */
  70813. export class GLTFLoader implements IGLTFLoader {
  70814. /** @hidden */
  70815. _completePromises: Promise<any>[];
  70816. private _disposed;
  70817. private _parent;
  70818. private _state;
  70819. private _extensions;
  70820. private _rootUrl;
  70821. private _fileName;
  70822. private _uniqueRootUrl;
  70823. private _gltf;
  70824. private _bin;
  70825. private _babylonScene;
  70826. private _rootBabylonMesh;
  70827. private _defaultBabylonMaterialData;
  70828. private _progressCallback?;
  70829. private _requests;
  70830. private static readonly _DefaultSampler;
  70831. private static _RegisteredExtensions;
  70832. /**
  70833. * Registers a loader extension.
  70834. * @param name The name of the loader extension.
  70835. * @param factory The factory function that creates the loader extension.
  70836. */
  70837. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  70838. /**
  70839. * Unregisters a loader extension.
  70840. * @param name The name of the loader extension.
  70841. * @returns A boolean indicating whether the extension has been unregistered
  70842. */
  70843. static UnregisterExtension(name: string): boolean;
  70844. /**
  70845. * Gets the loader state.
  70846. */
  70847. readonly state: Nullable<GLTFLoaderState>;
  70848. /**
  70849. * The object that represents the glTF JSON.
  70850. */
  70851. readonly gltf: IGLTF;
  70852. /**
  70853. * The BIN chunk of a binary glTF.
  70854. */
  70855. readonly bin: Nullable<IDataBuffer>;
  70856. /**
  70857. * The parent file loader.
  70858. */
  70859. readonly parent: GLTFFileLoader;
  70860. /**
  70861. * The Babylon scene when loading the asset.
  70862. */
  70863. readonly babylonScene: Scene;
  70864. /**
  70865. * The root Babylon mesh when loading the asset.
  70866. */
  70867. readonly rootBabylonMesh: Mesh;
  70868. /** @hidden */
  70869. constructor(parent: GLTFFileLoader);
  70870. /** @hidden */
  70871. dispose(): void;
  70872. /** @hidden */
  70873. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  70874. meshes: AbstractMesh[];
  70875. particleSystems: IParticleSystem[];
  70876. skeletons: Skeleton[];
  70877. animationGroups: AnimationGroup[];
  70878. }>;
  70879. /** @hidden */
  70880. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  70881. private _loadAsync;
  70882. private _loadData;
  70883. private _setupData;
  70884. private _loadExtensions;
  70885. private _checkExtensions;
  70886. private _setState;
  70887. private _createRootNode;
  70888. /**
  70889. * Loads a glTF scene.
  70890. * @param context The context when loading the asset
  70891. * @param scene The glTF scene property
  70892. * @returns A promise that resolves when the load is complete
  70893. */
  70894. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  70895. private _forEachPrimitive;
  70896. private _getMeshes;
  70897. private _getSkeletons;
  70898. private _getAnimationGroups;
  70899. private _startAnimations;
  70900. /**
  70901. * Loads a glTF node.
  70902. * @param context The context when loading the asset
  70903. * @param node The glTF node property
  70904. * @param assign A function called synchronously after parsing the glTF properties
  70905. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  70906. */
  70907. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  70908. private _loadMeshAsync;
  70909. /**
  70910. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  70911. * @param context The context when loading the asset
  70912. * @param name The mesh name when loading the asset
  70913. * @param node The glTF node when loading the asset
  70914. * @param mesh The glTF mesh when loading the asset
  70915. * @param primitive The glTF mesh primitive property
  70916. * @param assign A function called synchronously after parsing the glTF properties
  70917. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  70918. */
  70919. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  70920. private _loadVertexDataAsync;
  70921. private _createMorphTargets;
  70922. private _loadMorphTargetsAsync;
  70923. private _loadMorphTargetVertexDataAsync;
  70924. private static _LoadTransform;
  70925. private _loadSkinAsync;
  70926. private _loadBones;
  70927. private _loadBone;
  70928. private _loadSkinInverseBindMatricesDataAsync;
  70929. private _updateBoneMatrices;
  70930. private _getNodeMatrix;
  70931. /**
  70932. * Loads a glTF camera.
  70933. * @param context The context when loading the asset
  70934. * @param camera The glTF camera property
  70935. * @param assign A function called synchronously after parsing the glTF properties
  70936. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  70937. */
  70938. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  70939. private _loadAnimationsAsync;
  70940. /**
  70941. * Loads a glTF animation.
  70942. * @param context The context when loading the asset
  70943. * @param animation The glTF animation property
  70944. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  70945. */
  70946. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  70947. /**
  70948. * @hidden Loads a glTF animation channel.
  70949. * @param context The context when loading the asset
  70950. * @param animationContext The context of the animation when loading the asset
  70951. * @param animation The glTF animation property
  70952. * @param channel The glTF animation channel property
  70953. * @param babylonAnimationGroup The babylon animation group property
  70954. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  70955. * @returns A void promise when the channel load is complete
  70956. */
  70957. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  70958. private _loadAnimationSamplerAsync;
  70959. private _loadBufferAsync;
  70960. /**
  70961. * Loads a glTF buffer view.
  70962. * @param context The context when loading the asset
  70963. * @param bufferView The glTF buffer view property
  70964. * @returns A promise that resolves with the loaded data when the load is complete
  70965. */
  70966. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  70967. private _loadAccessorAsync;
  70968. private _loadFloatAccessorAsync;
  70969. private _loadIndicesAccessorAsync;
  70970. private _loadVertexBufferViewAsync;
  70971. private _loadVertexAccessorAsync;
  70972. private _loadMaterialMetallicRoughnessPropertiesAsync;
  70973. /** @hidden */
  70974. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  70975. private _createDefaultMaterial;
  70976. /**
  70977. * Creates a Babylon material from a glTF material.
  70978. * @param context The context when loading the asset
  70979. * @param material The glTF material property
  70980. * @param babylonDrawMode The draw mode for the Babylon material
  70981. * @returns The Babylon material
  70982. */
  70983. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  70984. /**
  70985. * Loads properties from a glTF material into a Babylon material.
  70986. * @param context The context when loading the asset
  70987. * @param material The glTF material property
  70988. * @param babylonMaterial The Babylon material
  70989. * @returns A promise that resolves when the load is complete
  70990. */
  70991. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  70992. /**
  70993. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  70994. * @param context The context when loading the asset
  70995. * @param material The glTF material property
  70996. * @param babylonMaterial The Babylon material
  70997. * @returns A promise that resolves when the load is complete
  70998. */
  70999. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  71000. /**
  71001. * Loads the alpha properties from a glTF material into a Babylon material.
  71002. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  71003. * @param context The context when loading the asset
  71004. * @param material The glTF material property
  71005. * @param babylonMaterial The Babylon material
  71006. */
  71007. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  71008. /**
  71009. * Loads a glTF texture info.
  71010. * @param context The context when loading the asset
  71011. * @param textureInfo The glTF texture info property
  71012. * @param assign A function called synchronously after parsing the glTF properties
  71013. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  71014. */
  71015. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  71016. private _loadTextureAsync;
  71017. private _loadSampler;
  71018. /**
  71019. * Loads a glTF image.
  71020. * @param context The context when loading the asset
  71021. * @param image The glTF image property
  71022. * @returns A promise that resolves with the loaded data when the load is complete
  71023. */
  71024. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  71025. /**
  71026. * Loads a glTF uri.
  71027. * @param context The context when loading the asset
  71028. * @param property The glTF property associated with the uri
  71029. * @param uri The base64 or relative uri
  71030. * @returns A promise that resolves with the loaded data when the load is complete
  71031. */
  71032. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  71033. private _onProgress;
  71034. /**
  71035. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  71036. * @param babylonObject the Babylon object with metadata
  71037. * @param pointer the JSON pointer
  71038. */
  71039. static AddPointerMetadata(babylonObject: {
  71040. metadata: any;
  71041. }, pointer: string): void;
  71042. private static _GetTextureWrapMode;
  71043. private static _GetTextureSamplingMode;
  71044. private static _GetTypedArrayConstructor;
  71045. private static _GetTypedArray;
  71046. private static _GetNumComponents;
  71047. private static _ValidateUri;
  71048. private static _GetDrawMode;
  71049. private _compileMaterialsAsync;
  71050. private _compileShadowGeneratorsAsync;
  71051. private _forEachExtensions;
  71052. private _applyExtensions;
  71053. private _extensionsOnLoading;
  71054. private _extensionsOnReady;
  71055. private _extensionsLoadSceneAsync;
  71056. private _extensionsLoadNodeAsync;
  71057. private _extensionsLoadCameraAsync;
  71058. private _extensionsLoadVertexDataAsync;
  71059. private _extensionsLoadMeshPrimitiveAsync;
  71060. private _extensionsLoadMaterialAsync;
  71061. private _extensionsCreateMaterial;
  71062. private _extensionsLoadMaterialPropertiesAsync;
  71063. private _extensionsLoadTextureInfoAsync;
  71064. private _extensionsLoadAnimationAsync;
  71065. private _extensionsLoadSkinAsync;
  71066. private _extensionsLoadUriAsync;
  71067. private _extensionsLoadBufferViewAsync;
  71068. private _extensionsLoadBufferAsync;
  71069. /**
  71070. * Helper method called by a loader extension to load an glTF extension.
  71071. * @param context The context when loading the asset
  71072. * @param property The glTF property to load the extension from
  71073. * @param extensionName The name of the extension to load
  71074. * @param actionAsync The action to run
  71075. * @returns The promise returned by actionAsync or null if the extension does not exist
  71076. */
  71077. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  71078. /**
  71079. * Helper method called by a loader extension to load a glTF extra.
  71080. * @param context The context when loading the asset
  71081. * @param property The glTF property to load the extra from
  71082. * @param extensionName The name of the extension to load
  71083. * @param actionAsync The action to run
  71084. * @returns The promise returned by actionAsync or null if the extra does not exist
  71085. */
  71086. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  71087. /**
  71088. * Checks for presence of an extension.
  71089. * @param name The name of the extension to check
  71090. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  71091. */
  71092. isExtensionUsed(name: string): boolean;
  71093. /**
  71094. * Increments the indentation level and logs a message.
  71095. * @param message The message to log
  71096. */
  71097. logOpen(message: string): void;
  71098. /**
  71099. * Decrements the indentation level.
  71100. */
  71101. logClose(): void;
  71102. /**
  71103. * Logs a message
  71104. * @param message The message to log
  71105. */
  71106. log(message: string): void;
  71107. /**
  71108. * Starts a performance counter.
  71109. * @param counterName The name of the performance counter
  71110. */
  71111. startPerformanceCounter(counterName: string): void;
  71112. /**
  71113. * Ends a performance counter.
  71114. * @param counterName The name of the performance counter
  71115. */
  71116. endPerformanceCounter(counterName: string): void;
  71117. }
  71118. }
  71119. declare module BABYLON.GLTF2.Loader.Extensions {
  71120. /**
  71121. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  71122. */
  71123. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  71124. /**
  71125. * The name of this extension.
  71126. */
  71127. readonly name: string;
  71128. /**
  71129. * Defines whether this extension is enabled.
  71130. */
  71131. enabled: boolean;
  71132. private _loader;
  71133. private _lights?;
  71134. /** @hidden */
  71135. constructor(loader: GLTFLoader);
  71136. /** @hidden */
  71137. dispose(): void;
  71138. /** @hidden */
  71139. onLoading(): void;
  71140. /** @hidden */
  71141. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  71142. private _loadLightAsync;
  71143. }
  71144. }
  71145. declare module BABYLON.GLTF2.Loader.Extensions {
  71146. /**
  71147. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  71148. */
  71149. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  71150. /**
  71151. * The name of this extension.
  71152. */
  71153. readonly name: string;
  71154. /**
  71155. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  71156. */
  71157. dracoCompression?: DracoCompression;
  71158. /**
  71159. * Defines whether this extension is enabled.
  71160. */
  71161. enabled: boolean;
  71162. private _loader;
  71163. /** @hidden */
  71164. constructor(loader: GLTFLoader);
  71165. /** @hidden */
  71166. dispose(): void;
  71167. /** @hidden */
  71168. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  71169. }
  71170. }
  71171. declare module BABYLON.GLTF2.Loader.Extensions {
  71172. /**
  71173. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  71174. */
  71175. export class KHR_lights implements IGLTFLoaderExtension {
  71176. /**
  71177. * The name of this extension.
  71178. */
  71179. readonly name: string;
  71180. /**
  71181. * Defines whether this extension is enabled.
  71182. */
  71183. enabled: boolean;
  71184. private _loader;
  71185. private _lights?;
  71186. /** @hidden */
  71187. constructor(loader: GLTFLoader);
  71188. /** @hidden */
  71189. dispose(): void;
  71190. /** @hidden */
  71191. onLoading(): void;
  71192. /** @hidden */
  71193. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  71194. }
  71195. }
  71196. declare module BABYLON.GLTF2.Loader.Extensions {
  71197. /**
  71198. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  71199. */
  71200. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  71201. /**
  71202. * The name of this extension.
  71203. */
  71204. readonly name: string;
  71205. /**
  71206. * Defines whether this extension is enabled.
  71207. */
  71208. enabled: boolean;
  71209. /**
  71210. * Defines a number that determines the order the extensions are applied.
  71211. */
  71212. order: number;
  71213. private _loader;
  71214. /** @hidden */
  71215. constructor(loader: GLTFLoader);
  71216. /** @hidden */
  71217. dispose(): void;
  71218. /** @hidden */
  71219. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  71220. private _loadSpecularGlossinessPropertiesAsync;
  71221. }
  71222. }
  71223. declare module BABYLON.GLTF2.Loader.Extensions {
  71224. /**
  71225. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  71226. */
  71227. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  71228. /**
  71229. * The name of this extension.
  71230. */
  71231. readonly name: string;
  71232. /**
  71233. * Defines whether this extension is enabled.
  71234. */
  71235. enabled: boolean;
  71236. /**
  71237. * Defines a number that determines the order the extensions are applied.
  71238. */
  71239. order: number;
  71240. private _loader;
  71241. /** @hidden */
  71242. constructor(loader: GLTFLoader);
  71243. /** @hidden */
  71244. dispose(): void;
  71245. /** @hidden */
  71246. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  71247. private _loadUnlitPropertiesAsync;
  71248. }
  71249. }
  71250. declare module BABYLON.GLTF2.Loader.Extensions {
  71251. /**
  71252. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  71253. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  71254. * !!! Experimental Extension Subject to Changes !!!
  71255. */
  71256. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  71257. /**
  71258. * The name of this extension.
  71259. */
  71260. readonly name: string;
  71261. /**
  71262. * Defines whether this extension is enabled.
  71263. */
  71264. enabled: boolean;
  71265. /**
  71266. * Defines a number that determines the order the extensions are applied.
  71267. */
  71268. order: number;
  71269. private _loader;
  71270. /** @hidden */
  71271. constructor(loader: GLTFLoader);
  71272. /** @hidden */
  71273. dispose(): void;
  71274. /** @hidden */
  71275. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  71276. private _loadClearCoatPropertiesAsync;
  71277. }
  71278. }
  71279. declare module BABYLON.GLTF2.Loader.Extensions {
  71280. /**
  71281. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  71282. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  71283. * !!! Experimental Extension Subject to Changes !!!
  71284. */
  71285. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  71286. /**
  71287. * The name of this extension.
  71288. */
  71289. readonly name: string;
  71290. /**
  71291. * Defines whether this extension is enabled.
  71292. */
  71293. enabled: boolean;
  71294. /**
  71295. * Defines a number that determines the order the extensions are applied.
  71296. */
  71297. order: number;
  71298. private _loader;
  71299. /** @hidden */
  71300. constructor(loader: GLTFLoader);
  71301. /** @hidden */
  71302. dispose(): void;
  71303. /** @hidden */
  71304. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  71305. private _loadSheenPropertiesAsync;
  71306. }
  71307. }
  71308. declare module BABYLON.GLTF2.Loader.Extensions {
  71309. /**
  71310. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  71311. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  71312. * !!! Experimental Extension Subject to Changes !!!
  71313. */
  71314. export class KHR_materials_specular implements IGLTFLoaderExtension {
  71315. /**
  71316. * The name of this extension.
  71317. */
  71318. readonly name: string;
  71319. /**
  71320. * Defines whether this extension is enabled.
  71321. */
  71322. enabled: boolean;
  71323. /**
  71324. * Defines a number that determines the order the extensions are applied.
  71325. */
  71326. order: number;
  71327. private _loader;
  71328. /** @hidden */
  71329. constructor(loader: GLTFLoader);
  71330. /** @hidden */
  71331. dispose(): void;
  71332. /** @hidden */
  71333. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  71334. private _loadSpecularPropertiesAsync;
  71335. }
  71336. }
  71337. declare module BABYLON.GLTF2.Loader.Extensions {
  71338. /**
  71339. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  71340. */
  71341. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  71342. /**
  71343. * The name of this extension.
  71344. */
  71345. readonly name: string;
  71346. /**
  71347. * Defines whether this extension is enabled.
  71348. */
  71349. enabled: boolean;
  71350. /** @hidden */
  71351. constructor(loader: GLTFLoader);
  71352. /** @hidden */
  71353. dispose(): void;
  71354. }
  71355. }
  71356. declare module BABYLON.GLTF2.Loader.Extensions {
  71357. /**
  71358. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  71359. */
  71360. export class KHR_texture_transform implements IGLTFLoaderExtension {
  71361. /**
  71362. * The name of this extension.
  71363. */
  71364. readonly name: string;
  71365. /**
  71366. * Defines whether this extension is enabled.
  71367. */
  71368. enabled: boolean;
  71369. private _loader;
  71370. /** @hidden */
  71371. constructor(loader: GLTFLoader);
  71372. /** @hidden */
  71373. dispose(): void;
  71374. /** @hidden */
  71375. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  71376. }
  71377. }
  71378. declare module BABYLON.GLTF2.Loader.Extensions {
  71379. /**
  71380. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  71381. */
  71382. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  71383. /**
  71384. * The name of this extension.
  71385. */
  71386. readonly name: string;
  71387. /**
  71388. * Defines whether this extension is enabled.
  71389. */
  71390. enabled: boolean;
  71391. private _loader;
  71392. private _clips;
  71393. private _emitters;
  71394. /** @hidden */
  71395. constructor(loader: GLTFLoader);
  71396. /** @hidden */
  71397. dispose(): void;
  71398. /** @hidden */
  71399. onLoading(): void;
  71400. /** @hidden */
  71401. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  71402. /** @hidden */
  71403. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  71404. /** @hidden */
  71405. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  71406. private _loadClipAsync;
  71407. private _loadEmitterAsync;
  71408. private _getEventAction;
  71409. private _loadAnimationEventAsync;
  71410. }
  71411. }
  71412. declare module BABYLON.GLTF2.Loader.Extensions {
  71413. /**
  71414. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  71415. */
  71416. export class MSFT_lod implements IGLTFLoaderExtension {
  71417. /**
  71418. * The name of this extension.
  71419. */
  71420. readonly name: string;
  71421. /**
  71422. * Defines whether this extension is enabled.
  71423. */
  71424. enabled: boolean;
  71425. /**
  71426. * Defines a number that determines the order the extensions are applied.
  71427. */
  71428. order: number;
  71429. /**
  71430. * Maximum number of LODs to load, starting from the lowest LOD.
  71431. */
  71432. maxLODsToLoad: number;
  71433. /**
  71434. * Observable raised when all node LODs of one level are loaded.
  71435. * The event data is the index of the loaded LOD starting from zero.
  71436. * Dispose the loader to cancel the loading of the next level of LODs.
  71437. */
  71438. onNodeLODsLoadedObservable: Observable<number>;
  71439. /**
  71440. * Observable raised when all material LODs of one level are loaded.
  71441. * The event data is the index of the loaded LOD starting from zero.
  71442. * Dispose the loader to cancel the loading of the next level of LODs.
  71443. */
  71444. onMaterialLODsLoadedObservable: Observable<number>;
  71445. private _loader;
  71446. private _nodeIndexLOD;
  71447. private _nodeSignalLODs;
  71448. private _nodePromiseLODs;
  71449. private _materialIndexLOD;
  71450. private _materialSignalLODs;
  71451. private _materialPromiseLODs;
  71452. private _indexLOD;
  71453. private _bufferLODs;
  71454. /** @hidden */
  71455. constructor(loader: GLTFLoader);
  71456. /** @hidden */
  71457. dispose(): void;
  71458. /** @hidden */
  71459. onReady(): void;
  71460. /** @hidden */
  71461. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  71462. /** @hidden */
  71463. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  71464. /** @hidden */
  71465. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  71466. /** @hidden */
  71467. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  71468. private _loadBufferLOD;
  71469. /**
  71470. * Gets an array of LOD properties from lowest to highest.
  71471. */
  71472. private _getLODs;
  71473. private _disposeUnusedMaterials;
  71474. }
  71475. }
  71476. declare module BABYLON.GLTF2.Loader.Extensions {
  71477. /** @hidden */
  71478. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  71479. readonly name: string;
  71480. enabled: boolean;
  71481. private _loader;
  71482. constructor(loader: GLTFLoader);
  71483. dispose(): void;
  71484. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  71485. }
  71486. }
  71487. declare module BABYLON.GLTF2.Loader.Extensions {
  71488. /** @hidden */
  71489. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  71490. readonly name: string;
  71491. enabled: boolean;
  71492. private _loader;
  71493. constructor(loader: GLTFLoader);
  71494. dispose(): void;
  71495. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  71496. }
  71497. }
  71498. declare module BABYLON.GLTF2.Loader.Extensions {
  71499. /**
  71500. * Store glTF extras (if present) in BJS objects' metadata
  71501. */
  71502. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  71503. /**
  71504. * The name of this extension.
  71505. */
  71506. readonly name: string;
  71507. /**
  71508. * Defines whether this extension is enabled.
  71509. */
  71510. enabled: boolean;
  71511. private _loader;
  71512. private _assignExtras;
  71513. /** @hidden */
  71514. constructor(loader: GLTFLoader);
  71515. /** @hidden */
  71516. dispose(): void;
  71517. /** @hidden */
  71518. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  71519. /** @hidden */
  71520. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  71521. /** @hidden */
  71522. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  71523. }
  71524. }
  71525. declare module BABYLON {
  71526. /**
  71527. * Class reading and parsing the MTL file bundled with the obj file.
  71528. */
  71529. export class MTLFileLoader {
  71530. /**
  71531. * All material loaded from the mtl will be set here
  71532. */
  71533. materials: StandardMaterial[];
  71534. /**
  71535. * This function will read the mtl file and create each material described inside
  71536. * This function could be improve by adding :
  71537. * -some component missing (Ni, Tf...)
  71538. * -including the specific options available
  71539. *
  71540. * @param scene defines the scene the material will be created in
  71541. * @param data defines the mtl data to parse
  71542. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  71543. */
  71544. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  71545. /**
  71546. * Gets the texture for the material.
  71547. *
  71548. * If the material is imported from input file,
  71549. * We sanitize the url to ensure it takes the textre from aside the material.
  71550. *
  71551. * @param rootUrl The root url to load from
  71552. * @param value The value stored in the mtl
  71553. * @return The Texture
  71554. */
  71555. private static _getTexture;
  71556. }
  71557. /**
  71558. * Options for loading OBJ/MTL files
  71559. */
  71560. type MeshLoadOptions = {
  71561. /**
  71562. * Defines if UVs are optimized by default during load.
  71563. */
  71564. OptimizeWithUV: boolean;
  71565. /**
  71566. * Defines custom scaling of UV coordinates of loaded meshes.
  71567. */
  71568. UVScaling: Vector2;
  71569. /**
  71570. * Invert model on y-axis (does a model scaling inversion)
  71571. */
  71572. InvertY: boolean;
  71573. /**
  71574. * Invert Y-Axis of referenced textures on load
  71575. */
  71576. InvertTextureY: boolean;
  71577. /**
  71578. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  71579. */
  71580. ImportVertexColors: boolean;
  71581. /**
  71582. * Compute the normals for the model, even if normals are present in the file.
  71583. */
  71584. ComputeNormals: boolean;
  71585. /**
  71586. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  71587. */
  71588. SkipMaterials: boolean;
  71589. /**
  71590. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  71591. */
  71592. MaterialLoadingFailsSilently: boolean;
  71593. };
  71594. /**
  71595. * OBJ file type loader.
  71596. * This is a babylon scene loader plugin.
  71597. */
  71598. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  71599. /**
  71600. * Defines if UVs are optimized by default during load.
  71601. */
  71602. static OPTIMIZE_WITH_UV: boolean;
  71603. /**
  71604. * Invert model on y-axis (does a model scaling inversion)
  71605. */
  71606. static INVERT_Y: boolean;
  71607. /**
  71608. * Invert Y-Axis of referenced textures on load
  71609. */
  71610. static INVERT_TEXTURE_Y: boolean;
  71611. /**
  71612. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  71613. */
  71614. static IMPORT_VERTEX_COLORS: boolean;
  71615. /**
  71616. * Compute the normals for the model, even if normals are present in the file.
  71617. */
  71618. static COMPUTE_NORMALS: boolean;
  71619. /**
  71620. * Defines custom scaling of UV coordinates of loaded meshes.
  71621. */
  71622. static UV_SCALING: Vector2;
  71623. /**
  71624. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  71625. */
  71626. static SKIP_MATERIALS: boolean;
  71627. /**
  71628. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  71629. *
  71630. * Defaults to true for backwards compatibility.
  71631. */
  71632. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  71633. /**
  71634. * Defines the name of the plugin.
  71635. */
  71636. name: string;
  71637. /**
  71638. * Defines the extension the plugin is able to load.
  71639. */
  71640. extensions: string;
  71641. /** @hidden */
  71642. obj: RegExp;
  71643. /** @hidden */
  71644. group: RegExp;
  71645. /** @hidden */
  71646. mtllib: RegExp;
  71647. /** @hidden */
  71648. usemtl: RegExp;
  71649. /** @hidden */
  71650. smooth: RegExp;
  71651. /** @hidden */
  71652. vertexPattern: RegExp;
  71653. /** @hidden */
  71654. normalPattern: RegExp;
  71655. /** @hidden */
  71656. uvPattern: RegExp;
  71657. /** @hidden */
  71658. facePattern1: RegExp;
  71659. /** @hidden */
  71660. facePattern2: RegExp;
  71661. /** @hidden */
  71662. facePattern3: RegExp;
  71663. /** @hidden */
  71664. facePattern4: RegExp;
  71665. /** @hidden */
  71666. facePattern5: RegExp;
  71667. private _meshLoadOptions;
  71668. /**
  71669. * Creates loader for .OBJ files
  71670. *
  71671. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  71672. */
  71673. constructor(meshLoadOptions?: MeshLoadOptions);
  71674. private static readonly currentMeshLoadOptions;
  71675. /**
  71676. * Calls synchronously the MTL file attached to this obj.
  71677. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  71678. * Without this function materials are not displayed in the first frame (but displayed after).
  71679. * In consequence it is impossible to get material information in your HTML file
  71680. *
  71681. * @param url The URL of the MTL file
  71682. * @param rootUrl
  71683. * @param onSuccess Callback function to be called when the MTL file is loaded
  71684. * @private
  71685. */
  71686. private _loadMTL;
  71687. /**
  71688. * Instantiates a OBJ file loader plugin.
  71689. * @returns the created plugin
  71690. */
  71691. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  71692. /**
  71693. * If the data string can be loaded directly.
  71694. *
  71695. * @param data string containing the file data
  71696. * @returns if the data can be loaded directly
  71697. */
  71698. canDirectLoad(data: string): boolean;
  71699. /**
  71700. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  71701. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  71702. * @param scene the scene the meshes should be added to
  71703. * @param data the OBJ data to load
  71704. * @param rootUrl root url to load from
  71705. * @param onProgress event that fires when loading progress has occured
  71706. * @param fileName Defines the name of the file to load
  71707. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  71708. */
  71709. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  71710. meshes: AbstractMesh[];
  71711. particleSystems: IParticleSystem[];
  71712. skeletons: Skeleton[];
  71713. animationGroups: AnimationGroup[];
  71714. }>;
  71715. /**
  71716. * Imports all objects from the loaded OBJ data and adds them to the scene
  71717. * @param scene the scene the objects should be added to
  71718. * @param data the OBJ data to load
  71719. * @param rootUrl root url to load from
  71720. * @param onProgress event that fires when loading progress has occured
  71721. * @param fileName Defines the name of the file to load
  71722. * @returns a promise which completes when objects have been loaded to the scene
  71723. */
  71724. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  71725. /**
  71726. * Load into an asset container.
  71727. * @param scene The scene to load into
  71728. * @param data The data to import
  71729. * @param rootUrl The root url for scene and resources
  71730. * @param onProgress The callback when the load progresses
  71731. * @param fileName Defines the name of the file to load
  71732. * @returns The loaded asset container
  71733. */
  71734. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  71735. /**
  71736. * Read the OBJ file and create an Array of meshes.
  71737. * Each mesh contains all information given by the OBJ and the MTL file.
  71738. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  71739. *
  71740. * @param meshesNames
  71741. * @param scene Scene The scene where are displayed the data
  71742. * @param data String The content of the obj file
  71743. * @param rootUrl String The path to the folder
  71744. * @returns Array<AbstractMesh>
  71745. * @private
  71746. */
  71747. private _parseSolid;
  71748. }
  71749. }
  71750. declare module BABYLON {
  71751. /**
  71752. * STL file type loader.
  71753. * This is a babylon scene loader plugin.
  71754. */
  71755. export class STLFileLoader implements ISceneLoaderPlugin {
  71756. /** @hidden */
  71757. solidPattern: RegExp;
  71758. /** @hidden */
  71759. facetsPattern: RegExp;
  71760. /** @hidden */
  71761. normalPattern: RegExp;
  71762. /** @hidden */
  71763. vertexPattern: RegExp;
  71764. /**
  71765. * Defines the name of the plugin.
  71766. */
  71767. name: string;
  71768. /**
  71769. * Defines the extensions the stl loader is able to load.
  71770. * force data to come in as an ArrayBuffer
  71771. * we'll convert to string if it looks like it's an ASCII .stl
  71772. */
  71773. extensions: ISceneLoaderPluginExtensions;
  71774. /**
  71775. * Import meshes into a scene.
  71776. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  71777. * @param scene The scene to import into
  71778. * @param data The data to import
  71779. * @param rootUrl The root url for scene and resources
  71780. * @param meshes The meshes array to import into
  71781. * @param particleSystems The particle systems array to import into
  71782. * @param skeletons The skeletons array to import into
  71783. * @param onError The callback when import fails
  71784. * @returns True if successful or false otherwise
  71785. */
  71786. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  71787. /**
  71788. * Load into a scene.
  71789. * @param scene The scene to load into
  71790. * @param data The data to import
  71791. * @param rootUrl The root url for scene and resources
  71792. * @param onError The callback when import fails
  71793. * @returns true if successful or false otherwise
  71794. */
  71795. load(scene: Scene, data: any, rootUrl: string): boolean;
  71796. /**
  71797. * Load into an asset container.
  71798. * @param scene The scene to load into
  71799. * @param data The data to import
  71800. * @param rootUrl The root url for scene and resources
  71801. * @param onError The callback when import fails
  71802. * @returns The loaded asset container
  71803. */
  71804. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  71805. private _isBinary;
  71806. private _parseBinary;
  71807. private _parseASCII;
  71808. }
  71809. }
  71810. declare module BABYLON {
  71811. /**
  71812. * Class for generating OBJ data from a Babylon scene.
  71813. */
  71814. export class OBJExport {
  71815. /**
  71816. * Exports the geometry of a Mesh array in .OBJ file format (text)
  71817. * @param mesh defines the list of meshes to serialize
  71818. * @param materials defines if materials should be exported
  71819. * @param matlibname defines the name of the associated mtl file
  71820. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  71821. * @returns the OBJ content
  71822. */
  71823. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  71824. /**
  71825. * Exports the material(s) of a mesh in .MTL file format (text)
  71826. * @param mesh defines the mesh to extract the material from
  71827. * @returns the mtl content
  71828. */
  71829. static MTL(mesh: Mesh): string;
  71830. }
  71831. }
  71832. declare module BABYLON {
  71833. /** @hidden */
  71834. export var __IGLTFExporterExtension: number;
  71835. /**
  71836. * Interface for extending the exporter
  71837. * @hidden
  71838. */
  71839. export interface IGLTFExporterExtension {
  71840. /**
  71841. * The name of this extension
  71842. */
  71843. readonly name: string;
  71844. /**
  71845. * Defines whether this extension is enabled
  71846. */
  71847. enabled: boolean;
  71848. /**
  71849. * Defines whether this extension is required
  71850. */
  71851. required: boolean;
  71852. }
  71853. }
  71854. declare module BABYLON.GLTF2.Exporter {
  71855. /** @hidden */
  71856. export var __IGLTFExporterExtensionV2: number;
  71857. /**
  71858. * Interface for a glTF exporter extension
  71859. * @hidden
  71860. */
  71861. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  71862. /**
  71863. * Define this method to modify the default behavior before exporting a texture
  71864. * @param context The context when loading the asset
  71865. * @param babylonTexture The Babylon.js texture
  71866. * @param mimeType The mime-type of the generated image
  71867. * @returns A promise that resolves with the exported texture
  71868. */
  71869. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  71870. /**
  71871. * Define this method to get notified when a texture info is created
  71872. * @param context The context when loading the asset
  71873. * @param textureInfo The glTF texture info
  71874. * @param babylonTexture The Babylon.js texture
  71875. */
  71876. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  71877. /**
  71878. * Define this method to modify the default behavior when exporting texture info
  71879. * @param context The context when loading the asset
  71880. * @param meshPrimitive glTF mesh primitive
  71881. * @param babylonSubMesh Babylon submesh
  71882. * @param binaryWriter glTF serializer binary writer instance
  71883. * @returns nullable IMeshPrimitive promise
  71884. */
  71885. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  71886. /**
  71887. * Define this method to modify the default behavior when exporting a node
  71888. * @param context The context when exporting the node
  71889. * @param node glTF node
  71890. * @param babylonNode BabylonJS node
  71891. * @returns nullable INode promise
  71892. */
  71893. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Promise<INode>;
  71894. /**
  71895. * Define this method to modify the default behavior when exporting a material
  71896. * @param material glTF material
  71897. * @param babylonMaterial BabylonJS material
  71898. * @returns nullable IMaterial promise
  71899. */
  71900. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  71901. /**
  71902. * Define this method to return additional textures to export from a material
  71903. * @param material glTF material
  71904. * @param babylonMaterial BabylonJS material
  71905. * @returns List of textures
  71906. */
  71907. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  71908. /** Gets a boolean indicating that this extension was used */
  71909. wasUsed: boolean;
  71910. /** Gets a boolean indicating that this extension is required for the file to work */
  71911. required: boolean;
  71912. /**
  71913. * Called after the exporter state changes to EXPORTING
  71914. */
  71915. onExporting?(): void;
  71916. }
  71917. }
  71918. declare module BABYLON.GLTF2.Exporter {
  71919. /**
  71920. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  71921. * @hidden
  71922. */
  71923. export class _GLTFMaterialExporter {
  71924. /**
  71925. * Represents the dielectric specular values for R, G and B
  71926. */
  71927. private static readonly _DielectricSpecular;
  71928. /**
  71929. * Allows the maximum specular power to be defined for material calculations
  71930. */
  71931. private static readonly _MaxSpecularPower;
  71932. /**
  71933. * Mapping to store textures
  71934. */
  71935. private _textureMap;
  71936. /**
  71937. * Numeric tolerance value
  71938. */
  71939. private static readonly _Epsilon;
  71940. /**
  71941. * Reference to the glTF Exporter
  71942. */
  71943. private _exporter;
  71944. constructor(exporter: _Exporter);
  71945. /**
  71946. * Specifies if two colors are approximately equal in value
  71947. * @param color1 first color to compare to
  71948. * @param color2 second color to compare to
  71949. * @param epsilon threshold value
  71950. */
  71951. private static FuzzyEquals;
  71952. /**
  71953. * Gets the materials from a Babylon scene and converts them to glTF materials
  71954. * @param scene babylonjs scene
  71955. * @param mimeType texture mime type
  71956. * @param images array of images
  71957. * @param textures array of textures
  71958. * @param materials array of materials
  71959. * @param imageData mapping of texture names to base64 textures
  71960. * @param hasTextureCoords specifies if texture coordinates are present on the material
  71961. */
  71962. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  71963. /**
  71964. * Makes a copy of the glTF material without the texture parameters
  71965. * @param originalMaterial original glTF material
  71966. * @returns glTF material without texture parameters
  71967. */
  71968. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  71969. /**
  71970. * Specifies if the material has any texture parameters present
  71971. * @param material glTF Material
  71972. * @returns boolean specifying if texture parameters are present
  71973. */
  71974. _hasTexturesPresent(material: IMaterial): boolean;
  71975. /**
  71976. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  71977. * @param babylonStandardMaterial
  71978. * @returns glTF Metallic Roughness Material representation
  71979. */
  71980. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  71981. /**
  71982. * Computes the metallic factor
  71983. * @param diffuse diffused value
  71984. * @param specular specular value
  71985. * @param oneMinusSpecularStrength one minus the specular strength
  71986. * @returns metallic value
  71987. */
  71988. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  71989. /**
  71990. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  71991. * @param glTFMaterial glTF material
  71992. * @param babylonMaterial Babylon material
  71993. */
  71994. private static _SetAlphaMode;
  71995. /**
  71996. * Converts a Babylon Standard Material to a glTF Material
  71997. * @param babylonStandardMaterial BJS Standard Material
  71998. * @param mimeType mime type to use for the textures
  71999. * @param images array of glTF image interfaces
  72000. * @param textures array of glTF texture interfaces
  72001. * @param materials array of glTF material interfaces
  72002. * @param imageData map of image file name to data
  72003. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  72004. */
  72005. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  72006. private _finishMaterial;
  72007. /**
  72008. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  72009. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  72010. * @param mimeType mime type to use for the textures
  72011. * @param images array of glTF image interfaces
  72012. * @param textures array of glTF texture interfaces
  72013. * @param materials array of glTF material interfaces
  72014. * @param imageData map of image file name to data
  72015. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  72016. */
  72017. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  72018. /**
  72019. * Converts an image typed array buffer to a base64 image
  72020. * @param buffer typed array buffer
  72021. * @param width width of the image
  72022. * @param height height of the image
  72023. * @param mimeType mimetype of the image
  72024. * @returns base64 image string
  72025. */
  72026. private _createBase64FromCanvasAsync;
  72027. /**
  72028. * Generates a white texture based on the specified width and height
  72029. * @param width width of the texture in pixels
  72030. * @param height height of the texture in pixels
  72031. * @param scene babylonjs scene
  72032. * @returns white texture
  72033. */
  72034. private _createWhiteTexture;
  72035. /**
  72036. * 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
  72037. * @param texture1 first texture to resize
  72038. * @param texture2 second texture to resize
  72039. * @param scene babylonjs scene
  72040. * @returns resized textures or null
  72041. */
  72042. private _resizeTexturesToSameDimensions;
  72043. /**
  72044. * Converts an array of pixels to a Float32Array
  72045. * Throws an error if the pixel format is not supported
  72046. * @param pixels - array buffer containing pixel values
  72047. * @returns Float32 of pixels
  72048. */
  72049. private _convertPixelArrayToFloat32;
  72050. /**
  72051. * Convert Specular Glossiness Textures to Metallic Roughness
  72052. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  72053. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  72054. * @param diffuseTexture texture used to store diffuse information
  72055. * @param specularGlossinessTexture texture used to store specular and glossiness information
  72056. * @param factors specular glossiness material factors
  72057. * @param mimeType the mime type to use for the texture
  72058. * @returns pbr metallic roughness interface or null
  72059. */
  72060. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  72061. /**
  72062. * Converts specular glossiness material properties to metallic roughness
  72063. * @param specularGlossiness interface with specular glossiness material properties
  72064. * @returns interface with metallic roughness material properties
  72065. */
  72066. private _convertSpecularGlossinessToMetallicRoughness;
  72067. /**
  72068. * Calculates the surface reflectance, independent of lighting conditions
  72069. * @param color Color source to calculate brightness from
  72070. * @returns number representing the perceived brightness, or zero if color is undefined
  72071. */
  72072. private _getPerceivedBrightness;
  72073. /**
  72074. * Returns the maximum color component value
  72075. * @param color
  72076. * @returns maximum color component value, or zero if color is null or undefined
  72077. */
  72078. private _getMaxComponent;
  72079. /**
  72080. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  72081. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  72082. * @param mimeType mime type to use for the textures
  72083. * @param images array of glTF image interfaces
  72084. * @param textures array of glTF texture interfaces
  72085. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  72086. * @param imageData map of image file name to data
  72087. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  72088. * @returns glTF PBR Metallic Roughness factors
  72089. */
  72090. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  72091. private _getGLTFTextureSampler;
  72092. private _getGLTFTextureWrapMode;
  72093. private _getGLTFTextureWrapModesSampler;
  72094. /**
  72095. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  72096. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  72097. * @param mimeType mime type to use for the textures
  72098. * @param images array of glTF image interfaces
  72099. * @param textures array of glTF texture interfaces
  72100. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  72101. * @param imageData map of image file name to data
  72102. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  72103. * @returns glTF PBR Metallic Roughness factors
  72104. */
  72105. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  72106. /**
  72107. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  72108. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  72109. * @param mimeType mime type to use for the textures
  72110. * @param images array of glTF image interfaces
  72111. * @param textures array of glTF texture interfaces
  72112. * @param materials array of glTF material interfaces
  72113. * @param imageData map of image file name to data
  72114. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  72115. */
  72116. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  72117. private setMetallicRoughnessPbrMaterial;
  72118. private getPixelsFromTexture;
  72119. /**
  72120. * Extracts a texture from a Babylon texture into file data and glTF data
  72121. * @param babylonTexture Babylon texture to extract
  72122. * @param mimeType Mime Type of the babylonTexture
  72123. * @return glTF texture info, or null if the texture format is not supported
  72124. */
  72125. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  72126. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  72127. /**
  72128. * Builds a texture from base64 string
  72129. * @param base64Texture base64 texture string
  72130. * @param baseTextureName Name to use for the texture
  72131. * @param mimeType image mime type for the texture
  72132. * @param images array of images
  72133. * @param textures array of textures
  72134. * @param imageData map of image data
  72135. * @returns glTF texture info, or null if the texture format is not supported
  72136. */
  72137. private _getTextureInfoFromBase64;
  72138. }
  72139. }
  72140. declare module BABYLON {
  72141. /**
  72142. * Class for holding and downloading glTF file data
  72143. */
  72144. export class GLTFData {
  72145. /**
  72146. * Object which contains the file name as the key and its data as the value
  72147. */
  72148. glTFFiles: {
  72149. [fileName: string]: string | Blob;
  72150. };
  72151. /**
  72152. * Initializes the glTF file object
  72153. */
  72154. constructor();
  72155. /**
  72156. * Downloads the glTF data as files based on their names and data
  72157. */
  72158. downloadFiles(): void;
  72159. }
  72160. }
  72161. declare module BABYLON {
  72162. /**
  72163. * Holds a collection of exporter options and parameters
  72164. */
  72165. export interface IExportOptions {
  72166. /**
  72167. * Function which indicates whether a babylon node should be exported or not
  72168. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  72169. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  72170. */
  72171. shouldExportNode?(node: Node): boolean;
  72172. /**
  72173. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  72174. * @param metadata source metadata to read from
  72175. * @returns the data to store to glTF node extras
  72176. */
  72177. metadataSelector?(metadata: any): any;
  72178. /**
  72179. * The sample rate to bake animation curves
  72180. */
  72181. animationSampleRate?: number;
  72182. /**
  72183. * Begin serialization without waiting for the scene to be ready
  72184. */
  72185. exportWithoutWaitingForScene?: boolean;
  72186. }
  72187. /**
  72188. * Class for generating glTF data from a Babylon scene.
  72189. */
  72190. export class GLTF2Export {
  72191. /**
  72192. * Exports the geometry of the scene to .gltf file format asynchronously
  72193. * @param scene Babylon scene with scene hierarchy information
  72194. * @param filePrefix File prefix to use when generating the glTF file
  72195. * @param options Exporter options
  72196. * @returns Returns an object with a .gltf file and associates texture names
  72197. * as keys and their data and paths as values
  72198. */
  72199. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  72200. private static _PreExportAsync;
  72201. private static _PostExportAsync;
  72202. /**
  72203. * Exports the geometry of the scene to .glb file format asychronously
  72204. * @param scene Babylon scene with scene hierarchy information
  72205. * @param filePrefix File prefix to use when generating glb file
  72206. * @param options Exporter options
  72207. * @returns Returns an object with a .glb filename as key and data as value
  72208. */
  72209. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  72210. }
  72211. }
  72212. declare module BABYLON.GLTF2.Exporter {
  72213. /**
  72214. * @hidden
  72215. */
  72216. export class _GLTFUtilities {
  72217. /**
  72218. * Creates a buffer view based on the supplied arguments
  72219. * @param bufferIndex index value of the specified buffer
  72220. * @param byteOffset byte offset value
  72221. * @param byteLength byte length of the bufferView
  72222. * @param byteStride byte distance between conequential elements
  72223. * @param name name of the buffer view
  72224. * @returns bufferView for glTF
  72225. */
  72226. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  72227. /**
  72228. * Creates an accessor based on the supplied arguments
  72229. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  72230. * @param name The name of the accessor
  72231. * @param type The type of the accessor
  72232. * @param componentType The datatype of components in the attribute
  72233. * @param count The number of attributes referenced by this accessor
  72234. * @param byteOffset The offset relative to the start of the bufferView in bytes
  72235. * @param min Minimum value of each component in this attribute
  72236. * @param max Maximum value of each component in this attribute
  72237. * @returns accessor for glTF
  72238. */
  72239. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  72240. /**
  72241. * Calculates the minimum and maximum values of an array of position floats
  72242. * @param positions Positions array of a mesh
  72243. * @param vertexStart Starting vertex offset to calculate min and max values
  72244. * @param vertexCount Number of vertices to check for min and max values
  72245. * @returns min number array and max number array
  72246. */
  72247. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  72248. min: number[];
  72249. max: number[];
  72250. };
  72251. /**
  72252. * Converts a new right-handed Vector3
  72253. * @param vector vector3 array
  72254. * @returns right-handed Vector3
  72255. */
  72256. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  72257. /**
  72258. * Converts a Vector3 to right-handed
  72259. * @param vector Vector3 to convert to right-handed
  72260. */
  72261. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  72262. /**
  72263. * Converts a three element number array to right-handed
  72264. * @param vector number array to convert to right-handed
  72265. */
  72266. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  72267. /**
  72268. * Converts a new right-handed Vector3
  72269. * @param vector vector3 array
  72270. * @returns right-handed Vector3
  72271. */
  72272. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  72273. /**
  72274. * Converts a Vector3 to right-handed
  72275. * @param vector Vector3 to convert to right-handed
  72276. */
  72277. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  72278. /**
  72279. * Converts a three element number array to right-handed
  72280. * @param vector number array to convert to right-handed
  72281. */
  72282. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  72283. /**
  72284. * Converts a Vector4 to right-handed
  72285. * @param vector Vector4 to convert to right-handed
  72286. */
  72287. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  72288. /**
  72289. * Converts a Vector4 to right-handed
  72290. * @param vector Vector4 to convert to right-handed
  72291. */
  72292. static _GetRightHandedArray4FromRef(vector: number[]): void;
  72293. /**
  72294. * Converts a Quaternion to right-handed
  72295. * @param quaternion Source quaternion to convert to right-handed
  72296. */
  72297. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  72298. /**
  72299. * Converts a Quaternion to right-handed
  72300. * @param quaternion Source quaternion to convert to right-handed
  72301. */
  72302. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  72303. static _NormalizeTangentFromRef(tangent: Vector4): void;
  72304. }
  72305. }
  72306. declare module BABYLON.GLTF2.Exporter {
  72307. /**
  72308. * Converts Babylon Scene into glTF 2.0.
  72309. * @hidden
  72310. */
  72311. export class _Exporter {
  72312. /**
  72313. * Stores the glTF to export
  72314. */
  72315. _glTF: IGLTF;
  72316. /**
  72317. * Stores all generated buffer views, which represents views into the main glTF buffer data
  72318. */
  72319. _bufferViews: IBufferView[];
  72320. /**
  72321. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  72322. */
  72323. _accessors: IAccessor[];
  72324. /**
  72325. * Stores all the generated nodes, which contains transform and/or mesh information per node
  72326. */
  72327. private _nodes;
  72328. /**
  72329. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  72330. */
  72331. private _scenes;
  72332. /**
  72333. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  72334. */
  72335. private _meshes;
  72336. /**
  72337. * Stores all the generated material information, which represents the appearance of each primitive
  72338. */
  72339. _materials: IMaterial[];
  72340. _materialMap: {
  72341. [materialID: number]: number;
  72342. };
  72343. /**
  72344. * Stores all the generated texture information, which is referenced by glTF materials
  72345. */
  72346. _textures: ITexture[];
  72347. /**
  72348. * Stores all the generated image information, which is referenced by glTF textures
  72349. */
  72350. _images: IImage[];
  72351. /**
  72352. * Stores all the texture samplers
  72353. */
  72354. _samplers: ISampler[];
  72355. /**
  72356. * Stores all the generated animation samplers, which is referenced by glTF animations
  72357. */
  72358. /**
  72359. * Stores the animations for glTF models
  72360. */
  72361. private _animations;
  72362. /**
  72363. * Stores the total amount of bytes stored in the glTF buffer
  72364. */
  72365. private _totalByteLength;
  72366. /**
  72367. * Stores a reference to the Babylon scene containing the source geometry and material information
  72368. */
  72369. _babylonScene: Scene;
  72370. /**
  72371. * Stores a map of the image data, where the key is the file name and the value
  72372. * is the image data
  72373. */
  72374. _imageData: {
  72375. [fileName: string]: {
  72376. data: Uint8Array;
  72377. mimeType: ImageMimeType;
  72378. };
  72379. };
  72380. /**
  72381. * Stores a map of the unique id of a node to its index in the node array
  72382. */
  72383. private _nodeMap;
  72384. /**
  72385. * Specifies if the Babylon scene should be converted to right-handed on export
  72386. */
  72387. _convertToRightHandedSystem: boolean;
  72388. /**
  72389. * Baked animation sample rate
  72390. */
  72391. private _animationSampleRate;
  72392. private _options;
  72393. private _localEngine;
  72394. _glTFMaterialExporter: _GLTFMaterialExporter;
  72395. private _extensions;
  72396. private static _ExtensionNames;
  72397. private static _ExtensionFactories;
  72398. private _applyExtension;
  72399. private _applyExtensions;
  72400. _extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  72401. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  72402. _extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Promise<Nullable<INode>>;
  72403. _extensionsPostExportMaterialAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  72404. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  72405. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  72406. private _forEachExtensions;
  72407. private _extensionsOnExporting;
  72408. /**
  72409. * Load glTF serializer extensions
  72410. */
  72411. private _loadExtensions;
  72412. /**
  72413. * Creates a glTF Exporter instance, which can accept optional exporter options
  72414. * @param babylonScene Babylon scene object
  72415. * @param options Options to modify the behavior of the exporter
  72416. */
  72417. constructor(babylonScene: Scene, options?: IExportOptions);
  72418. dispose(): void;
  72419. /**
  72420. * Registers a glTF exporter extension
  72421. * @param name Name of the extension to export
  72422. * @param factory The factory function that creates the exporter extension
  72423. */
  72424. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  72425. /**
  72426. * Un-registers an exporter extension
  72427. * @param name The name fo the exporter extension
  72428. * @returns A boolean indicating whether the extension has been un-registered
  72429. */
  72430. static UnregisterExtension(name: string): boolean;
  72431. /**
  72432. * Lazy load a local engine with premultiplied alpha set to false
  72433. */
  72434. _getLocalEngine(): Engine;
  72435. private reorderIndicesBasedOnPrimitiveMode;
  72436. /**
  72437. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  72438. * clock-wise during export to glTF
  72439. * @param submesh BabylonJS submesh
  72440. * @param primitiveMode Primitive mode of the mesh
  72441. * @param sideOrientation the winding order of the submesh
  72442. * @param vertexBufferKind The type of vertex attribute
  72443. * @param meshAttributeArray The vertex attribute data
  72444. * @param byteOffset The offset to the binary data
  72445. * @param binaryWriter The binary data for the glTF file
  72446. */
  72447. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  72448. /**
  72449. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  72450. * clock-wise during export to glTF
  72451. * @param submesh BabylonJS submesh
  72452. * @param primitiveMode Primitive mode of the mesh
  72453. * @param sideOrientation the winding order of the submesh
  72454. * @param vertexBufferKind The type of vertex attribute
  72455. * @param meshAttributeArray The vertex attribute data
  72456. * @param byteOffset The offset to the binary data
  72457. * @param binaryWriter The binary data for the glTF file
  72458. */
  72459. private reorderTriangleFillMode;
  72460. /**
  72461. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  72462. * clock-wise during export to glTF
  72463. * @param submesh BabylonJS submesh
  72464. * @param primitiveMode Primitive mode of the mesh
  72465. * @param sideOrientation the winding order of the submesh
  72466. * @param vertexBufferKind The type of vertex attribute
  72467. * @param meshAttributeArray The vertex attribute data
  72468. * @param byteOffset The offset to the binary data
  72469. * @param binaryWriter The binary data for the glTF file
  72470. */
  72471. private reorderTriangleStripDrawMode;
  72472. /**
  72473. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  72474. * clock-wise during export to glTF
  72475. * @param submesh BabylonJS submesh
  72476. * @param primitiveMode Primitive mode of the mesh
  72477. * @param sideOrientation the winding order of the submesh
  72478. * @param vertexBufferKind The type of vertex attribute
  72479. * @param meshAttributeArray The vertex attribute data
  72480. * @param byteOffset The offset to the binary data
  72481. * @param binaryWriter The binary data for the glTF file
  72482. */
  72483. private reorderTriangleFanMode;
  72484. /**
  72485. * Writes the vertex attribute data to binary
  72486. * @param vertices The vertices to write to the binary writer
  72487. * @param byteOffset The offset into the binary writer to overwrite binary data
  72488. * @param vertexAttributeKind The vertex attribute type
  72489. * @param meshAttributeArray The vertex attribute data
  72490. * @param binaryWriter The writer containing the binary data
  72491. */
  72492. private writeVertexAttributeData;
  72493. /**
  72494. * Writes mesh attribute data to a data buffer
  72495. * Returns the bytelength of the data
  72496. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  72497. * @param meshAttributeArray Array containing the attribute data
  72498. * @param binaryWriter The buffer to write the binary data to
  72499. * @param indices Used to specify the order of the vertex data
  72500. */
  72501. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  72502. /**
  72503. * Generates glTF json data
  72504. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  72505. * @param glTFPrefix Text to use when prefixing a glTF file
  72506. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  72507. * @returns json data as string
  72508. */
  72509. private generateJSON;
  72510. /**
  72511. * Generates data for .gltf and .bin files based on the glTF prefix string
  72512. * @param glTFPrefix Text to use when prefixing a glTF file
  72513. * @param dispose Dispose the exporter
  72514. * @returns GLTFData with glTF file data
  72515. */
  72516. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  72517. /**
  72518. * Creates a binary buffer for glTF
  72519. * @returns array buffer for binary data
  72520. */
  72521. private _generateBinaryAsync;
  72522. /**
  72523. * Pads the number to a multiple of 4
  72524. * @param num number to pad
  72525. * @returns padded number
  72526. */
  72527. private _getPadding;
  72528. /**
  72529. * @hidden
  72530. */
  72531. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  72532. /**
  72533. * Sets the TRS for each node
  72534. * @param node glTF Node for storing the transformation data
  72535. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  72536. */
  72537. private setNodeTransformation;
  72538. private getVertexBufferFromMesh;
  72539. /**
  72540. * Creates a bufferview based on the vertices type for the Babylon mesh
  72541. * @param kind Indicates the type of vertices data
  72542. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  72543. * @param binaryWriter The buffer to write the bufferview data to
  72544. */
  72545. private createBufferViewKind;
  72546. /**
  72547. * The primitive mode of the Babylon mesh
  72548. * @param babylonMesh The BabylonJS mesh
  72549. */
  72550. private getMeshPrimitiveMode;
  72551. /**
  72552. * Sets the primitive mode of the glTF mesh primitive
  72553. * @param meshPrimitive glTF mesh primitive
  72554. * @param primitiveMode The primitive mode
  72555. */
  72556. private setPrimitiveMode;
  72557. /**
  72558. * Sets the vertex attribute accessor based of the glTF mesh primitive
  72559. * @param meshPrimitive glTF mesh primitive
  72560. * @param attributeKind vertex attribute
  72561. * @returns boolean specifying if uv coordinates are present
  72562. */
  72563. private setAttributeKind;
  72564. /**
  72565. * Sets data for the primitive attributes of each submesh
  72566. * @param mesh glTF Mesh object to store the primitive attribute information
  72567. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  72568. * @param binaryWriter Buffer to write the attribute data to
  72569. */
  72570. private setPrimitiveAttributesAsync;
  72571. /**
  72572. * Creates a glTF scene based on the array of meshes
  72573. * Returns the the total byte offset
  72574. * @param babylonScene Babylon scene to get the mesh data from
  72575. * @param binaryWriter Buffer to write binary data to
  72576. */
  72577. private createSceneAsync;
  72578. /**
  72579. * Creates a mapping of Node unique id to node index and handles animations
  72580. * @param babylonScene Babylon Scene
  72581. * @param nodes Babylon transform nodes
  72582. * @param binaryWriter Buffer to write binary data to
  72583. * @returns Node mapping of unique id to index
  72584. */
  72585. private createNodeMapAndAnimationsAsync;
  72586. /**
  72587. * Creates a glTF node from a Babylon mesh
  72588. * @param babylonMesh Source Babylon mesh
  72589. * @param binaryWriter Buffer for storing geometry data
  72590. * @returns glTF node
  72591. */
  72592. private createNodeAsync;
  72593. }
  72594. /**
  72595. * @hidden
  72596. *
  72597. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  72598. */
  72599. export class _BinaryWriter {
  72600. /**
  72601. * Array buffer which stores all binary data
  72602. */
  72603. private _arrayBuffer;
  72604. /**
  72605. * View of the array buffer
  72606. */
  72607. private _dataView;
  72608. /**
  72609. * byte offset of data in array buffer
  72610. */
  72611. private _byteOffset;
  72612. /**
  72613. * Initialize binary writer with an initial byte length
  72614. * @param byteLength Initial byte length of the array buffer
  72615. */
  72616. constructor(byteLength: number);
  72617. /**
  72618. * Resize the array buffer to the specified byte length
  72619. * @param byteLength
  72620. */
  72621. private resizeBuffer;
  72622. /**
  72623. * Get an array buffer with the length of the byte offset
  72624. * @returns ArrayBuffer resized to the byte offset
  72625. */
  72626. getArrayBuffer(): ArrayBuffer;
  72627. /**
  72628. * Get the byte offset of the array buffer
  72629. * @returns byte offset
  72630. */
  72631. getByteOffset(): number;
  72632. /**
  72633. * Stores an UInt8 in the array buffer
  72634. * @param entry
  72635. * @param byteOffset If defined, specifies where to set the value as an offset.
  72636. */
  72637. setUInt8(entry: number, byteOffset?: number): void;
  72638. /**
  72639. * Gets an UInt32 in the array buffer
  72640. * @param entry
  72641. * @param byteOffset If defined, specifies where to set the value as an offset.
  72642. */
  72643. getUInt32(byteOffset: number): number;
  72644. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  72645. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  72646. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  72647. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  72648. /**
  72649. * Stores a Float32 in the array buffer
  72650. * @param entry
  72651. */
  72652. setFloat32(entry: number, byteOffset?: number): void;
  72653. /**
  72654. * Stores an UInt32 in the array buffer
  72655. * @param entry
  72656. * @param byteOffset If defined, specifies where to set the value as an offset.
  72657. */
  72658. setUInt32(entry: number, byteOffset?: number): void;
  72659. }
  72660. }
  72661. declare module BABYLON.GLTF2.Exporter {
  72662. /**
  72663. * @hidden
  72664. * Interface to store animation data.
  72665. */
  72666. export interface _IAnimationData {
  72667. /**
  72668. * Keyframe data.
  72669. */
  72670. inputs: number[];
  72671. /**
  72672. * Value data.
  72673. */
  72674. outputs: number[][];
  72675. /**
  72676. * Animation interpolation data.
  72677. */
  72678. samplerInterpolation: AnimationSamplerInterpolation;
  72679. /**
  72680. * Minimum keyframe value.
  72681. */
  72682. inputsMin: number;
  72683. /**
  72684. * Maximum keyframe value.
  72685. */
  72686. inputsMax: number;
  72687. }
  72688. /**
  72689. * @hidden
  72690. */
  72691. export interface _IAnimationInfo {
  72692. /**
  72693. * The target channel for the animation
  72694. */
  72695. animationChannelTargetPath: AnimationChannelTargetPath;
  72696. /**
  72697. * The glTF accessor type for the data.
  72698. */
  72699. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  72700. /**
  72701. * Specifies if quaternions should be used.
  72702. */
  72703. useQuaternion: boolean;
  72704. }
  72705. /**
  72706. * @hidden
  72707. * Utility class for generating glTF animation data from BabylonJS.
  72708. */
  72709. export class _GLTFAnimation {
  72710. /**
  72711. * @ignore
  72712. *
  72713. * Creates glTF channel animation from BabylonJS animation.
  72714. * @param babylonTransformNode - BabylonJS mesh.
  72715. * @param animation - animation.
  72716. * @param animationChannelTargetPath - The target animation channel.
  72717. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  72718. * @param useQuaternion - Specifies if quaternions are used.
  72719. * @returns nullable IAnimationData
  72720. */
  72721. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  72722. private static _DeduceAnimationInfo;
  72723. /**
  72724. * @ignore
  72725. * Create node animations from the transform node animations
  72726. * @param babylonNode
  72727. * @param runtimeGLTFAnimation
  72728. * @param idleGLTFAnimations
  72729. * @param nodeMap
  72730. * @param nodes
  72731. * @param binaryWriter
  72732. * @param bufferViews
  72733. * @param accessors
  72734. * @param convertToRightHandedSystem
  72735. */
  72736. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  72737. [key: number]: number;
  72738. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  72739. /**
  72740. * @ignore
  72741. * Create node animations from the animation groups
  72742. * @param babylonScene
  72743. * @param glTFAnimations
  72744. * @param nodeMap
  72745. * @param nodes
  72746. * @param binaryWriter
  72747. * @param bufferViews
  72748. * @param accessors
  72749. * @param convertToRightHandedSystem
  72750. */
  72751. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  72752. [key: number]: number;
  72753. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  72754. private static AddAnimation;
  72755. /**
  72756. * Create a baked animation
  72757. * @param babylonTransformNode BabylonJS mesh
  72758. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  72759. * @param animationChannelTargetPath animation target channel
  72760. * @param minFrame minimum animation frame
  72761. * @param maxFrame maximum animation frame
  72762. * @param fps frames per second of the animation
  72763. * @param inputs input key frames of the animation
  72764. * @param outputs output key frame data of the animation
  72765. * @param convertToRightHandedSystem converts the values to right-handed
  72766. * @param useQuaternion specifies if quaternions should be used
  72767. */
  72768. private static _CreateBakedAnimation;
  72769. private static _ConvertFactorToVector3OrQuaternion;
  72770. private static _SetInterpolatedValue;
  72771. /**
  72772. * Creates linear animation from the animation key frames
  72773. * @param babylonTransformNode BabylonJS mesh
  72774. * @param animation BabylonJS animation
  72775. * @param animationChannelTargetPath The target animation channel
  72776. * @param frameDelta The difference between the last and first frame of the animation
  72777. * @param inputs Array to store the key frame times
  72778. * @param outputs Array to store the key frame data
  72779. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  72780. * @param useQuaternion Specifies if quaternions are used in the animation
  72781. */
  72782. private static _CreateLinearOrStepAnimation;
  72783. /**
  72784. * Creates cubic spline animation from the animation key frames
  72785. * @param babylonTransformNode BabylonJS mesh
  72786. * @param animation BabylonJS animation
  72787. * @param animationChannelTargetPath The target animation channel
  72788. * @param frameDelta The difference between the last and first frame of the animation
  72789. * @param inputs Array to store the key frame times
  72790. * @param outputs Array to store the key frame data
  72791. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  72792. * @param useQuaternion Specifies if quaternions are used in the animation
  72793. */
  72794. private static _CreateCubicSplineAnimation;
  72795. private static _GetBasePositionRotationOrScale;
  72796. /**
  72797. * Adds a key frame value
  72798. * @param keyFrame
  72799. * @param animation
  72800. * @param outputs
  72801. * @param animationChannelTargetPath
  72802. * @param basePositionRotationOrScale
  72803. * @param convertToRightHandedSystem
  72804. * @param useQuaternion
  72805. */
  72806. private static _AddKeyframeValue;
  72807. /**
  72808. * Determine the interpolation based on the key frames
  72809. * @param keyFrames
  72810. * @param animationChannelTargetPath
  72811. * @param useQuaternion
  72812. */
  72813. private static _DeduceInterpolation;
  72814. /**
  72815. * Adds an input tangent or output tangent to the output data
  72816. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  72817. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  72818. * @param outputs The animation data by keyframe
  72819. * @param animationChannelTargetPath The target animation channel
  72820. * @param interpolation The interpolation type
  72821. * @param keyFrame The key frame with the animation data
  72822. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  72823. * @param useQuaternion Specifies if quaternions are used
  72824. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  72825. */
  72826. private static AddSplineTangent;
  72827. /**
  72828. * Get the minimum and maximum key frames' frame values
  72829. * @param keyFrames animation key frames
  72830. * @returns the minimum and maximum key frame value
  72831. */
  72832. private static calculateMinMaxKeyFrames;
  72833. }
  72834. }
  72835. declare module BABYLON.GLTF2.Exporter {
  72836. /** @hidden */
  72837. export var textureTransformPixelShader: {
  72838. name: string;
  72839. shader: string;
  72840. };
  72841. }
  72842. declare module BABYLON.GLTF2.Exporter.Extensions {
  72843. /**
  72844. * @hidden
  72845. */
  72846. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  72847. private _recordedTextures;
  72848. /** Name of this extension */
  72849. readonly name: string;
  72850. /** Defines whether this extension is enabled */
  72851. enabled: boolean;
  72852. /** Defines whether this extension is required */
  72853. required: boolean;
  72854. /** Reference to the glTF exporter */
  72855. private _isUsed;
  72856. constructor(exporter: _Exporter);
  72857. dispose(): void;
  72858. /** @hidden */
  72859. readonly wasUsed: boolean;
  72860. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  72861. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  72862. /**
  72863. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  72864. * @param babylonTexture
  72865. * @param offset
  72866. * @param rotation
  72867. * @param scale
  72868. * @param scene
  72869. */
  72870. private _textureTransformTextureAsync;
  72871. }
  72872. }
  72873. declare module BABYLON.GLTF2.Exporter.Extensions {
  72874. /**
  72875. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  72876. */
  72877. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  72878. /** The name of this extension. */
  72879. readonly name: string;
  72880. /** Defines whether this extension is enabled. */
  72881. enabled: boolean;
  72882. /** Defines whether this extension is required */
  72883. required: boolean;
  72884. /** Reference to the glTF exporter */
  72885. private _exporter;
  72886. private _lights;
  72887. /** @hidden */
  72888. constructor(exporter: _Exporter);
  72889. /** @hidden */
  72890. dispose(): void;
  72891. /** @hidden */
  72892. readonly wasUsed: boolean;
  72893. /** @hidden */
  72894. onExporting(): void;
  72895. /**
  72896. * Define this method to modify the default behavior when exporting a node
  72897. * @param context The context when exporting the node
  72898. * @param node glTF node
  72899. * @param babylonNode BabylonJS node
  72900. * @returns nullable INode promise
  72901. */
  72902. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Promise<INode>;
  72903. }
  72904. }
  72905. declare module BABYLON.GLTF2.Exporter.Extensions {
  72906. /**
  72907. * @hidden
  72908. */
  72909. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  72910. /** Name of this extension */
  72911. readonly name: string;
  72912. /** Defines whether this extension is enabled */
  72913. enabled: boolean;
  72914. /** Defines whether this extension is required */
  72915. required: boolean;
  72916. /** Reference to the glTF exporter */
  72917. private _textureInfos;
  72918. private _exportedTextures;
  72919. private _wasUsed;
  72920. constructor(exporter: _Exporter);
  72921. dispose(): void;
  72922. /** @hidden */
  72923. readonly wasUsed: boolean;
  72924. private _getTextureIndex;
  72925. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  72926. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  72927. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  72928. }
  72929. }
  72930. declare module BABYLON {
  72931. /**
  72932. * Class for generating STL data from a Babylon scene.
  72933. */
  72934. export class STLExport {
  72935. /**
  72936. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  72937. * @param meshes list defines the mesh to serialize
  72938. * @param download triggers the automatic download of the file.
  72939. * @param fileName changes the downloads fileName.
  72940. * @param binary changes the STL to a binary type.
  72941. * @param isLittleEndian toggle for binary type exporter.
  72942. * @returns the STL as UTF8 string
  72943. */
  72944. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  72945. }
  72946. }
  72947. declare module "babylonjs-gltf2interface" {
  72948. export = BABYLON.GLTF2;
  72949. }
  72950. /**
  72951. * Module for glTF 2.0 Interface
  72952. */
  72953. declare module BABYLON.GLTF2 {
  72954. /**
  72955. * The datatype of the components in the attribute
  72956. */
  72957. const enum AccessorComponentType {
  72958. /**
  72959. * Byte
  72960. */
  72961. BYTE = 5120,
  72962. /**
  72963. * Unsigned Byte
  72964. */
  72965. UNSIGNED_BYTE = 5121,
  72966. /**
  72967. * Short
  72968. */
  72969. SHORT = 5122,
  72970. /**
  72971. * Unsigned Short
  72972. */
  72973. UNSIGNED_SHORT = 5123,
  72974. /**
  72975. * Unsigned Int
  72976. */
  72977. UNSIGNED_INT = 5125,
  72978. /**
  72979. * Float
  72980. */
  72981. FLOAT = 5126,
  72982. }
  72983. /**
  72984. * Specifies if the attirbute is a scalar, vector, or matrix
  72985. */
  72986. const enum AccessorType {
  72987. /**
  72988. * Scalar
  72989. */
  72990. SCALAR = "SCALAR",
  72991. /**
  72992. * Vector2
  72993. */
  72994. VEC2 = "VEC2",
  72995. /**
  72996. * Vector3
  72997. */
  72998. VEC3 = "VEC3",
  72999. /**
  73000. * Vector4
  73001. */
  73002. VEC4 = "VEC4",
  73003. /**
  73004. * Matrix2x2
  73005. */
  73006. MAT2 = "MAT2",
  73007. /**
  73008. * Matrix3x3
  73009. */
  73010. MAT3 = "MAT3",
  73011. /**
  73012. * Matrix4x4
  73013. */
  73014. MAT4 = "MAT4",
  73015. }
  73016. /**
  73017. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  73018. */
  73019. const enum AnimationChannelTargetPath {
  73020. /**
  73021. * Translation
  73022. */
  73023. TRANSLATION = "translation",
  73024. /**
  73025. * Rotation
  73026. */
  73027. ROTATION = "rotation",
  73028. /**
  73029. * Scale
  73030. */
  73031. SCALE = "scale",
  73032. /**
  73033. * Weights
  73034. */
  73035. WEIGHTS = "weights",
  73036. }
  73037. /**
  73038. * Interpolation algorithm
  73039. */
  73040. const enum AnimationSamplerInterpolation {
  73041. /**
  73042. * The animated values are linearly interpolated between keyframes
  73043. */
  73044. LINEAR = "LINEAR",
  73045. /**
  73046. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  73047. */
  73048. STEP = "STEP",
  73049. /**
  73050. * The animation's interpolation is computed using a cubic spline with specified tangents
  73051. */
  73052. CUBICSPLINE = "CUBICSPLINE",
  73053. }
  73054. /**
  73055. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  73056. */
  73057. const enum CameraType {
  73058. /**
  73059. * A perspective camera containing properties to create a perspective projection matrix
  73060. */
  73061. PERSPECTIVE = "perspective",
  73062. /**
  73063. * An orthographic camera containing properties to create an orthographic projection matrix
  73064. */
  73065. ORTHOGRAPHIC = "orthographic",
  73066. }
  73067. /**
  73068. * The mime-type of the image
  73069. */
  73070. const enum ImageMimeType {
  73071. /**
  73072. * JPEG Mime-type
  73073. */
  73074. JPEG = "image/jpeg",
  73075. /**
  73076. * PNG Mime-type
  73077. */
  73078. PNG = "image/png",
  73079. }
  73080. /**
  73081. * The alpha rendering mode of the material
  73082. */
  73083. const enum MaterialAlphaMode {
  73084. /**
  73085. * The alpha value is ignored and the rendered output is fully opaque
  73086. */
  73087. OPAQUE = "OPAQUE",
  73088. /**
  73089. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  73090. */
  73091. MASK = "MASK",
  73092. /**
  73093. * 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)
  73094. */
  73095. BLEND = "BLEND",
  73096. }
  73097. /**
  73098. * The type of the primitives to render
  73099. */
  73100. const enum MeshPrimitiveMode {
  73101. /**
  73102. * Points
  73103. */
  73104. POINTS = 0,
  73105. /**
  73106. * Lines
  73107. */
  73108. LINES = 1,
  73109. /**
  73110. * Line Loop
  73111. */
  73112. LINE_LOOP = 2,
  73113. /**
  73114. * Line Strip
  73115. */
  73116. LINE_STRIP = 3,
  73117. /**
  73118. * Triangles
  73119. */
  73120. TRIANGLES = 4,
  73121. /**
  73122. * Triangle Strip
  73123. */
  73124. TRIANGLE_STRIP = 5,
  73125. /**
  73126. * Triangle Fan
  73127. */
  73128. TRIANGLE_FAN = 6,
  73129. }
  73130. /**
  73131. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  73132. */
  73133. const enum TextureMagFilter {
  73134. /**
  73135. * Nearest
  73136. */
  73137. NEAREST = 9728,
  73138. /**
  73139. * Linear
  73140. */
  73141. LINEAR = 9729,
  73142. }
  73143. /**
  73144. * Minification filter. All valid values correspond to WebGL enums
  73145. */
  73146. const enum TextureMinFilter {
  73147. /**
  73148. * Nearest
  73149. */
  73150. NEAREST = 9728,
  73151. /**
  73152. * Linear
  73153. */
  73154. LINEAR = 9729,
  73155. /**
  73156. * Nearest Mip-Map Nearest
  73157. */
  73158. NEAREST_MIPMAP_NEAREST = 9984,
  73159. /**
  73160. * Linear Mipmap Nearest
  73161. */
  73162. LINEAR_MIPMAP_NEAREST = 9985,
  73163. /**
  73164. * Nearest Mipmap Linear
  73165. */
  73166. NEAREST_MIPMAP_LINEAR = 9986,
  73167. /**
  73168. * Linear Mipmap Linear
  73169. */
  73170. LINEAR_MIPMAP_LINEAR = 9987,
  73171. }
  73172. /**
  73173. * S (U) wrapping mode. All valid values correspond to WebGL enums
  73174. */
  73175. const enum TextureWrapMode {
  73176. /**
  73177. * Clamp to Edge
  73178. */
  73179. CLAMP_TO_EDGE = 33071,
  73180. /**
  73181. * Mirrored Repeat
  73182. */
  73183. MIRRORED_REPEAT = 33648,
  73184. /**
  73185. * Repeat
  73186. */
  73187. REPEAT = 10497,
  73188. }
  73189. /**
  73190. * glTF Property
  73191. */
  73192. interface IProperty {
  73193. /**
  73194. * Dictionary object with extension-specific objects
  73195. */
  73196. extensions?: {
  73197. [key: string]: any;
  73198. };
  73199. /**
  73200. * Application-Specific data
  73201. */
  73202. extras?: any;
  73203. }
  73204. /**
  73205. * glTF Child of Root Property
  73206. */
  73207. interface IChildRootProperty extends IProperty {
  73208. /**
  73209. * The user-defined name of this object
  73210. */
  73211. name?: string;
  73212. }
  73213. /**
  73214. * Indices of those attributes that deviate from their initialization value
  73215. */
  73216. interface IAccessorSparseIndices extends IProperty {
  73217. /**
  73218. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  73219. */
  73220. bufferView: number;
  73221. /**
  73222. * The offset relative to the start of the bufferView in bytes. Must be aligned
  73223. */
  73224. byteOffset?: number;
  73225. /**
  73226. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  73227. */
  73228. componentType: AccessorComponentType;
  73229. }
  73230. /**
  73231. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  73232. */
  73233. interface IAccessorSparseValues extends IProperty {
  73234. /**
  73235. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  73236. */
  73237. bufferView: number;
  73238. /**
  73239. * The offset relative to the start of the bufferView in bytes. Must be aligned
  73240. */
  73241. byteOffset?: number;
  73242. }
  73243. /**
  73244. * Sparse storage of attributes that deviate from their initialization value
  73245. */
  73246. interface IAccessorSparse extends IProperty {
  73247. /**
  73248. * The number of attributes encoded in this sparse accessor
  73249. */
  73250. count: number;
  73251. /**
  73252. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  73253. */
  73254. indices: IAccessorSparseIndices;
  73255. /**
  73256. * 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
  73257. */
  73258. values: IAccessorSparseValues;
  73259. }
  73260. /**
  73261. * 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
  73262. */
  73263. interface IAccessor extends IChildRootProperty {
  73264. /**
  73265. * The index of the bufferview
  73266. */
  73267. bufferView?: number;
  73268. /**
  73269. * The offset relative to the start of the bufferView in bytes
  73270. */
  73271. byteOffset?: number;
  73272. /**
  73273. * The datatype of components in the attribute
  73274. */
  73275. componentType: AccessorComponentType;
  73276. /**
  73277. * Specifies whether integer data values should be normalized
  73278. */
  73279. normalized?: boolean;
  73280. /**
  73281. * The number of attributes referenced by this accessor
  73282. */
  73283. count: number;
  73284. /**
  73285. * Specifies if the attribute is a scalar, vector, or matrix
  73286. */
  73287. type: AccessorType;
  73288. /**
  73289. * Maximum value of each component in this attribute
  73290. */
  73291. max?: number[];
  73292. /**
  73293. * Minimum value of each component in this attribute
  73294. */
  73295. min?: number[];
  73296. /**
  73297. * Sparse storage of attributes that deviate from their initialization value
  73298. */
  73299. sparse?: IAccessorSparse;
  73300. }
  73301. /**
  73302. * Targets an animation's sampler at a node's property
  73303. */
  73304. interface IAnimationChannel extends IProperty {
  73305. /**
  73306. * The index of a sampler in this animation used to compute the value for the target
  73307. */
  73308. sampler: number;
  73309. /**
  73310. * The index of the node and TRS property to target
  73311. */
  73312. target: IAnimationChannelTarget;
  73313. }
  73314. /**
  73315. * The index of the node and TRS property that an animation channel targets
  73316. */
  73317. interface IAnimationChannelTarget extends IProperty {
  73318. /**
  73319. * The index of the node to target
  73320. */
  73321. node: number;
  73322. /**
  73323. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  73324. */
  73325. path: AnimationChannelTargetPath;
  73326. }
  73327. /**
  73328. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  73329. */
  73330. interface IAnimationSampler extends IProperty {
  73331. /**
  73332. * The index of an accessor containing keyframe input values, e.g., time
  73333. */
  73334. input: number;
  73335. /**
  73336. * Interpolation algorithm
  73337. */
  73338. interpolation?: AnimationSamplerInterpolation;
  73339. /**
  73340. * The index of an accessor, containing keyframe output values
  73341. */
  73342. output: number;
  73343. }
  73344. /**
  73345. * A keyframe animation
  73346. */
  73347. interface IAnimation extends IChildRootProperty {
  73348. /**
  73349. * An array of channels, each of which targets an animation's sampler at a node's property
  73350. */
  73351. channels: IAnimationChannel[];
  73352. /**
  73353. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  73354. */
  73355. samplers: IAnimationSampler[];
  73356. }
  73357. /**
  73358. * Metadata about the glTF asset
  73359. */
  73360. interface IAsset extends IChildRootProperty {
  73361. /**
  73362. * A copyright message suitable for display to credit the content creator
  73363. */
  73364. copyright?: string;
  73365. /**
  73366. * Tool that generated this glTF model. Useful for debugging
  73367. */
  73368. generator?: string;
  73369. /**
  73370. * The glTF version that this asset targets
  73371. */
  73372. version: string;
  73373. /**
  73374. * The minimum glTF version that this asset targets
  73375. */
  73376. minVersion?: string;
  73377. }
  73378. /**
  73379. * A buffer points to binary geometry, animation, or skins
  73380. */
  73381. interface IBuffer extends IChildRootProperty {
  73382. /**
  73383. * 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
  73384. */
  73385. uri?: string;
  73386. /**
  73387. * The length of the buffer in bytes
  73388. */
  73389. byteLength: number;
  73390. }
  73391. /**
  73392. * A view into a buffer generally representing a subset of the buffer
  73393. */
  73394. interface IBufferView extends IChildRootProperty {
  73395. /**
  73396. * The index of the buffer
  73397. */
  73398. buffer: number;
  73399. /**
  73400. * The offset into the buffer in bytes
  73401. */
  73402. byteOffset?: number;
  73403. /**
  73404. * The lenth of the bufferView in bytes
  73405. */
  73406. byteLength: number;
  73407. /**
  73408. * The stride, in bytes
  73409. */
  73410. byteStride?: number;
  73411. }
  73412. /**
  73413. * An orthographic camera containing properties to create an orthographic projection matrix
  73414. */
  73415. interface ICameraOrthographic extends IProperty {
  73416. /**
  73417. * The floating-point horizontal magnification of the view. Must not be zero
  73418. */
  73419. xmag: number;
  73420. /**
  73421. * The floating-point vertical magnification of the view. Must not be zero
  73422. */
  73423. ymag: number;
  73424. /**
  73425. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  73426. */
  73427. zfar: number;
  73428. /**
  73429. * The floating-point distance to the near clipping plane
  73430. */
  73431. znear: number;
  73432. }
  73433. /**
  73434. * A perspective camera containing properties to create a perspective projection matrix
  73435. */
  73436. interface ICameraPerspective extends IProperty {
  73437. /**
  73438. * The floating-point aspect ratio of the field of view
  73439. */
  73440. aspectRatio?: number;
  73441. /**
  73442. * The floating-point vertical field of view in radians
  73443. */
  73444. yfov: number;
  73445. /**
  73446. * The floating-point distance to the far clipping plane
  73447. */
  73448. zfar?: number;
  73449. /**
  73450. * The floating-point distance to the near clipping plane
  73451. */
  73452. znear: number;
  73453. }
  73454. /**
  73455. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  73456. */
  73457. interface ICamera extends IChildRootProperty {
  73458. /**
  73459. * An orthographic camera containing properties to create an orthographic projection matrix
  73460. */
  73461. orthographic?: ICameraOrthographic;
  73462. /**
  73463. * A perspective camera containing properties to create a perspective projection matrix
  73464. */
  73465. perspective?: ICameraPerspective;
  73466. /**
  73467. * Specifies if the camera uses a perspective or orthographic projection
  73468. */
  73469. type: CameraType;
  73470. }
  73471. /**
  73472. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  73473. */
  73474. interface IImage extends IChildRootProperty {
  73475. /**
  73476. * 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
  73477. */
  73478. uri?: string;
  73479. /**
  73480. * The image's MIME type
  73481. */
  73482. mimeType?: ImageMimeType;
  73483. /**
  73484. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  73485. */
  73486. bufferView?: number;
  73487. }
  73488. /**
  73489. * Material Normal Texture Info
  73490. */
  73491. interface IMaterialNormalTextureInfo extends ITextureInfo {
  73492. /**
  73493. * The scalar multiplier applied to each normal vector of the normal texture
  73494. */
  73495. scale?: number;
  73496. }
  73497. /**
  73498. * Material Occlusion Texture Info
  73499. */
  73500. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  73501. /**
  73502. * A scalar multiplier controlling the amount of occlusion applied
  73503. */
  73504. strength?: number;
  73505. }
  73506. /**
  73507. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  73508. */
  73509. interface IMaterialPbrMetallicRoughness {
  73510. /**
  73511. * The material's base color factor
  73512. */
  73513. baseColorFactor?: number[];
  73514. /**
  73515. * The base color texture
  73516. */
  73517. baseColorTexture?: ITextureInfo;
  73518. /**
  73519. * The metalness of the material
  73520. */
  73521. metallicFactor?: number;
  73522. /**
  73523. * The roughness of the material
  73524. */
  73525. roughnessFactor?: number;
  73526. /**
  73527. * The metallic-roughness texture
  73528. */
  73529. metallicRoughnessTexture?: ITextureInfo;
  73530. }
  73531. /**
  73532. * The material appearance of a primitive
  73533. */
  73534. interface IMaterial extends IChildRootProperty {
  73535. /**
  73536. * 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
  73537. */
  73538. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  73539. /**
  73540. * The normal map texture
  73541. */
  73542. normalTexture?: IMaterialNormalTextureInfo;
  73543. /**
  73544. * The occlusion map texture
  73545. */
  73546. occlusionTexture?: IMaterialOcclusionTextureInfo;
  73547. /**
  73548. * The emissive map texture
  73549. */
  73550. emissiveTexture?: ITextureInfo;
  73551. /**
  73552. * 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
  73553. */
  73554. emissiveFactor?: number[];
  73555. /**
  73556. * The alpha rendering mode of the material
  73557. */
  73558. alphaMode?: MaterialAlphaMode;
  73559. /**
  73560. * The alpha cutoff value of the material
  73561. */
  73562. alphaCutoff?: number;
  73563. /**
  73564. * Specifies whether the material is double sided
  73565. */
  73566. doubleSided?: boolean;
  73567. }
  73568. /**
  73569. * Geometry to be rendered with the given material
  73570. */
  73571. interface IMeshPrimitive extends IProperty {
  73572. /**
  73573. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  73574. */
  73575. attributes: {
  73576. [name: string]: number;
  73577. };
  73578. /**
  73579. * The index of the accessor that contains the indices
  73580. */
  73581. indices?: number;
  73582. /**
  73583. * The index of the material to apply to this primitive when rendering
  73584. */
  73585. material?: number;
  73586. /**
  73587. * The type of primitives to render. All valid values correspond to WebGL enums
  73588. */
  73589. mode?: MeshPrimitiveMode;
  73590. /**
  73591. * 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
  73592. */
  73593. targets?: {
  73594. [name: string]: number;
  73595. }[];
  73596. }
  73597. /**
  73598. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  73599. */
  73600. interface IMesh extends IChildRootProperty {
  73601. /**
  73602. * An array of primitives, each defining geometry to be rendered with a material
  73603. */
  73604. primitives: IMeshPrimitive[];
  73605. /**
  73606. * Array of weights to be applied to the Morph Targets
  73607. */
  73608. weights?: number[];
  73609. }
  73610. /**
  73611. * A node in the node hierarchy
  73612. */
  73613. interface INode extends IChildRootProperty {
  73614. /**
  73615. * The index of the camera referenced by this node
  73616. */
  73617. camera?: number;
  73618. /**
  73619. * The indices of this node's children
  73620. */
  73621. children?: number[];
  73622. /**
  73623. * The index of the skin referenced by this node
  73624. */
  73625. skin?: number;
  73626. /**
  73627. * A floating-point 4x4 transformation matrix stored in column-major order
  73628. */
  73629. matrix?: number[];
  73630. /**
  73631. * The index of the mesh in this node
  73632. */
  73633. mesh?: number;
  73634. /**
  73635. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  73636. */
  73637. rotation?: number[];
  73638. /**
  73639. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  73640. */
  73641. scale?: number[];
  73642. /**
  73643. * The node's translation along the x, y, and z axes
  73644. */
  73645. translation?: number[];
  73646. /**
  73647. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  73648. */
  73649. weights?: number[];
  73650. }
  73651. /**
  73652. * Texture sampler properties for filtering and wrapping modes
  73653. */
  73654. interface ISampler extends IChildRootProperty {
  73655. /**
  73656. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  73657. */
  73658. magFilter?: TextureMagFilter;
  73659. /**
  73660. * Minification filter. All valid values correspond to WebGL enums
  73661. */
  73662. minFilter?: TextureMinFilter;
  73663. /**
  73664. * S (U) wrapping mode. All valid values correspond to WebGL enums
  73665. */
  73666. wrapS?: TextureWrapMode;
  73667. /**
  73668. * T (V) wrapping mode. All valid values correspond to WebGL enums
  73669. */
  73670. wrapT?: TextureWrapMode;
  73671. }
  73672. /**
  73673. * The root nodes of a scene
  73674. */
  73675. interface IScene extends IChildRootProperty {
  73676. /**
  73677. * The indices of each root node
  73678. */
  73679. nodes: number[];
  73680. }
  73681. /**
  73682. * Joints and matrices defining a skin
  73683. */
  73684. interface ISkin extends IChildRootProperty {
  73685. /**
  73686. * 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
  73687. */
  73688. inverseBindMatrices?: number;
  73689. /**
  73690. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  73691. */
  73692. skeleton?: number;
  73693. /**
  73694. * 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)
  73695. */
  73696. joints: number[];
  73697. }
  73698. /**
  73699. * A texture and its sampler
  73700. */
  73701. interface ITexture extends IChildRootProperty {
  73702. /**
  73703. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  73704. */
  73705. sampler?: number;
  73706. /**
  73707. * The index of the image used by this texture
  73708. */
  73709. source: number;
  73710. }
  73711. /**
  73712. * Reference to a texture
  73713. */
  73714. interface ITextureInfo extends IProperty {
  73715. /**
  73716. * The index of the texture
  73717. */
  73718. index: number;
  73719. /**
  73720. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  73721. */
  73722. texCoord?: number;
  73723. }
  73724. /**
  73725. * The root object for a glTF asset
  73726. */
  73727. interface IGLTF extends IProperty {
  73728. /**
  73729. * An array of accessors. An accessor is a typed view into a bufferView
  73730. */
  73731. accessors?: IAccessor[];
  73732. /**
  73733. * An array of keyframe animations
  73734. */
  73735. animations?: IAnimation[];
  73736. /**
  73737. * Metadata about the glTF asset
  73738. */
  73739. asset: IAsset;
  73740. /**
  73741. * An array of buffers. A buffer points to binary geometry, animation, or skins
  73742. */
  73743. buffers?: IBuffer[];
  73744. /**
  73745. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  73746. */
  73747. bufferViews?: IBufferView[];
  73748. /**
  73749. * An array of cameras
  73750. */
  73751. cameras?: ICamera[];
  73752. /**
  73753. * Names of glTF extensions used somewhere in this asset
  73754. */
  73755. extensionsUsed?: string[];
  73756. /**
  73757. * Names of glTF extensions required to properly load this asset
  73758. */
  73759. extensionsRequired?: string[];
  73760. /**
  73761. * An array of images. An image defines data used to create a texture
  73762. */
  73763. images?: IImage[];
  73764. /**
  73765. * An array of materials. A material defines the appearance of a primitive
  73766. */
  73767. materials?: IMaterial[];
  73768. /**
  73769. * An array of meshes. A mesh is a set of primitives to be rendered
  73770. */
  73771. meshes?: IMesh[];
  73772. /**
  73773. * An array of nodes
  73774. */
  73775. nodes?: INode[];
  73776. /**
  73777. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  73778. */
  73779. samplers?: ISampler[];
  73780. /**
  73781. * The index of the default scene
  73782. */
  73783. scene?: number;
  73784. /**
  73785. * An array of scenes
  73786. */
  73787. scenes?: IScene[];
  73788. /**
  73789. * An array of skins. A skin is defined by joints and matrices
  73790. */
  73791. skins?: ISkin[];
  73792. /**
  73793. * An array of textures
  73794. */
  73795. textures?: ITexture[];
  73796. }
  73797. /**
  73798. * The glTF validation results
  73799. * @ignore
  73800. */
  73801. interface IGLTFValidationResults {
  73802. info: {
  73803. generator: string;
  73804. hasAnimations: boolean;
  73805. hasDefaultScene: boolean;
  73806. hasMaterials: boolean;
  73807. hasMorphTargets: boolean;
  73808. hasSkins: boolean;
  73809. hasTextures: boolean;
  73810. maxAttributesUsed: number;
  73811. primitivesCount: number
  73812. };
  73813. issues: {
  73814. messages: Array<string>;
  73815. numErrors: number;
  73816. numHints: number;
  73817. numInfos: number;
  73818. numWarnings: number;
  73819. truncated: boolean
  73820. };
  73821. mimeType: string;
  73822. uri: string;
  73823. validatedAt: string;
  73824. validatorVersion: string;
  73825. }
  73826. /**
  73827. * The glTF validation options
  73828. */
  73829. interface IGLTFValidationOptions {
  73830. /** Uri to use */
  73831. uri?: string;
  73832. /** Function used to load external resources */
  73833. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  73834. /** Boolean indicating that we need to validate accessor data */
  73835. validateAccessorData?: boolean;
  73836. /** max number of issues allowed */
  73837. maxIssues?: number;
  73838. /** Ignored issues */
  73839. ignoredIssues?: Array<string>;
  73840. /** Value to override severy settings */
  73841. severityOverrides?: Object;
  73842. }
  73843. /**
  73844. * The glTF validator object
  73845. * @ignore
  73846. */
  73847. interface IGLTFValidator {
  73848. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  73849. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  73850. }
  73851. }
  73852. declare module BABYLON {
  73853. /** @hidden */
  73854. export var cellPixelShader: {
  73855. name: string;
  73856. shader: string;
  73857. };
  73858. }
  73859. declare module BABYLON {
  73860. /** @hidden */
  73861. export var cellVertexShader: {
  73862. name: string;
  73863. shader: string;
  73864. };
  73865. }
  73866. declare module BABYLON {
  73867. export class CellMaterial extends BABYLON.PushMaterial {
  73868. private _diffuseTexture;
  73869. diffuseTexture: BABYLON.BaseTexture;
  73870. diffuseColor: BABYLON.Color3;
  73871. _computeHighLevel: boolean;
  73872. computeHighLevel: boolean;
  73873. private _disableLighting;
  73874. disableLighting: boolean;
  73875. private _maxSimultaneousLights;
  73876. maxSimultaneousLights: number;
  73877. private _renderId;
  73878. constructor(name: string, scene: BABYLON.Scene);
  73879. needAlphaBlending(): boolean;
  73880. needAlphaTesting(): boolean;
  73881. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  73882. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  73883. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  73884. getAnimatables(): BABYLON.IAnimatable[];
  73885. getActiveTextures(): BABYLON.BaseTexture[];
  73886. hasTexture(texture: BABYLON.BaseTexture): boolean;
  73887. dispose(forceDisposeEffect?: boolean): void;
  73888. getClassName(): string;
  73889. clone(name: string): CellMaterial;
  73890. serialize(): any;
  73891. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  73892. }
  73893. }
  73894. declare module BABYLON {
  73895. export class CustomShaderStructure {
  73896. FragmentStore: string;
  73897. VertexStore: string;
  73898. constructor();
  73899. }
  73900. export class ShaderSpecialParts {
  73901. constructor();
  73902. Fragment_Begin: string;
  73903. Fragment_Definitions: string;
  73904. Fragment_MainBegin: string;
  73905. Fragment_Custom_Diffuse: string;
  73906. Fragment_Before_Lights: string;
  73907. Fragment_Before_Fog: string;
  73908. Fragment_Custom_Alpha: string;
  73909. Fragment_Before_FragColor: string;
  73910. Vertex_Begin: string;
  73911. Vertex_Definitions: string;
  73912. Vertex_MainBegin: string;
  73913. Vertex_Before_PositionUpdated: string;
  73914. Vertex_Before_NormalUpdated: string;
  73915. Vertex_MainEnd: string;
  73916. }
  73917. export class CustomMaterial extends BABYLON.StandardMaterial {
  73918. static ShaderIndexer: number;
  73919. CustomParts: ShaderSpecialParts;
  73920. _isCreatedShader: boolean;
  73921. _createdShaderName: string;
  73922. _customUniform: string[];
  73923. _newUniforms: string[];
  73924. _newUniformInstances: any[];
  73925. _newSamplerInstances: BABYLON.Texture[];
  73926. FragmentShader: string;
  73927. VertexShader: string;
  73928. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  73929. ReviewUniform(name: string, arr: string[]): string[];
  73930. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  73931. constructor(name: string, scene: BABYLON.Scene);
  73932. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  73933. Fragment_Begin(shaderPart: string): CustomMaterial;
  73934. Fragment_Definitions(shaderPart: string): CustomMaterial;
  73935. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  73936. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  73937. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  73938. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  73939. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  73940. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  73941. Vertex_Begin(shaderPart: string): CustomMaterial;
  73942. Vertex_Definitions(shaderPart: string): CustomMaterial;
  73943. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  73944. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  73945. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  73946. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  73947. }
  73948. }
  73949. declare module BABYLON {
  73950. export class ShaderAlebdoParts {
  73951. constructor();
  73952. Fragment_Begin: string;
  73953. Fragment_Definitions: string;
  73954. Fragment_MainBegin: string;
  73955. Fragment_Custom_Albedo: string;
  73956. Fragment_Before_Lights: string;
  73957. Fragment_Custom_MetallicRoughness: string;
  73958. Fragment_Custom_MicroSurface: string;
  73959. Fragment_Before_Fog: string;
  73960. Fragment_Custom_Alpha: string;
  73961. Fragment_Before_FragColor: string;
  73962. Vertex_Begin: string;
  73963. Vertex_Definitions: string;
  73964. Vertex_MainBegin: string;
  73965. Vertex_Before_PositionUpdated: string;
  73966. Vertex_Before_NormalUpdated: string;
  73967. Vertex_MainEnd: string;
  73968. }
  73969. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  73970. static ShaderIndexer: number;
  73971. CustomParts: ShaderAlebdoParts;
  73972. _isCreatedShader: boolean;
  73973. _createdShaderName: string;
  73974. _customUniform: string[];
  73975. _newUniforms: string[];
  73976. _newUniformInstances: any[];
  73977. _newSamplerInstances: BABYLON.Texture[];
  73978. FragmentShader: string;
  73979. VertexShader: string;
  73980. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  73981. ReviewUniform(name: string, arr: string[]): string[];
  73982. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  73983. constructor(name: string, scene: BABYLON.Scene);
  73984. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  73985. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  73986. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  73987. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  73988. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  73989. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  73990. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  73991. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  73992. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  73993. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  73994. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  73995. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  73996. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  73997. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  73998. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  73999. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  74000. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  74001. }
  74002. }
  74003. declare module BABYLON {
  74004. /** @hidden */
  74005. export var firePixelShader: {
  74006. name: string;
  74007. shader: string;
  74008. };
  74009. }
  74010. declare module BABYLON {
  74011. /** @hidden */
  74012. export var fireVertexShader: {
  74013. name: string;
  74014. shader: string;
  74015. };
  74016. }
  74017. declare module BABYLON {
  74018. export class FireMaterial extends BABYLON.PushMaterial {
  74019. private _diffuseTexture;
  74020. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  74021. private _distortionTexture;
  74022. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  74023. private _opacityTexture;
  74024. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  74025. diffuseColor: BABYLON.Color3;
  74026. speed: number;
  74027. private _scaledDiffuse;
  74028. private _renderId;
  74029. private _lastTime;
  74030. constructor(name: string, scene: BABYLON.Scene);
  74031. needAlphaBlending(): boolean;
  74032. needAlphaTesting(): boolean;
  74033. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  74034. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  74035. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  74036. getAnimatables(): BABYLON.IAnimatable[];
  74037. getActiveTextures(): BABYLON.BaseTexture[];
  74038. hasTexture(texture: BABYLON.BaseTexture): boolean;
  74039. getClassName(): string;
  74040. dispose(forceDisposeEffect?: boolean): void;
  74041. clone(name: string): FireMaterial;
  74042. serialize(): any;
  74043. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  74044. }
  74045. }
  74046. declare module BABYLON {
  74047. /** @hidden */
  74048. export var furPixelShader: {
  74049. name: string;
  74050. shader: string;
  74051. };
  74052. }
  74053. declare module BABYLON {
  74054. /** @hidden */
  74055. export var furVertexShader: {
  74056. name: string;
  74057. shader: string;
  74058. };
  74059. }
  74060. declare module BABYLON {
  74061. export class FurMaterial extends BABYLON.PushMaterial {
  74062. private _diffuseTexture;
  74063. diffuseTexture: BABYLON.BaseTexture;
  74064. private _heightTexture;
  74065. heightTexture: BABYLON.BaseTexture;
  74066. diffuseColor: BABYLON.Color3;
  74067. furLength: number;
  74068. furAngle: number;
  74069. furColor: BABYLON.Color3;
  74070. furOffset: number;
  74071. furSpacing: number;
  74072. furGravity: BABYLON.Vector3;
  74073. furSpeed: number;
  74074. furDensity: number;
  74075. furOcclusion: number;
  74076. furTexture: BABYLON.DynamicTexture;
  74077. private _disableLighting;
  74078. disableLighting: boolean;
  74079. private _maxSimultaneousLights;
  74080. maxSimultaneousLights: number;
  74081. highLevelFur: boolean;
  74082. _meshes: BABYLON.AbstractMesh[];
  74083. private _renderId;
  74084. private _furTime;
  74085. constructor(name: string, scene: BABYLON.Scene);
  74086. furTime: number;
  74087. needAlphaBlending(): boolean;
  74088. needAlphaTesting(): boolean;
  74089. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  74090. updateFur(): void;
  74091. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  74092. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  74093. getAnimatables(): BABYLON.IAnimatable[];
  74094. getActiveTextures(): BABYLON.BaseTexture[];
  74095. hasTexture(texture: BABYLON.BaseTexture): boolean;
  74096. dispose(forceDisposeEffect?: boolean): void;
  74097. clone(name: string): FurMaterial;
  74098. serialize(): any;
  74099. getClassName(): string;
  74100. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  74101. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  74102. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  74103. }
  74104. }
  74105. declare module BABYLON {
  74106. /** @hidden */
  74107. export var gradientPixelShader: {
  74108. name: string;
  74109. shader: string;
  74110. };
  74111. }
  74112. declare module BABYLON {
  74113. /** @hidden */
  74114. export var gradientVertexShader: {
  74115. name: string;
  74116. shader: string;
  74117. };
  74118. }
  74119. declare module BABYLON {
  74120. export class GradientMaterial extends BABYLON.PushMaterial {
  74121. private _maxSimultaneousLights;
  74122. maxSimultaneousLights: number;
  74123. topColor: BABYLON.Color3;
  74124. topColorAlpha: number;
  74125. bottomColor: BABYLON.Color3;
  74126. bottomColorAlpha: number;
  74127. offset: number;
  74128. scale: number;
  74129. smoothness: number;
  74130. private _disableLighting;
  74131. disableLighting: boolean;
  74132. private _renderId;
  74133. constructor(name: string, scene: BABYLON.Scene);
  74134. needAlphaBlending(): boolean;
  74135. needAlphaTesting(): boolean;
  74136. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  74137. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  74138. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  74139. getAnimatables(): BABYLON.IAnimatable[];
  74140. dispose(forceDisposeEffect?: boolean): void;
  74141. clone(name: string): GradientMaterial;
  74142. serialize(): any;
  74143. getClassName(): string;
  74144. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  74145. }
  74146. }
  74147. declare module BABYLON {
  74148. /** @hidden */
  74149. export var gridPixelShader: {
  74150. name: string;
  74151. shader: string;
  74152. };
  74153. }
  74154. declare module BABYLON {
  74155. /** @hidden */
  74156. export var gridVertexShader: {
  74157. name: string;
  74158. shader: string;
  74159. };
  74160. }
  74161. declare module BABYLON {
  74162. /**
  74163. * The grid materials allows you to wrap any shape with a grid.
  74164. * Colors are customizable.
  74165. */
  74166. export class GridMaterial extends BABYLON.PushMaterial {
  74167. /**
  74168. * Main color of the grid (e.g. between lines)
  74169. */
  74170. mainColor: BABYLON.Color3;
  74171. /**
  74172. * Color of the grid lines.
  74173. */
  74174. lineColor: BABYLON.Color3;
  74175. /**
  74176. * The scale of the grid compared to unit.
  74177. */
  74178. gridRatio: number;
  74179. /**
  74180. * Allows setting an offset for the grid lines.
  74181. */
  74182. gridOffset: BABYLON.Vector3;
  74183. /**
  74184. * The frequency of thicker lines.
  74185. */
  74186. majorUnitFrequency: number;
  74187. /**
  74188. * The visibility of minor units in the grid.
  74189. */
  74190. minorUnitVisibility: number;
  74191. /**
  74192. * The grid opacity outside of the lines.
  74193. */
  74194. opacity: number;
  74195. /**
  74196. * Determine RBG output is premultiplied by alpha value.
  74197. */
  74198. preMultiplyAlpha: boolean;
  74199. private _opacityTexture;
  74200. opacityTexture: BABYLON.BaseTexture;
  74201. private _gridControl;
  74202. private _renderId;
  74203. /**
  74204. * constructor
  74205. * @param name The name given to the material in order to identify it afterwards.
  74206. * @param scene The scene the material is used in.
  74207. */
  74208. constructor(name: string, scene: BABYLON.Scene);
  74209. /**
  74210. * Returns wehter or not the grid requires alpha blending.
  74211. */
  74212. needAlphaBlending(): boolean;
  74213. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  74214. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  74215. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  74216. /**
  74217. * Dispose the material and its associated resources.
  74218. * @param forceDisposeEffect will also dispose the used effect when true
  74219. */
  74220. dispose(forceDisposeEffect?: boolean): void;
  74221. clone(name: string): GridMaterial;
  74222. serialize(): any;
  74223. getClassName(): string;
  74224. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  74225. }
  74226. }
  74227. declare module BABYLON {
  74228. /** @hidden */
  74229. export var lavaPixelShader: {
  74230. name: string;
  74231. shader: string;
  74232. };
  74233. }
  74234. declare module BABYLON {
  74235. /** @hidden */
  74236. export var lavaVertexShader: {
  74237. name: string;
  74238. shader: string;
  74239. };
  74240. }
  74241. declare module BABYLON {
  74242. export class LavaMaterial extends BABYLON.PushMaterial {
  74243. private _diffuseTexture;
  74244. diffuseTexture: BABYLON.BaseTexture;
  74245. noiseTexture: BABYLON.BaseTexture;
  74246. fogColor: BABYLON.Color3;
  74247. speed: number;
  74248. movingSpeed: number;
  74249. lowFrequencySpeed: number;
  74250. fogDensity: number;
  74251. private _lastTime;
  74252. diffuseColor: BABYLON.Color3;
  74253. private _disableLighting;
  74254. disableLighting: boolean;
  74255. private _unlit;
  74256. unlit: boolean;
  74257. private _maxSimultaneousLights;
  74258. maxSimultaneousLights: number;
  74259. private _scaledDiffuse;
  74260. private _renderId;
  74261. constructor(name: string, scene: BABYLON.Scene);
  74262. needAlphaBlending(): boolean;
  74263. needAlphaTesting(): boolean;
  74264. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  74265. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  74266. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  74267. getAnimatables(): BABYLON.IAnimatable[];
  74268. getActiveTextures(): BABYLON.BaseTexture[];
  74269. hasTexture(texture: BABYLON.BaseTexture): boolean;
  74270. dispose(forceDisposeEffect?: boolean): void;
  74271. clone(name: string): LavaMaterial;
  74272. serialize(): any;
  74273. getClassName(): string;
  74274. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  74275. }
  74276. }
  74277. declare module BABYLON {
  74278. /** @hidden */
  74279. export var mixPixelShader: {
  74280. name: string;
  74281. shader: string;
  74282. };
  74283. }
  74284. declare module BABYLON {
  74285. /** @hidden */
  74286. export var mixVertexShader: {
  74287. name: string;
  74288. shader: string;
  74289. };
  74290. }
  74291. declare module BABYLON {
  74292. export class MixMaterial extends BABYLON.PushMaterial {
  74293. /**
  74294. * Mix textures
  74295. */
  74296. private _mixTexture1;
  74297. mixTexture1: BABYLON.BaseTexture;
  74298. private _mixTexture2;
  74299. mixTexture2: BABYLON.BaseTexture;
  74300. /**
  74301. * Diffuse textures
  74302. */
  74303. private _diffuseTexture1;
  74304. diffuseTexture1: BABYLON.Texture;
  74305. private _diffuseTexture2;
  74306. diffuseTexture2: BABYLON.Texture;
  74307. private _diffuseTexture3;
  74308. diffuseTexture3: BABYLON.Texture;
  74309. private _diffuseTexture4;
  74310. diffuseTexture4: BABYLON.Texture;
  74311. private _diffuseTexture5;
  74312. diffuseTexture5: BABYLON.Texture;
  74313. private _diffuseTexture6;
  74314. diffuseTexture6: BABYLON.Texture;
  74315. private _diffuseTexture7;
  74316. diffuseTexture7: BABYLON.Texture;
  74317. private _diffuseTexture8;
  74318. diffuseTexture8: BABYLON.Texture;
  74319. /**
  74320. * Uniforms
  74321. */
  74322. diffuseColor: BABYLON.Color3;
  74323. specularColor: BABYLON.Color3;
  74324. specularPower: number;
  74325. private _disableLighting;
  74326. disableLighting: boolean;
  74327. private _maxSimultaneousLights;
  74328. maxSimultaneousLights: number;
  74329. private _renderId;
  74330. constructor(name: string, scene: BABYLON.Scene);
  74331. needAlphaBlending(): boolean;
  74332. needAlphaTesting(): boolean;
  74333. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  74334. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  74335. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  74336. getAnimatables(): BABYLON.IAnimatable[];
  74337. getActiveTextures(): BABYLON.BaseTexture[];
  74338. hasTexture(texture: BABYLON.BaseTexture): boolean;
  74339. dispose(forceDisposeEffect?: boolean): void;
  74340. clone(name: string): MixMaterial;
  74341. serialize(): any;
  74342. getClassName(): string;
  74343. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  74344. }
  74345. }
  74346. declare module BABYLON {
  74347. /** @hidden */
  74348. export var normalPixelShader: {
  74349. name: string;
  74350. shader: string;
  74351. };
  74352. }
  74353. declare module BABYLON {
  74354. /** @hidden */
  74355. export var normalVertexShader: {
  74356. name: string;
  74357. shader: string;
  74358. };
  74359. }
  74360. declare module BABYLON {
  74361. export class NormalMaterial extends BABYLON.PushMaterial {
  74362. private _diffuseTexture;
  74363. diffuseTexture: BABYLON.BaseTexture;
  74364. diffuseColor: BABYLON.Color3;
  74365. private _disableLighting;
  74366. disableLighting: boolean;
  74367. private _maxSimultaneousLights;
  74368. maxSimultaneousLights: number;
  74369. private _renderId;
  74370. constructor(name: string, scene: BABYLON.Scene);
  74371. needAlphaBlending(): boolean;
  74372. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  74373. needAlphaTesting(): boolean;
  74374. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  74375. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  74376. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  74377. getAnimatables(): BABYLON.IAnimatable[];
  74378. getActiveTextures(): BABYLON.BaseTexture[];
  74379. hasTexture(texture: BABYLON.BaseTexture): boolean;
  74380. dispose(forceDisposeEffect?: boolean): void;
  74381. clone(name: string): NormalMaterial;
  74382. serialize(): any;
  74383. getClassName(): string;
  74384. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  74385. }
  74386. }
  74387. declare module BABYLON {
  74388. /** @hidden */
  74389. export var shadowOnlyPixelShader: {
  74390. name: string;
  74391. shader: string;
  74392. };
  74393. }
  74394. declare module BABYLON {
  74395. /** @hidden */
  74396. export var shadowOnlyVertexShader: {
  74397. name: string;
  74398. shader: string;
  74399. };
  74400. }
  74401. declare module BABYLON {
  74402. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  74403. private _renderId;
  74404. private _activeLight;
  74405. constructor(name: string, scene: BABYLON.Scene);
  74406. shadowColor: BABYLON.Color3;
  74407. needAlphaBlending(): boolean;
  74408. needAlphaTesting(): boolean;
  74409. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  74410. activeLight: BABYLON.IShadowLight;
  74411. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  74412. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  74413. clone(name: string): ShadowOnlyMaterial;
  74414. serialize(): any;
  74415. getClassName(): string;
  74416. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  74417. }
  74418. }
  74419. declare module BABYLON {
  74420. /** @hidden */
  74421. export var simplePixelShader: {
  74422. name: string;
  74423. shader: string;
  74424. };
  74425. }
  74426. declare module BABYLON {
  74427. /** @hidden */
  74428. export var simpleVertexShader: {
  74429. name: string;
  74430. shader: string;
  74431. };
  74432. }
  74433. declare module BABYLON {
  74434. export class SimpleMaterial extends BABYLON.PushMaterial {
  74435. private _diffuseTexture;
  74436. diffuseTexture: BABYLON.BaseTexture;
  74437. diffuseColor: BABYLON.Color3;
  74438. private _disableLighting;
  74439. disableLighting: boolean;
  74440. private _maxSimultaneousLights;
  74441. maxSimultaneousLights: number;
  74442. private _renderId;
  74443. constructor(name: string, scene: BABYLON.Scene);
  74444. needAlphaBlending(): boolean;
  74445. needAlphaTesting(): boolean;
  74446. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  74447. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  74448. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  74449. getAnimatables(): BABYLON.IAnimatable[];
  74450. getActiveTextures(): BABYLON.BaseTexture[];
  74451. hasTexture(texture: BABYLON.BaseTexture): boolean;
  74452. dispose(forceDisposeEffect?: boolean): void;
  74453. clone(name: string): SimpleMaterial;
  74454. serialize(): any;
  74455. getClassName(): string;
  74456. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  74457. }
  74458. }
  74459. declare module BABYLON {
  74460. /** @hidden */
  74461. export var skyPixelShader: {
  74462. name: string;
  74463. shader: string;
  74464. };
  74465. }
  74466. declare module BABYLON {
  74467. /** @hidden */
  74468. export var skyVertexShader: {
  74469. name: string;
  74470. shader: string;
  74471. };
  74472. }
  74473. declare module BABYLON {
  74474. /**
  74475. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  74476. * @see https://doc.babylonjs.com/extensions/sky
  74477. */
  74478. export class SkyMaterial extends BABYLON.PushMaterial {
  74479. /**
  74480. * Defines the overall luminance of sky in interval ]0, 1[.
  74481. */
  74482. luminance: number;
  74483. /**
  74484. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  74485. */
  74486. turbidity: number;
  74487. /**
  74488. * Defines the sky appearance (light intensity).
  74489. */
  74490. rayleigh: number;
  74491. /**
  74492. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  74493. */
  74494. mieCoefficient: number;
  74495. /**
  74496. * Defines the amount of haze particles following the Mie scattering theory.
  74497. */
  74498. mieDirectionalG: number;
  74499. /**
  74500. * Defines the distance of the sun according to the active scene camera.
  74501. */
  74502. distance: number;
  74503. /**
  74504. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  74505. * "inclined".
  74506. */
  74507. inclination: number;
  74508. /**
  74509. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  74510. * an object direction and a reference direction.
  74511. */
  74512. azimuth: number;
  74513. /**
  74514. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  74515. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  74516. */
  74517. sunPosition: BABYLON.Vector3;
  74518. /**
  74519. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  74520. * .sunPosition property.
  74521. */
  74522. useSunPosition: boolean;
  74523. /**
  74524. * Defines an offset vector used to get a horizon offset.
  74525. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  74526. */
  74527. cameraOffset: BABYLON.Vector3;
  74528. private _cameraPosition;
  74529. private _renderId;
  74530. /**
  74531. * Instantiates a new sky material.
  74532. * This material allows to create dynamic and texture free
  74533. * effects for skyboxes by taking care of the atmosphere state.
  74534. * @see https://doc.babylonjs.com/extensions/sky
  74535. * @param name Define the name of the material in the scene
  74536. * @param scene Define the scene the material belong to
  74537. */
  74538. constructor(name: string, scene: BABYLON.Scene);
  74539. /**
  74540. * Specifies if the material will require alpha blending
  74541. * @returns a boolean specifying if alpha blending is needed
  74542. */
  74543. needAlphaBlending(): boolean;
  74544. /**
  74545. * Specifies if this material should be rendered in alpha test mode
  74546. * @returns false as the sky material doesn't need alpha testing.
  74547. */
  74548. needAlphaTesting(): boolean;
  74549. /**
  74550. * Get the texture used for alpha test purpose.
  74551. * @returns null as the sky material has no texture.
  74552. */
  74553. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  74554. /**
  74555. * Get if the submesh is ready to be used and all its information available.
  74556. * Child classes can use it to update shaders
  74557. * @param mesh defines the mesh to check
  74558. * @param subMesh defines which submesh to check
  74559. * @param useInstances specifies that instances should be used
  74560. * @returns a boolean indicating that the submesh is ready or not
  74561. */
  74562. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  74563. /**
  74564. * Binds the submesh to this material by preparing the effect and shader to draw
  74565. * @param world defines the world transformation matrix
  74566. * @param mesh defines the mesh containing the submesh
  74567. * @param subMesh defines the submesh to bind the material to
  74568. */
  74569. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  74570. /**
  74571. * Get the list of animatables in the material.
  74572. * @returns the list of animatables object used in the material
  74573. */
  74574. getAnimatables(): BABYLON.IAnimatable[];
  74575. /**
  74576. * Disposes the material
  74577. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  74578. */
  74579. dispose(forceDisposeEffect?: boolean): void;
  74580. /**
  74581. * Makes a duplicate of the material, and gives it a new name
  74582. * @param name defines the new name for the duplicated material
  74583. * @returns the cloned material
  74584. */
  74585. clone(name: string): SkyMaterial;
  74586. /**
  74587. * Serializes this material in a JSON representation
  74588. * @returns the serialized material object
  74589. */
  74590. serialize(): any;
  74591. /**
  74592. * Gets the current class name of the material e.g. "SkyMaterial"
  74593. * Mainly use in serialization.
  74594. * @returns the class name
  74595. */
  74596. getClassName(): string;
  74597. /**
  74598. * Creates a sky material from parsed material data
  74599. * @param source defines the JSON representation of the material
  74600. * @param scene defines the hosting scene
  74601. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  74602. * @returns a new sky material
  74603. */
  74604. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  74605. }
  74606. }
  74607. declare module BABYLON {
  74608. /** @hidden */
  74609. export var terrainPixelShader: {
  74610. name: string;
  74611. shader: string;
  74612. };
  74613. }
  74614. declare module BABYLON {
  74615. /** @hidden */
  74616. export var terrainVertexShader: {
  74617. name: string;
  74618. shader: string;
  74619. };
  74620. }
  74621. declare module BABYLON {
  74622. export class TerrainMaterial extends BABYLON.PushMaterial {
  74623. private _mixTexture;
  74624. mixTexture: BABYLON.BaseTexture;
  74625. private _diffuseTexture1;
  74626. diffuseTexture1: BABYLON.Texture;
  74627. private _diffuseTexture2;
  74628. diffuseTexture2: BABYLON.Texture;
  74629. private _diffuseTexture3;
  74630. diffuseTexture3: BABYLON.Texture;
  74631. private _bumpTexture1;
  74632. bumpTexture1: BABYLON.Texture;
  74633. private _bumpTexture2;
  74634. bumpTexture2: BABYLON.Texture;
  74635. private _bumpTexture3;
  74636. bumpTexture3: BABYLON.Texture;
  74637. diffuseColor: BABYLON.Color3;
  74638. specularColor: BABYLON.Color3;
  74639. specularPower: number;
  74640. private _disableLighting;
  74641. disableLighting: boolean;
  74642. private _maxSimultaneousLights;
  74643. maxSimultaneousLights: number;
  74644. private _renderId;
  74645. constructor(name: string, scene: BABYLON.Scene);
  74646. needAlphaBlending(): boolean;
  74647. needAlphaTesting(): boolean;
  74648. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  74649. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  74650. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  74651. getAnimatables(): BABYLON.IAnimatable[];
  74652. getActiveTextures(): BABYLON.BaseTexture[];
  74653. hasTexture(texture: BABYLON.BaseTexture): boolean;
  74654. dispose(forceDisposeEffect?: boolean): void;
  74655. clone(name: string): TerrainMaterial;
  74656. serialize(): any;
  74657. getClassName(): string;
  74658. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  74659. }
  74660. }
  74661. declare module BABYLON {
  74662. /** @hidden */
  74663. export var triplanarPixelShader: {
  74664. name: string;
  74665. shader: string;
  74666. };
  74667. }
  74668. declare module BABYLON {
  74669. /** @hidden */
  74670. export var triplanarVertexShader: {
  74671. name: string;
  74672. shader: string;
  74673. };
  74674. }
  74675. declare module BABYLON {
  74676. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  74677. mixTexture: BABYLON.BaseTexture;
  74678. private _diffuseTextureX;
  74679. diffuseTextureX: BABYLON.BaseTexture;
  74680. private _diffuseTextureY;
  74681. diffuseTextureY: BABYLON.BaseTexture;
  74682. private _diffuseTextureZ;
  74683. diffuseTextureZ: BABYLON.BaseTexture;
  74684. private _normalTextureX;
  74685. normalTextureX: BABYLON.BaseTexture;
  74686. private _normalTextureY;
  74687. normalTextureY: BABYLON.BaseTexture;
  74688. private _normalTextureZ;
  74689. normalTextureZ: BABYLON.BaseTexture;
  74690. tileSize: number;
  74691. diffuseColor: BABYLON.Color3;
  74692. specularColor: BABYLON.Color3;
  74693. specularPower: number;
  74694. private _disableLighting;
  74695. disableLighting: boolean;
  74696. private _maxSimultaneousLights;
  74697. maxSimultaneousLights: number;
  74698. private _renderId;
  74699. constructor(name: string, scene: BABYLON.Scene);
  74700. needAlphaBlending(): boolean;
  74701. needAlphaTesting(): boolean;
  74702. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  74703. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  74704. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  74705. getAnimatables(): BABYLON.IAnimatable[];
  74706. getActiveTextures(): BABYLON.BaseTexture[];
  74707. hasTexture(texture: BABYLON.BaseTexture): boolean;
  74708. dispose(forceDisposeEffect?: boolean): void;
  74709. clone(name: string): TriPlanarMaterial;
  74710. serialize(): any;
  74711. getClassName(): string;
  74712. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  74713. }
  74714. }
  74715. declare module BABYLON {
  74716. /** @hidden */
  74717. export var waterPixelShader: {
  74718. name: string;
  74719. shader: string;
  74720. };
  74721. }
  74722. declare module BABYLON {
  74723. /** @hidden */
  74724. export var waterVertexShader: {
  74725. name: string;
  74726. shader: string;
  74727. };
  74728. }
  74729. declare module BABYLON {
  74730. export class WaterMaterial extends BABYLON.PushMaterial {
  74731. renderTargetSize: BABYLON.Vector2;
  74732. private _bumpTexture;
  74733. bumpTexture: BABYLON.BaseTexture;
  74734. diffuseColor: BABYLON.Color3;
  74735. specularColor: BABYLON.Color3;
  74736. specularPower: number;
  74737. private _disableLighting;
  74738. disableLighting: boolean;
  74739. private _maxSimultaneousLights;
  74740. maxSimultaneousLights: number;
  74741. /**
  74742. * @param {number}: Represents the wind force
  74743. */
  74744. windForce: number;
  74745. /**
  74746. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  74747. */
  74748. windDirection: BABYLON.Vector2;
  74749. /**
  74750. * @param {number}: Wave height, represents the height of the waves
  74751. */
  74752. waveHeight: number;
  74753. /**
  74754. * @param {number}: Bump height, represents the bump height related to the bump map
  74755. */
  74756. bumpHeight: number;
  74757. /**
  74758. * @param {boolean}: Add a smaller moving bump to less steady waves.
  74759. */
  74760. private _bumpSuperimpose;
  74761. bumpSuperimpose: boolean;
  74762. /**
  74763. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  74764. */
  74765. private _fresnelSeparate;
  74766. fresnelSeparate: boolean;
  74767. /**
  74768. * @param {boolean}: bump Waves modify the reflection.
  74769. */
  74770. private _bumpAffectsReflection;
  74771. bumpAffectsReflection: boolean;
  74772. /**
  74773. * @param {number}: The water color blended with the refraction (near)
  74774. */
  74775. waterColor: BABYLON.Color3;
  74776. /**
  74777. * @param {number}: The blend factor related to the water color
  74778. */
  74779. colorBlendFactor: number;
  74780. /**
  74781. * @param {number}: The water color blended with the reflection (far)
  74782. */
  74783. waterColor2: BABYLON.Color3;
  74784. /**
  74785. * @param {number}: The blend factor related to the water color (reflection, far)
  74786. */
  74787. colorBlendFactor2: number;
  74788. /**
  74789. * @param {number}: Represents the maximum length of a wave
  74790. */
  74791. waveLength: number;
  74792. /**
  74793. * @param {number}: Defines the waves speed
  74794. */
  74795. waveSpeed: number;
  74796. /**
  74797. * Sets or gets wether or not automatic clipping should be enabled or not. Setting to true will save performances and
  74798. * will avoid calculating useless pixels in the pixel shader of the water material.
  74799. */
  74800. disableClipPlane: boolean;
  74801. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  74802. private _mesh;
  74803. private _refractionRTT;
  74804. private _reflectionRTT;
  74805. private _reflectionTransform;
  74806. private _lastTime;
  74807. private _lastDeltaTime;
  74808. private _renderId;
  74809. private _useLogarithmicDepth;
  74810. private _waitingRenderList;
  74811. private _imageProcessingConfiguration;
  74812. private _imageProcessingObserver;
  74813. /**
  74814. * Gets a boolean indicating that current material needs to register RTT
  74815. */
  74816. readonly hasRenderTargetTextures: boolean;
  74817. /**
  74818. * Constructor
  74819. */
  74820. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  74821. useLogarithmicDepth: boolean;
  74822. readonly refractionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  74823. readonly reflectionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  74824. addToRenderList(node: any): void;
  74825. enableRenderTargets(enable: boolean): void;
  74826. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  74827. readonly renderTargetsEnabled: boolean;
  74828. needAlphaBlending(): boolean;
  74829. needAlphaTesting(): boolean;
  74830. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  74831. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  74832. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  74833. private _createRenderTargets;
  74834. getAnimatables(): BABYLON.IAnimatable[];
  74835. getActiveTextures(): BABYLON.BaseTexture[];
  74836. hasTexture(texture: BABYLON.BaseTexture): boolean;
  74837. dispose(forceDisposeEffect?: boolean): void;
  74838. clone(name: string): WaterMaterial;
  74839. serialize(): any;
  74840. getClassName(): string;
  74841. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  74842. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  74843. }
  74844. }
  74845. declare module BABYLON {
  74846. /** @hidden */
  74847. export var asciiartPixelShader: {
  74848. name: string;
  74849. shader: string;
  74850. };
  74851. }
  74852. declare module BABYLON {
  74853. /**
  74854. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  74855. *
  74856. * It basically takes care rendering the font front the given font size to a texture.
  74857. * This is used later on in the postprocess.
  74858. */
  74859. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  74860. private _font;
  74861. private _text;
  74862. private _charSize;
  74863. /**
  74864. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  74865. */
  74866. readonly charSize: number;
  74867. /**
  74868. * Create a new instance of the Ascii Art FontTexture class
  74869. * @param name the name of the texture
  74870. * @param font the font to use, use the W3C CSS notation
  74871. * @param text the caracter set to use in the rendering.
  74872. * @param scene the scene that owns the texture
  74873. */
  74874. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  74875. /**
  74876. * Gets the max char width of a font.
  74877. * @param font the font to use, use the W3C CSS notation
  74878. * @return the max char width
  74879. */
  74880. private getFontWidth;
  74881. /**
  74882. * Gets the max char height of a font.
  74883. * @param font the font to use, use the W3C CSS notation
  74884. * @return the max char height
  74885. */
  74886. private getFontHeight;
  74887. /**
  74888. * Clones the current AsciiArtTexture.
  74889. * @return the clone of the texture.
  74890. */
  74891. clone(): AsciiArtFontTexture;
  74892. /**
  74893. * Parses a json object representing the texture and returns an instance of it.
  74894. * @param source the source JSON representation
  74895. * @param scene the scene to create the texture for
  74896. * @return the parsed texture
  74897. */
  74898. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  74899. }
  74900. /**
  74901. * Option available in the Ascii Art Post Process.
  74902. */
  74903. export interface IAsciiArtPostProcessOptions {
  74904. /**
  74905. * The font to use following the w3c font definition.
  74906. */
  74907. font?: string;
  74908. /**
  74909. * The character set to use in the postprocess.
  74910. */
  74911. characterSet?: string;
  74912. /**
  74913. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  74914. * This number is defined between 0 and 1;
  74915. */
  74916. mixToTile?: number;
  74917. /**
  74918. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  74919. * This number is defined between 0 and 1;
  74920. */
  74921. mixToNormal?: number;
  74922. }
  74923. /**
  74924. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  74925. *
  74926. * Simmply add it to your scene and let the nerd that lives in you have fun.
  74927. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  74928. */
  74929. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  74930. /**
  74931. * The font texture used to render the char in the post process.
  74932. */
  74933. private _asciiArtFontTexture;
  74934. /**
  74935. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  74936. * This number is defined between 0 and 1;
  74937. */
  74938. mixToTile: number;
  74939. /**
  74940. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  74941. * This number is defined between 0 and 1;
  74942. */
  74943. mixToNormal: number;
  74944. /**
  74945. * Instantiates a new Ascii Art Post Process.
  74946. * @param name the name to give to the postprocess
  74947. * @camera the camera to apply the post process to.
  74948. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  74949. */
  74950. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  74951. }
  74952. }
  74953. declare module BABYLON {
  74954. /** @hidden */
  74955. export var digitalrainPixelShader: {
  74956. name: string;
  74957. shader: string;
  74958. };
  74959. }
  74960. declare module BABYLON {
  74961. /**
  74962. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  74963. *
  74964. * It basically takes care rendering the font front the given font size to a texture.
  74965. * This is used later on in the postprocess.
  74966. */
  74967. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  74968. private _font;
  74969. private _text;
  74970. private _charSize;
  74971. /**
  74972. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  74973. */
  74974. readonly charSize: number;
  74975. /**
  74976. * Create a new instance of the Digital Rain FontTexture class
  74977. * @param name the name of the texture
  74978. * @param font the font to use, use the W3C CSS notation
  74979. * @param text the caracter set to use in the rendering.
  74980. * @param scene the scene that owns the texture
  74981. */
  74982. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  74983. /**
  74984. * Gets the max char width of a font.
  74985. * @param font the font to use, use the W3C CSS notation
  74986. * @return the max char width
  74987. */
  74988. private getFontWidth;
  74989. /**
  74990. * Gets the max char height of a font.
  74991. * @param font the font to use, use the W3C CSS notation
  74992. * @return the max char height
  74993. */
  74994. private getFontHeight;
  74995. /**
  74996. * Clones the current DigitalRainFontTexture.
  74997. * @return the clone of the texture.
  74998. */
  74999. clone(): DigitalRainFontTexture;
  75000. /**
  75001. * Parses a json object representing the texture and returns an instance of it.
  75002. * @param source the source JSON representation
  75003. * @param scene the scene to create the texture for
  75004. * @return the parsed texture
  75005. */
  75006. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  75007. }
  75008. /**
  75009. * Option available in the Digital Rain Post Process.
  75010. */
  75011. export interface IDigitalRainPostProcessOptions {
  75012. /**
  75013. * The font to use following the w3c font definition.
  75014. */
  75015. font?: string;
  75016. /**
  75017. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  75018. * This number is defined between 0 and 1;
  75019. */
  75020. mixToTile?: number;
  75021. /**
  75022. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  75023. * This number is defined between 0 and 1;
  75024. */
  75025. mixToNormal?: number;
  75026. }
  75027. /**
  75028. * DigitalRainPostProcess helps rendering everithing in digital rain.
  75029. *
  75030. * Simmply add it to your scene and let the nerd that lives in you have fun.
  75031. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  75032. */
  75033. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  75034. /**
  75035. * The font texture used to render the char in the post process.
  75036. */
  75037. private _digitalRainFontTexture;
  75038. /**
  75039. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  75040. * This number is defined between 0 and 1;
  75041. */
  75042. mixToTile: number;
  75043. /**
  75044. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  75045. * This number is defined between 0 and 1;
  75046. */
  75047. mixToNormal: number;
  75048. /**
  75049. * Instantiates a new Digital Rain Post Process.
  75050. * @param name the name to give to the postprocess
  75051. * @camera the camera to apply the post process to.
  75052. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  75053. */
  75054. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  75055. }
  75056. }
  75057. declare module BABYLON {
  75058. /** @hidden */
  75059. export var oceanPostProcessPixelShader: {
  75060. name: string;
  75061. shader: string;
  75062. };
  75063. }
  75064. declare module BABYLON {
  75065. /**
  75066. * Option available in the Ocean Post Process.
  75067. */
  75068. export interface IOceanPostProcessOptions {
  75069. /**
  75070. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  75071. */
  75072. reflectionSize?: number | {
  75073. width: number;
  75074. height: number;
  75075. } | {
  75076. ratio: number;
  75077. };
  75078. /**
  75079. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  75080. */
  75081. refractionSize?: number | {
  75082. width: number;
  75083. height: number;
  75084. } | {
  75085. ratio: number;
  75086. };
  75087. }
  75088. /**
  75089. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  75090. *
  75091. * Simmply add it to your scene and let the nerd that lives in you have fun.
  75092. * Example usage:
  75093. * var pp = new OceanPostProcess("myOcean", camera);
  75094. * pp.reflectionEnabled = true;
  75095. * pp.refractionEnabled = true;
  75096. */
  75097. export class OceanPostProcess extends BABYLON.PostProcess {
  75098. /**
  75099. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  75100. */
  75101. /**
  75102. * Sets weither or not the real-time reflection is enabled on the ocean.
  75103. * Is set to true, the reflection mirror texture will be used as reflection texture.
  75104. */
  75105. reflectionEnabled: boolean;
  75106. /**
  75107. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  75108. */
  75109. /**
  75110. * Sets weither or not the real-time refraction is enabled on the ocean.
  75111. * Is set to true, the refraction render target texture will be used as refraction texture.
  75112. */
  75113. refractionEnabled: boolean;
  75114. /**
  75115. * Gets wether or not the post-processes is supported by the running hardware.
  75116. * This requires draw buffer supports.
  75117. */
  75118. readonly isSupported: boolean;
  75119. /**
  75120. * This is the reflection mirror texture used to display reflections on the ocean.
  75121. * By default, render list is empty.
  75122. */
  75123. reflectionTexture: BABYLON.MirrorTexture;
  75124. /**
  75125. * This is the refraction render target texture used to display refraction on the ocean.
  75126. * By default, render list is empty.
  75127. */
  75128. refractionTexture: BABYLON.RenderTargetTexture;
  75129. private _time;
  75130. private _cameraRotation;
  75131. private _cameraViewMatrix;
  75132. private _reflectionEnabled;
  75133. private _refractionEnabled;
  75134. private _geometryRenderer;
  75135. /**
  75136. * Instantiates a new Ocean Post Process.
  75137. * @param name the name to give to the postprocess.
  75138. * @camera the camera to apply the post process to.
  75139. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  75140. */
  75141. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  75142. /**
  75143. * Returns the appropriate defines according to the current configuration.
  75144. */
  75145. private _getDefines;
  75146. /**
  75147. * Computes the current camera rotation as the shader requires a camera rotation.
  75148. */
  75149. private _computeCameraRotation;
  75150. }
  75151. }
  75152. declare module BABYLON {
  75153. /** @hidden */
  75154. export var brickProceduralTexturePixelShader: {
  75155. name: string;
  75156. shader: string;
  75157. };
  75158. }
  75159. declare module BABYLON {
  75160. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  75161. private _numberOfBricksHeight;
  75162. private _numberOfBricksWidth;
  75163. private _jointColor;
  75164. private _brickColor;
  75165. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  75166. updateShaderUniforms(): void;
  75167. numberOfBricksHeight: number;
  75168. numberOfBricksWidth: number;
  75169. jointColor: BABYLON.Color3;
  75170. brickColor: BABYLON.Color3;
  75171. /**
  75172. * Serializes this brick procedural texture
  75173. * @returns a serialized brick procedural texture object
  75174. */
  75175. serialize(): any;
  75176. /**
  75177. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  75178. * @param parsedTexture defines parsed texture data
  75179. * @param scene defines the current scene
  75180. * @param rootUrl defines the root URL containing brick procedural texture information
  75181. * @returns a parsed Brick Procedural BABYLON.Texture
  75182. */
  75183. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  75184. }
  75185. }
  75186. declare module BABYLON {
  75187. /** @hidden */
  75188. export var cloudProceduralTexturePixelShader: {
  75189. name: string;
  75190. shader: string;
  75191. };
  75192. }
  75193. declare module BABYLON {
  75194. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  75195. private _skyColor;
  75196. private _cloudColor;
  75197. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  75198. updateShaderUniforms(): void;
  75199. skyColor: BABYLON.Color4;
  75200. cloudColor: BABYLON.Color4;
  75201. /**
  75202. * Serializes this cloud procedural texture
  75203. * @returns a serialized cloud procedural texture object
  75204. */
  75205. serialize(): any;
  75206. /**
  75207. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  75208. * @param parsedTexture defines parsed texture data
  75209. * @param scene defines the current scene
  75210. * @param rootUrl defines the root URL containing cloud procedural texture information
  75211. * @returns a parsed Cloud Procedural BABYLON.Texture
  75212. */
  75213. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  75214. }
  75215. }
  75216. declare module BABYLON {
  75217. /** @hidden */
  75218. export var fireProceduralTexturePixelShader: {
  75219. name: string;
  75220. shader: string;
  75221. };
  75222. }
  75223. declare module BABYLON {
  75224. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  75225. private _time;
  75226. private _speed;
  75227. private _autoGenerateTime;
  75228. private _fireColors;
  75229. private _alphaThreshold;
  75230. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  75231. updateShaderUniforms(): void;
  75232. render(useCameraPostProcess?: boolean): void;
  75233. static readonly PurpleFireColors: BABYLON.Color3[];
  75234. static readonly GreenFireColors: BABYLON.Color3[];
  75235. static readonly RedFireColors: BABYLON.Color3[];
  75236. static readonly BlueFireColors: BABYLON.Color3[];
  75237. autoGenerateTime: boolean;
  75238. fireColors: BABYLON.Color3[];
  75239. time: number;
  75240. speed: BABYLON.Vector2;
  75241. alphaThreshold: number;
  75242. /**
  75243. * Serializes this fire procedural texture
  75244. * @returns a serialized fire procedural texture object
  75245. */
  75246. serialize(): any;
  75247. /**
  75248. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  75249. * @param parsedTexture defines parsed texture data
  75250. * @param scene defines the current scene
  75251. * @param rootUrl defines the root URL containing fire procedural texture information
  75252. * @returns a parsed Fire Procedural BABYLON.Texture
  75253. */
  75254. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  75255. }
  75256. }
  75257. declare module BABYLON {
  75258. /** @hidden */
  75259. export var grassProceduralTexturePixelShader: {
  75260. name: string;
  75261. shader: string;
  75262. };
  75263. }
  75264. declare module BABYLON {
  75265. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  75266. private _grassColors;
  75267. private _groundColor;
  75268. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  75269. updateShaderUniforms(): void;
  75270. grassColors: BABYLON.Color3[];
  75271. groundColor: BABYLON.Color3;
  75272. /**
  75273. * Serializes this grass procedural texture
  75274. * @returns a serialized grass procedural texture object
  75275. */
  75276. serialize(): any;
  75277. /**
  75278. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  75279. * @param parsedTexture defines parsed texture data
  75280. * @param scene defines the current scene
  75281. * @param rootUrl defines the root URL containing grass procedural texture information
  75282. * @returns a parsed Grass Procedural BABYLON.Texture
  75283. */
  75284. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  75285. }
  75286. }
  75287. declare module BABYLON {
  75288. /** @hidden */
  75289. export var marbleProceduralTexturePixelShader: {
  75290. name: string;
  75291. shader: string;
  75292. };
  75293. }
  75294. declare module BABYLON {
  75295. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  75296. private _numberOfTilesHeight;
  75297. private _numberOfTilesWidth;
  75298. private _amplitude;
  75299. private _jointColor;
  75300. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  75301. updateShaderUniforms(): void;
  75302. numberOfTilesHeight: number;
  75303. amplitude: number;
  75304. numberOfTilesWidth: number;
  75305. jointColor: BABYLON.Color3;
  75306. /**
  75307. * Serializes this marble procedural texture
  75308. * @returns a serialized marble procedural texture object
  75309. */
  75310. serialize(): any;
  75311. /**
  75312. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  75313. * @param parsedTexture defines parsed texture data
  75314. * @param scene defines the current scene
  75315. * @param rootUrl defines the root URL containing marble procedural texture information
  75316. * @returns a parsed Marble Procedural BABYLON.Texture
  75317. */
  75318. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  75319. }
  75320. }
  75321. declare module BABYLON {
  75322. /** @hidden */
  75323. export var normalMapProceduralTexturePixelShader: {
  75324. name: string;
  75325. shader: string;
  75326. };
  75327. }
  75328. declare module BABYLON {
  75329. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  75330. private _baseTexture;
  75331. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  75332. updateShaderUniforms(): void;
  75333. render(useCameraPostProcess?: boolean): void;
  75334. resize(size: any, generateMipMaps: any): void;
  75335. baseTexture: BABYLON.Texture;
  75336. /**
  75337. * Serializes this normal map procedural texture
  75338. * @returns a serialized normal map procedural texture object
  75339. */
  75340. serialize(): any;
  75341. /**
  75342. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  75343. * @param parsedTexture defines parsed texture data
  75344. * @param scene defines the current scene
  75345. * @param rootUrl defines the root URL containing normal map procedural texture information
  75346. * @returns a parsed Normal Map Procedural BABYLON.Texture
  75347. */
  75348. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  75349. }
  75350. }
  75351. declare module BABYLON {
  75352. /** @hidden */
  75353. export var perlinNoiseProceduralTexturePixelShader: {
  75354. name: string;
  75355. shader: string;
  75356. };
  75357. }
  75358. declare module BABYLON {
  75359. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  75360. time: number;
  75361. timeScale: number;
  75362. translationSpeed: number;
  75363. private _currentTranslation;
  75364. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  75365. updateShaderUniforms(): void;
  75366. render(useCameraPostProcess?: boolean): void;
  75367. resize(size: any, generateMipMaps: any): void;
  75368. /**
  75369. * Serializes this perlin noise procedural texture
  75370. * @returns a serialized perlin noise procedural texture object
  75371. */
  75372. serialize(): any;
  75373. /**
  75374. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  75375. * @param parsedTexture defines parsed texture data
  75376. * @param scene defines the current scene
  75377. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  75378. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  75379. */
  75380. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  75381. }
  75382. }
  75383. declare module BABYLON {
  75384. /** @hidden */
  75385. export var roadProceduralTexturePixelShader: {
  75386. name: string;
  75387. shader: string;
  75388. };
  75389. }
  75390. declare module BABYLON {
  75391. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  75392. private _roadColor;
  75393. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  75394. updateShaderUniforms(): void;
  75395. roadColor: BABYLON.Color3;
  75396. /**
  75397. * Serializes this road procedural texture
  75398. * @returns a serialized road procedural texture object
  75399. */
  75400. serialize(): any;
  75401. /**
  75402. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  75403. * @param parsedTexture defines parsed texture data
  75404. * @param scene defines the current scene
  75405. * @param rootUrl defines the root URL containing road procedural texture information
  75406. * @returns a parsed Road Procedural BABYLON.Texture
  75407. */
  75408. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  75409. }
  75410. }
  75411. declare module BABYLON {
  75412. /** @hidden */
  75413. export var starfieldProceduralTexturePixelShader: {
  75414. name: string;
  75415. shader: string;
  75416. };
  75417. }
  75418. declare module BABYLON {
  75419. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  75420. private _time;
  75421. private _alpha;
  75422. private _beta;
  75423. private _zoom;
  75424. private _formuparam;
  75425. private _stepsize;
  75426. private _tile;
  75427. private _brightness;
  75428. private _darkmatter;
  75429. private _distfading;
  75430. private _saturation;
  75431. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  75432. updateShaderUniforms(): void;
  75433. time: number;
  75434. alpha: number;
  75435. beta: number;
  75436. formuparam: number;
  75437. stepsize: number;
  75438. zoom: number;
  75439. tile: number;
  75440. brightness: number;
  75441. darkmatter: number;
  75442. distfading: number;
  75443. saturation: number;
  75444. /**
  75445. * Serializes this starfield procedural texture
  75446. * @returns a serialized starfield procedural texture object
  75447. */
  75448. serialize(): any;
  75449. /**
  75450. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  75451. * @param parsedTexture defines parsed texture data
  75452. * @param scene defines the current scene
  75453. * @param rootUrl defines the root URL containing startfield procedural texture information
  75454. * @returns a parsed Starfield Procedural BABYLON.Texture
  75455. */
  75456. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  75457. }
  75458. }
  75459. declare module BABYLON {
  75460. /** @hidden */
  75461. export var woodProceduralTexturePixelShader: {
  75462. name: string;
  75463. shader: string;
  75464. };
  75465. }
  75466. declare module BABYLON {
  75467. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  75468. private _ampScale;
  75469. private _woodColor;
  75470. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  75471. updateShaderUniforms(): void;
  75472. ampScale: number;
  75473. woodColor: BABYLON.Color3;
  75474. /**
  75475. * Serializes this wood procedural texture
  75476. * @returns a serialized wood procedural texture object
  75477. */
  75478. serialize(): any;
  75479. /**
  75480. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  75481. * @param parsedTexture defines parsed texture data
  75482. * @param scene defines the current scene
  75483. * @param rootUrl defines the root URL containing wood procedural texture information
  75484. * @returns a parsed Wood Procedural BABYLON.Texture
  75485. */
  75486. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  75487. }
  75488. }