documentation.d.ts 3.5 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813678146781567816678176781867819678206782167822678236782467825678266782767828678296783067831678326783367834678356783667837678386783967840678416784267843678446784567846678476784867849678506785167852678536785467855678566785767858678596786067861678626786367864678656786667867678686786967870678716787267873678746787567876678776787867879678806788167882678836788467885678866788767888678896789067891678926789367894678956789667897678986789967900679016790267903679046790567906679076790867909679106791167912679136791467915679166791767918679196792067921679226792367924679256792667927679286792967930679316793267933679346793567936679376793867939679406794167942679436794467945679466794767948679496795067951679526795367954679556795667957679586795967960679616796267963679646796567966679676796867969679706797167972679736797467975679766797767978679796798067981679826798367984679856798667987679886798967990679916799267993679946799567996679976799867999680006800168002680036800468005680066800768008680096801068011680126801368014680156801668017680186801968020680216802268023680246802568026680276802868029680306803168032680336803468035680366803768038680396804068041680426804368044680456804668047680486804968050680516805268053680546805568056680576805868059680606806168062680636806468065680666806768068680696807068071680726807368074680756807668077680786807968080680816808268083680846808568086680876808868089680906809168092680936809468095680966809768098680996810068101681026810368104681056810668107681086810968110681116811268113681146811568116681176811868119681206812168122681236812468125681266812768128681296813068131681326813368134681356813668137681386813968140681416814268143681446814568146681476814868149681506815168152681536815468155681566815768158681596816068161681626816368164681656816668167681686816968170681716817268173681746817568176681776817868179681806818168182681836818468185681866818768188681896819068191681926819368194681956819668197681986819968200682016820268203682046820568206682076820868209682106821168212682136821468215682166821768218682196822068221682226822368224682256822668227682286822968230682316823268233682346823568236682376823868239682406824168242682436824468245682466824768248682496825068251682526825368254682556825668257682586825968260682616826268263682646826568266682676826868269682706827168272682736827468275682766827768278682796828068281682826828368284682856828668287682886828968290682916829268293682946829568296682976829868299683006830168302683036830468305683066830768308683096831068311683126831368314683156831668317683186831968320683216832268323683246832568326683276832868329683306833168332683336833468335683366833768338683396834068341683426834368344683456834668347683486834968350683516835268353683546835568356683576835868359683606836168362683636836468365683666836768368683696837068371683726837368374683756837668377683786837968380683816838268383683846838568386683876838868389683906839168392683936839468395683966839768398683996840068401684026840368404684056840668407684086840968410684116841268413684146841568416684176841868419684206842168422684236842468425684266842768428684296843068431684326843368434684356843668437684386843968440684416844268443684446844568446684476844868449684506845168452684536845468455684566845768458684596846068461684626846368464684656846668467684686846968470684716847268473684746847568476684776847868479684806848168482684836848468485684866848768488684896849068491684926849368494684956849668497684986849968500685016850268503685046850568506685076850868509685106851168512685136851468515685166851768518685196852068521685226852368524685256852668527685286852968530685316853268533685346853568536685376853868539685406854168542685436854468545685466854768548685496855068551685526855368554685556855668557685586855968560685616856268563685646856568566685676856868569685706857168572685736857468575685766857768578685796858068581685826858368584685856858668587685886858968590685916859268593685946859568596685976859868599686006860168602686036860468605686066860768608686096861068611686126861368614686156861668617686186861968620686216862268623686246862568626686276862868629686306863168632686336863468635686366863768638686396864068641686426864368644686456864668647686486864968650686516865268653686546865568656686576865868659686606866168662686636866468665686666866768668686696867068671686726867368674686756867668677686786867968680686816868268683686846868568686686876868868689686906869168692686936869468695686966869768698686996870068701687026870368704687056870668707687086870968710687116871268713687146871568716687176871868719687206872168722687236872468725687266872768728687296873068731687326873368734687356873668737687386873968740687416874268743687446874568746687476874868749687506875168752687536875468755687566875768758687596876068761687626876368764687656876668767687686876968770687716877268773687746877568776687776877868779687806878168782687836878468785687866878768788687896879068791687926879368794687956879668797687986879968800688016880268803688046880568806688076880868809688106881168812688136881468815688166881768818688196882068821688226882368824688256882668827688286882968830688316883268833688346883568836688376883868839688406884168842688436884468845688466884768848688496885068851688526885368854688556885668857688586885968860688616886268863688646886568866688676886868869688706887168872688736887468875688766887768878688796888068881688826888368884688856888668887688886888968890688916889268893688946889568896688976889868899689006890168902689036890468905689066890768908689096891068911689126891368914689156891668917689186891968920689216892268923689246892568926689276892868929689306893168932689336893468935689366893768938689396894068941689426894368944689456894668947689486894968950689516895268953689546895568956689576895868959689606896168962689636896468965689666896768968689696897068971689726897368974689756897668977689786897968980689816898268983689846898568986689876898868989689906899168992689936899468995689966899768998689996900069001690026900369004690056900669007690086900969010690116901269013690146901569016690176901869019690206902169022690236902469025690266902769028690296903069031690326903369034690356903669037690386903969040690416904269043690446904569046690476904869049690506905169052690536905469055690566905769058690596906069061690626906369064690656906669067690686906969070690716907269073690746907569076690776907869079690806908169082690836908469085690866908769088690896909069091690926909369094690956909669097690986909969100691016910269103691046910569106691076910869109691106911169112691136911469115691166911769118691196912069121691226912369124691256912669127691286912969130691316913269133691346913569136691376913869139691406914169142691436914469145691466914769148691496915069151691526915369154691556915669157691586915969160691616916269163691646916569166691676916869169691706917169172691736917469175691766917769178691796918069181691826918369184691856918669187691886918969190691916919269193691946919569196691976919869199692006920169202692036920469205692066920769208692096921069211692126921369214692156921669217692186921969220692216922269223692246922569226692276922869229692306923169232692336923469235692366923769238692396924069241692426924369244692456924669247692486924969250692516925269253692546925569256692576925869259692606926169262692636926469265692666926769268692696927069271692726927369274692756927669277692786927969280692816928269283692846928569286692876928869289692906929169292692936929469295692966929769298692996930069301693026930369304693056930669307693086930969310693116931269313693146931569316693176931869319693206932169322693236932469325693266932769328693296933069331693326933369334693356933669337693386933969340693416934269343693446934569346693476934869349693506935169352693536935469355693566935769358693596936069361693626936369364693656936669367693686936969370693716937269373693746937569376693776937869379693806938169382693836938469385693866938769388693896939069391693926939369394693956939669397693986939969400694016940269403694046940569406694076940869409694106941169412694136941469415694166941769418694196942069421694226942369424694256942669427694286942969430694316943269433694346943569436694376943869439694406944169442694436944469445694466944769448694496945069451694526945369454694556945669457694586945969460694616946269463694646946569466694676946869469694706947169472694736947469475694766947769478694796948069481694826948369484694856948669487694886948969490694916949269493694946949569496694976949869499695006950169502695036950469505695066950769508695096951069511695126951369514695156951669517695186951969520695216952269523695246952569526695276952869529695306953169532695336953469535695366953769538695396954069541695426954369544695456954669547695486954969550695516955269553695546955569556695576955869559695606956169562695636956469565695666956769568695696957069571695726957369574695756957669577695786957969580695816958269583695846958569586695876958869589695906959169592695936959469595695966959769598695996960069601696026960369604696056960669607696086960969610696116961269613696146961569616696176961869619696206962169622696236962469625696266962769628696296963069631696326963369634696356963669637696386963969640696416964269643696446964569646696476964869649696506965169652696536965469655696566965769658696596966069661696626966369664696656966669667696686966969670696716967269673696746967569676696776967869679696806968169682696836968469685696866968769688696896969069691696926969369694696956969669697696986969969700697016970269703697046970569706697076970869709697106971169712697136971469715697166971769718697196972069721697226972369724697256972669727697286972969730697316973269733697346973569736697376973869739697406974169742697436974469745697466974769748697496975069751697526975369754697556975669757697586975969760697616976269763697646976569766697676976869769697706977169772697736977469775697766977769778697796978069781697826978369784697856978669787697886978969790697916979269793697946979569796697976979869799698006980169802698036980469805698066980769808698096981069811698126981369814698156981669817698186981969820698216982269823698246982569826698276982869829698306983169832698336983469835698366983769838698396984069841698426984369844698456984669847698486984969850698516985269853698546985569856698576985869859698606986169862698636986469865698666986769868698696987069871698726987369874698756987669877698786987969880698816988269883698846988569886698876988869889698906989169892698936989469895698966989769898698996990069901699026990369904699056990669907699086990969910699116991269913699146991569916699176991869919699206992169922699236992469925699266992769928699296993069931699326993369934699356993669937699386993969940699416994269943699446994569946699476994869949699506995169952699536995469955699566995769958699596996069961699626996369964699656996669967699686996969970699716997269973699746997569976699776997869979699806998169982699836998469985699866998769988699896999069991699926999369994699956999669997699986999970000700017000270003700047000570006700077000870009700107001170012700137001470015700167001770018700197002070021700227002370024700257002670027700287002970030700317003270033700347003570036700377003870039700407004170042700437004470045700467004770048700497005070051700527005370054700557005670057700587005970060700617006270063700647006570066700677006870069700707007170072700737007470075700767007770078700797008070081700827008370084700857008670087700887008970090700917009270093700947009570096700977009870099701007010170102701037010470105701067010770108701097011070111701127011370114701157011670117701187011970120701217012270123701247012570126701277012870129701307013170132701337013470135701367013770138701397014070141701427014370144701457014670147701487014970150701517015270153701547015570156701577015870159701607016170162701637016470165701667016770168701697017070171701727017370174701757017670177701787017970180701817018270183701847018570186701877018870189701907019170192701937019470195701967019770198701997020070201702027020370204702057020670207702087020970210702117021270213702147021570216702177021870219702207022170222702237022470225702267022770228702297023070231702327023370234702357023670237702387023970240702417024270243702447024570246702477024870249702507025170252702537025470255702567025770258702597026070261702627026370264702657026670267702687026970270702717027270273702747027570276702777027870279702807028170282702837028470285702867028770288702897029070291702927029370294702957029670297702987029970300703017030270303703047030570306703077030870309703107031170312703137031470315703167031770318703197032070321703227032370324703257032670327703287032970330703317033270333703347033570336703377033870339703407034170342703437034470345703467034770348703497035070351703527035370354703557035670357703587035970360703617036270363703647036570366703677036870369703707037170372703737037470375703767037770378703797038070381703827038370384703857038670387703887038970390703917039270393703947039570396703977039870399704007040170402704037040470405704067040770408704097041070411704127041370414704157041670417704187041970420704217042270423704247042570426704277042870429704307043170432704337043470435704367043770438704397044070441704427044370444704457044670447704487044970450704517045270453704547045570456704577045870459704607046170462704637046470465704667046770468704697047070471704727047370474704757047670477704787047970480704817048270483704847048570486704877048870489704907049170492704937049470495704967049770498704997050070501705027050370504705057050670507705087050970510705117051270513705147051570516705177051870519705207052170522705237052470525705267052770528705297053070531705327053370534705357053670537705387053970540705417054270543705447054570546705477054870549705507055170552705537055470555705567055770558705597056070561705627056370564705657056670567705687056970570705717057270573705747057570576705777057870579705807058170582705837058470585705867058770588705897059070591705927059370594705957059670597705987059970600706017060270603706047060570606706077060870609706107061170612706137061470615706167061770618706197062070621706227062370624706257062670627706287062970630706317063270633706347063570636706377063870639706407064170642706437064470645706467064770648706497065070651706527065370654706557065670657706587065970660706617066270663706647066570666706677066870669706707067170672706737067470675706767067770678706797068070681706827068370684706857068670687706887068970690706917069270693706947069570696706977069870699707007070170702707037070470705707067070770708707097071070711707127071370714707157071670717707187071970720707217072270723707247072570726707277072870729707307073170732707337073470735707367073770738707397074070741707427074370744707457074670747707487074970750707517075270753707547075570756707577075870759707607076170762707637076470765707667076770768707697077070771707727077370774707757077670777707787077970780707817078270783707847078570786707877078870789707907079170792707937079470795707967079770798707997080070801708027080370804708057080670807708087080970810708117081270813708147081570816708177081870819708207082170822708237082470825708267082770828708297083070831708327083370834708357083670837708387083970840708417084270843708447084570846708477084870849708507085170852708537085470855708567085770858708597086070861708627086370864708657086670867708687086970870708717087270873708747087570876708777087870879708807088170882708837088470885708867088770888708897089070891708927089370894708957089670897708987089970900709017090270903709047090570906709077090870909709107091170912709137091470915709167091770918709197092070921709227092370924709257092670927709287092970930709317093270933709347093570936709377093870939709407094170942709437094470945709467094770948709497095070951709527095370954709557095670957709587095970960709617096270963709647096570966709677096870969709707097170972709737097470975709767097770978709797098070981709827098370984709857098670987709887098970990709917099270993709947099570996709977099870999710007100171002710037100471005710067100771008710097101071011710127101371014710157101671017710187101971020710217102271023710247102571026710277102871029710307103171032710337103471035710367103771038710397104071041710427104371044710457104671047710487104971050710517105271053710547105571056710577105871059710607106171062710637106471065710667106771068710697107071071710727107371074710757107671077710787107971080710817108271083710847108571086710877108871089710907109171092710937109471095710967109771098710997110071101711027110371104711057110671107711087110971110711117111271113711147111571116711177111871119711207112171122711237112471125711267112771128711297113071131711327113371134711357113671137711387113971140711417114271143711447114571146711477114871149711507115171152711537115471155711567115771158711597116071161711627116371164711657116671167711687116971170711717117271173711747117571176711777117871179711807118171182711837118471185711867118771188711897119071191711927119371194711957119671197711987119971200712017120271203712047120571206712077120871209712107121171212712137121471215712167121771218712197122071221712227122371224712257122671227712287122971230712317123271233712347123571236712377123871239712407124171242712437124471245712467124771248712497125071251712527125371254712557125671257712587125971260712617126271263712647126571266712677126871269712707127171272712737127471275712767127771278712797128071281712827128371284712857128671287712887128971290712917129271293712947129571296712977129871299713007130171302713037130471305713067130771308713097131071311713127131371314713157131671317713187131971320713217132271323713247132571326713277132871329713307133171332713337133471335713367133771338713397134071341713427134371344713457134671347713487134971350713517135271353713547135571356713577135871359713607136171362713637136471365713667136771368713697137071371713727137371374713757137671377713787137971380713817138271383713847138571386713877138871389713907139171392713937139471395713967139771398713997140071401714027140371404714057140671407714087140971410714117141271413714147141571416714177141871419714207142171422714237142471425714267142771428714297143071431714327143371434714357143671437714387143971440714417144271443714447144571446714477144871449714507145171452714537145471455714567145771458714597146071461714627146371464714657146671467714687146971470714717147271473714747147571476714777147871479714807148171482714837148471485714867148771488714897149071491714927149371494714957149671497714987149971500715017150271503715047150571506715077150871509715107151171512715137151471515715167151771518715197152071521715227152371524715257152671527715287152971530715317153271533715347153571536715377153871539715407154171542715437154471545715467154771548715497155071551715527155371554715557155671557715587155971560715617156271563715647156571566715677156871569715707157171572715737157471575715767157771578715797158071581715827158371584715857158671587715887158971590715917159271593715947159571596715977159871599716007160171602716037160471605716067160771608716097161071611716127161371614716157161671617716187161971620716217162271623716247162571626716277162871629716307163171632716337163471635716367163771638716397164071641716427164371644716457164671647716487164971650716517165271653716547165571656716577165871659716607166171662716637166471665716667166771668716697167071671716727167371674716757167671677716787167971680716817168271683716847168571686716877168871689716907169171692716937169471695716967169771698716997170071701717027170371704717057170671707717087170971710717117171271713717147171571716717177171871719717207172171722717237172471725717267172771728717297173071731717327173371734717357173671737717387173971740717417174271743717447174571746717477174871749717507175171752717537175471755717567175771758717597176071761717627176371764717657176671767717687176971770717717177271773717747177571776717777177871779717807178171782717837178471785717867178771788717897179071791717927179371794717957179671797717987179971800718017180271803718047180571806718077180871809718107181171812718137181471815718167181771818718197182071821718227182371824718257182671827718287182971830718317183271833718347183571836718377183871839718407184171842718437184471845718467184771848718497185071851718527185371854718557185671857718587185971860718617186271863718647186571866718677186871869718707187171872718737187471875718767187771878718797188071881718827188371884718857188671887718887188971890718917189271893718947189571896718977189871899719007190171902719037190471905719067190771908719097191071911719127191371914719157191671917719187191971920719217192271923719247192571926719277192871929719307193171932719337193471935719367193771938719397194071941719427194371944719457194671947719487194971950719517195271953719547195571956719577195871959719607196171962719637196471965719667196771968719697197071971719727197371974719757197671977719787197971980719817198271983719847198571986719877198871989719907199171992719937199471995719967199771998719997200072001720027200372004720057200672007720087200972010720117201272013720147201572016720177201872019720207202172022720237202472025720267202772028720297203072031720327203372034720357203672037720387203972040720417204272043720447204572046720477204872049720507205172052720537205472055720567205772058720597206072061720627206372064720657206672067720687206972070720717207272073720747207572076720777207872079720807208172082720837208472085720867208772088720897209072091720927209372094720957209672097720987209972100721017210272103721047210572106721077210872109721107211172112721137211472115721167211772118721197212072121721227212372124721257212672127721287212972130721317213272133721347213572136721377213872139721407214172142721437214472145721467214772148721497215072151721527215372154721557215672157721587215972160721617216272163721647216572166721677216872169721707217172172721737217472175721767217772178721797218072181721827218372184721857218672187721887218972190721917219272193721947219572196721977219872199722007220172202722037220472205722067220772208722097221072211722127221372214722157221672217722187221972220722217222272223722247222572226722277222872229722307223172232722337223472235722367223772238722397224072241722427224372244722457224672247722487224972250722517225272253722547225572256722577225872259722607226172262722637226472265722667226772268722697227072271722727227372274722757227672277722787227972280722817228272283722847228572286722877228872289722907229172292722937229472295722967229772298722997230072301723027230372304723057230672307723087230972310723117231272313723147231572316723177231872319723207232172322723237232472325723267232772328723297233072331723327233372334723357233672337723387233972340723417234272343723447234572346723477234872349723507235172352723537235472355723567235772358723597236072361723627236372364723657236672367723687236972370723717237272373723747237572376723777237872379723807238172382723837238472385723867238772388723897239072391723927239372394723957239672397723987239972400724017240272403724047240572406724077240872409724107241172412724137241472415724167241772418724197242072421724227242372424724257242672427724287242972430724317243272433724347243572436724377243872439724407244172442724437244472445724467244772448724497245072451724527245372454724557245672457724587245972460724617246272463724647246572466724677246872469724707247172472724737247472475724767247772478724797248072481724827248372484724857248672487724887248972490724917249272493724947249572496724977249872499725007250172502725037250472505725067250772508725097251072511725127251372514725157251672517725187251972520725217252272523725247252572526725277252872529725307253172532725337253472535725367253772538725397254072541725427254372544725457254672547725487254972550725517255272553725547255572556725577255872559725607256172562725637256472565725667256772568725697257072571725727257372574725757257672577725787257972580725817258272583725847258572586725877258872589725907259172592725937259472595725967259772598725997260072601726027260372604726057260672607726087260972610726117261272613726147261572616726177261872619726207262172622726237262472625726267262772628726297263072631726327263372634726357263672637726387263972640726417264272643726447264572646726477264872649726507265172652726537265472655726567265772658726597266072661726627266372664726657266672667726687266972670726717267272673726747267572676726777267872679726807268172682726837268472685726867268772688726897269072691726927269372694726957269672697726987269972700727017270272703727047270572706727077270872709727107271172712727137271472715727167271772718727197272072721727227272372724727257272672727727287272972730727317273272733727347273572736727377273872739727407274172742727437274472745727467274772748727497275072751727527275372754727557275672757727587275972760727617276272763727647276572766727677276872769727707277172772727737277472775727767277772778727797278072781727827278372784727857278672787727887278972790727917279272793727947279572796727977279872799728007280172802728037280472805728067280772808728097281072811728127281372814728157281672817728187281972820728217282272823728247282572826728277282872829728307283172832728337283472835728367283772838728397284072841728427284372844728457284672847728487284972850728517285272853728547285572856728577285872859728607286172862728637286472865728667286772868728697287072871728727287372874728757287672877728787287972880728817288272883728847288572886728877288872889728907289172892728937289472895728967289772898728997290072901729027290372904729057290672907729087290972910729117291272913729147291572916729177291872919729207292172922729237292472925729267292772928729297293072931729327293372934729357293672937729387293972940729417294272943729447294572946729477294872949729507295172952729537295472955729567295772958729597296072961729627296372964729657296672967729687296972970729717297272973729747297572976729777297872979729807298172982729837298472985729867298772988729897299072991729927299372994729957299672997729987299973000730017300273003730047300573006730077300873009730107301173012730137301473015730167301773018730197302073021730227302373024730257302673027730287302973030730317303273033730347303573036730377303873039730407304173042730437304473045730467304773048730497305073051730527305373054730557305673057730587305973060730617306273063730647306573066730677306873069730707307173072730737307473075730767307773078730797308073081730827308373084730857308673087730887308973090730917309273093730947309573096730977309873099731007310173102731037310473105731067310773108731097311073111731127311373114731157311673117731187311973120731217312273123731247312573126731277312873129731307313173132731337313473135731367313773138731397314073141731427314373144731457314673147731487314973150731517315273153731547315573156731577315873159731607316173162731637316473165731667316773168731697317073171731727317373174731757317673177731787317973180731817318273183731847318573186731877318873189731907319173192731937319473195731967319773198731997320073201732027320373204732057320673207732087320973210732117321273213732147321573216732177321873219732207322173222732237322473225732267322773228732297323073231732327323373234732357323673237732387323973240732417324273243732447324573246732477324873249732507325173252732537325473255732567325773258732597326073261732627326373264732657326673267732687326973270732717327273273732747327573276732777327873279732807328173282732837328473285732867328773288732897329073291732927329373294732957329673297732987329973300733017330273303733047330573306733077330873309733107331173312733137331473315733167331773318733197332073321733227332373324733257332673327733287332973330733317333273333733347333573336733377333873339733407334173342733437334473345733467334773348733497335073351733527335373354733557335673357733587335973360733617336273363733647336573366733677336873369733707337173372733737337473375733767337773378733797338073381733827338373384733857338673387733887338973390733917339273393733947339573396733977339873399734007340173402734037340473405734067340773408734097341073411734127341373414734157341673417734187341973420734217342273423734247342573426734277342873429734307343173432734337343473435734367343773438734397344073441734427344373444734457344673447734487344973450734517345273453734547345573456734577345873459734607346173462734637346473465734667346773468734697347073471734727347373474734757347673477734787347973480734817348273483734847348573486734877348873489734907349173492734937349473495734967349773498734997350073501735027350373504735057350673507735087350973510735117351273513735147351573516735177351873519735207352173522735237352473525735267352773528735297353073531735327353373534735357353673537735387353973540735417354273543735447354573546735477354873549735507355173552735537355473555735567355773558735597356073561735627356373564735657356673567735687356973570735717357273573735747357573576735777357873579735807358173582735837358473585735867358773588735897359073591735927359373594735957359673597735987359973600736017360273603736047360573606736077360873609736107361173612736137361473615736167361773618736197362073621736227362373624736257362673627736287362973630736317363273633736347363573636736377363873639736407364173642736437364473645736467364773648736497365073651736527365373654736557365673657736587365973660736617366273663736647366573666736677366873669736707367173672736737367473675736767367773678736797368073681736827368373684736857368673687736887368973690736917369273693736947369573696736977369873699737007370173702737037370473705737067370773708737097371073711737127371373714737157371673717737187371973720737217372273723737247372573726737277372873729737307373173732737337373473735737367373773738737397374073741737427374373744737457374673747737487374973750737517375273753737547375573756737577375873759737607376173762737637376473765737667376773768737697377073771737727377373774737757377673777737787377973780737817378273783737847378573786737877378873789737907379173792737937379473795737967379773798737997380073801738027380373804738057380673807738087380973810738117381273813738147381573816738177381873819738207382173822738237382473825738267382773828738297383073831738327383373834738357383673837738387383973840738417384273843738447384573846738477384873849738507385173852738537385473855738567385773858738597386073861738627386373864738657386673867738687386973870738717387273873738747387573876738777387873879738807388173882738837388473885738867388773888738897389073891738927389373894738957389673897738987389973900739017390273903739047390573906739077390873909739107391173912739137391473915739167391773918739197392073921739227392373924739257392673927739287392973930739317393273933739347393573936739377393873939739407394173942739437394473945739467394773948739497395073951739527395373954739557395673957739587395973960739617396273963739647396573966739677396873969739707397173972739737397473975739767397773978739797398073981739827398373984739857398673987739887398973990739917399273993739947399573996739977399873999740007400174002740037400474005740067400774008740097401074011740127401374014740157401674017740187401974020740217402274023740247402574026740277402874029740307403174032740337403474035740367403774038740397404074041740427404374044740457404674047740487404974050740517405274053740547405574056740577405874059740607406174062740637406474065740667406774068740697407074071740727407374074740757407674077740787407974080740817408274083740847408574086740877408874089740907409174092740937409474095740967409774098740997410074101741027410374104741057410674107741087410974110741117411274113741147411574116741177411874119741207412174122741237412474125741267412774128741297413074131741327413374134741357413674137741387413974140741417414274143741447414574146741477414874149741507415174152741537415474155741567415774158741597416074161741627416374164741657416674167741687416974170741717417274173741747417574176741777417874179741807418174182741837418474185741867418774188741897419074191741927419374194741957419674197741987419974200742017420274203742047420574206742077420874209742107421174212742137421474215742167421774218742197422074221742227422374224742257422674227742287422974230742317423274233742347423574236742377423874239742407424174242742437424474245742467424774248742497425074251742527425374254742557425674257742587425974260742617426274263742647426574266742677426874269742707427174272742737427474275742767427774278742797428074281742827428374284742857428674287742887428974290742917429274293742947429574296742977429874299743007430174302743037430474305743067430774308743097431074311743127431374314743157431674317743187431974320743217432274323743247432574326743277432874329743307433174332743337433474335743367433774338743397434074341743427434374344743457434674347743487434974350743517435274353743547435574356743577435874359743607436174362743637436474365743667436774368743697437074371743727437374374743757437674377743787437974380743817438274383743847438574386743877438874389743907439174392743937439474395743967439774398743997440074401744027440374404744057440674407744087440974410744117441274413744147441574416744177441874419744207442174422744237442474425744267442774428744297443074431744327443374434744357443674437744387443974440744417444274443744447444574446744477444874449744507445174452744537445474455744567445774458744597446074461744627446374464744657446674467744687446974470744717447274473744747447574476744777447874479744807448174482744837448474485744867448774488744897449074491744927449374494744957449674497744987449974500745017450274503745047450574506745077450874509745107451174512745137451474515745167451774518745197452074521745227452374524745257452674527745287452974530745317453274533745347453574536745377453874539745407454174542745437454474545745467454774548745497455074551745527455374554745557455674557745587455974560745617456274563745647456574566745677456874569745707457174572745737457474575745767457774578745797458074581745827458374584745857458674587745887458974590745917459274593745947459574596745977459874599746007460174602746037460474605746067460774608746097461074611746127461374614746157461674617746187461974620746217462274623746247462574626746277462874629746307463174632746337463474635746367463774638746397464074641746427464374644746457464674647746487464974650746517465274653746547465574656746577465874659746607466174662746637466474665746667466774668746697467074671746727467374674746757467674677746787467974680746817468274683746847468574686746877468874689746907469174692746937469474695746967469774698746997470074701747027470374704747057470674707747087470974710747117471274713747147471574716747177471874719747207472174722747237472474725747267472774728747297473074731747327473374734747357473674737747387473974740747417474274743747447474574746747477474874749747507475174752747537475474755747567475774758747597476074761747627476374764747657476674767747687476974770747717477274773747747477574776747777477874779747807478174782747837478474785747867478774788747897479074791747927479374794747957479674797747987479974800748017480274803748047480574806748077480874809748107481174812748137481474815748167481774818748197482074821748227482374824748257482674827748287482974830748317483274833748347483574836748377483874839748407484174842748437484474845748467484774848748497485074851748527485374854748557485674857748587485974860748617486274863748647486574866748677486874869748707487174872748737487474875748767487774878748797488074881748827488374884748857488674887748887488974890748917489274893748947489574896748977489874899749007490174902749037490474905749067490774908749097491074911749127491374914749157491674917749187491974920749217492274923749247492574926749277492874929749307493174932749337493474935749367493774938749397494074941749427494374944749457494674947749487494974950749517495274953749547495574956749577495874959749607496174962749637496474965749667496774968749697497074971749727497374974749757497674977749787497974980749817498274983749847498574986749877498874989749907499174992749937499474995749967499774998749997500075001750027500375004750057500675007750087500975010750117501275013750147501575016750177501875019750207502175022750237502475025750267502775028750297503075031750327503375034750357503675037750387503975040750417504275043750447504575046750477504875049750507505175052750537505475055750567505775058750597506075061750627506375064750657506675067750687506975070750717507275073750747507575076750777507875079750807508175082750837508475085750867508775088750897509075091750927509375094750957509675097750987509975100751017510275103751047510575106751077510875109751107511175112751137511475115751167511775118751197512075121751227512375124751257512675127751287512975130751317513275133751347513575136751377513875139751407514175142751437514475145751467514775148751497515075151751527515375154751557515675157751587515975160751617516275163751647516575166751677516875169751707517175172751737517475175751767517775178751797518075181751827518375184751857518675187751887518975190751917519275193751947519575196751977519875199752007520175202752037520475205752067520775208752097521075211752127521375214752157521675217752187521975220752217522275223752247522575226752277522875229752307523175232752337523475235752367523775238752397524075241752427524375244752457524675247752487524975250752517525275253752547525575256752577525875259752607526175262752637526475265752667526775268752697527075271752727527375274752757527675277752787527975280752817528275283752847528575286752877528875289752907529175292752937529475295752967529775298752997530075301753027530375304753057530675307753087530975310753117531275313753147531575316753177531875319753207532175322753237532475325753267532775328753297533075331753327533375334753357533675337753387533975340753417534275343753447534575346753477534875349753507535175352753537535475355753567535775358753597536075361753627536375364753657536675367753687536975370753717537275373753747537575376753777537875379753807538175382753837538475385753867538775388753897539075391753927539375394753957539675397753987539975400754017540275403754047540575406754077540875409754107541175412754137541475415754167541775418754197542075421754227542375424754257542675427754287542975430754317543275433754347543575436754377543875439754407544175442754437544475445754467544775448754497545075451754527545375454754557545675457754587545975460754617546275463754647546575466754677546875469754707547175472754737547475475754767547775478754797548075481754827548375484754857548675487754887548975490754917549275493754947549575496754977549875499755007550175502755037550475505755067550775508755097551075511755127551375514755157551675517755187551975520755217552275523755247552575526755277552875529755307553175532755337553475535755367553775538755397554075541755427554375544755457554675547755487554975550755517555275553755547555575556755577555875559755607556175562755637556475565755667556775568755697557075571755727557375574755757557675577755787557975580755817558275583755847558575586755877558875589755907559175592755937559475595755967559775598755997560075601756027560375604756057560675607756087560975610756117561275613756147561575616756177561875619756207562175622756237562475625756267562775628756297563075631756327563375634756357563675637756387563975640756417564275643756447564575646756477564875649756507565175652756537565475655756567565775658756597566075661756627566375664756657566675667756687566975670756717567275673756747567575676756777567875679756807568175682756837568475685756867568775688756897569075691756927569375694756957569675697756987569975700757017570275703757047570575706757077570875709757107571175712757137571475715757167571775718757197572075721757227572375724757257572675727757287572975730757317573275733757347573575736757377573875739757407574175742757437574475745757467574775748757497575075751757527575375754757557575675757757587575975760757617576275763757647576575766757677576875769757707577175772757737577475775757767577775778757797578075781757827578375784757857578675787757887578975790757917579275793757947579575796757977579875799758007580175802758037580475805758067580775808758097581075811758127581375814758157581675817758187581975820758217582275823758247582575826758277582875829758307583175832758337583475835758367583775838758397584075841758427584375844758457584675847758487584975850758517585275853758547585575856758577585875859758607586175862758637586475865758667586775868758697587075871758727587375874758757587675877758787587975880758817588275883758847588575886758877588875889758907589175892758937589475895758967589775898758997590075901759027590375904759057590675907759087590975910759117591275913759147591575916759177591875919759207592175922759237592475925759267592775928759297593075931759327593375934759357593675937759387593975940759417594275943759447594575946759477594875949759507595175952759537595475955759567595775958759597596075961759627596375964759657596675967759687596975970759717597275973759747597575976759777597875979759807598175982759837598475985759867598775988759897599075991759927599375994759957599675997759987599976000760017600276003760047600576006760077600876009760107601176012760137601476015760167601776018760197602076021760227602376024760257602676027760287602976030760317603276033760347603576036760377603876039760407604176042760437604476045760467604776048760497605076051760527605376054760557605676057760587605976060760617606276063760647606576066760677606876069760707607176072760737607476075760767607776078760797608076081760827608376084760857608676087760887608976090760917609276093760947609576096760977609876099761007610176102761037610476105761067610776108761097611076111761127611376114761157611676117761187611976120761217612276123761247612576126761277612876129761307613176132761337613476135761367613776138761397614076141761427614376144761457614676147761487614976150761517615276153761547615576156761577615876159761607616176162761637616476165761667616776168761697617076171761727617376174761757617676177761787617976180761817618276183761847618576186761877618876189761907619176192761937619476195761967619776198761997620076201762027620376204762057620676207762087620976210762117621276213762147621576216762177621876219762207622176222762237622476225762267622776228762297623076231762327623376234762357623676237762387623976240762417624276243762447624576246762477624876249762507625176252762537625476255762567625776258762597626076261762627626376264762657626676267762687626976270762717627276273762747627576276762777627876279762807628176282762837628476285762867628776288762897629076291762927629376294762957629676297762987629976300763017630276303763047630576306763077630876309763107631176312763137631476315763167631776318763197632076321763227632376324763257632676327763287632976330763317633276333763347633576336763377633876339763407634176342763437634476345763467634776348763497635076351763527635376354763557635676357763587635976360763617636276363763647636576366763677636876369763707637176372763737637476375763767637776378763797638076381763827638376384763857638676387763887638976390763917639276393763947639576396763977639876399764007640176402764037640476405764067640776408764097641076411764127641376414764157641676417764187641976420764217642276423764247642576426764277642876429764307643176432764337643476435764367643776438764397644076441764427644376444764457644676447764487644976450764517645276453764547645576456764577645876459764607646176462764637646476465764667646776468764697647076471764727647376474764757647676477764787647976480764817648276483764847648576486764877648876489764907649176492764937649476495764967649776498764997650076501765027650376504765057650676507765087650976510765117651276513765147651576516765177651876519765207652176522765237652476525765267652776528765297653076531765327653376534765357653676537765387653976540765417654276543765447654576546765477654876549765507655176552765537655476555765567655776558765597656076561765627656376564765657656676567765687656976570765717657276573765747657576576765777657876579765807658176582765837658476585765867658776588765897659076591765927659376594765957659676597765987659976600766017660276603766047660576606766077660876609766107661176612766137661476615766167661776618766197662076621766227662376624766257662676627766287662976630766317663276633766347663576636766377663876639766407664176642766437664476645766467664776648766497665076651766527665376654766557665676657766587665976660766617666276663766647666576666766677666876669766707667176672766737667476675766767667776678766797668076681766827668376684766857668676687766887668976690766917669276693766947669576696766977669876699767007670176702767037670476705767067670776708767097671076711767127671376714767157671676717767187671976720767217672276723767247672576726767277672876729767307673176732767337673476735767367673776738767397674076741767427674376744767457674676747767487674976750767517675276753767547675576756767577675876759767607676176762767637676476765767667676776768767697677076771767727677376774767757677676777767787677976780767817678276783767847678576786767877678876789767907679176792767937679476795767967679776798767997680076801768027680376804768057680676807768087680976810768117681276813768147681576816768177681876819768207682176822768237682476825768267682776828768297683076831768327683376834768357683676837768387683976840768417684276843768447684576846768477684876849768507685176852768537685476855768567685776858768597686076861768627686376864768657686676867768687686976870768717687276873768747687576876768777687876879768807688176882768837688476885768867688776888768897689076891768927689376894768957689676897768987689976900769017690276903769047690576906769077690876909769107691176912769137691476915769167691776918769197692076921769227692376924769257692676927769287692976930769317693276933769347693576936769377693876939769407694176942769437694476945769467694776948769497695076951769527695376954769557695676957769587695976960769617696276963769647696576966769677696876969769707697176972769737697476975769767697776978769797698076981769827698376984769857698676987769887698976990769917699276993769947699576996769977699876999770007700177002770037700477005770067700777008770097701077011770127701377014770157701677017770187701977020770217702277023770247702577026770277702877029770307703177032770337703477035770367703777038770397704077041770427704377044770457704677047770487704977050770517705277053770547705577056770577705877059770607706177062770637706477065770667706777068770697707077071770727707377074770757707677077770787707977080770817708277083770847708577086770877708877089770907709177092770937709477095770967709777098770997710077101771027710377104771057710677107771087710977110771117711277113771147711577116771177711877119771207712177122771237712477125771267712777128771297713077131771327713377134771357713677137771387713977140771417714277143771447714577146771477714877149771507715177152771537715477155771567715777158771597716077161771627716377164771657716677167771687716977170771717717277173771747717577176771777717877179771807718177182771837718477185771867718777188771897719077191771927719377194771957719677197771987719977200772017720277203772047720577206772077720877209772107721177212772137721477215772167721777218772197722077221772227722377224772257722677227772287722977230772317723277233772347723577236772377723877239772407724177242772437724477245772467724777248772497725077251772527725377254772557725677257772587725977260772617726277263772647726577266772677726877269772707727177272772737727477275772767727777278772797728077281772827728377284772857728677287772887728977290772917729277293772947729577296772977729877299773007730177302773037730477305773067730777308773097731077311773127731377314773157731677317773187731977320773217732277323773247732577326773277732877329773307733177332773337733477335773367733777338773397734077341773427734377344773457734677347773487734977350773517735277353773547735577356773577735877359773607736177362773637736477365773667736777368773697737077371773727737377374773757737677377773787737977380773817738277383773847738577386773877738877389773907739177392773937739477395773967739777398773997740077401774027740377404774057740677407774087740977410774117741277413774147741577416774177741877419774207742177422774237742477425774267742777428774297743077431774327743377434774357743677437774387743977440774417744277443774447744577446774477744877449774507745177452774537745477455774567745777458774597746077461774627746377464774657746677467774687746977470774717747277473774747747577476774777747877479774807748177482774837748477485774867748777488774897749077491774927749377494774957749677497774987749977500775017750277503775047750577506775077750877509775107751177512775137751477515775167751777518775197752077521775227752377524775257752677527775287752977530775317753277533775347753577536775377753877539775407754177542775437754477545775467754777548775497755077551775527755377554775557755677557775587755977560775617756277563775647756577566775677756877569775707757177572775737757477575775767757777578775797758077581775827758377584775857758677587775887758977590775917759277593775947759577596775977759877599776007760177602776037760477605776067760777608776097761077611776127761377614776157761677617776187761977620776217762277623776247762577626776277762877629776307763177632776337763477635776367763777638776397764077641776427764377644776457764677647776487764977650776517765277653776547765577656776577765877659776607766177662776637766477665776667766777668776697767077671776727767377674776757767677677776787767977680776817768277683776847768577686776877768877689776907769177692776937769477695776967769777698776997770077701777027770377704777057770677707777087770977710777117771277713777147771577716777177771877719777207772177722777237772477725777267772777728777297773077731777327773377734777357773677737777387773977740777417774277743777447774577746777477774877749777507775177752777537775477755777567775777758777597776077761777627776377764777657776677767777687776977770777717777277773777747777577776777777777877779777807778177782777837778477785777867778777788777897779077791777927779377794777957779677797777987779977800778017780277803778047780577806778077780877809778107781177812778137781477815778167781777818778197782077821778227782377824778257782677827778287782977830778317783277833778347783577836778377783877839778407784177842778437784477845778467784777848778497785077851778527785377854778557785677857778587785977860778617786277863778647786577866778677786877869778707787177872778737787477875778767787777878778797788077881778827788377884778857788677887778887788977890778917789277893778947789577896778977789877899779007790177902779037790477905779067790777908779097791077911779127791377914779157791677917779187791977920779217792277923779247792577926779277792877929779307793177932779337793477935779367793777938779397794077941779427794377944779457794677947779487794977950779517795277953779547795577956779577795877959779607796177962779637796477965779667796777968779697797077971779727797377974779757797677977779787797977980779817798277983779847798577986779877798877989779907799177992779937799477995779967799777998779997800078001780027800378004780057800678007780087800978010780117801278013780147801578016780177801878019780207802178022780237802478025780267802778028780297803078031780327803378034780357803678037780387803978040780417804278043780447804578046780477804878049780507805178052780537805478055780567805778058780597806078061780627806378064780657806678067780687806978070780717807278073780747807578076780777807878079780807808178082780837808478085780867808778088780897809078091780927809378094780957809678097780987809978100781017810278103781047810578106781077810878109781107811178112781137811478115781167811778118781197812078121781227812378124781257812678127781287812978130781317813278133781347813578136781377813878139781407814178142781437814478145781467814778148781497815078151781527815378154781557815678157781587815978160781617816278163781647816578166781677816878169781707817178172781737817478175781767817778178781797818078181781827818378184781857818678187781887818978190781917819278193781947819578196781977819878199782007820178202782037820478205782067820778208782097821078211782127821378214782157821678217782187821978220782217822278223782247822578226782277822878229782307823178232782337823478235782367823778238782397824078241782427824378244782457824678247782487824978250782517825278253782547825578256782577825878259782607826178262782637826478265782667826778268782697827078271782727827378274782757827678277782787827978280782817828278283782847828578286782877828878289782907829178292782937829478295782967829778298782997830078301783027830378304783057830678307783087830978310783117831278313783147831578316783177831878319783207832178322783237832478325783267832778328783297833078331783327833378334783357833678337783387833978340783417834278343783447834578346783477834878349783507835178352783537835478355783567835778358783597836078361783627836378364783657836678367783687836978370783717837278373783747837578376783777837878379783807838178382783837838478385783867838778388783897839078391783927839378394783957839678397783987839978400784017840278403784047840578406784077840878409784107841178412784137841478415784167841778418784197842078421784227842378424784257842678427784287842978430784317843278433784347843578436784377843878439784407844178442784437844478445784467844778448784497845078451784527845378454784557845678457784587845978460784617846278463784647846578466784677846878469784707847178472784737847478475784767847778478784797848078481784827848378484784857848678487784887848978490784917849278493784947849578496784977849878499785007850178502785037850478505785067850778508785097851078511785127851378514785157851678517785187851978520785217852278523785247852578526785277852878529785307853178532785337853478535785367853778538785397854078541785427854378544785457854678547785487854978550785517855278553785547855578556785577855878559785607856178562785637856478565785667856778568785697857078571785727857378574785757857678577785787857978580785817858278583785847858578586785877858878589785907859178592785937859478595785967859778598785997860078601786027860378604786057860678607786087860978610786117861278613786147861578616786177861878619786207862178622786237862478625786267862778628786297863078631786327863378634786357863678637786387863978640786417864278643786447864578646786477864878649786507865178652786537865478655786567865778658786597866078661786627866378664786657866678667786687866978670786717867278673786747867578676786777867878679786807868178682786837868478685786867868778688786897869078691786927869378694786957869678697786987869978700787017870278703787047870578706787077870878709787107871178712787137871478715787167871778718787197872078721787227872378724787257872678727787287872978730787317873278733787347873578736787377873878739787407874178742787437874478745787467874778748787497875078751787527875378754787557875678757787587875978760787617876278763787647876578766787677876878769787707877178772787737877478775787767877778778787797878078781787827878378784787857878678787787887878978790787917879278793787947879578796787977879878799788007880178802788037880478805788067880778808788097881078811788127881378814788157881678817788187881978820788217882278823788247882578826788277882878829788307883178832788337883478835788367883778838788397884078841788427884378844788457884678847788487884978850788517885278853788547885578856788577885878859788607886178862788637886478865788667886778868788697887078871788727887378874788757887678877788787887978880788817888278883788847888578886788877888878889788907889178892788937889478895788967889778898788997890078901789027890378904789057890678907789087890978910789117891278913789147891578916789177891878919789207892178922789237892478925789267892778928789297893078931789327893378934789357893678937789387893978940789417894278943789447894578946789477894878949789507895178952789537895478955789567895778958789597896078961789627896378964789657896678967789687896978970789717897278973789747897578976789777897878979789807898178982789837898478985789867898778988789897899078991789927899378994789957899678997789987899979000790017900279003790047900579006790077900879009790107901179012790137901479015790167901779018790197902079021790227902379024790257902679027790287902979030790317903279033790347903579036790377903879039790407904179042790437904479045790467904779048790497905079051790527905379054790557905679057790587905979060790617906279063790647906579066790677906879069790707907179072790737907479075790767907779078790797908079081790827908379084790857908679087790887908979090790917909279093790947909579096790977909879099791007910179102791037910479105791067910779108791097911079111791127911379114791157911679117791187911979120791217912279123791247912579126791277912879129791307913179132791337913479135791367913779138791397914079141791427914379144791457914679147791487914979150791517915279153791547915579156791577915879159791607916179162791637916479165791667916779168791697917079171791727917379174791757917679177791787917979180791817918279183791847918579186791877918879189791907919179192791937919479195791967919779198791997920079201792027920379204792057920679207792087920979210792117921279213792147921579216792177921879219792207922179222792237922479225792267922779228792297923079231792327923379234792357923679237792387923979240792417924279243792447924579246792477924879249792507925179252792537925479255792567925779258792597926079261792627926379264792657926679267792687926979270792717927279273792747927579276792777927879279792807928179282792837928479285792867928779288792897929079291792927929379294792957929679297792987929979300793017930279303793047930579306793077930879309793107931179312793137931479315793167931779318793197932079321793227932379324793257932679327793287932979330793317933279333793347933579336793377933879339793407934179342793437934479345793467934779348793497935079351793527935379354793557935679357793587935979360793617936279363793647936579366793677936879369793707937179372793737937479375793767937779378793797938079381793827938379384793857938679387793887938979390793917939279393793947939579396793977939879399794007940179402794037940479405794067940779408794097941079411794127941379414794157941679417794187941979420794217942279423794247942579426794277942879429794307943179432794337943479435794367943779438794397944079441794427944379444794457944679447794487944979450794517945279453794547945579456794577945879459794607946179462794637946479465794667946779468794697947079471794727947379474794757947679477794787947979480794817948279483794847948579486794877948879489794907949179492794937949479495794967949779498794997950079501795027950379504795057950679507795087950979510795117951279513795147951579516795177951879519795207952179522795237952479525795267952779528795297953079531795327953379534795357953679537795387953979540795417954279543795447954579546795477954879549795507955179552795537955479555795567955779558795597956079561795627956379564795657956679567795687956979570795717957279573795747957579576795777957879579795807958179582795837958479585795867958779588795897959079591795927959379594795957959679597795987959979600796017960279603796047960579606796077960879609796107961179612796137961479615796167961779618796197962079621796227962379624796257962679627796287962979630796317963279633796347963579636796377963879639796407964179642796437964479645796467964779648796497965079651796527965379654796557965679657796587965979660796617966279663796647966579666796677966879669796707967179672796737967479675796767967779678796797968079681796827968379684796857968679687796887968979690796917969279693796947969579696796977969879699797007970179702797037970479705797067970779708797097971079711797127971379714797157971679717797187971979720797217972279723797247972579726797277972879729797307973179732797337973479735797367973779738797397974079741797427974379744797457974679747797487974979750797517975279753797547975579756797577975879759797607976179762797637976479765797667976779768797697977079771797727977379774797757977679777797787977979780797817978279783797847978579786797877978879789797907979179792797937979479795797967979779798797997980079801798027980379804798057980679807798087980979810798117981279813798147981579816798177981879819798207982179822798237982479825798267982779828798297983079831798327983379834798357983679837798387983979840798417984279843798447984579846798477984879849798507985179852798537985479855798567985779858798597986079861798627986379864798657986679867798687986979870798717987279873798747987579876798777987879879798807988179882798837988479885798867988779888798897989079891798927989379894798957989679897798987989979900799017990279903799047990579906799077990879909799107991179912799137991479915799167991779918799197992079921799227992379924799257992679927799287992979930799317993279933799347993579936799377993879939799407994179942799437994479945799467994779948799497995079951799527995379954799557995679957799587995979960799617996279963799647996579966799677996879969799707997179972799737997479975799767997779978799797998079981799827998379984799857998679987799887998979990799917999279993799947999579996799977999879999800008000180002800038000480005800068000780008800098001080011800128001380014800158001680017800188001980020800218002280023800248002580026800278002880029800308003180032800338003480035800368003780038800398004080041800428004380044800458004680047800488004980050800518005280053800548005580056800578005880059800608006180062800638006480065800668006780068800698007080071800728007380074800758007680077800788007980080800818008280083800848008580086800878008880089800908009180092800938009480095800968009780098800998010080101801028010380104801058010680107801088010980110801118011280113801148011580116801178011880119801208012180122801238012480125801268012780128801298013080131801328013380134801358013680137801388013980140801418014280143801448014580146801478014880149801508015180152801538015480155801568015780158801598016080161801628016380164801658016680167801688016980170801718017280173801748017580176801778017880179801808018180182801838018480185801868018780188801898019080191801928019380194801958019680197801988019980200802018020280203802048020580206802078020880209802108021180212802138021480215802168021780218802198022080221802228022380224802258022680227802288022980230802318023280233802348023580236802378023880239802408024180242802438024480245802468024780248802498025080251802528025380254802558025680257802588025980260802618026280263802648026580266802678026880269802708027180272802738027480275802768027780278802798028080281802828028380284802858028680287802888028980290802918029280293802948029580296802978029880299803008030180302803038030480305803068030780308803098031080311803128031380314803158031680317803188031980320803218032280323803248032580326803278032880329803308033180332803338033480335803368033780338803398034080341803428034380344803458034680347803488034980350803518035280353803548035580356803578035880359803608036180362803638036480365803668036780368803698037080371803728037380374803758037680377803788037980380803818038280383803848038580386803878038880389803908039180392803938039480395803968039780398803998040080401804028040380404804058040680407804088040980410804118041280413804148041580416804178041880419804208042180422804238042480425804268042780428804298043080431804328043380434804358043680437804388043980440804418044280443804448044580446804478044880449804508045180452804538045480455804568045780458804598046080461804628046380464804658046680467804688046980470804718047280473804748047580476804778047880479804808048180482804838048480485804868048780488804898049080491804928049380494804958049680497804988049980500805018050280503805048050580506805078050880509805108051180512805138051480515805168051780518805198052080521805228052380524805258052680527805288052980530805318053280533805348053580536805378053880539805408054180542805438054480545805468054780548805498055080551805528055380554805558055680557805588055980560805618056280563805648056580566805678056880569805708057180572805738057480575805768057780578805798058080581805828058380584805858058680587805888058980590805918059280593805948059580596805978059880599806008060180602806038060480605806068060780608806098061080611806128061380614806158061680617806188061980620806218062280623806248062580626806278062880629806308063180632806338063480635806368063780638806398064080641806428064380644806458064680647806488064980650806518065280653806548065580656806578065880659806608066180662806638066480665806668066780668806698067080671806728067380674806758067680677806788067980680806818068280683806848068580686806878068880689806908069180692806938069480695806968069780698806998070080701807028070380704807058070680707807088070980710807118071280713807148071580716807178071880719807208072180722807238072480725807268072780728807298073080731807328073380734807358073680737807388073980740807418074280743807448074580746807478074880749807508075180752807538075480755807568075780758807598076080761807628076380764807658076680767807688076980770807718077280773807748077580776807778077880779807808078180782807838078480785807868078780788807898079080791807928079380794807958079680797807988079980800808018080280803808048080580806808078080880809808108081180812808138081480815808168081780818808198082080821808228082380824808258082680827808288082980830808318083280833808348083580836808378083880839808408084180842808438084480845808468084780848808498085080851808528085380854808558085680857808588085980860808618086280863808648086580866808678086880869808708087180872808738087480875808768087780878808798088080881808828088380884808858088680887808888088980890808918089280893808948089580896808978089880899809008090180902809038090480905809068090780908809098091080911809128091380914809158091680917809188091980920809218092280923809248092580926809278092880929809308093180932809338093480935809368093780938809398094080941809428094380944809458094680947809488094980950809518095280953809548095580956809578095880959809608096180962809638096480965809668096780968809698097080971809728097380974809758097680977809788097980980809818098280983809848098580986809878098880989809908099180992809938099480995809968099780998809998100081001810028100381004810058100681007810088100981010810118101281013810148101581016810178101881019810208102181022810238102481025810268102781028810298103081031810328103381034810358103681037810388103981040810418104281043810448104581046810478104881049810508105181052810538105481055810568105781058810598106081061810628106381064810658106681067810688106981070810718107281073810748107581076810778107881079810808108181082810838108481085810868108781088810898109081091810928109381094810958109681097810988109981100811018110281103811048110581106811078110881109811108111181112811138111481115811168111781118811198112081121811228112381124811258112681127811288112981130811318113281133811348113581136811378113881139811408114181142811438114481145811468114781148811498115081151811528115381154811558115681157811588115981160811618116281163811648116581166811678116881169811708117181172811738117481175811768117781178811798118081181811828118381184811858118681187811888118981190811918119281193811948119581196811978119881199812008120181202812038120481205812068120781208812098121081211812128121381214812158121681217812188121981220812218122281223812248122581226812278122881229812308123181232812338123481235812368123781238812398124081241812428124381244812458124681247812488124981250812518125281253812548125581256812578125881259812608126181262812638126481265812668126781268812698127081271812728127381274812758127681277812788127981280812818128281283812848128581286812878128881289812908129181292812938129481295812968129781298812998130081301813028130381304813058130681307813088130981310813118131281313813148131581316813178131881319813208132181322813238132481325813268132781328813298133081331813328133381334813358133681337813388133981340813418134281343813448134581346813478134881349813508135181352813538135481355813568135781358813598136081361813628136381364813658136681367813688136981370813718137281373813748137581376813778137881379813808138181382813838138481385813868138781388813898139081391813928139381394813958139681397813988139981400814018140281403814048140581406814078140881409814108141181412814138141481415814168141781418814198142081421814228142381424814258142681427814288142981430814318143281433814348143581436814378143881439814408144181442814438144481445814468144781448814498145081451814528145381454814558145681457814588145981460814618146281463814648146581466814678146881469814708147181472814738147481475814768147781478814798148081481814828148381484814858148681487814888148981490814918149281493814948149581496814978149881499815008150181502815038150481505815068150781508815098151081511815128151381514815158151681517815188151981520815218152281523815248152581526815278152881529815308153181532815338153481535815368153781538815398154081541815428154381544815458154681547815488154981550815518155281553815548155581556815578155881559815608156181562815638156481565815668156781568815698157081571815728157381574815758157681577815788157981580815818158281583815848158581586815878158881589815908159181592815938159481595815968159781598815998160081601816028160381604816058160681607816088160981610816118161281613816148161581616816178161881619816208162181622816238162481625816268162781628816298163081631816328163381634816358163681637816388163981640816418164281643816448164581646816478164881649816508165181652816538165481655816568165781658816598166081661816628166381664816658166681667816688166981670816718167281673816748167581676816778167881679816808168181682816838168481685816868168781688816898169081691816928169381694816958169681697816988169981700817018170281703817048170581706817078170881709817108171181712817138171481715817168171781718817198172081721817228172381724817258172681727817288172981730817318173281733817348173581736817378173881739817408174181742817438174481745817468174781748817498175081751817528175381754817558175681757817588175981760817618176281763817648176581766817678176881769817708177181772817738177481775817768177781778817798178081781817828178381784817858178681787817888178981790817918179281793817948179581796817978179881799818008180181802818038180481805818068180781808818098181081811818128181381814818158181681817818188181981820818218182281823818248182581826818278182881829818308183181832818338183481835818368183781838818398184081841818428184381844818458184681847818488184981850818518185281853818548185581856818578185881859818608186181862818638186481865818668186781868818698187081871818728187381874818758187681877818788187981880818818188281883818848188581886818878188881889818908189181892818938189481895818968189781898818998190081901819028190381904819058190681907819088190981910819118191281913819148191581916819178191881919819208192181922819238192481925819268192781928819298193081931819328193381934819358193681937819388193981940819418194281943819448194581946819478194881949819508195181952819538195481955819568195781958819598196081961819628196381964819658196681967819688196981970819718197281973819748197581976819778197881979819808198181982819838198481985819868198781988819898199081991819928199381994819958199681997819988199982000820018200282003820048200582006820078200882009820108201182012820138201482015820168201782018820198202082021820228202382024820258202682027820288202982030820318203282033820348203582036820378203882039820408204182042820438204482045820468204782048820498205082051820528205382054820558205682057820588205982060820618206282063820648206582066820678206882069820708207182072820738207482075820768207782078820798208082081820828208382084820858208682087820888208982090820918209282093820948209582096820978209882099821008210182102821038210482105821068210782108821098211082111821128211382114821158211682117821188211982120821218212282123821248212582126821278212882129821308213182132821338213482135821368213782138821398214082141821428214382144821458214682147821488214982150821518215282153821548215582156821578215882159821608216182162821638216482165821668216782168821698217082171821728217382174821758217682177821788217982180821818218282183821848218582186821878218882189821908219182192821938219482195821968219782198821998220082201822028220382204822058220682207822088220982210822118221282213822148221582216822178221882219822208222182222822238222482225822268222782228822298223082231822328223382234822358223682237822388223982240822418224282243822448224582246822478224882249822508225182252822538225482255822568225782258822598226082261822628226382264822658226682267822688226982270822718227282273822748227582276822778227882279822808228182282822838228482285822868228782288822898229082291822928229382294822958229682297822988229982300823018230282303823048230582306823078230882309823108231182312823138231482315823168231782318823198232082321823228232382324823258232682327823288232982330823318233282333823348233582336823378233882339823408234182342823438234482345823468234782348823498235082351823528235382354823558235682357823588235982360823618236282363823648236582366823678236882369823708237182372823738237482375823768237782378823798238082381823828238382384823858238682387823888238982390823918239282393823948239582396823978239882399824008240182402824038240482405824068240782408824098241082411824128241382414824158241682417824188241982420824218242282423824248242582426824278242882429824308243182432824338243482435824368243782438824398244082441824428244382444824458244682447824488244982450824518245282453824548245582456824578245882459824608246182462824638246482465824668246782468824698247082471824728247382474824758247682477824788247982480824818248282483824848248582486824878248882489824908249182492824938249482495824968249782498824998250082501825028250382504825058250682507825088250982510825118251282513825148251582516825178251882519825208252182522825238252482525825268252782528825298253082531825328253382534825358253682537825388253982540825418254282543825448254582546825478254882549825508255182552825538255482555825568255782558825598256082561825628256382564825658256682567825688256982570825718257282573825748257582576825778257882579825808258182582825838258482585825868258782588825898259082591825928259382594825958259682597825988259982600826018260282603826048260582606826078260882609826108261182612826138261482615826168261782618826198262082621826228262382624826258262682627826288262982630826318263282633826348263582636826378263882639826408264182642826438264482645826468264782648826498265082651826528265382654826558265682657826588265982660826618266282663826648266582666826678266882669826708267182672826738267482675826768267782678826798268082681826828268382684826858268682687826888268982690826918269282693826948269582696826978269882699827008270182702827038270482705827068270782708827098271082711827128271382714827158271682717827188271982720827218272282723827248272582726827278272882729827308273182732827338273482735827368273782738827398274082741827428274382744827458274682747827488274982750827518275282753827548275582756827578275882759827608276182762827638276482765827668276782768827698277082771827728277382774827758277682777827788277982780827818278282783827848278582786827878278882789827908279182792827938279482795827968279782798827998280082801828028280382804828058280682807828088280982810828118281282813828148281582816828178281882819828208282182822828238282482825828268282782828828298283082831828328283382834828358283682837828388283982840828418284282843828448284582846828478284882849828508285182852828538285482855828568285782858828598286082861828628286382864828658286682867828688286982870828718287282873828748287582876828778287882879828808288182882828838288482885828868288782888828898289082891828928289382894828958289682897828988289982900829018290282903829048290582906829078290882909829108291182912829138291482915829168291782918829198292082921829228292382924829258292682927829288292982930829318293282933829348293582936829378293882939829408294182942829438294482945829468294782948829498295082951829528295382954829558295682957829588295982960829618296282963829648296582966829678296882969829708297182972829738297482975829768297782978829798298082981829828298382984829858298682987829888298982990829918299282993829948299582996829978299882999830008300183002830038300483005830068300783008830098301083011830128301383014830158301683017830188301983020830218302283023830248302583026830278302883029830308303183032830338303483035830368303783038830398304083041830428304383044830458304683047830488304983050830518305283053830548305583056830578305883059830608306183062830638306483065830668306783068830698307083071830728307383074830758307683077830788307983080830818308283083830848308583086830878308883089830908309183092830938309483095830968309783098830998310083101831028310383104831058310683107831088310983110831118311283113831148311583116831178311883119831208312183122831238312483125831268312783128831298313083131831328313383134831358313683137831388313983140831418314283143831448314583146831478314883149831508315183152831538315483155831568315783158831598316083161831628316383164831658316683167831688316983170831718317283173831748317583176831778317883179831808318183182831838318483185831868318783188831898319083191831928319383194831958319683197831988319983200832018320283203832048320583206832078320883209832108321183212832138321483215832168321783218832198322083221832228322383224832258322683227832288322983230832318323283233832348323583236832378323883239832408324183242832438324483245832468324783248832498325083251832528325383254832558325683257832588325983260832618326283263832648326583266832678326883269832708327183272832738327483275832768327783278832798328083281832828328383284832858328683287832888328983290832918329283293832948329583296832978329883299833008330183302833038330483305833068330783308833098331083311833128331383314833158331683317833188331983320833218332283323833248332583326833278332883329833308333183332833338333483335833368333783338833398334083341833428334383344833458334683347833488334983350833518335283353833548335583356833578335883359833608336183362833638336483365833668336783368833698337083371833728337383374833758337683377833788337983380833818338283383833848338583386833878338883389833908339183392833938339483395833968339783398833998340083401834028340383404834058340683407834088340983410834118341283413834148341583416834178341883419834208342183422834238342483425834268342783428834298343083431834328343383434834358343683437834388343983440834418344283443834448344583446834478344883449834508345183452834538345483455834568345783458834598346083461834628346383464834658346683467834688346983470834718347283473834748347583476834778347883479834808348183482834838348483485834868348783488834898349083491834928349383494834958349683497834988349983500835018350283503835048350583506835078350883509835108351183512835138351483515835168351783518835198352083521835228352383524835258352683527835288352983530835318353283533835348353583536835378353883539835408354183542835438354483545835468354783548835498355083551835528355383554835558355683557835588355983560835618356283563835648356583566835678356883569835708357183572835738357483575835768357783578835798358083581835828358383584835858358683587835888358983590835918359283593835948359583596835978359883599836008360183602836038360483605836068360783608836098361083611836128361383614836158361683617836188361983620836218362283623836248362583626836278362883629836308363183632836338363483635836368363783638836398364083641836428364383644836458364683647836488364983650836518365283653836548365583656836578365883659836608366183662836638366483665836668366783668836698367083671836728367383674836758367683677836788367983680836818368283683836848368583686836878368883689836908369183692836938369483695836968369783698836998370083701837028370383704837058370683707
  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. get 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. * Check if the document object exists
  289. * @returns true if the document object exists
  290. */
  291. static IsDocumentAvailable(): boolean;
  292. /**
  293. * Extracts text content from a DOM element hierarchy
  294. * @param element defines the root element
  295. * @returns a string
  296. */
  297. static GetDOMTextContent(element: HTMLElement): string;
  298. }
  299. }
  300. declare module BABYLON {
  301. /**
  302. * Logger used througouht the application to allow configuration of
  303. * the log level required for the messages.
  304. */
  305. export class Logger {
  306. /**
  307. * No log
  308. */
  309. static readonly NoneLogLevel: number;
  310. /**
  311. * Only message logs
  312. */
  313. static readonly MessageLogLevel: number;
  314. /**
  315. * Only warning logs
  316. */
  317. static readonly WarningLogLevel: number;
  318. /**
  319. * Only error logs
  320. */
  321. static readonly ErrorLogLevel: number;
  322. /**
  323. * All logs
  324. */
  325. static readonly AllLogLevel: number;
  326. private static _LogCache;
  327. /**
  328. * Gets a value indicating the number of loading errors
  329. * @ignorenaming
  330. */
  331. static errorsCount: number;
  332. /**
  333. * Callback called when a new log is added
  334. */
  335. static OnNewCacheEntry: (entry: string) => void;
  336. private static _AddLogEntry;
  337. private static _FormatMessage;
  338. private static _LogDisabled;
  339. private static _LogEnabled;
  340. private static _WarnDisabled;
  341. private static _WarnEnabled;
  342. private static _ErrorDisabled;
  343. private static _ErrorEnabled;
  344. /**
  345. * Log a message to the console
  346. */
  347. static Log: (message: string) => void;
  348. /**
  349. * Write a warning message to the console
  350. */
  351. static Warn: (message: string) => void;
  352. /**
  353. * Write an error message to the console
  354. */
  355. static Error: (message: string) => void;
  356. /**
  357. * Gets current log cache (list of logs)
  358. */
  359. static get LogCache(): string;
  360. /**
  361. * Clears the log cache
  362. */
  363. static ClearLogCache(): void;
  364. /**
  365. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  366. */
  367. static set LogLevels(level: number);
  368. }
  369. }
  370. declare module BABYLON {
  371. /** @hidden */
  372. export class _TypeStore {
  373. /** @hidden */
  374. static RegisteredTypes: {
  375. [key: string]: Object;
  376. };
  377. /** @hidden */
  378. static GetClass(fqdn: string): any;
  379. }
  380. }
  381. declare module BABYLON {
  382. /**
  383. * Helper to manipulate strings
  384. */
  385. export class StringTools {
  386. /**
  387. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  388. * @param str Source string
  389. * @param suffix Suffix to search for in the source string
  390. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  391. */
  392. static EndsWith(str: string, suffix: string): boolean;
  393. /**
  394. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  395. * @param str Source string
  396. * @param suffix Suffix to search for in the source string
  397. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  398. */
  399. static StartsWith(str: string, suffix: string): boolean;
  400. /**
  401. * Decodes a buffer into a string
  402. * @param buffer The buffer to decode
  403. * @returns The decoded string
  404. */
  405. static Decode(buffer: Uint8Array | Uint16Array): string;
  406. /**
  407. * Encode a buffer to a base64 string
  408. * @param buffer defines the buffer to encode
  409. * @returns the encoded string
  410. */
  411. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  412. /**
  413. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  414. * @param num the number to convert and pad
  415. * @param length the expected length of the string
  416. * @returns the padded string
  417. */
  418. static PadNumber(num: number, length: number): string;
  419. }
  420. }
  421. declare module BABYLON {
  422. /**
  423. * Class containing a set of static utilities functions for deep copy.
  424. */
  425. export class DeepCopier {
  426. /**
  427. * Tries to copy an object by duplicating every property
  428. * @param source defines the source object
  429. * @param destination defines the target object
  430. * @param doNotCopyList defines a list of properties to avoid
  431. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  432. */
  433. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  434. }
  435. }
  436. declare module BABYLON {
  437. /**
  438. * Class containing a set of static utilities functions for precision date
  439. */
  440. export class PrecisionDate {
  441. /**
  442. * Gets either window.performance.now() if supported or Date.now() else
  443. */
  444. static get Now(): number;
  445. }
  446. }
  447. declare module BABYLON {
  448. /** @hidden */
  449. export class _DevTools {
  450. static WarnImport(name: string): string;
  451. }
  452. }
  453. declare module BABYLON {
  454. /**
  455. * Interface used to define the mechanism to get data from the network
  456. */
  457. export interface IWebRequest {
  458. /**
  459. * Returns client's response url
  460. */
  461. responseURL: string;
  462. /**
  463. * Returns client's status
  464. */
  465. status: number;
  466. /**
  467. * Returns client's status as a text
  468. */
  469. statusText: string;
  470. }
  471. }
  472. declare module BABYLON {
  473. /**
  474. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  475. */
  476. export class WebRequest implements IWebRequest {
  477. private _xhr;
  478. /**
  479. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  480. * i.e. when loading files, where the server/service expects an Authorization header
  481. */
  482. static CustomRequestHeaders: {
  483. [key: string]: string;
  484. };
  485. /**
  486. * Add callback functions in this array to update all the requests before they get sent to the network
  487. */
  488. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  489. private _injectCustomRequestHeaders;
  490. /**
  491. * Gets or sets a function to be called when loading progress changes
  492. */
  493. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  494. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  495. /**
  496. * Returns client's state
  497. */
  498. get readyState(): number;
  499. /**
  500. * Returns client's status
  501. */
  502. get status(): number;
  503. /**
  504. * Returns client's status as a text
  505. */
  506. get statusText(): string;
  507. /**
  508. * Returns client's response
  509. */
  510. get response(): any;
  511. /**
  512. * Returns client's response url
  513. */
  514. get responseURL(): string;
  515. /**
  516. * Returns client's response as text
  517. */
  518. get responseText(): string;
  519. /**
  520. * Gets or sets the expected response type
  521. */
  522. get responseType(): XMLHttpRequestResponseType;
  523. set responseType(value: XMLHttpRequestResponseType);
  524. /** @hidden */
  525. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  526. /** @hidden */
  527. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  528. /**
  529. * Cancels any network activity
  530. */
  531. abort(): void;
  532. /**
  533. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  534. * @param body defines an optional request body
  535. */
  536. send(body?: Document | BodyInit | null): void;
  537. /**
  538. * Sets the request method, request URL
  539. * @param method defines the method to use (GET, POST, etc..)
  540. * @param url defines the url to connect with
  541. */
  542. open(method: string, url: string): void;
  543. /**
  544. * Sets the value of a request header.
  545. * @param name The name of the header whose value is to be set
  546. * @param value The value to set as the body of the header
  547. */
  548. setRequestHeader(name: string, value: string): void;
  549. /**
  550. * Get the string containing the text of a particular header's value.
  551. * @param name The name of the header
  552. * @returns The string containing the text of the given header name
  553. */
  554. getResponseHeader(name: string): Nullable<string>;
  555. }
  556. }
  557. declare module BABYLON {
  558. /**
  559. * File request interface
  560. */
  561. export interface IFileRequest {
  562. /**
  563. * Raised when the request is complete (success or error).
  564. */
  565. onCompleteObservable: Observable<IFileRequest>;
  566. /**
  567. * Aborts the request for a file.
  568. */
  569. abort: () => void;
  570. }
  571. }
  572. declare module BABYLON {
  573. /**
  574. * Define options used to create a render target texture
  575. */
  576. export class RenderTargetCreationOptions {
  577. /**
  578. * Specifies is mipmaps must be generated
  579. */
  580. generateMipMaps?: boolean;
  581. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  582. generateDepthBuffer?: boolean;
  583. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  584. generateStencilBuffer?: boolean;
  585. /** Defines texture type (int by default) */
  586. type?: number;
  587. /** Defines sampling mode (trilinear by default) */
  588. samplingMode?: number;
  589. /** Defines format (RGBA by default) */
  590. format?: number;
  591. }
  592. }
  593. declare module BABYLON {
  594. /** Defines the cross module used constants to avoid circular dependncies */
  595. export class Constants {
  596. /** Defines that alpha blending is disabled */
  597. static readonly ALPHA_DISABLE: number;
  598. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  599. static readonly ALPHA_ADD: number;
  600. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  601. static readonly ALPHA_COMBINE: number;
  602. /** Defines that alpha blending is DEST - SRC * DEST */
  603. static readonly ALPHA_SUBTRACT: number;
  604. /** Defines that alpha blending is SRC * DEST */
  605. static readonly ALPHA_MULTIPLY: number;
  606. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  607. static readonly ALPHA_MAXIMIZED: number;
  608. /** Defines that alpha blending is SRC + DEST */
  609. static readonly ALPHA_ONEONE: number;
  610. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  611. static readonly ALPHA_PREMULTIPLIED: number;
  612. /**
  613. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  614. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  615. */
  616. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  617. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  618. static readonly ALPHA_INTERPOLATE: number;
  619. /**
  620. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  621. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  622. */
  623. static readonly ALPHA_SCREENMODE: number;
  624. /**
  625. * Defines that alpha blending is SRC + DST
  626. * Alpha will be set to SRC ALPHA + DST ALPHA
  627. */
  628. static readonly ALPHA_ONEONE_ONEONE: number;
  629. /**
  630. * Defines that alpha blending is SRC * DST ALPHA + DST
  631. * Alpha will be set to 0
  632. */
  633. static readonly ALPHA_ALPHATOCOLOR: number;
  634. /**
  635. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  636. */
  637. static readonly ALPHA_REVERSEONEMINUS: number;
  638. /**
  639. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  640. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  641. */
  642. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  643. /**
  644. * Defines that alpha blending is SRC + DST
  645. * Alpha will be set to SRC ALPHA
  646. */
  647. static readonly ALPHA_ONEONE_ONEZERO: number;
  648. /**
  649. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  650. * Alpha will be set to DST ALPHA
  651. */
  652. static readonly ALPHA_EXCLUSION: number;
  653. /** Defines that alpha blending equation a SUM */
  654. static readonly ALPHA_EQUATION_ADD: number;
  655. /** Defines that alpha blending equation a SUBSTRACTION */
  656. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  657. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  658. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  659. /** Defines that alpha blending equation a MAX operation */
  660. static readonly ALPHA_EQUATION_MAX: number;
  661. /** Defines that alpha blending equation a MIN operation */
  662. static readonly ALPHA_EQUATION_MIN: number;
  663. /**
  664. * Defines that alpha blending equation a DARKEN operation:
  665. * It takes the min of the src and sums the alpha channels.
  666. */
  667. static readonly ALPHA_EQUATION_DARKEN: number;
  668. /** Defines that the ressource is not delayed*/
  669. static readonly DELAYLOADSTATE_NONE: number;
  670. /** Defines that the ressource was successfully delay loaded */
  671. static readonly DELAYLOADSTATE_LOADED: number;
  672. /** Defines that the ressource is currently delay loading */
  673. static readonly DELAYLOADSTATE_LOADING: number;
  674. /** Defines that the ressource is delayed and has not started loading */
  675. static readonly DELAYLOADSTATE_NOTLOADED: number;
  676. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  677. static readonly NEVER: number;
  678. /** 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 */
  679. static readonly ALWAYS: number;
  680. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  681. static readonly LESS: number;
  682. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  683. static readonly EQUAL: number;
  684. /** 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 */
  685. static readonly LEQUAL: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  687. static readonly GREATER: number;
  688. /** 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 */
  689. static readonly GEQUAL: number;
  690. /** 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 */
  691. static readonly NOTEQUAL: number;
  692. /** Passed to stencilOperation to specify that stencil value must be kept */
  693. static readonly KEEP: number;
  694. /** Passed to stencilOperation to specify that stencil value must be replaced */
  695. static readonly REPLACE: number;
  696. /** Passed to stencilOperation to specify that stencil value must be incremented */
  697. static readonly INCR: number;
  698. /** Passed to stencilOperation to specify that stencil value must be decremented */
  699. static readonly DECR: number;
  700. /** Passed to stencilOperation to specify that stencil value must be inverted */
  701. static readonly INVERT: number;
  702. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  703. static readonly INCR_WRAP: number;
  704. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  705. static readonly DECR_WRAP: number;
  706. /** Texture is not repeating outside of 0..1 UVs */
  707. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  708. /** Texture is repeating outside of 0..1 UVs */
  709. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  710. /** Texture is repeating and mirrored */
  711. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  712. /** ALPHA */
  713. static readonly TEXTUREFORMAT_ALPHA: number;
  714. /** LUMINANCE */
  715. static readonly TEXTUREFORMAT_LUMINANCE: number;
  716. /** LUMINANCE_ALPHA */
  717. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  718. /** RGB */
  719. static readonly TEXTUREFORMAT_RGB: number;
  720. /** RGBA */
  721. static readonly TEXTUREFORMAT_RGBA: number;
  722. /** RED */
  723. static readonly TEXTUREFORMAT_RED: number;
  724. /** RED (2nd reference) */
  725. static readonly TEXTUREFORMAT_R: number;
  726. /** RG */
  727. static readonly TEXTUREFORMAT_RG: number;
  728. /** RED_INTEGER */
  729. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  730. /** RED_INTEGER (2nd reference) */
  731. static readonly TEXTUREFORMAT_R_INTEGER: number;
  732. /** RG_INTEGER */
  733. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  734. /** RGB_INTEGER */
  735. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  736. /** RGBA_INTEGER */
  737. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  738. /** UNSIGNED_BYTE */
  739. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  740. /** UNSIGNED_BYTE (2nd reference) */
  741. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  742. /** FLOAT */
  743. static readonly TEXTURETYPE_FLOAT: number;
  744. /** HALF_FLOAT */
  745. static readonly TEXTURETYPE_HALF_FLOAT: number;
  746. /** BYTE */
  747. static readonly TEXTURETYPE_BYTE: number;
  748. /** SHORT */
  749. static readonly TEXTURETYPE_SHORT: number;
  750. /** UNSIGNED_SHORT */
  751. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  752. /** INT */
  753. static readonly TEXTURETYPE_INT: number;
  754. /** UNSIGNED_INT */
  755. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  756. /** UNSIGNED_SHORT_4_4_4_4 */
  757. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  758. /** UNSIGNED_SHORT_5_5_5_1 */
  759. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  760. /** UNSIGNED_SHORT_5_6_5 */
  761. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  762. /** UNSIGNED_INT_2_10_10_10_REV */
  763. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  764. /** UNSIGNED_INT_24_8 */
  765. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  766. /** UNSIGNED_INT_10F_11F_11F_REV */
  767. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  768. /** UNSIGNED_INT_5_9_9_9_REV */
  769. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  770. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  771. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  772. /** nearest is mag = nearest and min = nearest and no mip */
  773. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  774. /** mag = nearest and min = nearest and mip = none */
  775. static readonly TEXTURE_NEAREST_NEAREST: number;
  776. /** Bilinear is mag = linear and min = linear and no mip */
  777. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  778. /** mag = linear and min = linear and mip = none */
  779. static readonly TEXTURE_LINEAR_LINEAR: number;
  780. /** Trilinear is mag = linear and min = linear and mip = linear */
  781. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  782. /** Trilinear is mag = linear and min = linear and mip = linear */
  783. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  784. /** mag = nearest and min = nearest and mip = nearest */
  785. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  786. /** mag = nearest and min = linear and mip = nearest */
  787. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  788. /** mag = nearest and min = linear and mip = linear */
  789. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  790. /** mag = nearest and min = linear and mip = none */
  791. static readonly TEXTURE_NEAREST_LINEAR: number;
  792. /** nearest is mag = nearest and min = nearest and mip = linear */
  793. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  794. /** mag = linear and min = nearest and mip = nearest */
  795. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  796. /** mag = linear and min = nearest and mip = linear */
  797. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  798. /** Bilinear is mag = linear and min = linear and mip = nearest */
  799. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  800. /** mag = linear and min = nearest and mip = none */
  801. static readonly TEXTURE_LINEAR_NEAREST: number;
  802. /** Explicit coordinates mode */
  803. static readonly TEXTURE_EXPLICIT_MODE: number;
  804. /** Spherical coordinates mode */
  805. static readonly TEXTURE_SPHERICAL_MODE: number;
  806. /** Planar coordinates mode */
  807. static readonly TEXTURE_PLANAR_MODE: number;
  808. /** Cubic coordinates mode */
  809. static readonly TEXTURE_CUBIC_MODE: number;
  810. /** Projection coordinates mode */
  811. static readonly TEXTURE_PROJECTION_MODE: number;
  812. /** Skybox coordinates mode */
  813. static readonly TEXTURE_SKYBOX_MODE: number;
  814. /** Inverse Cubic coordinates mode */
  815. static readonly TEXTURE_INVCUBIC_MODE: number;
  816. /** Equirectangular coordinates mode */
  817. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  818. /** Equirectangular Fixed coordinates mode */
  819. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  820. /** Equirectangular Fixed Mirrored coordinates mode */
  821. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  822. /** Offline (baking) quality for texture filtering */
  823. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  824. /** High quality for texture filtering */
  825. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  826. /** Medium quality for texture filtering */
  827. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  828. /** Low quality for texture filtering */
  829. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  830. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  831. static readonly SCALEMODE_FLOOR: number;
  832. /** Defines that texture rescaling will look for the nearest power of 2 size */
  833. static readonly SCALEMODE_NEAREST: number;
  834. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  835. static readonly SCALEMODE_CEILING: number;
  836. /**
  837. * The dirty texture flag value
  838. */
  839. static readonly MATERIAL_TextureDirtyFlag: number;
  840. /**
  841. * The dirty light flag value
  842. */
  843. static readonly MATERIAL_LightDirtyFlag: number;
  844. /**
  845. * The dirty fresnel flag value
  846. */
  847. static readonly MATERIAL_FresnelDirtyFlag: number;
  848. /**
  849. * The dirty attribute flag value
  850. */
  851. static readonly MATERIAL_AttributesDirtyFlag: number;
  852. /**
  853. * The dirty misc flag value
  854. */
  855. static readonly MATERIAL_MiscDirtyFlag: number;
  856. /**
  857. * The all dirty flag value
  858. */
  859. static readonly MATERIAL_AllDirtyFlag: number;
  860. /**
  861. * Returns the triangle fill mode
  862. */
  863. static readonly MATERIAL_TriangleFillMode: number;
  864. /**
  865. * Returns the wireframe mode
  866. */
  867. static readonly MATERIAL_WireFrameFillMode: number;
  868. /**
  869. * Returns the point fill mode
  870. */
  871. static readonly MATERIAL_PointFillMode: number;
  872. /**
  873. * Returns the point list draw mode
  874. */
  875. static readonly MATERIAL_PointListDrawMode: number;
  876. /**
  877. * Returns the line list draw mode
  878. */
  879. static readonly MATERIAL_LineListDrawMode: number;
  880. /**
  881. * Returns the line loop draw mode
  882. */
  883. static readonly MATERIAL_LineLoopDrawMode: number;
  884. /**
  885. * Returns the line strip draw mode
  886. */
  887. static readonly MATERIAL_LineStripDrawMode: number;
  888. /**
  889. * Returns the triangle strip draw mode
  890. */
  891. static readonly MATERIAL_TriangleStripDrawMode: number;
  892. /**
  893. * Returns the triangle fan draw mode
  894. */
  895. static readonly MATERIAL_TriangleFanDrawMode: number;
  896. /**
  897. * Stores the clock-wise side orientation
  898. */
  899. static readonly MATERIAL_ClockWiseSideOrientation: number;
  900. /**
  901. * Stores the counter clock-wise side orientation
  902. */
  903. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  904. /**
  905. * Nothing
  906. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  907. */
  908. static readonly ACTION_NothingTrigger: number;
  909. /**
  910. * On pick
  911. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  912. */
  913. static readonly ACTION_OnPickTrigger: number;
  914. /**
  915. * On left pick
  916. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  917. */
  918. static readonly ACTION_OnLeftPickTrigger: number;
  919. /**
  920. * On right pick
  921. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  922. */
  923. static readonly ACTION_OnRightPickTrigger: number;
  924. /**
  925. * On center pick
  926. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  927. */
  928. static readonly ACTION_OnCenterPickTrigger: number;
  929. /**
  930. * On pick down
  931. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  932. */
  933. static readonly ACTION_OnPickDownTrigger: number;
  934. /**
  935. * On double pick
  936. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  937. */
  938. static readonly ACTION_OnDoublePickTrigger: number;
  939. /**
  940. * On pick up
  941. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  942. */
  943. static readonly ACTION_OnPickUpTrigger: number;
  944. /**
  945. * On pick out.
  946. * This trigger will only be raised if you also declared a OnPickDown
  947. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  948. */
  949. static readonly ACTION_OnPickOutTrigger: number;
  950. /**
  951. * On long press
  952. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  953. */
  954. static readonly ACTION_OnLongPressTrigger: number;
  955. /**
  956. * On pointer over
  957. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  958. */
  959. static readonly ACTION_OnPointerOverTrigger: number;
  960. /**
  961. * On pointer out
  962. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  963. */
  964. static readonly ACTION_OnPointerOutTrigger: number;
  965. /**
  966. * On every frame
  967. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  968. */
  969. static readonly ACTION_OnEveryFrameTrigger: number;
  970. /**
  971. * On intersection enter
  972. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  973. */
  974. static readonly ACTION_OnIntersectionEnterTrigger: number;
  975. /**
  976. * On intersection exit
  977. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  978. */
  979. static readonly ACTION_OnIntersectionExitTrigger: number;
  980. /**
  981. * On key down
  982. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  983. */
  984. static readonly ACTION_OnKeyDownTrigger: number;
  985. /**
  986. * On key up
  987. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  988. */
  989. static readonly ACTION_OnKeyUpTrigger: number;
  990. /**
  991. * Billboard mode will only apply to Y axis
  992. */
  993. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  994. /**
  995. * Billboard mode will apply to all axes
  996. */
  997. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  998. /**
  999. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  1000. */
  1001. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  1002. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  1003. * Test order :
  1004. * Is the bounding sphere outside the frustum ?
  1005. * If not, are the bounding box vertices outside the frustum ?
  1006. * It not, then the cullable object is in the frustum.
  1007. */
  1008. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1009. /** Culling strategy : Bounding Sphere Only.
  1010. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1011. * It's also less accurate than the standard because some not visible objects can still be selected.
  1012. * Test : is the bounding sphere outside the frustum ?
  1013. * If not, then the cullable object is in the frustum.
  1014. */
  1015. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1016. /** Culling strategy : Optimistic Inclusion.
  1017. * This in an inclusion test first, then the standard exclusion test.
  1018. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1019. * 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.
  1020. * Anyway, it's as accurate as the standard strategy.
  1021. * Test :
  1022. * Is the cullable object bounding sphere center in the frustum ?
  1023. * If not, apply the default culling strategy.
  1024. */
  1025. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1026. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1027. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1028. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1029. * 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.
  1030. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1031. * Test :
  1032. * Is the cullable object bounding sphere center in the frustum ?
  1033. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1034. */
  1035. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1036. /**
  1037. * No logging while loading
  1038. */
  1039. static readonly SCENELOADER_NO_LOGGING: number;
  1040. /**
  1041. * Minimal logging while loading
  1042. */
  1043. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1044. /**
  1045. * Summary logging while loading
  1046. */
  1047. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1048. /**
  1049. * Detailled logging while loading
  1050. */
  1051. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1052. }
  1053. }
  1054. declare module BABYLON {
  1055. /**
  1056. * This represents the required contract to create a new type of texture loader.
  1057. */
  1058. export interface IInternalTextureLoader {
  1059. /**
  1060. * Defines wether the loader supports cascade loading the different faces.
  1061. */
  1062. supportCascades: boolean;
  1063. /**
  1064. * This returns if the loader support the current file information.
  1065. * @param extension defines the file extension of the file being loaded
  1066. * @returns true if the loader can load the specified file
  1067. */
  1068. canLoad(extension: string): boolean;
  1069. /**
  1070. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1071. * @param data contains the texture data
  1072. * @param texture defines the BabylonJS internal texture
  1073. * @param createPolynomials will be true if polynomials have been requested
  1074. * @param onLoad defines the callback to trigger once the texture is ready
  1075. * @param onError defines the callback to trigger in case of error
  1076. */
  1077. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1078. /**
  1079. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1080. * @param data contains the texture data
  1081. * @param texture defines the BabylonJS internal texture
  1082. * @param callback defines the method to call once ready to upload
  1083. */
  1084. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1085. }
  1086. }
  1087. declare module BABYLON {
  1088. /**
  1089. * Class used to store and describe the pipeline context associated with an effect
  1090. */
  1091. export interface IPipelineContext {
  1092. /**
  1093. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1094. */
  1095. isAsync: boolean;
  1096. /**
  1097. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1098. */
  1099. isReady: boolean;
  1100. /** @hidden */
  1101. _getVertexShaderCode(): string | null;
  1102. /** @hidden */
  1103. _getFragmentShaderCode(): string | null;
  1104. /** @hidden */
  1105. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1106. }
  1107. }
  1108. declare module BABYLON {
  1109. /**
  1110. * Class used to store gfx data (like WebGLBuffer)
  1111. */
  1112. export class DataBuffer {
  1113. /**
  1114. * Gets or sets the number of objects referencing this buffer
  1115. */
  1116. references: number;
  1117. /** Gets or sets the size of the underlying buffer */
  1118. capacity: number;
  1119. /**
  1120. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1121. */
  1122. is32Bits: boolean;
  1123. /**
  1124. * Gets the underlying buffer
  1125. */
  1126. get underlyingResource(): any;
  1127. }
  1128. }
  1129. declare module BABYLON {
  1130. /** @hidden */
  1131. export interface IShaderProcessor {
  1132. attributeProcessor?: (attribute: string) => string;
  1133. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1134. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1135. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1136. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1137. lineProcessor?: (line: string, isFragment: boolean) => string;
  1138. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1139. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1140. }
  1141. }
  1142. declare module BABYLON {
  1143. /** @hidden */
  1144. export interface ProcessingOptions {
  1145. defines: string[];
  1146. indexParameters: any;
  1147. isFragment: boolean;
  1148. shouldUseHighPrecisionShader: boolean;
  1149. supportsUniformBuffers: boolean;
  1150. shadersRepository: string;
  1151. includesShadersStore: {
  1152. [key: string]: string;
  1153. };
  1154. processor?: IShaderProcessor;
  1155. version: string;
  1156. platformName: string;
  1157. lookForClosingBracketForUniformBuffer?: boolean;
  1158. }
  1159. }
  1160. declare module BABYLON {
  1161. /** @hidden */
  1162. export class ShaderCodeNode {
  1163. line: string;
  1164. children: ShaderCodeNode[];
  1165. additionalDefineKey?: string;
  1166. additionalDefineValue?: string;
  1167. isValid(preprocessors: {
  1168. [key: string]: string;
  1169. }): boolean;
  1170. process(preprocessors: {
  1171. [key: string]: string;
  1172. }, options: ProcessingOptions): string;
  1173. }
  1174. }
  1175. declare module BABYLON {
  1176. /** @hidden */
  1177. export class ShaderCodeCursor {
  1178. private _lines;
  1179. lineIndex: number;
  1180. get currentLine(): string;
  1181. get canRead(): boolean;
  1182. set lines(value: string[]);
  1183. }
  1184. }
  1185. declare module BABYLON {
  1186. /** @hidden */
  1187. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1188. process(preprocessors: {
  1189. [key: string]: string;
  1190. }, options: ProcessingOptions): string;
  1191. }
  1192. }
  1193. declare module BABYLON {
  1194. /** @hidden */
  1195. export class ShaderDefineExpression {
  1196. isTrue(preprocessors: {
  1197. [key: string]: string;
  1198. }): boolean;
  1199. private static _OperatorPriority;
  1200. private static _Stack;
  1201. static postfixToInfix(postfix: string[]): string;
  1202. static infixToPostfix(infix: string): string[];
  1203. }
  1204. }
  1205. declare module BABYLON {
  1206. /** @hidden */
  1207. export class ShaderCodeTestNode extends ShaderCodeNode {
  1208. testExpression: ShaderDefineExpression;
  1209. isValid(preprocessors: {
  1210. [key: string]: string;
  1211. }): boolean;
  1212. }
  1213. }
  1214. declare module BABYLON {
  1215. /** @hidden */
  1216. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1217. define: string;
  1218. not: boolean;
  1219. constructor(define: string, not?: boolean);
  1220. isTrue(preprocessors: {
  1221. [key: string]: string;
  1222. }): boolean;
  1223. }
  1224. }
  1225. declare module BABYLON {
  1226. /** @hidden */
  1227. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1228. leftOperand: ShaderDefineExpression;
  1229. rightOperand: ShaderDefineExpression;
  1230. isTrue(preprocessors: {
  1231. [key: string]: string;
  1232. }): boolean;
  1233. }
  1234. }
  1235. declare module BABYLON {
  1236. /** @hidden */
  1237. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1238. leftOperand: ShaderDefineExpression;
  1239. rightOperand: ShaderDefineExpression;
  1240. isTrue(preprocessors: {
  1241. [key: string]: string;
  1242. }): boolean;
  1243. }
  1244. }
  1245. declare module BABYLON {
  1246. /** @hidden */
  1247. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1248. define: string;
  1249. operand: string;
  1250. testValue: string;
  1251. constructor(define: string, operand: string, testValue: string);
  1252. isTrue(preprocessors: {
  1253. [key: string]: string;
  1254. }): boolean;
  1255. }
  1256. }
  1257. declare module BABYLON {
  1258. /**
  1259. * Class used to enable access to offline support
  1260. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1261. */
  1262. export interface IOfflineProvider {
  1263. /**
  1264. * Gets a boolean indicating if scene must be saved in the database
  1265. */
  1266. enableSceneOffline: boolean;
  1267. /**
  1268. * Gets a boolean indicating if textures must be saved in the database
  1269. */
  1270. enableTexturesOffline: boolean;
  1271. /**
  1272. * Open the offline support and make it available
  1273. * @param successCallback defines the callback to call on success
  1274. * @param errorCallback defines the callback to call on error
  1275. */
  1276. open(successCallback: () => void, errorCallback: () => void): void;
  1277. /**
  1278. * Loads an image from the offline support
  1279. * @param url defines the url to load from
  1280. * @param image defines the target DOM image
  1281. */
  1282. loadImage(url: string, image: HTMLImageElement): void;
  1283. /**
  1284. * Loads a file from offline support
  1285. * @param url defines the URL to load from
  1286. * @param sceneLoaded defines a callback to call on success
  1287. * @param progressCallBack defines a callback to call when progress changed
  1288. * @param errorCallback defines a callback to call on error
  1289. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1290. */
  1291. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1292. }
  1293. }
  1294. declare module BABYLON {
  1295. /**
  1296. * Class used to help managing file picking and drag'n'drop
  1297. * File Storage
  1298. */
  1299. export class FilesInputStore {
  1300. /**
  1301. * List of files ready to be loaded
  1302. */
  1303. static FilesToLoad: {
  1304. [key: string]: File;
  1305. };
  1306. }
  1307. }
  1308. declare module BABYLON {
  1309. /**
  1310. * Class used to define a retry strategy when error happens while loading assets
  1311. */
  1312. export class RetryStrategy {
  1313. /**
  1314. * Function used to defines an exponential back off strategy
  1315. * @param maxRetries defines the maximum number of retries (3 by default)
  1316. * @param baseInterval defines the interval between retries
  1317. * @returns the strategy function to use
  1318. */
  1319. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1320. }
  1321. }
  1322. declare module BABYLON {
  1323. /**
  1324. * @ignore
  1325. * Application error to support additional information when loading a file
  1326. */
  1327. export abstract class BaseError extends Error {
  1328. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1329. }
  1330. }
  1331. declare module BABYLON {
  1332. /** @ignore */
  1333. export class LoadFileError extends BaseError {
  1334. request?: WebRequest;
  1335. file?: File;
  1336. /**
  1337. * Creates a new LoadFileError
  1338. * @param message defines the message of the error
  1339. * @param request defines the optional web request
  1340. * @param file defines the optional file
  1341. */
  1342. constructor(message: string, object?: WebRequest | File);
  1343. }
  1344. /** @ignore */
  1345. export class RequestFileError extends BaseError {
  1346. request: WebRequest;
  1347. /**
  1348. * Creates a new LoadFileError
  1349. * @param message defines the message of the error
  1350. * @param request defines the optional web request
  1351. */
  1352. constructor(message: string, request: WebRequest);
  1353. }
  1354. /** @ignore */
  1355. export class ReadFileError extends BaseError {
  1356. file: File;
  1357. /**
  1358. * Creates a new ReadFileError
  1359. * @param message defines the message of the error
  1360. * @param file defines the optional file
  1361. */
  1362. constructor(message: string, file: File);
  1363. }
  1364. /**
  1365. * @hidden
  1366. */
  1367. export class FileTools {
  1368. /**
  1369. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1370. */
  1371. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1372. /**
  1373. * Gets or sets the base URL to use to load assets
  1374. */
  1375. static BaseUrl: string;
  1376. /**
  1377. * Default behaviour for cors in the application.
  1378. * It can be a string if the expected behavior is identical in the entire app.
  1379. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1380. */
  1381. static CorsBehavior: string | ((url: string | string[]) => string);
  1382. /**
  1383. * Gets or sets a function used to pre-process url before using them to load assets
  1384. */
  1385. static PreprocessUrl: (url: string) => string;
  1386. /**
  1387. * Removes unwanted characters from an url
  1388. * @param url defines the url to clean
  1389. * @returns the cleaned url
  1390. */
  1391. private static _CleanUrl;
  1392. /**
  1393. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1394. * @param url define the url we are trying
  1395. * @param element define the dom element where to configure the cors policy
  1396. */
  1397. static SetCorsBehavior(url: string | string[], element: {
  1398. crossOrigin: string | null;
  1399. }): void;
  1400. /**
  1401. * Loads an image as an HTMLImageElement.
  1402. * @param input url string, ArrayBuffer, or Blob to load
  1403. * @param onLoad callback called when the image successfully loads
  1404. * @param onError callback called when the image fails to load
  1405. * @param offlineProvider offline provider for caching
  1406. * @param mimeType optional mime type
  1407. * @returns the HTMLImageElement of the loaded image
  1408. */
  1409. 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>;
  1410. /**
  1411. * Reads a file from a File object
  1412. * @param file defines the file to load
  1413. * @param onSuccess defines the callback to call when data is loaded
  1414. * @param onProgress defines the callback to call during loading process
  1415. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1416. * @param onError defines the callback to call when an error occurs
  1417. * @returns a file request object
  1418. */
  1419. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1420. /**
  1421. * Loads a file from a url
  1422. * @param url url to load
  1423. * @param onSuccess callback called when the file successfully loads
  1424. * @param onProgress callback called while file is loading (if the server supports this mode)
  1425. * @param offlineProvider defines the offline provider for caching
  1426. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1427. * @param onError callback called when the file fails to load
  1428. * @returns a file request object
  1429. */
  1430. 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;
  1431. /**
  1432. * Loads a file
  1433. * @param url url to load
  1434. * @param onSuccess callback called when the file successfully loads
  1435. * @param onProgress callback called while file is loading (if the server supports this mode)
  1436. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1437. * @param onError callback called when the file fails to load
  1438. * @param onOpened callback called when the web request is opened
  1439. * @returns a file request object
  1440. */
  1441. 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;
  1442. /**
  1443. * Checks if the loaded document was accessed via `file:`-Protocol.
  1444. * @returns boolean
  1445. */
  1446. static IsFileURL(): boolean;
  1447. }
  1448. }
  1449. declare module BABYLON {
  1450. /** @hidden */
  1451. export class ShaderProcessor {
  1452. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1453. private static _ProcessPrecision;
  1454. private static _ExtractOperation;
  1455. private static _BuildSubExpression;
  1456. private static _BuildExpression;
  1457. private static _MoveCursorWithinIf;
  1458. private static _MoveCursor;
  1459. private static _EvaluatePreProcessors;
  1460. private static _PreparePreProcessors;
  1461. private static _ProcessShaderConversion;
  1462. private static _ProcessIncludes;
  1463. /**
  1464. * Loads a file from a url
  1465. * @param url url to load
  1466. * @param onSuccess callback called when the file successfully loads
  1467. * @param onProgress callback called while file is loading (if the server supports this mode)
  1468. * @param offlineProvider defines the offline provider for caching
  1469. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1470. * @param onError callback called when the file fails to load
  1471. * @returns a file request object
  1472. * @hidden
  1473. */
  1474. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1475. }
  1476. }
  1477. declare module BABYLON {
  1478. /**
  1479. * @hidden
  1480. */
  1481. export interface IColor4Like {
  1482. r: float;
  1483. g: float;
  1484. b: float;
  1485. a: float;
  1486. }
  1487. /**
  1488. * @hidden
  1489. */
  1490. export interface IColor3Like {
  1491. r: float;
  1492. g: float;
  1493. b: float;
  1494. }
  1495. /**
  1496. * @hidden
  1497. */
  1498. export interface IVector4Like {
  1499. x: float;
  1500. y: float;
  1501. z: float;
  1502. w: float;
  1503. }
  1504. /**
  1505. * @hidden
  1506. */
  1507. export interface IVector3Like {
  1508. x: float;
  1509. y: float;
  1510. z: float;
  1511. }
  1512. /**
  1513. * @hidden
  1514. */
  1515. export interface IVector2Like {
  1516. x: float;
  1517. y: float;
  1518. }
  1519. /**
  1520. * @hidden
  1521. */
  1522. export interface IMatrixLike {
  1523. toArray(): DeepImmutable<Float32Array>;
  1524. updateFlag: int;
  1525. }
  1526. /**
  1527. * @hidden
  1528. */
  1529. export interface IViewportLike {
  1530. x: float;
  1531. y: float;
  1532. width: float;
  1533. height: float;
  1534. }
  1535. /**
  1536. * @hidden
  1537. */
  1538. export interface IPlaneLike {
  1539. normal: IVector3Like;
  1540. d: float;
  1541. normalize(): void;
  1542. }
  1543. }
  1544. declare module BABYLON {
  1545. /**
  1546. * Interface used to define common properties for effect fallbacks
  1547. */
  1548. export interface IEffectFallbacks {
  1549. /**
  1550. * Removes the defines that should be removed when falling back.
  1551. * @param currentDefines defines the current define statements for the shader.
  1552. * @param effect defines the current effect we try to compile
  1553. * @returns The resulting defines with defines of the current rank removed.
  1554. */
  1555. reduce(currentDefines: string, effect: Effect): string;
  1556. /**
  1557. * Removes the fallback from the bound mesh.
  1558. */
  1559. unBindMesh(): void;
  1560. /**
  1561. * Checks to see if more fallbacks are still availible.
  1562. */
  1563. hasMoreFallbacks: boolean;
  1564. }
  1565. }
  1566. declare module BABYLON {
  1567. /**
  1568. * Class used to evalaute queries containing `and` and `or` operators
  1569. */
  1570. export class AndOrNotEvaluator {
  1571. /**
  1572. * Evaluate a query
  1573. * @param query defines the query to evaluate
  1574. * @param evaluateCallback defines the callback used to filter result
  1575. * @returns true if the query matches
  1576. */
  1577. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1578. private static _HandleParenthesisContent;
  1579. private static _SimplifyNegation;
  1580. }
  1581. }
  1582. declare module BABYLON {
  1583. /**
  1584. * Class used to store custom tags
  1585. */
  1586. export class Tags {
  1587. /**
  1588. * Adds support for tags on the given object
  1589. * @param obj defines the object to use
  1590. */
  1591. static EnableFor(obj: any): void;
  1592. /**
  1593. * Removes tags support
  1594. * @param obj defines the object to use
  1595. */
  1596. static DisableFor(obj: any): void;
  1597. /**
  1598. * Gets a boolean indicating if the given object has tags
  1599. * @param obj defines the object to use
  1600. * @returns a boolean
  1601. */
  1602. static HasTags(obj: any): boolean;
  1603. /**
  1604. * Gets the tags available on a given object
  1605. * @param obj defines the object to use
  1606. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1607. * @returns the tags
  1608. */
  1609. static GetTags(obj: any, asString?: boolean): any;
  1610. /**
  1611. * Adds tags to an object
  1612. * @param obj defines the object to use
  1613. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1614. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1615. */
  1616. static AddTagsTo(obj: any, tagsString: string): void;
  1617. /**
  1618. * @hidden
  1619. */
  1620. static _AddTagTo(obj: any, tag: string): void;
  1621. /**
  1622. * Removes specific tags from a specific object
  1623. * @param obj defines the object to use
  1624. * @param tagsString defines the tags to remove
  1625. */
  1626. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1627. /**
  1628. * @hidden
  1629. */
  1630. static _RemoveTagFrom(obj: any, tag: string): void;
  1631. /**
  1632. * Defines if tags hosted on an object match a given query
  1633. * @param obj defines the object to use
  1634. * @param tagsQuery defines the tag query
  1635. * @returns a boolean
  1636. */
  1637. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1638. }
  1639. }
  1640. declare module BABYLON {
  1641. /**
  1642. * Scalar computation library
  1643. */
  1644. export class Scalar {
  1645. /**
  1646. * Two pi constants convenient for computation.
  1647. */
  1648. static TwoPi: number;
  1649. /**
  1650. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1651. * @param a number
  1652. * @param b number
  1653. * @param epsilon (default = 1.401298E-45)
  1654. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1655. */
  1656. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1657. /**
  1658. * Returns a string : the upper case translation of the number i to hexadecimal.
  1659. * @param i number
  1660. * @returns the upper case translation of the number i to hexadecimal.
  1661. */
  1662. static ToHex(i: number): string;
  1663. /**
  1664. * Returns -1 if value is negative and +1 is value is positive.
  1665. * @param value the value
  1666. * @returns the value itself if it's equal to zero.
  1667. */
  1668. static Sign(value: number): number;
  1669. /**
  1670. * Returns the value itself if it's between min and max.
  1671. * Returns min if the value is lower than min.
  1672. * Returns max if the value is greater than max.
  1673. * @param value the value to clmap
  1674. * @param min the min value to clamp to (default: 0)
  1675. * @param max the max value to clamp to (default: 1)
  1676. * @returns the clamped value
  1677. */
  1678. static Clamp(value: number, min?: number, max?: number): number;
  1679. /**
  1680. * the log2 of value.
  1681. * @param value the value to compute log2 of
  1682. * @returns the log2 of value.
  1683. */
  1684. static Log2(value: number): number;
  1685. /**
  1686. * Loops the value, so that it is never larger than length and never smaller than 0.
  1687. *
  1688. * This is similar to the modulo operator but it works with floating point numbers.
  1689. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1690. * With t = 5 and length = 2.5, the result would be 0.0.
  1691. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1692. * @param value the value
  1693. * @param length the length
  1694. * @returns the looped value
  1695. */
  1696. static Repeat(value: number, length: number): number;
  1697. /**
  1698. * Normalize the value between 0.0 and 1.0 using min and max values
  1699. * @param value value to normalize
  1700. * @param min max to normalize between
  1701. * @param max min to normalize between
  1702. * @returns the normalized value
  1703. */
  1704. static Normalize(value: number, min: number, max: number): number;
  1705. /**
  1706. * Denormalize the value from 0.0 and 1.0 using min and max values
  1707. * @param normalized value to denormalize
  1708. * @param min max to denormalize between
  1709. * @param max min to denormalize between
  1710. * @returns the denormalized value
  1711. */
  1712. static Denormalize(normalized: number, min: number, max: number): number;
  1713. /**
  1714. * Calculates the shortest difference between two given angles given in degrees.
  1715. * @param current current angle in degrees
  1716. * @param target target angle in degrees
  1717. * @returns the delta
  1718. */
  1719. static DeltaAngle(current: number, target: number): number;
  1720. /**
  1721. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1722. * @param tx value
  1723. * @param length length
  1724. * @returns The returned value will move back and forth between 0 and length
  1725. */
  1726. static PingPong(tx: number, length: number): number;
  1727. /**
  1728. * Interpolates between min and max with smoothing at the limits.
  1729. *
  1730. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1731. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1732. * @param from from
  1733. * @param to to
  1734. * @param tx value
  1735. * @returns the smooth stepped value
  1736. */
  1737. static SmoothStep(from: number, to: number, tx: number): number;
  1738. /**
  1739. * Moves a value current towards target.
  1740. *
  1741. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1742. * Negative values of maxDelta pushes the value away from target.
  1743. * @param current current value
  1744. * @param target target value
  1745. * @param maxDelta max distance to move
  1746. * @returns resulting value
  1747. */
  1748. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1749. /**
  1750. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1751. *
  1752. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1753. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1754. * @param current current value
  1755. * @param target target value
  1756. * @param maxDelta max distance to move
  1757. * @returns resulting angle
  1758. */
  1759. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1760. /**
  1761. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1762. * @param start start value
  1763. * @param end target value
  1764. * @param amount amount to lerp between
  1765. * @returns the lerped value
  1766. */
  1767. static Lerp(start: number, end: number, amount: number): number;
  1768. /**
  1769. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1770. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1771. * @param start start value
  1772. * @param end target value
  1773. * @param amount amount to lerp between
  1774. * @returns the lerped value
  1775. */
  1776. static LerpAngle(start: number, end: number, amount: number): number;
  1777. /**
  1778. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1779. * @param a start value
  1780. * @param b target value
  1781. * @param value value between a and b
  1782. * @returns the inverseLerp value
  1783. */
  1784. static InverseLerp(a: number, b: number, value: number): number;
  1785. /**
  1786. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1787. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1788. * @param value1 spline value
  1789. * @param tangent1 spline value
  1790. * @param value2 spline value
  1791. * @param tangent2 spline value
  1792. * @param amount input value
  1793. * @returns hermite result
  1794. */
  1795. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1796. /**
  1797. * Returns a random float number between and min and max values
  1798. * @param min min value of random
  1799. * @param max max value of random
  1800. * @returns random value
  1801. */
  1802. static RandomRange(min: number, max: number): number;
  1803. /**
  1804. * This function returns percentage of a number in a given range.
  1805. *
  1806. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1807. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1808. * @param number to convert to percentage
  1809. * @param min min range
  1810. * @param max max range
  1811. * @returns the percentage
  1812. */
  1813. static RangeToPercent(number: number, min: number, max: number): number;
  1814. /**
  1815. * This function returns number that corresponds to the percentage in a given range.
  1816. *
  1817. * PercentToRange(0.34,0,100) will return 34.
  1818. * @param percent to convert to number
  1819. * @param min min range
  1820. * @param max max range
  1821. * @returns the number
  1822. */
  1823. static PercentToRange(percent: number, min: number, max: number): number;
  1824. /**
  1825. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1826. * @param angle The angle to normalize in radian.
  1827. * @return The converted angle.
  1828. */
  1829. static NormalizeRadians(angle: number): number;
  1830. }
  1831. }
  1832. declare module BABYLON {
  1833. /**
  1834. * Constant used to convert a value to gamma space
  1835. * @ignorenaming
  1836. */
  1837. export const ToGammaSpace: number;
  1838. /**
  1839. * Constant used to convert a value to linear space
  1840. * @ignorenaming
  1841. */
  1842. export const ToLinearSpace = 2.2;
  1843. /**
  1844. * Constant used to define the minimal number value in Babylon.js
  1845. * @ignorenaming
  1846. */
  1847. let Epsilon: number;
  1848. }
  1849. declare module BABYLON {
  1850. /**
  1851. * Class used to represent a viewport on screen
  1852. */
  1853. export class Viewport {
  1854. /** viewport left coordinate */
  1855. x: number;
  1856. /** viewport top coordinate */
  1857. y: number;
  1858. /**viewport width */
  1859. width: number;
  1860. /** viewport height */
  1861. height: number;
  1862. /**
  1863. * Creates a Viewport object located at (x, y) and sized (width, height)
  1864. * @param x defines viewport left coordinate
  1865. * @param y defines viewport top coordinate
  1866. * @param width defines the viewport width
  1867. * @param height defines the viewport height
  1868. */
  1869. constructor(
  1870. /** viewport left coordinate */
  1871. x: number,
  1872. /** viewport top coordinate */
  1873. y: number,
  1874. /**viewport width */
  1875. width: number,
  1876. /** viewport height */
  1877. height: number);
  1878. /**
  1879. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1880. * @param renderWidth defines the rendering width
  1881. * @param renderHeight defines the rendering height
  1882. * @returns a new Viewport
  1883. */
  1884. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1885. /**
  1886. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1887. * @param renderWidth defines the rendering width
  1888. * @param renderHeight defines the rendering height
  1889. * @param ref defines the target viewport
  1890. * @returns the current viewport
  1891. */
  1892. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1893. /**
  1894. * Returns a new Viewport copied from the current one
  1895. * @returns a new Viewport
  1896. */
  1897. clone(): Viewport;
  1898. }
  1899. }
  1900. declare module BABYLON {
  1901. /**
  1902. * Class containing a set of static utilities functions for arrays.
  1903. */
  1904. export class ArrayTools {
  1905. /**
  1906. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1907. * @param size the number of element to construct and put in the array
  1908. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1909. * @returns a new array filled with new objects
  1910. */
  1911. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1912. }
  1913. }
  1914. declare module BABYLON {
  1915. /**
  1916. * Represens a plane by the equation ax + by + cz + d = 0
  1917. */
  1918. export class Plane {
  1919. private static _TmpMatrix;
  1920. /**
  1921. * Normal of the plane (a,b,c)
  1922. */
  1923. normal: Vector3;
  1924. /**
  1925. * d component of the plane
  1926. */
  1927. d: number;
  1928. /**
  1929. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  1930. * @param a a component of the plane
  1931. * @param b b component of the plane
  1932. * @param c c component of the plane
  1933. * @param d d component of the plane
  1934. */
  1935. constructor(a: number, b: number, c: number, d: number);
  1936. /**
  1937. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  1938. */
  1939. asArray(): number[];
  1940. /**
  1941. * @returns a new plane copied from the current Plane.
  1942. */
  1943. clone(): Plane;
  1944. /**
  1945. * @returns the string "Plane".
  1946. */
  1947. getClassName(): string;
  1948. /**
  1949. * @returns the Plane hash code.
  1950. */
  1951. getHashCode(): number;
  1952. /**
  1953. * Normalize the current Plane in place.
  1954. * @returns the updated Plane.
  1955. */
  1956. normalize(): Plane;
  1957. /**
  1958. * Applies a transformation the plane and returns the result
  1959. * @param transformation the transformation matrix to be applied to the plane
  1960. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  1961. */
  1962. transform(transformation: DeepImmutable<Matrix>): Plane;
  1963. /**
  1964. * Compute the dot product between the point and the plane normal
  1965. * @param point point to calculate the dot product with
  1966. * @returns the dot product (float) of the point coordinates and the plane normal.
  1967. */
  1968. dotCoordinate(point: DeepImmutable<Vector3>): number;
  1969. /**
  1970. * Updates the current Plane from the plane defined by the three given points.
  1971. * @param point1 one of the points used to contruct the plane
  1972. * @param point2 one of the points used to contruct the plane
  1973. * @param point3 one of the points used to contruct the plane
  1974. * @returns the updated Plane.
  1975. */
  1976. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  1977. /**
  1978. * Checks if the plane is facing a given direction
  1979. * @param direction the direction to check if the plane is facing
  1980. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  1981. * @returns True is the vector "direction" is the same side than the plane normal.
  1982. */
  1983. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  1984. /**
  1985. * Calculates the distance to a point
  1986. * @param point point to calculate distance to
  1987. * @returns the signed distance (float) from the given point to the Plane.
  1988. */
  1989. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  1990. /**
  1991. * Creates a plane from an array
  1992. * @param array the array to create a plane from
  1993. * @returns a new Plane from the given array.
  1994. */
  1995. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  1996. /**
  1997. * Creates a plane from three points
  1998. * @param point1 point used to create the plane
  1999. * @param point2 point used to create the plane
  2000. * @param point3 point used to create the plane
  2001. * @returns a new Plane defined by the three given points.
  2002. */
  2003. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2004. /**
  2005. * Creates a plane from an origin point and a normal
  2006. * @param origin origin of the plane to be constructed
  2007. * @param normal normal of the plane to be constructed
  2008. * @returns a new Plane the normal vector to this plane at the given origin point.
  2009. * Note : the vector "normal" is updated because normalized.
  2010. */
  2011. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  2012. /**
  2013. * Calculates the distance from a plane and a point
  2014. * @param origin origin of the plane to be constructed
  2015. * @param normal normal of the plane to be constructed
  2016. * @param point point to calculate distance to
  2017. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2018. */
  2019. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2020. }
  2021. }
  2022. declare module BABYLON {
  2023. /**
  2024. * Class representing a vector containing 2 coordinates
  2025. */
  2026. export class Vector2 {
  2027. /** defines the first coordinate */
  2028. x: number;
  2029. /** defines the second coordinate */
  2030. y: number;
  2031. /**
  2032. * Creates a new Vector2 from the given x and y coordinates
  2033. * @param x defines the first coordinate
  2034. * @param y defines the second coordinate
  2035. */
  2036. constructor(
  2037. /** defines the first coordinate */
  2038. x?: number,
  2039. /** defines the second coordinate */
  2040. y?: number);
  2041. /**
  2042. * Gets a string with the Vector2 coordinates
  2043. * @returns a string with the Vector2 coordinates
  2044. */
  2045. toString(): string;
  2046. /**
  2047. * Gets class name
  2048. * @returns the string "Vector2"
  2049. */
  2050. getClassName(): string;
  2051. /**
  2052. * Gets current vector hash code
  2053. * @returns the Vector2 hash code as a number
  2054. */
  2055. getHashCode(): number;
  2056. /**
  2057. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2058. * @param array defines the source array
  2059. * @param index defines the offset in source array
  2060. * @returns the current Vector2
  2061. */
  2062. toArray(array: FloatArray, index?: number): Vector2;
  2063. /**
  2064. * Copy the current vector to an array
  2065. * @returns a new array with 2 elements: the Vector2 coordinates.
  2066. */
  2067. asArray(): number[];
  2068. /**
  2069. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2070. * @param source defines the source Vector2
  2071. * @returns the current updated Vector2
  2072. */
  2073. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2074. /**
  2075. * Sets the Vector2 coordinates with the given floats
  2076. * @param x defines the first coordinate
  2077. * @param y defines the second coordinate
  2078. * @returns the current updated Vector2
  2079. */
  2080. copyFromFloats(x: number, y: number): Vector2;
  2081. /**
  2082. * Sets the Vector2 coordinates with the given floats
  2083. * @param x defines the first coordinate
  2084. * @param y defines the second coordinate
  2085. * @returns the current updated Vector2
  2086. */
  2087. set(x: number, y: number): Vector2;
  2088. /**
  2089. * Add another vector with the current one
  2090. * @param otherVector defines the other vector
  2091. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2092. */
  2093. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2094. /**
  2095. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2096. * @param otherVector defines the other vector
  2097. * @param result defines the target vector
  2098. * @returns the unmodified current Vector2
  2099. */
  2100. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2101. /**
  2102. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2103. * @param otherVector defines the other vector
  2104. * @returns the current updated Vector2
  2105. */
  2106. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2107. /**
  2108. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2109. * @param otherVector defines the other vector
  2110. * @returns a new Vector2
  2111. */
  2112. addVector3(otherVector: Vector3): Vector2;
  2113. /**
  2114. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2115. * @param otherVector defines the other vector
  2116. * @returns a new Vector2
  2117. */
  2118. subtract(otherVector: Vector2): Vector2;
  2119. /**
  2120. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2121. * @param otherVector defines the other vector
  2122. * @param result defines the target vector
  2123. * @returns the unmodified current Vector2
  2124. */
  2125. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2126. /**
  2127. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2128. * @param otherVector defines the other vector
  2129. * @returns the current updated Vector2
  2130. */
  2131. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2132. /**
  2133. * Multiplies in place the current Vector2 coordinates by the given ones
  2134. * @param otherVector defines the other vector
  2135. * @returns the current updated Vector2
  2136. */
  2137. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2138. /**
  2139. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2140. * @param otherVector defines the other vector
  2141. * @returns a new Vector2
  2142. */
  2143. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2144. /**
  2145. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2146. * @param otherVector defines the other vector
  2147. * @param result defines the target vector
  2148. * @returns the unmodified current Vector2
  2149. */
  2150. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2151. /**
  2152. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2153. * @param x defines the first coordinate
  2154. * @param y defines the second coordinate
  2155. * @returns a new Vector2
  2156. */
  2157. multiplyByFloats(x: number, y: number): Vector2;
  2158. /**
  2159. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2160. * @param otherVector defines the other vector
  2161. * @returns a new Vector2
  2162. */
  2163. divide(otherVector: Vector2): Vector2;
  2164. /**
  2165. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2166. * @param otherVector defines the other vector
  2167. * @param result defines the target vector
  2168. * @returns the unmodified current Vector2
  2169. */
  2170. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2171. /**
  2172. * Divides the current Vector2 coordinates by the given ones
  2173. * @param otherVector defines the other vector
  2174. * @returns the current updated Vector2
  2175. */
  2176. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2177. /**
  2178. * Gets a new Vector2 with current Vector2 negated coordinates
  2179. * @returns a new Vector2
  2180. */
  2181. negate(): Vector2;
  2182. /**
  2183. * Negate this vector in place
  2184. * @returns this
  2185. */
  2186. negateInPlace(): Vector2;
  2187. /**
  2188. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2189. * @param result defines the Vector3 object where to store the result
  2190. * @returns the current Vector2
  2191. */
  2192. negateToRef(result: Vector2): Vector2;
  2193. /**
  2194. * Multiply the Vector2 coordinates by scale
  2195. * @param scale defines the scaling factor
  2196. * @returns the current updated Vector2
  2197. */
  2198. scaleInPlace(scale: number): Vector2;
  2199. /**
  2200. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2201. * @param scale defines the scaling factor
  2202. * @returns a new Vector2
  2203. */
  2204. scale(scale: number): Vector2;
  2205. /**
  2206. * Scale the current Vector2 values by a factor to a given Vector2
  2207. * @param scale defines the scale factor
  2208. * @param result defines the Vector2 object where to store the result
  2209. * @returns the unmodified current Vector2
  2210. */
  2211. scaleToRef(scale: number, result: Vector2): Vector2;
  2212. /**
  2213. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2214. * @param scale defines the scale factor
  2215. * @param result defines the Vector2 object where to store the result
  2216. * @returns the unmodified current Vector2
  2217. */
  2218. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2219. /**
  2220. * Gets a boolean if two vectors are equals
  2221. * @param otherVector defines the other vector
  2222. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2223. */
  2224. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2225. /**
  2226. * Gets a boolean if two vectors are equals (using an epsilon value)
  2227. * @param otherVector defines the other vector
  2228. * @param epsilon defines the minimal distance to consider equality
  2229. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2230. */
  2231. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2232. /**
  2233. * Gets a new Vector2 from current Vector2 floored values
  2234. * @returns a new Vector2
  2235. */
  2236. floor(): Vector2;
  2237. /**
  2238. * Gets a new Vector2 from current Vector2 floored values
  2239. * @returns a new Vector2
  2240. */
  2241. fract(): Vector2;
  2242. /**
  2243. * Gets the length of the vector
  2244. * @returns the vector length (float)
  2245. */
  2246. length(): number;
  2247. /**
  2248. * Gets the vector squared length
  2249. * @returns the vector squared length (float)
  2250. */
  2251. lengthSquared(): number;
  2252. /**
  2253. * Normalize the vector
  2254. * @returns the current updated Vector2
  2255. */
  2256. normalize(): Vector2;
  2257. /**
  2258. * Gets a new Vector2 copied from the Vector2
  2259. * @returns a new Vector2
  2260. */
  2261. clone(): Vector2;
  2262. /**
  2263. * Gets a new Vector2(0, 0)
  2264. * @returns a new Vector2
  2265. */
  2266. static Zero(): Vector2;
  2267. /**
  2268. * Gets a new Vector2(1, 1)
  2269. * @returns a new Vector2
  2270. */
  2271. static One(): Vector2;
  2272. /**
  2273. * Gets a new Vector2 set from the given index element of the given array
  2274. * @param array defines the data source
  2275. * @param offset defines the offset in the data source
  2276. * @returns a new Vector2
  2277. */
  2278. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2279. /**
  2280. * Sets "result" from the given index element of the given array
  2281. * @param array defines the data source
  2282. * @param offset defines the offset in the data source
  2283. * @param result defines the target vector
  2284. */
  2285. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2286. /**
  2287. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2288. * @param value1 defines 1st point of control
  2289. * @param value2 defines 2nd point of control
  2290. * @param value3 defines 3rd point of control
  2291. * @param value4 defines 4th point of control
  2292. * @param amount defines the interpolation factor
  2293. * @returns a new Vector2
  2294. */
  2295. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2296. /**
  2297. * 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".
  2298. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2299. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2300. * @param value defines the value to clamp
  2301. * @param min defines the lower limit
  2302. * @param max defines the upper limit
  2303. * @returns a new Vector2
  2304. */
  2305. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2306. /**
  2307. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2308. * @param value1 defines the 1st control point
  2309. * @param tangent1 defines the outgoing tangent
  2310. * @param value2 defines the 2nd control point
  2311. * @param tangent2 defines the incoming tangent
  2312. * @param amount defines the interpolation factor
  2313. * @returns a new Vector2
  2314. */
  2315. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2316. /**
  2317. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2318. * @param start defines the start vector
  2319. * @param end defines the end vector
  2320. * @param amount defines the interpolation factor
  2321. * @returns a new Vector2
  2322. */
  2323. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2324. /**
  2325. * Gets the dot product of the vector "left" and the vector "right"
  2326. * @param left defines first vector
  2327. * @param right defines second vector
  2328. * @returns the dot product (float)
  2329. */
  2330. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2331. /**
  2332. * Returns a new Vector2 equal to the normalized given vector
  2333. * @param vector defines the vector to normalize
  2334. * @returns a new Vector2
  2335. */
  2336. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2337. /**
  2338. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2339. * @param left defines 1st vector
  2340. * @param right defines 2nd vector
  2341. * @returns a new Vector2
  2342. */
  2343. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2344. /**
  2345. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2346. * @param left defines 1st vector
  2347. * @param right defines 2nd vector
  2348. * @returns a new Vector2
  2349. */
  2350. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2351. /**
  2352. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2353. * @param vector defines the vector to transform
  2354. * @param transformation defines the matrix to apply
  2355. * @returns a new Vector2
  2356. */
  2357. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2358. /**
  2359. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2360. * @param vector defines the vector to transform
  2361. * @param transformation defines the matrix to apply
  2362. * @param result defines the target vector
  2363. */
  2364. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2365. /**
  2366. * Determines if a given vector is included in a triangle
  2367. * @param p defines the vector to test
  2368. * @param p0 defines 1st triangle point
  2369. * @param p1 defines 2nd triangle point
  2370. * @param p2 defines 3rd triangle point
  2371. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2372. */
  2373. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2374. /**
  2375. * Gets the distance between the vectors "value1" and "value2"
  2376. * @param value1 defines first vector
  2377. * @param value2 defines second vector
  2378. * @returns the distance between vectors
  2379. */
  2380. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2381. /**
  2382. * Returns the squared distance between the vectors "value1" and "value2"
  2383. * @param value1 defines first vector
  2384. * @param value2 defines second vector
  2385. * @returns the squared distance between vectors
  2386. */
  2387. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2388. /**
  2389. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2390. * @param value1 defines first vector
  2391. * @param value2 defines second vector
  2392. * @returns a new Vector2
  2393. */
  2394. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2395. /**
  2396. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2397. * @param p defines the middle point
  2398. * @param segA defines one point of the segment
  2399. * @param segB defines the other point of the segment
  2400. * @returns the shortest distance
  2401. */
  2402. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2403. }
  2404. /**
  2405. * Class used to store (x,y,z) vector representation
  2406. * A Vector3 is the main object used in 3D geometry
  2407. * It can represent etiher the coordinates of a point the space, either a direction
  2408. * Reminder: js uses a left handed forward facing system
  2409. */
  2410. export class Vector3 {
  2411. /**
  2412. * Defines the first coordinates (on X axis)
  2413. */
  2414. x: number;
  2415. /**
  2416. * Defines the second coordinates (on Y axis)
  2417. */
  2418. y: number;
  2419. /**
  2420. * Defines the third coordinates (on Z axis)
  2421. */
  2422. z: number;
  2423. private static _UpReadOnly;
  2424. private static _ZeroReadOnly;
  2425. /**
  2426. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2427. * @param x defines the first coordinates (on X axis)
  2428. * @param y defines the second coordinates (on Y axis)
  2429. * @param z defines the third coordinates (on Z axis)
  2430. */
  2431. constructor(
  2432. /**
  2433. * Defines the first coordinates (on X axis)
  2434. */
  2435. x?: number,
  2436. /**
  2437. * Defines the second coordinates (on Y axis)
  2438. */
  2439. y?: number,
  2440. /**
  2441. * Defines the third coordinates (on Z axis)
  2442. */
  2443. z?: number);
  2444. /**
  2445. * Creates a string representation of the Vector3
  2446. * @returns a string with the Vector3 coordinates.
  2447. */
  2448. toString(): string;
  2449. /**
  2450. * Gets the class name
  2451. * @returns the string "Vector3"
  2452. */
  2453. getClassName(): string;
  2454. /**
  2455. * Creates the Vector3 hash code
  2456. * @returns a number which tends to be unique between Vector3 instances
  2457. */
  2458. getHashCode(): number;
  2459. /**
  2460. * Creates an array containing three elements : the coordinates of the Vector3
  2461. * @returns a new array of numbers
  2462. */
  2463. asArray(): number[];
  2464. /**
  2465. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2466. * @param array defines the destination array
  2467. * @param index defines the offset in the destination array
  2468. * @returns the current Vector3
  2469. */
  2470. toArray(array: FloatArray, index?: number): Vector3;
  2471. /**
  2472. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2473. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2474. */
  2475. toQuaternion(): Quaternion;
  2476. /**
  2477. * Adds the given vector to the current Vector3
  2478. * @param otherVector defines the second operand
  2479. * @returns the current updated Vector3
  2480. */
  2481. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2482. /**
  2483. * Adds the given coordinates to the current Vector3
  2484. * @param x defines the x coordinate of the operand
  2485. * @param y defines the y coordinate of the operand
  2486. * @param z defines the z coordinate of the operand
  2487. * @returns the current updated Vector3
  2488. */
  2489. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2490. /**
  2491. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2492. * @param otherVector defines the second operand
  2493. * @returns the resulting Vector3
  2494. */
  2495. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2496. /**
  2497. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2498. * @param otherVector defines the second operand
  2499. * @param result defines the Vector3 object where to store the result
  2500. * @returns the current Vector3
  2501. */
  2502. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2503. /**
  2504. * Subtract the given vector from the current Vector3
  2505. * @param otherVector defines the second operand
  2506. * @returns the current updated Vector3
  2507. */
  2508. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2509. /**
  2510. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2511. * @param otherVector defines the second operand
  2512. * @returns the resulting Vector3
  2513. */
  2514. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2515. /**
  2516. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2517. * @param otherVector defines the second operand
  2518. * @param result defines the Vector3 object where to store the result
  2519. * @returns the current Vector3
  2520. */
  2521. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2522. /**
  2523. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2524. * @param x defines the x coordinate of the operand
  2525. * @param y defines the y coordinate of the operand
  2526. * @param z defines the z coordinate of the operand
  2527. * @returns the resulting Vector3
  2528. */
  2529. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2530. /**
  2531. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2532. * @param x defines the x coordinate of the operand
  2533. * @param y defines the y coordinate of the operand
  2534. * @param z defines the z coordinate of the operand
  2535. * @param result defines the Vector3 object where to store the result
  2536. * @returns the current Vector3
  2537. */
  2538. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2539. /**
  2540. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2541. * @returns a new Vector3
  2542. */
  2543. negate(): Vector3;
  2544. /**
  2545. * Negate this vector in place
  2546. * @returns this
  2547. */
  2548. negateInPlace(): Vector3;
  2549. /**
  2550. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2551. * @param result defines the Vector3 object where to store the result
  2552. * @returns the current Vector3
  2553. */
  2554. negateToRef(result: Vector3): Vector3;
  2555. /**
  2556. * Multiplies the Vector3 coordinates by the float "scale"
  2557. * @param scale defines the multiplier factor
  2558. * @returns the current updated Vector3
  2559. */
  2560. scaleInPlace(scale: number): Vector3;
  2561. /**
  2562. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2563. * @param scale defines the multiplier factor
  2564. * @returns a new Vector3
  2565. */
  2566. scale(scale: number): Vector3;
  2567. /**
  2568. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2569. * @param scale defines the multiplier factor
  2570. * @param result defines the Vector3 object where to store the result
  2571. * @returns the current Vector3
  2572. */
  2573. scaleToRef(scale: number, result: Vector3): Vector3;
  2574. /**
  2575. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2576. * @param scale defines the scale factor
  2577. * @param result defines the Vector3 object where to store the result
  2578. * @returns the unmodified current Vector3
  2579. */
  2580. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2581. /**
  2582. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2583. * @param origin defines the origin of the projection ray
  2584. * @param plane defines the plane to project to
  2585. * @returns the projected vector3
  2586. */
  2587. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2588. /**
  2589. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2590. * @param origin defines the origin of the projection ray
  2591. * @param plane defines the plane to project to
  2592. * @param result defines the Vector3 where to store the result
  2593. */
  2594. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2595. /**
  2596. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2597. * @param otherVector defines the second operand
  2598. * @returns true if both vectors are equals
  2599. */
  2600. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2601. /**
  2602. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2603. * @param otherVector defines the second operand
  2604. * @param epsilon defines the minimal distance to define values as equals
  2605. * @returns true if both vectors are distant less than epsilon
  2606. */
  2607. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2608. /**
  2609. * Returns true if the current Vector3 coordinates equals the given floats
  2610. * @param x defines the x coordinate of the operand
  2611. * @param y defines the y coordinate of the operand
  2612. * @param z defines the z coordinate of the operand
  2613. * @returns true if both vectors are equals
  2614. */
  2615. equalsToFloats(x: number, y: number, z: number): boolean;
  2616. /**
  2617. * Multiplies the current Vector3 coordinates by the given ones
  2618. * @param otherVector defines the second operand
  2619. * @returns the current updated Vector3
  2620. */
  2621. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2622. /**
  2623. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2624. * @param otherVector defines the second operand
  2625. * @returns the new Vector3
  2626. */
  2627. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2628. /**
  2629. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2630. * @param otherVector defines the second operand
  2631. * @param result defines the Vector3 object where to store the result
  2632. * @returns the current Vector3
  2633. */
  2634. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2635. /**
  2636. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2637. * @param x defines the x coordinate of the operand
  2638. * @param y defines the y coordinate of the operand
  2639. * @param z defines the z coordinate of the operand
  2640. * @returns the new Vector3
  2641. */
  2642. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2643. /**
  2644. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2645. * @param otherVector defines the second operand
  2646. * @returns the new Vector3
  2647. */
  2648. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2649. /**
  2650. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2651. * @param otherVector defines the second operand
  2652. * @param result defines the Vector3 object where to store the result
  2653. * @returns the current Vector3
  2654. */
  2655. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2656. /**
  2657. * Divides the current Vector3 coordinates by the given ones.
  2658. * @param otherVector defines the second operand
  2659. * @returns the current updated Vector3
  2660. */
  2661. divideInPlace(otherVector: Vector3): Vector3;
  2662. /**
  2663. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2664. * @param other defines the second operand
  2665. * @returns the current updated Vector3
  2666. */
  2667. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2668. /**
  2669. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2670. * @param other defines the second operand
  2671. * @returns the current updated Vector3
  2672. */
  2673. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2674. /**
  2675. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2676. * @param x defines the x coordinate of the operand
  2677. * @param y defines the y coordinate of the operand
  2678. * @param z defines the z coordinate of the operand
  2679. * @returns the current updated Vector3
  2680. */
  2681. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2682. /**
  2683. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2684. * @param x defines the x coordinate of the operand
  2685. * @param y defines the y coordinate of the operand
  2686. * @param z defines the z coordinate of the operand
  2687. * @returns the current updated Vector3
  2688. */
  2689. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2690. /**
  2691. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2692. * Check if is non uniform within a certain amount of decimal places to account for this
  2693. * @param epsilon the amount the values can differ
  2694. * @returns if the the vector is non uniform to a certain number of decimal places
  2695. */
  2696. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2697. /**
  2698. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2699. */
  2700. get isNonUniform(): boolean;
  2701. /**
  2702. * Gets a new Vector3 from current Vector3 floored values
  2703. * @returns a new Vector3
  2704. */
  2705. floor(): Vector3;
  2706. /**
  2707. * Gets a new Vector3 from current Vector3 floored values
  2708. * @returns a new Vector3
  2709. */
  2710. fract(): Vector3;
  2711. /**
  2712. * Gets the length of the Vector3
  2713. * @returns the length of the Vector3
  2714. */
  2715. length(): number;
  2716. /**
  2717. * Gets the squared length of the Vector3
  2718. * @returns squared length of the Vector3
  2719. */
  2720. lengthSquared(): number;
  2721. /**
  2722. * Normalize the current Vector3.
  2723. * Please note that this is an in place operation.
  2724. * @returns the current updated Vector3
  2725. */
  2726. normalize(): Vector3;
  2727. /**
  2728. * Reorders the x y z properties of the vector in place
  2729. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2730. * @returns the current updated vector
  2731. */
  2732. reorderInPlace(order: string): this;
  2733. /**
  2734. * Rotates the vector around 0,0,0 by a quaternion
  2735. * @param quaternion the rotation quaternion
  2736. * @param result vector to store the result
  2737. * @returns the resulting vector
  2738. */
  2739. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2740. /**
  2741. * Rotates a vector around a given point
  2742. * @param quaternion the rotation quaternion
  2743. * @param point the point to rotate around
  2744. * @param result vector to store the result
  2745. * @returns the resulting vector
  2746. */
  2747. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2748. /**
  2749. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2750. * The cross product is then orthogonal to both current and "other"
  2751. * @param other defines the right operand
  2752. * @returns the cross product
  2753. */
  2754. cross(other: Vector3): Vector3;
  2755. /**
  2756. * Normalize the current Vector3 with the given input length.
  2757. * Please note that this is an in place operation.
  2758. * @param len the length of the vector
  2759. * @returns the current updated Vector3
  2760. */
  2761. normalizeFromLength(len: number): Vector3;
  2762. /**
  2763. * Normalize the current Vector3 to a new vector
  2764. * @returns the new Vector3
  2765. */
  2766. normalizeToNew(): Vector3;
  2767. /**
  2768. * Normalize the current Vector3 to the reference
  2769. * @param reference define the Vector3 to update
  2770. * @returns the updated Vector3
  2771. */
  2772. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2773. /**
  2774. * Creates a new Vector3 copied from the current Vector3
  2775. * @returns the new Vector3
  2776. */
  2777. clone(): Vector3;
  2778. /**
  2779. * Copies the given vector coordinates to the current Vector3 ones
  2780. * @param source defines the source Vector3
  2781. * @returns the current updated Vector3
  2782. */
  2783. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2784. /**
  2785. * Copies the given floats to the current Vector3 coordinates
  2786. * @param x defines the x coordinate of the operand
  2787. * @param y defines the y coordinate of the operand
  2788. * @param z defines the z coordinate of the operand
  2789. * @returns the current updated Vector3
  2790. */
  2791. copyFromFloats(x: number, y: number, z: number): Vector3;
  2792. /**
  2793. * Copies the given floats to the current Vector3 coordinates
  2794. * @param x defines the x coordinate of the operand
  2795. * @param y defines the y coordinate of the operand
  2796. * @param z defines the z coordinate of the operand
  2797. * @returns the current updated Vector3
  2798. */
  2799. set(x: number, y: number, z: number): Vector3;
  2800. /**
  2801. * Copies the given float to the current Vector3 coordinates
  2802. * @param v defines the x, y and z coordinates of the operand
  2803. * @returns the current updated Vector3
  2804. */
  2805. setAll(v: number): Vector3;
  2806. /**
  2807. * Get the clip factor between two vectors
  2808. * @param vector0 defines the first operand
  2809. * @param vector1 defines the second operand
  2810. * @param axis defines the axis to use
  2811. * @param size defines the size along the axis
  2812. * @returns the clip factor
  2813. */
  2814. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2815. /**
  2816. * Get angle between two vectors
  2817. * @param vector0 angle between vector0 and vector1
  2818. * @param vector1 angle between vector0 and vector1
  2819. * @param normal direction of the normal
  2820. * @return the angle between vector0 and vector1
  2821. */
  2822. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2823. /**
  2824. * Returns a new Vector3 set from the index "offset" of the given array
  2825. * @param array defines the source array
  2826. * @param offset defines the offset in the source array
  2827. * @returns the new Vector3
  2828. */
  2829. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2830. /**
  2831. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2832. * @param array defines the source array
  2833. * @param offset defines the offset in the source array
  2834. * @returns the new Vector3
  2835. * @deprecated Please use FromArray instead.
  2836. */
  2837. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2838. /**
  2839. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2840. * @param array defines the source array
  2841. * @param offset defines the offset in the source array
  2842. * @param result defines the Vector3 where to store the result
  2843. */
  2844. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2845. /**
  2846. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2847. * @param array defines the source array
  2848. * @param offset defines the offset in the source array
  2849. * @param result defines the Vector3 where to store the result
  2850. * @deprecated Please use FromArrayToRef instead.
  2851. */
  2852. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2853. /**
  2854. * Sets the given vector "result" with the given floats.
  2855. * @param x defines the x coordinate of the source
  2856. * @param y defines the y coordinate of the source
  2857. * @param z defines the z coordinate of the source
  2858. * @param result defines the Vector3 where to store the result
  2859. */
  2860. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2861. /**
  2862. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2863. * @returns a new empty Vector3
  2864. */
  2865. static Zero(): Vector3;
  2866. /**
  2867. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2868. * @returns a new unit Vector3
  2869. */
  2870. static One(): Vector3;
  2871. /**
  2872. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2873. * @returns a new up Vector3
  2874. */
  2875. static Up(): Vector3;
  2876. /**
  2877. * Gets a up Vector3 that must not be updated
  2878. */
  2879. static get UpReadOnly(): DeepImmutable<Vector3>;
  2880. /**
  2881. * Gets a zero Vector3 that must not be updated
  2882. */
  2883. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2884. /**
  2885. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2886. * @returns a new down Vector3
  2887. */
  2888. static Down(): Vector3;
  2889. /**
  2890. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2891. * @param rightHandedSystem is the scene right-handed (negative z)
  2892. * @returns a new forward Vector3
  2893. */
  2894. static Forward(rightHandedSystem?: boolean): Vector3;
  2895. /**
  2896. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2897. * @param rightHandedSystem is the scene right-handed (negative-z)
  2898. * @returns a new forward Vector3
  2899. */
  2900. static Backward(rightHandedSystem?: boolean): Vector3;
  2901. /**
  2902. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2903. * @returns a new right Vector3
  2904. */
  2905. static Right(): Vector3;
  2906. /**
  2907. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2908. * @returns a new left Vector3
  2909. */
  2910. static Left(): Vector3;
  2911. /**
  2912. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2913. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2914. * @param vector defines the Vector3 to transform
  2915. * @param transformation defines the transformation matrix
  2916. * @returns the transformed Vector3
  2917. */
  2918. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2919. /**
  2920. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2921. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2922. * @param vector defines the Vector3 to transform
  2923. * @param transformation defines the transformation matrix
  2924. * @param result defines the Vector3 where to store the result
  2925. */
  2926. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2927. /**
  2928. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2929. * This method computes tranformed coordinates only, not transformed direction vectors
  2930. * @param x define the x coordinate of the source vector
  2931. * @param y define the y coordinate of the source vector
  2932. * @param z define the z coordinate of the source vector
  2933. * @param transformation defines the transformation matrix
  2934. * @param result defines the Vector3 where to store the result
  2935. */
  2936. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2937. /**
  2938. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2939. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2940. * @param vector defines the Vector3 to transform
  2941. * @param transformation defines the transformation matrix
  2942. * @returns the new Vector3
  2943. */
  2944. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2945. /**
  2946. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2947. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2948. * @param vector defines the Vector3 to transform
  2949. * @param transformation defines the transformation matrix
  2950. * @param result defines the Vector3 where to store the result
  2951. */
  2952. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2953. /**
  2954. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2955. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2956. * @param x define the x coordinate of the source vector
  2957. * @param y define the y coordinate of the source vector
  2958. * @param z define the z coordinate of the source vector
  2959. * @param transformation defines the transformation matrix
  2960. * @param result defines the Vector3 where to store the result
  2961. */
  2962. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2963. /**
  2964. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2965. * @param value1 defines the first control point
  2966. * @param value2 defines the second control point
  2967. * @param value3 defines the third control point
  2968. * @param value4 defines the fourth control point
  2969. * @param amount defines the amount on the spline to use
  2970. * @returns the new Vector3
  2971. */
  2972. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2973. /**
  2974. * 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"
  2975. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2976. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2977. * @param value defines the current value
  2978. * @param min defines the lower range value
  2979. * @param max defines the upper range value
  2980. * @returns the new Vector3
  2981. */
  2982. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2983. /**
  2984. * 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"
  2985. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2986. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2987. * @param value defines the current value
  2988. * @param min defines the lower range value
  2989. * @param max defines the upper range value
  2990. * @param result defines the Vector3 where to store the result
  2991. */
  2992. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2993. /**
  2994. * Checks if a given vector is inside a specific range
  2995. * @param v defines the vector to test
  2996. * @param min defines the minimum range
  2997. * @param max defines the maximum range
  2998. */
  2999. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3000. /**
  3001. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3002. * @param value1 defines the first control point
  3003. * @param tangent1 defines the first tangent vector
  3004. * @param value2 defines the second control point
  3005. * @param tangent2 defines the second tangent vector
  3006. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3007. * @returns the new Vector3
  3008. */
  3009. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3010. /**
  3011. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3012. * @param start defines the start value
  3013. * @param end defines the end value
  3014. * @param amount max defines amount between both (between 0 and 1)
  3015. * @returns the new Vector3
  3016. */
  3017. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3018. /**
  3019. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3020. * @param start defines the start value
  3021. * @param end defines the end value
  3022. * @param amount max defines amount between both (between 0 and 1)
  3023. * @param result defines the Vector3 where to store the result
  3024. */
  3025. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3026. /**
  3027. * Returns the dot product (float) between the vectors "left" and "right"
  3028. * @param left defines the left operand
  3029. * @param right defines the right operand
  3030. * @returns the dot product
  3031. */
  3032. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3033. /**
  3034. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3035. * The cross product is then orthogonal to both "left" and "right"
  3036. * @param left defines the left operand
  3037. * @param right defines the right operand
  3038. * @returns the cross product
  3039. */
  3040. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3041. /**
  3042. * Sets the given vector "result" with the cross product of "left" and "right"
  3043. * The cross product is then orthogonal to both "left" and "right"
  3044. * @param left defines the left operand
  3045. * @param right defines the right operand
  3046. * @param result defines the Vector3 where to store the result
  3047. */
  3048. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  3049. /**
  3050. * Returns a new Vector3 as the normalization of the given vector
  3051. * @param vector defines the Vector3 to normalize
  3052. * @returns the new Vector3
  3053. */
  3054. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3055. /**
  3056. * Sets the given vector "result" with the normalization of the given first vector
  3057. * @param vector defines the Vector3 to normalize
  3058. * @param result defines the Vector3 where to store the result
  3059. */
  3060. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3061. /**
  3062. * Project a Vector3 onto screen space
  3063. * @param vector defines the Vector3 to project
  3064. * @param world defines the world matrix to use
  3065. * @param transform defines the transform (view x projection) matrix to use
  3066. * @param viewport defines the screen viewport to use
  3067. * @returns the new Vector3
  3068. */
  3069. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3070. /** @hidden */
  3071. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3072. /**
  3073. * Unproject from screen space to object space
  3074. * @param source defines the screen space Vector3 to use
  3075. * @param viewportWidth defines the current width of the viewport
  3076. * @param viewportHeight defines the current height of the viewport
  3077. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3078. * @param transform defines the transform (view x projection) matrix to use
  3079. * @returns the new Vector3
  3080. */
  3081. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3082. /**
  3083. * Unproject from screen space to object space
  3084. * @param source defines the screen space Vector3 to use
  3085. * @param viewportWidth defines the current width of the viewport
  3086. * @param viewportHeight defines the current height of the viewport
  3087. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3088. * @param view defines the view matrix to use
  3089. * @param projection defines the projection matrix to use
  3090. * @returns the new Vector3
  3091. */
  3092. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3093. /**
  3094. * Unproject from screen space to object space
  3095. * @param source defines the screen space Vector3 to use
  3096. * @param viewportWidth defines the current width of the viewport
  3097. * @param viewportHeight defines the current height of the viewport
  3098. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3099. * @param view defines the view matrix to use
  3100. * @param projection defines the projection matrix to use
  3101. * @param result defines the Vector3 where to store the result
  3102. */
  3103. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3104. /**
  3105. * Unproject from screen space to object space
  3106. * @param sourceX defines the screen space x coordinate to use
  3107. * @param sourceY defines the screen space y coordinate to use
  3108. * @param sourceZ defines the screen space z coordinate to use
  3109. * @param viewportWidth defines the current width of the viewport
  3110. * @param viewportHeight defines the current height of the viewport
  3111. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3112. * @param view defines the view matrix to use
  3113. * @param projection defines the projection matrix to use
  3114. * @param result defines the Vector3 where to store the result
  3115. */
  3116. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3117. /**
  3118. * Gets the minimal coordinate values between two Vector3
  3119. * @param left defines the first operand
  3120. * @param right defines the second operand
  3121. * @returns the new Vector3
  3122. */
  3123. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3124. /**
  3125. * Gets the maximal coordinate values between two Vector3
  3126. * @param left defines the first operand
  3127. * @param right defines the second operand
  3128. * @returns the new Vector3
  3129. */
  3130. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3131. /**
  3132. * Returns the distance between the vectors "value1" and "value2"
  3133. * @param value1 defines the first operand
  3134. * @param value2 defines the second operand
  3135. * @returns the distance
  3136. */
  3137. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3138. /**
  3139. * Returns the squared distance between the vectors "value1" and "value2"
  3140. * @param value1 defines the first operand
  3141. * @param value2 defines the second operand
  3142. * @returns the squared distance
  3143. */
  3144. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3145. /**
  3146. * Returns a new Vector3 located at the center between "value1" and "value2"
  3147. * @param value1 defines the first operand
  3148. * @param value2 defines the second operand
  3149. * @returns the new Vector3
  3150. */
  3151. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3152. /**
  3153. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3154. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3155. * to something in order to rotate it from its local system to the given target system
  3156. * Note: axis1, axis2 and axis3 are normalized during this operation
  3157. * @param axis1 defines the first axis
  3158. * @param axis2 defines the second axis
  3159. * @param axis3 defines the third axis
  3160. * @returns a new Vector3
  3161. */
  3162. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3163. /**
  3164. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3165. * @param axis1 defines the first axis
  3166. * @param axis2 defines the second axis
  3167. * @param axis3 defines the third axis
  3168. * @param ref defines the Vector3 where to store the result
  3169. */
  3170. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3171. }
  3172. /**
  3173. * Vector4 class created for EulerAngle class conversion to Quaternion
  3174. */
  3175. export class Vector4 {
  3176. /** x value of the vector */
  3177. x: number;
  3178. /** y value of the vector */
  3179. y: number;
  3180. /** z value of the vector */
  3181. z: number;
  3182. /** w value of the vector */
  3183. w: number;
  3184. /**
  3185. * Creates a Vector4 object from the given floats.
  3186. * @param x x value of the vector
  3187. * @param y y value of the vector
  3188. * @param z z value of the vector
  3189. * @param w w value of the vector
  3190. */
  3191. constructor(
  3192. /** x value of the vector */
  3193. x: number,
  3194. /** y value of the vector */
  3195. y: number,
  3196. /** z value of the vector */
  3197. z: number,
  3198. /** w value of the vector */
  3199. w: number);
  3200. /**
  3201. * Returns the string with the Vector4 coordinates.
  3202. * @returns a string containing all the vector values
  3203. */
  3204. toString(): string;
  3205. /**
  3206. * Returns the string "Vector4".
  3207. * @returns "Vector4"
  3208. */
  3209. getClassName(): string;
  3210. /**
  3211. * Returns the Vector4 hash code.
  3212. * @returns a unique hash code
  3213. */
  3214. getHashCode(): number;
  3215. /**
  3216. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3217. * @returns the resulting array
  3218. */
  3219. asArray(): number[];
  3220. /**
  3221. * Populates the given array from the given index with the Vector4 coordinates.
  3222. * @param array array to populate
  3223. * @param index index of the array to start at (default: 0)
  3224. * @returns the Vector4.
  3225. */
  3226. toArray(array: FloatArray, index?: number): Vector4;
  3227. /**
  3228. * Adds the given vector to the current Vector4.
  3229. * @param otherVector the vector to add
  3230. * @returns the updated Vector4.
  3231. */
  3232. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3233. /**
  3234. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3235. * @param otherVector the vector to add
  3236. * @returns the resulting vector
  3237. */
  3238. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3239. /**
  3240. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3241. * @param otherVector the vector to add
  3242. * @param result the vector to store the result
  3243. * @returns the current Vector4.
  3244. */
  3245. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3246. /**
  3247. * Subtract in place the given vector from the current Vector4.
  3248. * @param otherVector the vector to subtract
  3249. * @returns the updated Vector4.
  3250. */
  3251. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3252. /**
  3253. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3254. * @param otherVector the vector to add
  3255. * @returns the new vector with the result
  3256. */
  3257. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3258. /**
  3259. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3260. * @param otherVector the vector to subtract
  3261. * @param result the vector to store the result
  3262. * @returns the current Vector4.
  3263. */
  3264. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3265. /**
  3266. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3267. */
  3268. /**
  3269. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3270. * @param x value to subtract
  3271. * @param y value to subtract
  3272. * @param z value to subtract
  3273. * @param w value to subtract
  3274. * @returns new vector containing the result
  3275. */
  3276. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3277. /**
  3278. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3279. * @param x value to subtract
  3280. * @param y value to subtract
  3281. * @param z value to subtract
  3282. * @param w value to subtract
  3283. * @param result the vector to store the result in
  3284. * @returns the current Vector4.
  3285. */
  3286. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3287. /**
  3288. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3289. * @returns a new vector with the negated values
  3290. */
  3291. negate(): Vector4;
  3292. /**
  3293. * Negate this vector in place
  3294. * @returns this
  3295. */
  3296. negateInPlace(): Vector4;
  3297. /**
  3298. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3299. * @param result defines the Vector3 object where to store the result
  3300. * @returns the current Vector4
  3301. */
  3302. negateToRef(result: Vector4): Vector4;
  3303. /**
  3304. * Multiplies the current Vector4 coordinates by scale (float).
  3305. * @param scale the number to scale with
  3306. * @returns the updated Vector4.
  3307. */
  3308. scaleInPlace(scale: number): Vector4;
  3309. /**
  3310. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3311. * @param scale the number to scale with
  3312. * @returns a new vector with the result
  3313. */
  3314. scale(scale: number): Vector4;
  3315. /**
  3316. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3317. * @param scale the number to scale with
  3318. * @param result a vector to store the result in
  3319. * @returns the current Vector4.
  3320. */
  3321. scaleToRef(scale: number, result: Vector4): Vector4;
  3322. /**
  3323. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3324. * @param scale defines the scale factor
  3325. * @param result defines the Vector4 object where to store the result
  3326. * @returns the unmodified current Vector4
  3327. */
  3328. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3329. /**
  3330. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3331. * @param otherVector the vector to compare against
  3332. * @returns true if they are equal
  3333. */
  3334. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3335. /**
  3336. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3337. * @param otherVector vector to compare against
  3338. * @param epsilon (Default: very small number)
  3339. * @returns true if they are equal
  3340. */
  3341. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3342. /**
  3343. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3344. * @param x x value to compare against
  3345. * @param y y value to compare against
  3346. * @param z z value to compare against
  3347. * @param w w value to compare against
  3348. * @returns true if equal
  3349. */
  3350. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3351. /**
  3352. * Multiplies in place the current Vector4 by the given one.
  3353. * @param otherVector vector to multiple with
  3354. * @returns the updated Vector4.
  3355. */
  3356. multiplyInPlace(otherVector: Vector4): Vector4;
  3357. /**
  3358. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3359. * @param otherVector vector to multiple with
  3360. * @returns resulting new vector
  3361. */
  3362. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3363. /**
  3364. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3365. * @param otherVector vector to multiple with
  3366. * @param result vector to store the result
  3367. * @returns the current Vector4.
  3368. */
  3369. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3370. /**
  3371. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3372. * @param x x value multiply with
  3373. * @param y y value multiply with
  3374. * @param z z value multiply with
  3375. * @param w w value multiply with
  3376. * @returns resulting new vector
  3377. */
  3378. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3379. /**
  3380. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3381. * @param otherVector vector to devide with
  3382. * @returns resulting new vector
  3383. */
  3384. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3385. /**
  3386. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3387. * @param otherVector vector to devide with
  3388. * @param result vector to store the result
  3389. * @returns the current Vector4.
  3390. */
  3391. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3392. /**
  3393. * Divides the current Vector3 coordinates by the given ones.
  3394. * @param otherVector vector to devide with
  3395. * @returns the updated Vector3.
  3396. */
  3397. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3398. /**
  3399. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3400. * @param other defines the second operand
  3401. * @returns the current updated Vector4
  3402. */
  3403. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3404. /**
  3405. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3406. * @param other defines the second operand
  3407. * @returns the current updated Vector4
  3408. */
  3409. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3410. /**
  3411. * Gets a new Vector4 from current Vector4 floored values
  3412. * @returns a new Vector4
  3413. */
  3414. floor(): Vector4;
  3415. /**
  3416. * Gets a new Vector4 from current Vector3 floored values
  3417. * @returns a new Vector4
  3418. */
  3419. fract(): Vector4;
  3420. /**
  3421. * Returns the Vector4 length (float).
  3422. * @returns the length
  3423. */
  3424. length(): number;
  3425. /**
  3426. * Returns the Vector4 squared length (float).
  3427. * @returns the length squared
  3428. */
  3429. lengthSquared(): number;
  3430. /**
  3431. * Normalizes in place the Vector4.
  3432. * @returns the updated Vector4.
  3433. */
  3434. normalize(): Vector4;
  3435. /**
  3436. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3437. * @returns this converted to a new vector3
  3438. */
  3439. toVector3(): Vector3;
  3440. /**
  3441. * Returns a new Vector4 copied from the current one.
  3442. * @returns the new cloned vector
  3443. */
  3444. clone(): Vector4;
  3445. /**
  3446. * Updates the current Vector4 with the given one coordinates.
  3447. * @param source the source vector to copy from
  3448. * @returns the updated Vector4.
  3449. */
  3450. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3451. /**
  3452. * Updates the current Vector4 coordinates with the given floats.
  3453. * @param x float to copy from
  3454. * @param y float to copy from
  3455. * @param z float to copy from
  3456. * @param w float to copy from
  3457. * @returns the updated Vector4.
  3458. */
  3459. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3460. /**
  3461. * Updates the current Vector4 coordinates with the given floats.
  3462. * @param x float to set from
  3463. * @param y float to set from
  3464. * @param z float to set from
  3465. * @param w float to set from
  3466. * @returns the updated Vector4.
  3467. */
  3468. set(x: number, y: number, z: number, w: number): Vector4;
  3469. /**
  3470. * Copies the given float to the current Vector3 coordinates
  3471. * @param v defines the x, y, z and w coordinates of the operand
  3472. * @returns the current updated Vector3
  3473. */
  3474. setAll(v: number): Vector4;
  3475. /**
  3476. * Returns a new Vector4 set from the starting index of the given array.
  3477. * @param array the array to pull values from
  3478. * @param offset the offset into the array to start at
  3479. * @returns the new vector
  3480. */
  3481. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3482. /**
  3483. * Updates the given vector "result" from the starting index of the given array.
  3484. * @param array the array to pull values from
  3485. * @param offset the offset into the array to start at
  3486. * @param result the vector to store the result in
  3487. */
  3488. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3489. /**
  3490. * Updates the given vector "result" from the starting index of the given Float32Array.
  3491. * @param array the array to pull values from
  3492. * @param offset the offset into the array to start at
  3493. * @param result the vector to store the result in
  3494. */
  3495. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3496. /**
  3497. * Updates the given vector "result" coordinates from the given floats.
  3498. * @param x float to set from
  3499. * @param y float to set from
  3500. * @param z float to set from
  3501. * @param w float to set from
  3502. * @param result the vector to the floats in
  3503. */
  3504. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3505. /**
  3506. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3507. * @returns the new vector
  3508. */
  3509. static Zero(): Vector4;
  3510. /**
  3511. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3512. * @returns the new vector
  3513. */
  3514. static One(): Vector4;
  3515. /**
  3516. * Returns a new normalized Vector4 from the given one.
  3517. * @param vector the vector to normalize
  3518. * @returns the vector
  3519. */
  3520. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3521. /**
  3522. * Updates the given vector "result" from the normalization of the given one.
  3523. * @param vector the vector to normalize
  3524. * @param result the vector to store the result in
  3525. */
  3526. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3527. /**
  3528. * Returns a vector with the minimum values from the left and right vectors
  3529. * @param left left vector to minimize
  3530. * @param right right vector to minimize
  3531. * @returns a new vector with the minimum of the left and right vector values
  3532. */
  3533. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3534. /**
  3535. * Returns a vector with the maximum values from the left and right vectors
  3536. * @param left left vector to maximize
  3537. * @param right right vector to maximize
  3538. * @returns a new vector with the maximum of the left and right vector values
  3539. */
  3540. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3541. /**
  3542. * Returns the distance (float) between the vectors "value1" and "value2".
  3543. * @param value1 value to calulate the distance between
  3544. * @param value2 value to calulate the distance between
  3545. * @return the distance between the two vectors
  3546. */
  3547. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3548. /**
  3549. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3550. * @param value1 value to calulate the distance between
  3551. * @param value2 value to calulate the distance between
  3552. * @return the distance between the two vectors squared
  3553. */
  3554. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3555. /**
  3556. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3557. * @param value1 value to calulate the center between
  3558. * @param value2 value to calulate the center between
  3559. * @return the center between the two vectors
  3560. */
  3561. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3562. /**
  3563. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3564. * This methods computes transformed normalized direction vectors only.
  3565. * @param vector the vector to transform
  3566. * @param transformation the transformation matrix to apply
  3567. * @returns the new vector
  3568. */
  3569. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3570. /**
  3571. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3572. * This methods computes transformed normalized direction vectors only.
  3573. * @param vector the vector to transform
  3574. * @param transformation the transformation matrix to apply
  3575. * @param result the vector to store the result in
  3576. */
  3577. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3578. /**
  3579. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3580. * This methods computes transformed normalized direction vectors only.
  3581. * @param x value to transform
  3582. * @param y value to transform
  3583. * @param z value to transform
  3584. * @param w value to transform
  3585. * @param transformation the transformation matrix to apply
  3586. * @param result the vector to store the results in
  3587. */
  3588. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3589. /**
  3590. * Creates a new Vector4 from a Vector3
  3591. * @param source defines the source data
  3592. * @param w defines the 4th component (default is 0)
  3593. * @returns a new Vector4
  3594. */
  3595. static FromVector3(source: Vector3, w?: number): Vector4;
  3596. }
  3597. /**
  3598. * Class used to store quaternion data
  3599. * @see https://en.wikipedia.org/wiki/Quaternion
  3600. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3601. */
  3602. export class Quaternion {
  3603. /** defines the first component (0 by default) */
  3604. x: number;
  3605. /** defines the second component (0 by default) */
  3606. y: number;
  3607. /** defines the third component (0 by default) */
  3608. z: number;
  3609. /** defines the fourth component (1.0 by default) */
  3610. w: number;
  3611. /**
  3612. * Creates a new Quaternion from the given floats
  3613. * @param x defines the first component (0 by default)
  3614. * @param y defines the second component (0 by default)
  3615. * @param z defines the third component (0 by default)
  3616. * @param w defines the fourth component (1.0 by default)
  3617. */
  3618. constructor(
  3619. /** defines the first component (0 by default) */
  3620. x?: number,
  3621. /** defines the second component (0 by default) */
  3622. y?: number,
  3623. /** defines the third component (0 by default) */
  3624. z?: number,
  3625. /** defines the fourth component (1.0 by default) */
  3626. w?: number);
  3627. /**
  3628. * Gets a string representation for the current quaternion
  3629. * @returns a string with the Quaternion coordinates
  3630. */
  3631. toString(): string;
  3632. /**
  3633. * Gets the class name of the quaternion
  3634. * @returns the string "Quaternion"
  3635. */
  3636. getClassName(): string;
  3637. /**
  3638. * Gets a hash code for this quaternion
  3639. * @returns the quaternion hash code
  3640. */
  3641. getHashCode(): number;
  3642. /**
  3643. * Copy the quaternion to an array
  3644. * @returns a new array populated with 4 elements from the quaternion coordinates
  3645. */
  3646. asArray(): number[];
  3647. /**
  3648. * Check if two quaternions are equals
  3649. * @param otherQuaternion defines the second operand
  3650. * @return true if the current quaternion and the given one coordinates are strictly equals
  3651. */
  3652. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3653. /**
  3654. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3655. * @param otherQuaternion defines the other quaternion
  3656. * @param epsilon defines the minimal distance to consider equality
  3657. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3658. */
  3659. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3660. /**
  3661. * Clone the current quaternion
  3662. * @returns a new quaternion copied from the current one
  3663. */
  3664. clone(): Quaternion;
  3665. /**
  3666. * Copy a quaternion to the current one
  3667. * @param other defines the other quaternion
  3668. * @returns the updated current quaternion
  3669. */
  3670. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3671. /**
  3672. * Updates the current quaternion with the given float coordinates
  3673. * @param x defines the x coordinate
  3674. * @param y defines the y coordinate
  3675. * @param z defines the z coordinate
  3676. * @param w defines the w coordinate
  3677. * @returns the updated current quaternion
  3678. */
  3679. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3680. /**
  3681. * Updates the current quaternion from the given float coordinates
  3682. * @param x defines the x coordinate
  3683. * @param y defines the y coordinate
  3684. * @param z defines the z coordinate
  3685. * @param w defines the w coordinate
  3686. * @returns the updated current quaternion
  3687. */
  3688. set(x: number, y: number, z: number, w: number): Quaternion;
  3689. /**
  3690. * Adds two quaternions
  3691. * @param other defines the second operand
  3692. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3693. */
  3694. add(other: DeepImmutable<Quaternion>): Quaternion;
  3695. /**
  3696. * Add a quaternion to the current one
  3697. * @param other defines the quaternion to add
  3698. * @returns the current quaternion
  3699. */
  3700. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3701. /**
  3702. * Subtract two quaternions
  3703. * @param other defines the second operand
  3704. * @returns a new quaternion as the subtraction result of the given one from the current one
  3705. */
  3706. subtract(other: Quaternion): Quaternion;
  3707. /**
  3708. * Multiplies the current quaternion by a scale factor
  3709. * @param value defines the scale factor
  3710. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3711. */
  3712. scale(value: number): Quaternion;
  3713. /**
  3714. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3715. * @param scale defines the scale factor
  3716. * @param result defines the Quaternion object where to store the result
  3717. * @returns the unmodified current quaternion
  3718. */
  3719. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3720. /**
  3721. * Multiplies in place the current quaternion by a scale factor
  3722. * @param value defines the scale factor
  3723. * @returns the current modified quaternion
  3724. */
  3725. scaleInPlace(value: number): Quaternion;
  3726. /**
  3727. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3728. * @param scale defines the scale factor
  3729. * @param result defines the Quaternion object where to store the result
  3730. * @returns the unmodified current quaternion
  3731. */
  3732. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3733. /**
  3734. * Multiplies two quaternions
  3735. * @param q1 defines the second operand
  3736. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3737. */
  3738. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3739. /**
  3740. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3741. * @param q1 defines the second operand
  3742. * @param result defines the target quaternion
  3743. * @returns the current quaternion
  3744. */
  3745. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3746. /**
  3747. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3748. * @param q1 defines the second operand
  3749. * @returns the currentupdated quaternion
  3750. */
  3751. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3752. /**
  3753. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3754. * @param ref defines the target quaternion
  3755. * @returns the current quaternion
  3756. */
  3757. conjugateToRef(ref: Quaternion): Quaternion;
  3758. /**
  3759. * Conjugates in place (1-q) the current quaternion
  3760. * @returns the current updated quaternion
  3761. */
  3762. conjugateInPlace(): Quaternion;
  3763. /**
  3764. * Conjugates in place (1-q) the current quaternion
  3765. * @returns a new quaternion
  3766. */
  3767. conjugate(): Quaternion;
  3768. /**
  3769. * Gets length of current quaternion
  3770. * @returns the quaternion length (float)
  3771. */
  3772. length(): number;
  3773. /**
  3774. * Normalize in place the current quaternion
  3775. * @returns the current updated quaternion
  3776. */
  3777. normalize(): Quaternion;
  3778. /**
  3779. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3780. * @param order is a reserved parameter and is ignore for now
  3781. * @returns a new Vector3 containing the Euler angles
  3782. */
  3783. toEulerAngles(order?: string): Vector3;
  3784. /**
  3785. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3786. * @param result defines the vector which will be filled with the Euler angles
  3787. * @param order is a reserved parameter and is ignore for now
  3788. * @returns the current unchanged quaternion
  3789. */
  3790. toEulerAnglesToRef(result: Vector3): Quaternion;
  3791. /**
  3792. * Updates the given rotation matrix with the current quaternion values
  3793. * @param result defines the target matrix
  3794. * @returns the current unchanged quaternion
  3795. */
  3796. toRotationMatrix(result: Matrix): Quaternion;
  3797. /**
  3798. * Updates the current quaternion from the given rotation matrix values
  3799. * @param matrix defines the source matrix
  3800. * @returns the current updated quaternion
  3801. */
  3802. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3803. /**
  3804. * Creates a new quaternion from a rotation matrix
  3805. * @param matrix defines the source matrix
  3806. * @returns a new quaternion created from the given rotation matrix values
  3807. */
  3808. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3809. /**
  3810. * Updates the given quaternion with the given rotation matrix values
  3811. * @param matrix defines the source matrix
  3812. * @param result defines the target quaternion
  3813. */
  3814. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3815. /**
  3816. * Returns the dot product (float) between the quaternions "left" and "right"
  3817. * @param left defines the left operand
  3818. * @param right defines the right operand
  3819. * @returns the dot product
  3820. */
  3821. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3822. /**
  3823. * Checks if the two quaternions are close to each other
  3824. * @param quat0 defines the first quaternion to check
  3825. * @param quat1 defines the second quaternion to check
  3826. * @returns true if the two quaternions are close to each other
  3827. */
  3828. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3829. /**
  3830. * Creates an empty quaternion
  3831. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3832. */
  3833. static Zero(): Quaternion;
  3834. /**
  3835. * Inverse a given quaternion
  3836. * @param q defines the source quaternion
  3837. * @returns a new quaternion as the inverted current quaternion
  3838. */
  3839. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3840. /**
  3841. * Inverse a given quaternion
  3842. * @param q defines the source quaternion
  3843. * @param result the quaternion the result will be stored in
  3844. * @returns the result quaternion
  3845. */
  3846. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3847. /**
  3848. * Creates an identity quaternion
  3849. * @returns the identity quaternion
  3850. */
  3851. static Identity(): Quaternion;
  3852. /**
  3853. * Gets a boolean indicating if the given quaternion is identity
  3854. * @param quaternion defines the quaternion to check
  3855. * @returns true if the quaternion is identity
  3856. */
  3857. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3858. /**
  3859. * Creates a quaternion from a rotation around an axis
  3860. * @param axis defines the axis to use
  3861. * @param angle defines the angle to use
  3862. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3863. */
  3864. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3865. /**
  3866. * Creates a rotation around an axis and stores it into the given quaternion
  3867. * @param axis defines the axis to use
  3868. * @param angle defines the angle to use
  3869. * @param result defines the target quaternion
  3870. * @returns the target quaternion
  3871. */
  3872. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3873. /**
  3874. * Creates a new quaternion from data stored into an array
  3875. * @param array defines the data source
  3876. * @param offset defines the offset in the source array where the data starts
  3877. * @returns a new quaternion
  3878. */
  3879. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3880. /**
  3881. * Updates the given quaternion "result" from the starting index of the given array.
  3882. * @param array the array to pull values from
  3883. * @param offset the offset into the array to start at
  3884. * @param result the quaternion to store the result in
  3885. */
  3886. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3887. /**
  3888. * Create a quaternion from Euler rotation angles
  3889. * @param x Pitch
  3890. * @param y Yaw
  3891. * @param z Roll
  3892. * @returns the new Quaternion
  3893. */
  3894. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3895. /**
  3896. * Updates a quaternion from Euler rotation angles
  3897. * @param x Pitch
  3898. * @param y Yaw
  3899. * @param z Roll
  3900. * @param result the quaternion to store the result
  3901. * @returns the updated quaternion
  3902. */
  3903. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3904. /**
  3905. * Create a quaternion from Euler rotation vector
  3906. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3907. * @returns the new Quaternion
  3908. */
  3909. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3910. /**
  3911. * Updates a quaternion from Euler rotation vector
  3912. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3913. * @param result the quaternion to store the result
  3914. * @returns the updated quaternion
  3915. */
  3916. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3917. /**
  3918. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3919. * @param yaw defines the rotation around Y axis
  3920. * @param pitch defines the rotation around X axis
  3921. * @param roll defines the rotation around Z axis
  3922. * @returns the new quaternion
  3923. */
  3924. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3925. /**
  3926. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3927. * @param yaw defines the rotation around Y axis
  3928. * @param pitch defines the rotation around X axis
  3929. * @param roll defines the rotation around Z axis
  3930. * @param result defines the target quaternion
  3931. */
  3932. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3933. /**
  3934. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3935. * @param alpha defines the rotation around first axis
  3936. * @param beta defines the rotation around second axis
  3937. * @param gamma defines the rotation around third axis
  3938. * @returns the new quaternion
  3939. */
  3940. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3941. /**
  3942. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3943. * @param alpha defines the rotation around first axis
  3944. * @param beta defines the rotation around second axis
  3945. * @param gamma defines the rotation around third axis
  3946. * @param result defines the target quaternion
  3947. */
  3948. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3949. /**
  3950. * 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)
  3951. * @param axis1 defines the first axis
  3952. * @param axis2 defines the second axis
  3953. * @param axis3 defines the third axis
  3954. * @returns the new quaternion
  3955. */
  3956. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3957. /**
  3958. * 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
  3959. * @param axis1 defines the first axis
  3960. * @param axis2 defines the second axis
  3961. * @param axis3 defines the third axis
  3962. * @param ref defines the target quaternion
  3963. */
  3964. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3965. /**
  3966. * Interpolates between two quaternions
  3967. * @param left defines first quaternion
  3968. * @param right defines second quaternion
  3969. * @param amount defines the gradient to use
  3970. * @returns the new interpolated quaternion
  3971. */
  3972. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3973. /**
  3974. * Interpolates between two quaternions and stores it into a target quaternion
  3975. * @param left defines first quaternion
  3976. * @param right defines second quaternion
  3977. * @param amount defines the gradient to use
  3978. * @param result defines the target quaternion
  3979. */
  3980. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3981. /**
  3982. * Interpolate between two quaternions using Hermite interpolation
  3983. * @param value1 defines first quaternion
  3984. * @param tangent1 defines the incoming tangent
  3985. * @param value2 defines second quaternion
  3986. * @param tangent2 defines the outgoing tangent
  3987. * @param amount defines the target quaternion
  3988. * @returns the new interpolated quaternion
  3989. */
  3990. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3991. }
  3992. /**
  3993. * Class used to store matrix data (4x4)
  3994. */
  3995. export class Matrix {
  3996. private static _updateFlagSeed;
  3997. private static _identityReadOnly;
  3998. private _isIdentity;
  3999. private _isIdentityDirty;
  4000. private _isIdentity3x2;
  4001. private _isIdentity3x2Dirty;
  4002. /**
  4003. * Gets the update flag of the matrix which is an unique number for the matrix.
  4004. * It will be incremented every time the matrix data change.
  4005. * You can use it to speed the comparison between two versions of the same matrix.
  4006. */
  4007. updateFlag: number;
  4008. private readonly _m;
  4009. /**
  4010. * Gets the internal data of the matrix
  4011. */
  4012. get m(): DeepImmutable<Float32Array>;
  4013. /** @hidden */
  4014. _markAsUpdated(): void;
  4015. /** @hidden */
  4016. private _updateIdentityStatus;
  4017. /**
  4018. * Creates an empty matrix (filled with zeros)
  4019. */
  4020. constructor();
  4021. /**
  4022. * Check if the current matrix is identity
  4023. * @returns true is the matrix is the identity matrix
  4024. */
  4025. isIdentity(): boolean;
  4026. /**
  4027. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4028. * @returns true is the matrix is the identity matrix
  4029. */
  4030. isIdentityAs3x2(): boolean;
  4031. /**
  4032. * Gets the determinant of the matrix
  4033. * @returns the matrix determinant
  4034. */
  4035. determinant(): number;
  4036. /**
  4037. * Returns the matrix as a Float32Array
  4038. * @returns the matrix underlying array
  4039. */
  4040. toArray(): DeepImmutable<Float32Array>;
  4041. /**
  4042. * Returns the matrix as a Float32Array
  4043. * @returns the matrix underlying array.
  4044. */
  4045. asArray(): DeepImmutable<Float32Array>;
  4046. /**
  4047. * Inverts the current matrix in place
  4048. * @returns the current inverted matrix
  4049. */
  4050. invert(): Matrix;
  4051. /**
  4052. * Sets all the matrix elements to zero
  4053. * @returns the current matrix
  4054. */
  4055. reset(): Matrix;
  4056. /**
  4057. * Adds the current matrix with a second one
  4058. * @param other defines the matrix to add
  4059. * @returns a new matrix as the addition of the current matrix and the given one
  4060. */
  4061. add(other: DeepImmutable<Matrix>): Matrix;
  4062. /**
  4063. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4064. * @param other defines the matrix to add
  4065. * @param result defines the target matrix
  4066. * @returns the current matrix
  4067. */
  4068. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4069. /**
  4070. * Adds in place the given matrix to the current matrix
  4071. * @param other defines the second operand
  4072. * @returns the current updated matrix
  4073. */
  4074. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4075. /**
  4076. * Sets the given matrix to the current inverted Matrix
  4077. * @param other defines the target matrix
  4078. * @returns the unmodified current matrix
  4079. */
  4080. invertToRef(other: Matrix): Matrix;
  4081. /**
  4082. * add a value at the specified position in the current Matrix
  4083. * @param index the index of the value within the matrix. between 0 and 15.
  4084. * @param value the value to be added
  4085. * @returns the current updated matrix
  4086. */
  4087. addAtIndex(index: number, value: number): Matrix;
  4088. /**
  4089. * mutiply the specified position in the current Matrix by a value
  4090. * @param index the index of the value within the matrix. between 0 and 15.
  4091. * @param value the value to be added
  4092. * @returns the current updated matrix
  4093. */
  4094. multiplyAtIndex(index: number, value: number): Matrix;
  4095. /**
  4096. * Inserts the translation vector (using 3 floats) in the current matrix
  4097. * @param x defines the 1st component of the translation
  4098. * @param y defines the 2nd component of the translation
  4099. * @param z defines the 3rd component of the translation
  4100. * @returns the current updated matrix
  4101. */
  4102. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4103. /**
  4104. * Adds the translation vector (using 3 floats) in the current matrix
  4105. * @param x defines the 1st component of the translation
  4106. * @param y defines the 2nd component of the translation
  4107. * @param z defines the 3rd component of the translation
  4108. * @returns the current updated matrix
  4109. */
  4110. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4111. /**
  4112. * Inserts the translation vector in the current matrix
  4113. * @param vector3 defines the translation to insert
  4114. * @returns the current updated matrix
  4115. */
  4116. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4117. /**
  4118. * Gets the translation value of the current matrix
  4119. * @returns a new Vector3 as the extracted translation from the matrix
  4120. */
  4121. getTranslation(): Vector3;
  4122. /**
  4123. * Fill a Vector3 with the extracted translation from the matrix
  4124. * @param result defines the Vector3 where to store the translation
  4125. * @returns the current matrix
  4126. */
  4127. getTranslationToRef(result: Vector3): Matrix;
  4128. /**
  4129. * Remove rotation and scaling part from the matrix
  4130. * @returns the updated matrix
  4131. */
  4132. removeRotationAndScaling(): Matrix;
  4133. /**
  4134. * Multiply two matrices
  4135. * @param other defines the second operand
  4136. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4137. */
  4138. multiply(other: DeepImmutable<Matrix>): Matrix;
  4139. /**
  4140. * Copy the current matrix from the given one
  4141. * @param other defines the source matrix
  4142. * @returns the current updated matrix
  4143. */
  4144. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4145. /**
  4146. * Populates the given array from the starting index with the current matrix values
  4147. * @param array defines the target array
  4148. * @param offset defines the offset in the target array where to start storing values
  4149. * @returns the current matrix
  4150. */
  4151. copyToArray(array: Float32Array, offset?: number): Matrix;
  4152. /**
  4153. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4154. * @param other defines the second operand
  4155. * @param result defines the matrix where to store the multiplication
  4156. * @returns the current matrix
  4157. */
  4158. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4159. /**
  4160. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4161. * @param other defines the second operand
  4162. * @param result defines the array where to store the multiplication
  4163. * @param offset defines the offset in the target array where to start storing values
  4164. * @returns the current matrix
  4165. */
  4166. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4167. /**
  4168. * Check equality between this matrix and a second one
  4169. * @param value defines the second matrix to compare
  4170. * @returns true is the current matrix and the given one values are strictly equal
  4171. */
  4172. equals(value: DeepImmutable<Matrix>): boolean;
  4173. /**
  4174. * Clone the current matrix
  4175. * @returns a new matrix from the current matrix
  4176. */
  4177. clone(): Matrix;
  4178. /**
  4179. * Returns the name of the current matrix class
  4180. * @returns the string "Matrix"
  4181. */
  4182. getClassName(): string;
  4183. /**
  4184. * Gets the hash code of the current matrix
  4185. * @returns the hash code
  4186. */
  4187. getHashCode(): number;
  4188. /**
  4189. * Decomposes the current Matrix into a translation, rotation and scaling components
  4190. * @param scale defines the scale vector3 given as a reference to update
  4191. * @param rotation defines the rotation quaternion given as a reference to update
  4192. * @param translation defines the translation vector3 given as a reference to update
  4193. * @returns true if operation was successful
  4194. */
  4195. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4196. /**
  4197. * Gets specific row of the matrix
  4198. * @param index defines the number of the row to get
  4199. * @returns the index-th row of the current matrix as a new Vector4
  4200. */
  4201. getRow(index: number): Nullable<Vector4>;
  4202. /**
  4203. * Sets the index-th row of the current matrix to the vector4 values
  4204. * @param index defines the number of the row to set
  4205. * @param row defines the target vector4
  4206. * @returns the updated current matrix
  4207. */
  4208. setRow(index: number, row: Vector4): Matrix;
  4209. /**
  4210. * Compute the transpose of the matrix
  4211. * @returns the new transposed matrix
  4212. */
  4213. transpose(): Matrix;
  4214. /**
  4215. * Compute the transpose of the matrix and store it in a given matrix
  4216. * @param result defines the target matrix
  4217. * @returns the current matrix
  4218. */
  4219. transposeToRef(result: Matrix): Matrix;
  4220. /**
  4221. * Sets the index-th row of the current matrix with the given 4 x float values
  4222. * @param index defines the row index
  4223. * @param x defines the x component to set
  4224. * @param y defines the y component to set
  4225. * @param z defines the z component to set
  4226. * @param w defines the w component to set
  4227. * @returns the updated current matrix
  4228. */
  4229. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4230. /**
  4231. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4232. * @param scale defines the scale factor
  4233. * @returns a new matrix
  4234. */
  4235. scale(scale: number): Matrix;
  4236. /**
  4237. * Scale the current matrix values by a factor to a given result matrix
  4238. * @param scale defines the scale factor
  4239. * @param result defines the matrix to store the result
  4240. * @returns the current matrix
  4241. */
  4242. scaleToRef(scale: number, result: Matrix): Matrix;
  4243. /**
  4244. * Scale the current matrix values by a factor and add the result to a given matrix
  4245. * @param scale defines the scale factor
  4246. * @param result defines the Matrix to store the result
  4247. * @returns the current matrix
  4248. */
  4249. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4250. /**
  4251. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4252. * @param ref matrix to store the result
  4253. */
  4254. toNormalMatrix(ref: Matrix): void;
  4255. /**
  4256. * Gets only rotation part of the current matrix
  4257. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4258. */
  4259. getRotationMatrix(): Matrix;
  4260. /**
  4261. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4262. * @param result defines the target matrix to store data to
  4263. * @returns the current matrix
  4264. */
  4265. getRotationMatrixToRef(result: Matrix): Matrix;
  4266. /**
  4267. * Toggles model matrix from being right handed to left handed in place and vice versa
  4268. */
  4269. toggleModelMatrixHandInPlace(): void;
  4270. /**
  4271. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4272. */
  4273. toggleProjectionMatrixHandInPlace(): void;
  4274. /**
  4275. * Creates a matrix from an array
  4276. * @param array defines the source array
  4277. * @param offset defines an offset in the source array
  4278. * @returns a new Matrix set from the starting index of the given array
  4279. */
  4280. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4281. /**
  4282. * Copy the content of an array into a given matrix
  4283. * @param array defines the source array
  4284. * @param offset defines an offset in the source array
  4285. * @param result defines the target matrix
  4286. */
  4287. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4288. /**
  4289. * Stores an array into a matrix after having multiplied each component by a given factor
  4290. * @param array defines the source array
  4291. * @param offset defines the offset in the source array
  4292. * @param scale defines the scaling factor
  4293. * @param result defines the target matrix
  4294. */
  4295. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4296. /**
  4297. * Gets an identity matrix that must not be updated
  4298. */
  4299. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4300. /**
  4301. * Stores a list of values (16) inside a given matrix
  4302. * @param initialM11 defines 1st value of 1st row
  4303. * @param initialM12 defines 2nd value of 1st row
  4304. * @param initialM13 defines 3rd value of 1st row
  4305. * @param initialM14 defines 4th value of 1st row
  4306. * @param initialM21 defines 1st value of 2nd row
  4307. * @param initialM22 defines 2nd value of 2nd row
  4308. * @param initialM23 defines 3rd value of 2nd row
  4309. * @param initialM24 defines 4th value of 2nd row
  4310. * @param initialM31 defines 1st value of 3rd row
  4311. * @param initialM32 defines 2nd value of 3rd row
  4312. * @param initialM33 defines 3rd value of 3rd row
  4313. * @param initialM34 defines 4th value of 3rd row
  4314. * @param initialM41 defines 1st value of 4th row
  4315. * @param initialM42 defines 2nd value of 4th row
  4316. * @param initialM43 defines 3rd value of 4th row
  4317. * @param initialM44 defines 4th value of 4th row
  4318. * @param result defines the target matrix
  4319. */
  4320. 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;
  4321. /**
  4322. * Creates new matrix from a list of values (16)
  4323. * @param initialM11 defines 1st value of 1st row
  4324. * @param initialM12 defines 2nd value of 1st row
  4325. * @param initialM13 defines 3rd value of 1st row
  4326. * @param initialM14 defines 4th value of 1st row
  4327. * @param initialM21 defines 1st value of 2nd row
  4328. * @param initialM22 defines 2nd value of 2nd row
  4329. * @param initialM23 defines 3rd value of 2nd row
  4330. * @param initialM24 defines 4th value of 2nd row
  4331. * @param initialM31 defines 1st value of 3rd row
  4332. * @param initialM32 defines 2nd value of 3rd row
  4333. * @param initialM33 defines 3rd value of 3rd row
  4334. * @param initialM34 defines 4th value of 3rd row
  4335. * @param initialM41 defines 1st value of 4th row
  4336. * @param initialM42 defines 2nd value of 4th row
  4337. * @param initialM43 defines 3rd value of 4th row
  4338. * @param initialM44 defines 4th value of 4th row
  4339. * @returns the new matrix
  4340. */
  4341. 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;
  4342. /**
  4343. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4344. * @param scale defines the scale vector3
  4345. * @param rotation defines the rotation quaternion
  4346. * @param translation defines the translation vector3
  4347. * @returns a new matrix
  4348. */
  4349. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4350. /**
  4351. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4352. * @param scale defines the scale vector3
  4353. * @param rotation defines the rotation quaternion
  4354. * @param translation defines the translation vector3
  4355. * @param result defines the target matrix
  4356. */
  4357. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4358. /**
  4359. * Creates a new identity matrix
  4360. * @returns a new identity matrix
  4361. */
  4362. static Identity(): Matrix;
  4363. /**
  4364. * Creates a new identity matrix and stores the result in a given matrix
  4365. * @param result defines the target matrix
  4366. */
  4367. static IdentityToRef(result: Matrix): void;
  4368. /**
  4369. * Creates a new zero matrix
  4370. * @returns a new zero matrix
  4371. */
  4372. static Zero(): Matrix;
  4373. /**
  4374. * Creates a new rotation matrix for "angle" radians around the X axis
  4375. * @param angle defines the angle (in radians) to use
  4376. * @return the new matrix
  4377. */
  4378. static RotationX(angle: number): Matrix;
  4379. /**
  4380. * Creates a new matrix as the invert of a given matrix
  4381. * @param source defines the source matrix
  4382. * @returns the new matrix
  4383. */
  4384. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4385. /**
  4386. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4387. * @param angle defines the angle (in radians) to use
  4388. * @param result defines the target matrix
  4389. */
  4390. static RotationXToRef(angle: number, result: Matrix): void;
  4391. /**
  4392. * Creates a new rotation matrix for "angle" radians around the Y axis
  4393. * @param angle defines the angle (in radians) to use
  4394. * @return the new matrix
  4395. */
  4396. static RotationY(angle: number): Matrix;
  4397. /**
  4398. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4399. * @param angle defines the angle (in radians) to use
  4400. * @param result defines the target matrix
  4401. */
  4402. static RotationYToRef(angle: number, result: Matrix): void;
  4403. /**
  4404. * Creates a new rotation matrix for "angle" radians around the Z axis
  4405. * @param angle defines the angle (in radians) to use
  4406. * @return the new matrix
  4407. */
  4408. static RotationZ(angle: number): Matrix;
  4409. /**
  4410. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4411. * @param angle defines the angle (in radians) to use
  4412. * @param result defines the target matrix
  4413. */
  4414. static RotationZToRef(angle: number, result: Matrix): void;
  4415. /**
  4416. * Creates a new rotation matrix for "angle" radians around the given axis
  4417. * @param axis defines the axis to use
  4418. * @param angle defines the angle (in radians) to use
  4419. * @return the new matrix
  4420. */
  4421. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4422. /**
  4423. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4424. * @param axis defines the axis to use
  4425. * @param angle defines the angle (in radians) to use
  4426. * @param result defines the target matrix
  4427. */
  4428. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4429. /**
  4430. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4431. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4432. * @param from defines the vector to align
  4433. * @param to defines the vector to align to
  4434. * @param result defines the target matrix
  4435. */
  4436. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4437. /**
  4438. * Creates a rotation matrix
  4439. * @param yaw defines the yaw angle in radians (Y axis)
  4440. * @param pitch defines the pitch angle in radians (X axis)
  4441. * @param roll defines the roll angle in radians (X axis)
  4442. * @returns the new rotation matrix
  4443. */
  4444. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4445. /**
  4446. * Creates a rotation matrix and stores it in a given matrix
  4447. * @param yaw defines the yaw angle in radians (Y axis)
  4448. * @param pitch defines the pitch angle in radians (X axis)
  4449. * @param roll defines the roll angle in radians (X axis)
  4450. * @param result defines the target matrix
  4451. */
  4452. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4453. /**
  4454. * Creates a scaling matrix
  4455. * @param x defines the scale factor on X axis
  4456. * @param y defines the scale factor on Y axis
  4457. * @param z defines the scale factor on Z axis
  4458. * @returns the new matrix
  4459. */
  4460. static Scaling(x: number, y: number, z: number): Matrix;
  4461. /**
  4462. * Creates a scaling matrix and stores it in a given matrix
  4463. * @param x defines the scale factor on X axis
  4464. * @param y defines the scale factor on Y axis
  4465. * @param z defines the scale factor on Z axis
  4466. * @param result defines the target matrix
  4467. */
  4468. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4469. /**
  4470. * Creates a translation matrix
  4471. * @param x defines the translation on X axis
  4472. * @param y defines the translation on Y axis
  4473. * @param z defines the translationon Z axis
  4474. * @returns the new matrix
  4475. */
  4476. static Translation(x: number, y: number, z: number): Matrix;
  4477. /**
  4478. * Creates a translation matrix and stores it in a given matrix
  4479. * @param x defines the translation on X axis
  4480. * @param y defines the translation on Y axis
  4481. * @param z defines the translationon Z axis
  4482. * @param result defines the target matrix
  4483. */
  4484. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4485. /**
  4486. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4487. * @param startValue defines the start value
  4488. * @param endValue defines the end value
  4489. * @param gradient defines the gradient factor
  4490. * @returns the new matrix
  4491. */
  4492. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4493. /**
  4494. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4495. * @param startValue defines the start value
  4496. * @param endValue defines the end value
  4497. * @param gradient defines the gradient factor
  4498. * @param result defines the Matrix object where to store data
  4499. */
  4500. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4501. /**
  4502. * Builds a new matrix whose values are computed by:
  4503. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4504. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4505. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4506. * @param startValue defines the first matrix
  4507. * @param endValue defines the second matrix
  4508. * @param gradient defines the gradient between the two matrices
  4509. * @returns the new matrix
  4510. */
  4511. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4512. /**
  4513. * Update a matrix to values which are computed by:
  4514. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4515. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4516. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4517. * @param startValue defines the first matrix
  4518. * @param endValue defines the second matrix
  4519. * @param gradient defines the gradient between the two matrices
  4520. * @param result defines the target matrix
  4521. */
  4522. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4523. /**
  4524. * 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"
  4525. * This function works in left handed mode
  4526. * @param eye defines the final position of the entity
  4527. * @param target defines where the entity should look at
  4528. * @param up defines the up vector for the entity
  4529. * @returns the new matrix
  4530. */
  4531. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4532. /**
  4533. * 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".
  4534. * This function works in left handed mode
  4535. * @param eye defines the final position of the entity
  4536. * @param target defines where the entity should look at
  4537. * @param up defines the up vector for the entity
  4538. * @param result defines the target matrix
  4539. */
  4540. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4541. /**
  4542. * 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"
  4543. * This function works in right handed mode
  4544. * @param eye defines the final position of the entity
  4545. * @param target defines where the entity should look at
  4546. * @param up defines the up vector for the entity
  4547. * @returns the new matrix
  4548. */
  4549. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4550. /**
  4551. * 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".
  4552. * This function works in right handed mode
  4553. * @param eye defines the final position of the entity
  4554. * @param target defines where the entity should look at
  4555. * @param up defines the up vector for the entity
  4556. * @param result defines the target matrix
  4557. */
  4558. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4559. /**
  4560. * Create a left-handed orthographic projection matrix
  4561. * @param width defines the viewport width
  4562. * @param height defines the viewport height
  4563. * @param znear defines the near clip plane
  4564. * @param zfar defines the far clip plane
  4565. * @returns a new matrix as a left-handed orthographic projection matrix
  4566. */
  4567. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4568. /**
  4569. * Store a left-handed orthographic projection to a given matrix
  4570. * @param width defines the viewport width
  4571. * @param height defines the viewport height
  4572. * @param znear defines the near clip plane
  4573. * @param zfar defines the far clip plane
  4574. * @param result defines the target matrix
  4575. */
  4576. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4577. /**
  4578. * Create a left-handed orthographic projection matrix
  4579. * @param left defines the viewport left coordinate
  4580. * @param right defines the viewport right coordinate
  4581. * @param bottom defines the viewport bottom coordinate
  4582. * @param top defines the viewport top coordinate
  4583. * @param znear defines the near clip plane
  4584. * @param zfar defines the far clip plane
  4585. * @returns a new matrix as a left-handed orthographic projection matrix
  4586. */
  4587. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4588. /**
  4589. * Stores a left-handed orthographic projection into a given matrix
  4590. * @param left defines the viewport left coordinate
  4591. * @param right defines the viewport right coordinate
  4592. * @param bottom defines the viewport bottom coordinate
  4593. * @param top defines the viewport top coordinate
  4594. * @param znear defines the near clip plane
  4595. * @param zfar defines the far clip plane
  4596. * @param result defines the target matrix
  4597. */
  4598. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4599. /**
  4600. * Creates a right-handed orthographic projection matrix
  4601. * @param left defines the viewport left coordinate
  4602. * @param right defines the viewport right coordinate
  4603. * @param bottom defines the viewport bottom coordinate
  4604. * @param top defines the viewport top coordinate
  4605. * @param znear defines the near clip plane
  4606. * @param zfar defines the far clip plane
  4607. * @returns a new matrix as a right-handed orthographic projection matrix
  4608. */
  4609. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4610. /**
  4611. * Stores a right-handed orthographic projection into a given matrix
  4612. * @param left defines the viewport left coordinate
  4613. * @param right defines the viewport right coordinate
  4614. * @param bottom defines the viewport bottom coordinate
  4615. * @param top defines the viewport top coordinate
  4616. * @param znear defines the near clip plane
  4617. * @param zfar defines the far clip plane
  4618. * @param result defines the target matrix
  4619. */
  4620. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4621. /**
  4622. * Creates a left-handed perspective projection matrix
  4623. * @param width defines the viewport width
  4624. * @param height defines the viewport height
  4625. * @param znear defines the near clip plane
  4626. * @param zfar defines the far clip plane
  4627. * @returns a new matrix as a left-handed perspective projection matrix
  4628. */
  4629. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4630. /**
  4631. * Creates a left-handed perspective projection matrix
  4632. * @param fov defines the horizontal field of view
  4633. * @param aspect defines the aspect ratio
  4634. * @param znear defines the near clip plane
  4635. * @param zfar defines the far clip plane
  4636. * @returns a new matrix as a left-handed perspective projection matrix
  4637. */
  4638. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4639. /**
  4640. * Stores a left-handed perspective projection into a given matrix
  4641. * @param fov defines the horizontal field of view
  4642. * @param aspect defines the aspect ratio
  4643. * @param znear defines the near clip plane
  4644. * @param zfar defines the far clip plane
  4645. * @param result defines the target matrix
  4646. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4647. */
  4648. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4649. /**
  4650. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4651. * @param fov defines the horizontal field of view
  4652. * @param aspect defines the aspect ratio
  4653. * @param znear defines the near clip plane
  4654. * @param zfar not used as infinity is used as far clip
  4655. * @param result defines the target matrix
  4656. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4657. */
  4658. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4659. /**
  4660. * Creates a right-handed perspective projection matrix
  4661. * @param fov defines the horizontal field of view
  4662. * @param aspect defines the aspect ratio
  4663. * @param znear defines the near clip plane
  4664. * @param zfar defines the far clip plane
  4665. * @returns a new matrix as a right-handed perspective projection matrix
  4666. */
  4667. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4668. /**
  4669. * Stores a right-handed perspective projection into a given matrix
  4670. * @param fov defines the horizontal field of view
  4671. * @param aspect defines the aspect ratio
  4672. * @param znear defines the near clip plane
  4673. * @param zfar defines the far clip plane
  4674. * @param result defines the target matrix
  4675. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4676. */
  4677. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4678. /**
  4679. * Stores a right-handed perspective projection into a given matrix
  4680. * @param fov defines the horizontal field of view
  4681. * @param aspect defines the aspect ratio
  4682. * @param znear defines the near clip plane
  4683. * @param zfar not used as infinity is used as far clip
  4684. * @param result defines the target matrix
  4685. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4686. */
  4687. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4688. /**
  4689. * Stores a perspective projection for WebVR info a given matrix
  4690. * @param fov defines the field of view
  4691. * @param znear defines the near clip plane
  4692. * @param zfar defines the far clip plane
  4693. * @param result defines the target matrix
  4694. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4695. */
  4696. static PerspectiveFovWebVRToRef(fov: {
  4697. upDegrees: number;
  4698. downDegrees: number;
  4699. leftDegrees: number;
  4700. rightDegrees: number;
  4701. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4702. /**
  4703. * Computes a complete transformation matrix
  4704. * @param viewport defines the viewport to use
  4705. * @param world defines the world matrix
  4706. * @param view defines the view matrix
  4707. * @param projection defines the projection matrix
  4708. * @param zmin defines the near clip plane
  4709. * @param zmax defines the far clip plane
  4710. * @returns the transformation matrix
  4711. */
  4712. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4713. /**
  4714. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4715. * @param matrix defines the matrix to use
  4716. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4717. */
  4718. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4719. /**
  4720. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4721. * @param matrix defines the matrix to use
  4722. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4723. */
  4724. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4725. /**
  4726. * Compute the transpose of a given matrix
  4727. * @param matrix defines the matrix to transpose
  4728. * @returns the new matrix
  4729. */
  4730. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4731. /**
  4732. * Compute the transpose of a matrix and store it in a target matrix
  4733. * @param matrix defines the matrix to transpose
  4734. * @param result defines the target matrix
  4735. */
  4736. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4737. /**
  4738. * Computes a reflection matrix from a plane
  4739. * @param plane defines the reflection plane
  4740. * @returns a new matrix
  4741. */
  4742. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4743. /**
  4744. * Computes a reflection matrix from a plane
  4745. * @param plane defines the reflection plane
  4746. * @param result defines the target matrix
  4747. */
  4748. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4749. /**
  4750. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4751. * @param xaxis defines the value of the 1st axis
  4752. * @param yaxis defines the value of the 2nd axis
  4753. * @param zaxis defines the value of the 3rd axis
  4754. * @param result defines the target matrix
  4755. */
  4756. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4757. /**
  4758. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4759. * @param quat defines the quaternion to use
  4760. * @param result defines the target matrix
  4761. */
  4762. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4763. }
  4764. /**
  4765. * @hidden
  4766. */
  4767. export class TmpVectors {
  4768. static Vector2: Vector2[];
  4769. static Vector3: Vector3[];
  4770. static Vector4: Vector4[];
  4771. static Quaternion: Quaternion[];
  4772. static Matrix: Matrix[];
  4773. }
  4774. }
  4775. declare module BABYLON {
  4776. /**
  4777. * Defines potential orientation for back face culling
  4778. */
  4779. export enum Orientation {
  4780. /**
  4781. * Clockwise
  4782. */
  4783. CW = 0,
  4784. /** Counter clockwise */
  4785. CCW = 1
  4786. }
  4787. /** Class used to represent a Bezier curve */
  4788. export class BezierCurve {
  4789. /**
  4790. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4791. * @param t defines the time
  4792. * @param x1 defines the left coordinate on X axis
  4793. * @param y1 defines the left coordinate on Y axis
  4794. * @param x2 defines the right coordinate on X axis
  4795. * @param y2 defines the right coordinate on Y axis
  4796. * @returns the interpolated value
  4797. */
  4798. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4799. }
  4800. /**
  4801. * Defines angle representation
  4802. */
  4803. export class Angle {
  4804. private _radians;
  4805. /**
  4806. * Creates an Angle object of "radians" radians (float).
  4807. * @param radians the angle in radians
  4808. */
  4809. constructor(radians: number);
  4810. /**
  4811. * Get value in degrees
  4812. * @returns the Angle value in degrees (float)
  4813. */
  4814. degrees(): number;
  4815. /**
  4816. * Get value in radians
  4817. * @returns the Angle value in radians (float)
  4818. */
  4819. radians(): number;
  4820. /**
  4821. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4822. * @param a defines first vector
  4823. * @param b defines second vector
  4824. * @returns a new Angle
  4825. */
  4826. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4827. /**
  4828. * Gets a new Angle object from the given float in radians
  4829. * @param radians defines the angle value in radians
  4830. * @returns a new Angle
  4831. */
  4832. static FromRadians(radians: number): Angle;
  4833. /**
  4834. * Gets a new Angle object from the given float in degrees
  4835. * @param degrees defines the angle value in degrees
  4836. * @returns a new Angle
  4837. */
  4838. static FromDegrees(degrees: number): Angle;
  4839. }
  4840. /**
  4841. * This represents an arc in a 2d space.
  4842. */
  4843. export class Arc2 {
  4844. /** Defines the start point of the arc */
  4845. startPoint: Vector2;
  4846. /** Defines the mid point of the arc */
  4847. midPoint: Vector2;
  4848. /** Defines the end point of the arc */
  4849. endPoint: Vector2;
  4850. /**
  4851. * Defines the center point of the arc.
  4852. */
  4853. centerPoint: Vector2;
  4854. /**
  4855. * Defines the radius of the arc.
  4856. */
  4857. radius: number;
  4858. /**
  4859. * Defines the angle of the arc (from mid point to end point).
  4860. */
  4861. angle: Angle;
  4862. /**
  4863. * Defines the start angle of the arc (from start point to middle point).
  4864. */
  4865. startAngle: Angle;
  4866. /**
  4867. * Defines the orientation of the arc (clock wise/counter clock wise).
  4868. */
  4869. orientation: Orientation;
  4870. /**
  4871. * Creates an Arc object from the three given points : start, middle and end.
  4872. * @param startPoint Defines the start point of the arc
  4873. * @param midPoint Defines the midlle point of the arc
  4874. * @param endPoint Defines the end point of the arc
  4875. */
  4876. constructor(
  4877. /** Defines the start point of the arc */
  4878. startPoint: Vector2,
  4879. /** Defines the mid point of the arc */
  4880. midPoint: Vector2,
  4881. /** Defines the end point of the arc */
  4882. endPoint: Vector2);
  4883. }
  4884. /**
  4885. * Represents a 2D path made up of multiple 2D points
  4886. */
  4887. export class Path2 {
  4888. private _points;
  4889. private _length;
  4890. /**
  4891. * If the path start and end point are the same
  4892. */
  4893. closed: boolean;
  4894. /**
  4895. * Creates a Path2 object from the starting 2D coordinates x and y.
  4896. * @param x the starting points x value
  4897. * @param y the starting points y value
  4898. */
  4899. constructor(x: number, y: number);
  4900. /**
  4901. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4902. * @param x the added points x value
  4903. * @param y the added points y value
  4904. * @returns the updated Path2.
  4905. */
  4906. addLineTo(x: number, y: number): Path2;
  4907. /**
  4908. * 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.
  4909. * @param midX middle point x value
  4910. * @param midY middle point y value
  4911. * @param endX end point x value
  4912. * @param endY end point y value
  4913. * @param numberOfSegments (default: 36)
  4914. * @returns the updated Path2.
  4915. */
  4916. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4917. /**
  4918. * Closes the Path2.
  4919. * @returns the Path2.
  4920. */
  4921. close(): Path2;
  4922. /**
  4923. * Gets the sum of the distance between each sequential point in the path
  4924. * @returns the Path2 total length (float).
  4925. */
  4926. length(): number;
  4927. /**
  4928. * Gets the points which construct the path
  4929. * @returns the Path2 internal array of points.
  4930. */
  4931. getPoints(): Vector2[];
  4932. /**
  4933. * Retreives the point at the distance aways from the starting point
  4934. * @param normalizedLengthPosition the length along the path to retreive the point from
  4935. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4936. */
  4937. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4938. /**
  4939. * Creates a new path starting from an x and y position
  4940. * @param x starting x value
  4941. * @param y starting y value
  4942. * @returns a new Path2 starting at the coordinates (x, y).
  4943. */
  4944. static StartingAt(x: number, y: number): Path2;
  4945. }
  4946. /**
  4947. * Represents a 3D path made up of multiple 3D points
  4948. */
  4949. export class Path3D {
  4950. /**
  4951. * an array of Vector3, the curve axis of the Path3D
  4952. */
  4953. path: Vector3[];
  4954. private _curve;
  4955. private _distances;
  4956. private _tangents;
  4957. private _normals;
  4958. private _binormals;
  4959. private _raw;
  4960. private _alignTangentsWithPath;
  4961. private readonly _pointAtData;
  4962. /**
  4963. * new Path3D(path, normal, raw)
  4964. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4965. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4966. * @param path an array of Vector3, the curve axis of the Path3D
  4967. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4968. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4969. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4970. */
  4971. constructor(
  4972. /**
  4973. * an array of Vector3, the curve axis of the Path3D
  4974. */
  4975. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4976. /**
  4977. * Returns the Path3D array of successive Vector3 designing its curve.
  4978. * @returns the Path3D array of successive Vector3 designing its curve.
  4979. */
  4980. getCurve(): Vector3[];
  4981. /**
  4982. * Returns the Path3D array of successive Vector3 designing its curve.
  4983. * @returns the Path3D array of successive Vector3 designing its curve.
  4984. */
  4985. getPoints(): Vector3[];
  4986. /**
  4987. * @returns the computed length (float) of the path.
  4988. */
  4989. length(): number;
  4990. /**
  4991. * Returns an array populated with tangent vectors on each Path3D curve point.
  4992. * @returns an array populated with tangent vectors on each Path3D curve point.
  4993. */
  4994. getTangents(): Vector3[];
  4995. /**
  4996. * Returns an array populated with normal vectors on each Path3D curve point.
  4997. * @returns an array populated with normal vectors on each Path3D curve point.
  4998. */
  4999. getNormals(): Vector3[];
  5000. /**
  5001. * Returns an array populated with binormal vectors on each Path3D curve point.
  5002. * @returns an array populated with binormal vectors on each Path3D curve point.
  5003. */
  5004. getBinormals(): Vector3[];
  5005. /**
  5006. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5007. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5008. */
  5009. getDistances(): number[];
  5010. /**
  5011. * Returns an interpolated point along this path
  5012. * @param position the position of the point along this path, from 0.0 to 1.0
  5013. * @returns a new Vector3 as the point
  5014. */
  5015. getPointAt(position: number): Vector3;
  5016. /**
  5017. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5018. * @param position the position of the point along this path, from 0.0 to 1.0
  5019. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5020. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5021. */
  5022. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5023. /**
  5024. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5025. * @param position the position of the point along this path, from 0.0 to 1.0
  5026. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5027. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5028. */
  5029. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5030. /**
  5031. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5032. * @param position the position of the point along this path, from 0.0 to 1.0
  5033. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5034. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5035. */
  5036. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5037. /**
  5038. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5039. * @param position the position of the point along this path, from 0.0 to 1.0
  5040. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5041. */
  5042. getDistanceAt(position: number): number;
  5043. /**
  5044. * Returns the array index of the previous point of an interpolated point along this path
  5045. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5046. * @returns the array index
  5047. */
  5048. getPreviousPointIndexAt(position: number): number;
  5049. /**
  5050. * 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)
  5051. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5052. * @returns the sub position
  5053. */
  5054. getSubPositionAt(position: number): number;
  5055. /**
  5056. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5057. * @param target the vector of which to get the closest position to
  5058. * @returns the position of the closest virtual point on this path to the target vector
  5059. */
  5060. getClosestPositionTo(target: Vector3): number;
  5061. /**
  5062. * Returns a sub path (slice) of this path
  5063. * @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
  5064. * @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
  5065. * @returns a sub path (slice) of this path
  5066. */
  5067. slice(start?: number, end?: number): Path3D;
  5068. /**
  5069. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5070. * @param path path which all values are copied into the curves points
  5071. * @param firstNormal which should be projected onto the curve
  5072. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5073. * @returns the same object updated.
  5074. */
  5075. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5076. private _compute;
  5077. private _getFirstNonNullVector;
  5078. private _getLastNonNullVector;
  5079. private _normalVector;
  5080. /**
  5081. * Updates the point at data for an interpolated point along this curve
  5082. * @param position the position of the point along this curve, from 0.0 to 1.0
  5083. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5084. * @returns the (updated) point at data
  5085. */
  5086. private _updatePointAtData;
  5087. /**
  5088. * Updates the point at data from the specified parameters
  5089. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5090. * @param point the interpolated point
  5091. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5092. */
  5093. private _setPointAtData;
  5094. /**
  5095. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5096. */
  5097. private _updateInterpolationMatrix;
  5098. }
  5099. /**
  5100. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5101. * A Curve3 is designed from a series of successive Vector3.
  5102. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5103. */
  5104. export class Curve3 {
  5105. private _points;
  5106. private _length;
  5107. /**
  5108. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5109. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5110. * @param v1 (Vector3) the control point
  5111. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5112. * @param nbPoints (integer) the wanted number of points in the curve
  5113. * @returns the created Curve3
  5114. */
  5115. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5116. /**
  5117. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5118. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5119. * @param v1 (Vector3) the first control point
  5120. * @param v2 (Vector3) the second control point
  5121. * @param v3 (Vector3) the end point of the Cubic Bezier
  5122. * @param nbPoints (integer) the wanted number of points in the curve
  5123. * @returns the created Curve3
  5124. */
  5125. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5126. /**
  5127. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5128. * @param p1 (Vector3) the origin point of the Hermite Spline
  5129. * @param t1 (Vector3) the tangent vector at the origin point
  5130. * @param p2 (Vector3) the end point of the Hermite Spline
  5131. * @param t2 (Vector3) the tangent vector at the end point
  5132. * @param nbPoints (integer) the wanted number of points in the curve
  5133. * @returns the created Curve3
  5134. */
  5135. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5136. /**
  5137. * Returns a Curve3 object along a CatmullRom Spline curve :
  5138. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5139. * @param nbPoints (integer) the wanted number of points between each curve control points
  5140. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5141. * @returns the created Curve3
  5142. */
  5143. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5144. /**
  5145. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5146. * A Curve3 is designed from a series of successive Vector3.
  5147. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5148. * @param points points which make up the curve
  5149. */
  5150. constructor(points: Vector3[]);
  5151. /**
  5152. * @returns the Curve3 stored array of successive Vector3
  5153. */
  5154. getPoints(): Vector3[];
  5155. /**
  5156. * @returns the computed length (float) of the curve.
  5157. */
  5158. length(): number;
  5159. /**
  5160. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5161. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5162. * curveA and curveB keep unchanged.
  5163. * @param curve the curve to continue from this curve
  5164. * @returns the newly constructed curve
  5165. */
  5166. continue(curve: DeepImmutable<Curve3>): Curve3;
  5167. private _computeLength;
  5168. }
  5169. }
  5170. declare module BABYLON {
  5171. /**
  5172. * This represents the main contract an easing function should follow.
  5173. * Easing functions are used throughout the animation system.
  5174. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5175. */
  5176. export interface IEasingFunction {
  5177. /**
  5178. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5179. * of the easing function.
  5180. * The link below provides some of the most common examples of easing functions.
  5181. * @see https://easings.net/
  5182. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5183. * @returns the corresponding value on the curve defined by the easing function
  5184. */
  5185. ease(gradient: number): number;
  5186. }
  5187. /**
  5188. * Base class used for every default easing function.
  5189. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5190. */
  5191. export class EasingFunction implements IEasingFunction {
  5192. /**
  5193. * Interpolation follows the mathematical formula associated with the easing function.
  5194. */
  5195. static readonly EASINGMODE_EASEIN: number;
  5196. /**
  5197. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5198. */
  5199. static readonly EASINGMODE_EASEOUT: number;
  5200. /**
  5201. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5202. */
  5203. static readonly EASINGMODE_EASEINOUT: number;
  5204. private _easingMode;
  5205. /**
  5206. * Sets the easing mode of the current function.
  5207. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5208. */
  5209. setEasingMode(easingMode: number): void;
  5210. /**
  5211. * Gets the current easing mode.
  5212. * @returns the easing mode
  5213. */
  5214. getEasingMode(): number;
  5215. /**
  5216. * @hidden
  5217. */
  5218. easeInCore(gradient: number): number;
  5219. /**
  5220. * Given an input gradient between 0 and 1, this returns the corresponding value
  5221. * of the easing function.
  5222. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5223. * @returns the corresponding value on the curve defined by the easing function
  5224. */
  5225. ease(gradient: number): number;
  5226. }
  5227. /**
  5228. * Easing function with a circle shape (see link below).
  5229. * @see https://easings.net/#easeInCirc
  5230. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5231. */
  5232. export class CircleEase extends EasingFunction implements IEasingFunction {
  5233. /** @hidden */
  5234. easeInCore(gradient: number): number;
  5235. }
  5236. /**
  5237. * Easing function with a ease back shape (see link below).
  5238. * @see https://easings.net/#easeInBack
  5239. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5240. */
  5241. export class BackEase extends EasingFunction implements IEasingFunction {
  5242. /** Defines the amplitude of the function */
  5243. amplitude: number;
  5244. /**
  5245. * Instantiates a back ease easing
  5246. * @see https://easings.net/#easeInBack
  5247. * @param amplitude Defines the amplitude of the function
  5248. */
  5249. constructor(
  5250. /** Defines the amplitude of the function */
  5251. amplitude?: number);
  5252. /** @hidden */
  5253. easeInCore(gradient: number): number;
  5254. }
  5255. /**
  5256. * Easing function with a bouncing shape (see link below).
  5257. * @see https://easings.net/#easeInBounce
  5258. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5259. */
  5260. export class BounceEase extends EasingFunction implements IEasingFunction {
  5261. /** Defines the number of bounces */
  5262. bounces: number;
  5263. /** Defines the amplitude of the bounce */
  5264. bounciness: number;
  5265. /**
  5266. * Instantiates a bounce easing
  5267. * @see https://easings.net/#easeInBounce
  5268. * @param bounces Defines the number of bounces
  5269. * @param bounciness Defines the amplitude of the bounce
  5270. */
  5271. constructor(
  5272. /** Defines the number of bounces */
  5273. bounces?: number,
  5274. /** Defines the amplitude of the bounce */
  5275. bounciness?: number);
  5276. /** @hidden */
  5277. easeInCore(gradient: number): number;
  5278. }
  5279. /**
  5280. * Easing function with a power of 3 shape (see link below).
  5281. * @see https://easings.net/#easeInCubic
  5282. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5283. */
  5284. export class CubicEase extends EasingFunction implements IEasingFunction {
  5285. /** @hidden */
  5286. easeInCore(gradient: number): number;
  5287. }
  5288. /**
  5289. * Easing function with an elastic shape (see link below).
  5290. * @see https://easings.net/#easeInElastic
  5291. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5292. */
  5293. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5294. /** Defines the number of oscillations*/
  5295. oscillations: number;
  5296. /** Defines the amplitude of the oscillations*/
  5297. springiness: number;
  5298. /**
  5299. * Instantiates an elastic easing function
  5300. * @see https://easings.net/#easeInElastic
  5301. * @param oscillations Defines the number of oscillations
  5302. * @param springiness Defines the amplitude of the oscillations
  5303. */
  5304. constructor(
  5305. /** Defines the number of oscillations*/
  5306. oscillations?: number,
  5307. /** Defines the amplitude of the oscillations*/
  5308. springiness?: number);
  5309. /** @hidden */
  5310. easeInCore(gradient: number): number;
  5311. }
  5312. /**
  5313. * Easing function with an exponential shape (see link below).
  5314. * @see https://easings.net/#easeInExpo
  5315. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5316. */
  5317. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5318. /** Defines the exponent of the function */
  5319. exponent: number;
  5320. /**
  5321. * Instantiates an exponential easing function
  5322. * @see https://easings.net/#easeInExpo
  5323. * @param exponent Defines the exponent of the function
  5324. */
  5325. constructor(
  5326. /** Defines the exponent of the function */
  5327. exponent?: number);
  5328. /** @hidden */
  5329. easeInCore(gradient: number): number;
  5330. }
  5331. /**
  5332. * Easing function with a power shape (see link below).
  5333. * @see https://easings.net/#easeInQuad
  5334. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5335. */
  5336. export class PowerEase extends EasingFunction implements IEasingFunction {
  5337. /** Defines the power of the function */
  5338. power: number;
  5339. /**
  5340. * Instantiates an power base easing function
  5341. * @see https://easings.net/#easeInQuad
  5342. * @param power Defines the power of the function
  5343. */
  5344. constructor(
  5345. /** Defines the power of the function */
  5346. power?: number);
  5347. /** @hidden */
  5348. easeInCore(gradient: number): number;
  5349. }
  5350. /**
  5351. * Easing function with a power of 2 shape (see link below).
  5352. * @see https://easings.net/#easeInQuad
  5353. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5354. */
  5355. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5356. /** @hidden */
  5357. easeInCore(gradient: number): number;
  5358. }
  5359. /**
  5360. * Easing function with a power of 4 shape (see link below).
  5361. * @see https://easings.net/#easeInQuart
  5362. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5363. */
  5364. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5365. /** @hidden */
  5366. easeInCore(gradient: number): number;
  5367. }
  5368. /**
  5369. * Easing function with a power of 5 shape (see link below).
  5370. * @see https://easings.net/#easeInQuint
  5371. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5372. */
  5373. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5374. /** @hidden */
  5375. easeInCore(gradient: number): number;
  5376. }
  5377. /**
  5378. * Easing function with a sin shape (see link below).
  5379. * @see https://easings.net/#easeInSine
  5380. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5381. */
  5382. export class SineEase extends EasingFunction implements IEasingFunction {
  5383. /** @hidden */
  5384. easeInCore(gradient: number): number;
  5385. }
  5386. /**
  5387. * Easing function with a bezier shape (see link below).
  5388. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5389. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5390. */
  5391. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5392. /** Defines the x component of the start tangent in the bezier curve */
  5393. x1: number;
  5394. /** Defines the y component of the start tangent in the bezier curve */
  5395. y1: number;
  5396. /** Defines the x component of the end tangent in the bezier curve */
  5397. x2: number;
  5398. /** Defines the y component of the end tangent in the bezier curve */
  5399. y2: number;
  5400. /**
  5401. * Instantiates a bezier function
  5402. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5403. * @param x1 Defines the x component of the start tangent in the bezier curve
  5404. * @param y1 Defines the y component of the start tangent in the bezier curve
  5405. * @param x2 Defines the x component of the end tangent in the bezier curve
  5406. * @param y2 Defines the y component of the end tangent in the bezier curve
  5407. */
  5408. constructor(
  5409. /** Defines the x component of the start tangent in the bezier curve */
  5410. x1?: number,
  5411. /** Defines the y component of the start tangent in the bezier curve */
  5412. y1?: number,
  5413. /** Defines the x component of the end tangent in the bezier curve */
  5414. x2?: number,
  5415. /** Defines the y component of the end tangent in the bezier curve */
  5416. y2?: number);
  5417. /** @hidden */
  5418. easeInCore(gradient: number): number;
  5419. }
  5420. }
  5421. declare module BABYLON {
  5422. /**
  5423. * Class used to hold a RBG color
  5424. */
  5425. export class Color3 {
  5426. /**
  5427. * Defines the red component (between 0 and 1, default is 0)
  5428. */
  5429. r: number;
  5430. /**
  5431. * Defines the green component (between 0 and 1, default is 0)
  5432. */
  5433. g: number;
  5434. /**
  5435. * Defines the blue component (between 0 and 1, default is 0)
  5436. */
  5437. b: number;
  5438. /**
  5439. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5440. * @param r defines the red component (between 0 and 1, default is 0)
  5441. * @param g defines the green component (between 0 and 1, default is 0)
  5442. * @param b defines the blue component (between 0 and 1, default is 0)
  5443. */
  5444. constructor(
  5445. /**
  5446. * Defines the red component (between 0 and 1, default is 0)
  5447. */
  5448. r?: number,
  5449. /**
  5450. * Defines the green component (between 0 and 1, default is 0)
  5451. */
  5452. g?: number,
  5453. /**
  5454. * Defines the blue component (between 0 and 1, default is 0)
  5455. */
  5456. b?: number);
  5457. /**
  5458. * Creates a string with the Color3 current values
  5459. * @returns the string representation of the Color3 object
  5460. */
  5461. toString(): string;
  5462. /**
  5463. * Returns the string "Color3"
  5464. * @returns "Color3"
  5465. */
  5466. getClassName(): string;
  5467. /**
  5468. * Compute the Color3 hash code
  5469. * @returns an unique number that can be used to hash Color3 objects
  5470. */
  5471. getHashCode(): number;
  5472. /**
  5473. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5474. * @param array defines the array where to store the r,g,b components
  5475. * @param index defines an optional index in the target array to define where to start storing values
  5476. * @returns the current Color3 object
  5477. */
  5478. toArray(array: FloatArray, index?: number): Color3;
  5479. /**
  5480. * Returns a new Color4 object from the current Color3 and the given alpha
  5481. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5482. * @returns a new Color4 object
  5483. */
  5484. toColor4(alpha?: number): Color4;
  5485. /**
  5486. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5487. * @returns the new array
  5488. */
  5489. asArray(): number[];
  5490. /**
  5491. * Returns the luminance value
  5492. * @returns a float value
  5493. */
  5494. toLuminance(): number;
  5495. /**
  5496. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5497. * @param otherColor defines the second operand
  5498. * @returns the new Color3 object
  5499. */
  5500. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5501. /**
  5502. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5503. * @param otherColor defines the second operand
  5504. * @param result defines the Color3 object where to store the result
  5505. * @returns the current Color3
  5506. */
  5507. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5508. /**
  5509. * Determines equality between Color3 objects
  5510. * @param otherColor defines the second operand
  5511. * @returns true if the rgb values are equal to the given ones
  5512. */
  5513. equals(otherColor: DeepImmutable<Color3>): boolean;
  5514. /**
  5515. * Determines equality between the current Color3 object and a set of r,b,g values
  5516. * @param r defines the red component to check
  5517. * @param g defines the green component to check
  5518. * @param b defines the blue component to check
  5519. * @returns true if the rgb values are equal to the given ones
  5520. */
  5521. equalsFloats(r: number, g: number, b: number): boolean;
  5522. /**
  5523. * Multiplies in place each rgb value by scale
  5524. * @param scale defines the scaling factor
  5525. * @returns the updated Color3
  5526. */
  5527. scale(scale: number): Color3;
  5528. /**
  5529. * Multiplies the rgb values by scale and stores the result into "result"
  5530. * @param scale defines the scaling factor
  5531. * @param result defines the Color3 object where to store the result
  5532. * @returns the unmodified current Color3
  5533. */
  5534. scaleToRef(scale: number, result: Color3): Color3;
  5535. /**
  5536. * Scale the current Color3 values by a factor and add the result to a given Color3
  5537. * @param scale defines the scale factor
  5538. * @param result defines color to store the result into
  5539. * @returns the unmodified current Color3
  5540. */
  5541. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5542. /**
  5543. * Clamps the rgb values by the min and max values and stores the result into "result"
  5544. * @param min defines minimum clamping value (default is 0)
  5545. * @param max defines maximum clamping value (default is 1)
  5546. * @param result defines color to store the result into
  5547. * @returns the original Color3
  5548. */
  5549. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5550. /**
  5551. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5552. * @param otherColor defines the second operand
  5553. * @returns the new Color3
  5554. */
  5555. add(otherColor: DeepImmutable<Color3>): Color3;
  5556. /**
  5557. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5558. * @param otherColor defines the second operand
  5559. * @param result defines Color3 object to store the result into
  5560. * @returns the unmodified current Color3
  5561. */
  5562. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5563. /**
  5564. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5565. * @param otherColor defines the second operand
  5566. * @returns the new Color3
  5567. */
  5568. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5569. /**
  5570. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5571. * @param otherColor defines the second operand
  5572. * @param result defines Color3 object to store the result into
  5573. * @returns the unmodified current Color3
  5574. */
  5575. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5576. /**
  5577. * Copy the current object
  5578. * @returns a new Color3 copied the current one
  5579. */
  5580. clone(): Color3;
  5581. /**
  5582. * Copies the rgb values from the source in the current Color3
  5583. * @param source defines the source Color3 object
  5584. * @returns the updated Color3 object
  5585. */
  5586. copyFrom(source: DeepImmutable<Color3>): Color3;
  5587. /**
  5588. * Updates the Color3 rgb values from the given floats
  5589. * @param r defines the red component to read from
  5590. * @param g defines the green component to read from
  5591. * @param b defines the blue component to read from
  5592. * @returns the current Color3 object
  5593. */
  5594. copyFromFloats(r: number, g: number, b: number): Color3;
  5595. /**
  5596. * Updates the Color3 rgb values from the given floats
  5597. * @param r defines the red component to read from
  5598. * @param g defines the green component to read from
  5599. * @param b defines the blue component to read from
  5600. * @returns the current Color3 object
  5601. */
  5602. set(r: number, g: number, b: number): Color3;
  5603. /**
  5604. * Compute the Color3 hexadecimal code as a string
  5605. * @returns a string containing the hexadecimal representation of the Color3 object
  5606. */
  5607. toHexString(): string;
  5608. /**
  5609. * Computes a new Color3 converted from the current one to linear space
  5610. * @returns a new Color3 object
  5611. */
  5612. toLinearSpace(): Color3;
  5613. /**
  5614. * Converts current color in rgb space to HSV values
  5615. * @returns a new color3 representing the HSV values
  5616. */
  5617. toHSV(): Color3;
  5618. /**
  5619. * Converts current color in rgb space to HSV values
  5620. * @param result defines the Color3 where to store the HSV values
  5621. */
  5622. toHSVToRef(result: Color3): void;
  5623. /**
  5624. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5625. * @param convertedColor defines the Color3 object where to store the linear space version
  5626. * @returns the unmodified Color3
  5627. */
  5628. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5629. /**
  5630. * Computes a new Color3 converted from the current one to gamma space
  5631. * @returns a new Color3 object
  5632. */
  5633. toGammaSpace(): Color3;
  5634. /**
  5635. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5636. * @param convertedColor defines the Color3 object where to store the gamma space version
  5637. * @returns the unmodified Color3
  5638. */
  5639. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5640. private static _BlackReadOnly;
  5641. /**
  5642. * Convert Hue, saturation and value to a Color3 (RGB)
  5643. * @param hue defines the hue
  5644. * @param saturation defines the saturation
  5645. * @param value defines the value
  5646. * @param result defines the Color3 where to store the RGB values
  5647. */
  5648. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5649. /**
  5650. * Creates a new Color3 from the string containing valid hexadecimal values
  5651. * @param hex defines a string containing valid hexadecimal values
  5652. * @returns a new Color3 object
  5653. */
  5654. static FromHexString(hex: string): Color3;
  5655. /**
  5656. * Creates a new Color3 from the starting index of the given array
  5657. * @param array defines the source array
  5658. * @param offset defines an offset in the source array
  5659. * @returns a new Color3 object
  5660. */
  5661. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5662. /**
  5663. * Creates a new Color3 from integer values (< 256)
  5664. * @param r defines the red component to read from (value between 0 and 255)
  5665. * @param g defines the green component to read from (value between 0 and 255)
  5666. * @param b defines the blue component to read from (value between 0 and 255)
  5667. * @returns a new Color3 object
  5668. */
  5669. static FromInts(r: number, g: number, b: number): Color3;
  5670. /**
  5671. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5672. * @param start defines the start Color3 value
  5673. * @param end defines the end Color3 value
  5674. * @param amount defines the gradient value between start and end
  5675. * @returns a new Color3 object
  5676. */
  5677. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5678. /**
  5679. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5680. * @param left defines the start value
  5681. * @param right defines the end value
  5682. * @param amount defines the gradient factor
  5683. * @param result defines the Color3 object where to store the result
  5684. */
  5685. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5686. /**
  5687. * Returns a Color3 value containing a red color
  5688. * @returns a new Color3 object
  5689. */
  5690. static Red(): Color3;
  5691. /**
  5692. * Returns a Color3 value containing a green color
  5693. * @returns a new Color3 object
  5694. */
  5695. static Green(): Color3;
  5696. /**
  5697. * Returns a Color3 value containing a blue color
  5698. * @returns a new Color3 object
  5699. */
  5700. static Blue(): Color3;
  5701. /**
  5702. * Returns a Color3 value containing a black color
  5703. * @returns a new Color3 object
  5704. */
  5705. static Black(): Color3;
  5706. /**
  5707. * Gets a Color3 value containing a black color that must not be updated
  5708. */
  5709. static get BlackReadOnly(): DeepImmutable<Color3>;
  5710. /**
  5711. * Returns a Color3 value containing a white color
  5712. * @returns a new Color3 object
  5713. */
  5714. static White(): Color3;
  5715. /**
  5716. * Returns a Color3 value containing a purple color
  5717. * @returns a new Color3 object
  5718. */
  5719. static Purple(): Color3;
  5720. /**
  5721. * Returns a Color3 value containing a magenta color
  5722. * @returns a new Color3 object
  5723. */
  5724. static Magenta(): Color3;
  5725. /**
  5726. * Returns a Color3 value containing a yellow color
  5727. * @returns a new Color3 object
  5728. */
  5729. static Yellow(): Color3;
  5730. /**
  5731. * Returns a Color3 value containing a gray color
  5732. * @returns a new Color3 object
  5733. */
  5734. static Gray(): Color3;
  5735. /**
  5736. * Returns a Color3 value containing a teal color
  5737. * @returns a new Color3 object
  5738. */
  5739. static Teal(): Color3;
  5740. /**
  5741. * Returns a Color3 value containing a random color
  5742. * @returns a new Color3 object
  5743. */
  5744. static Random(): Color3;
  5745. }
  5746. /**
  5747. * Class used to hold a RBGA color
  5748. */
  5749. export class Color4 {
  5750. /**
  5751. * Defines the red component (between 0 and 1, default is 0)
  5752. */
  5753. r: number;
  5754. /**
  5755. * Defines the green component (between 0 and 1, default is 0)
  5756. */
  5757. g: number;
  5758. /**
  5759. * Defines the blue component (between 0 and 1, default is 0)
  5760. */
  5761. b: number;
  5762. /**
  5763. * Defines the alpha component (between 0 and 1, default is 1)
  5764. */
  5765. a: number;
  5766. /**
  5767. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5768. * @param r defines the red component (between 0 and 1, default is 0)
  5769. * @param g defines the green component (between 0 and 1, default is 0)
  5770. * @param b defines the blue component (between 0 and 1, default is 0)
  5771. * @param a defines the alpha component (between 0 and 1, default is 1)
  5772. */
  5773. constructor(
  5774. /**
  5775. * Defines the red component (between 0 and 1, default is 0)
  5776. */
  5777. r?: number,
  5778. /**
  5779. * Defines the green component (between 0 and 1, default is 0)
  5780. */
  5781. g?: number,
  5782. /**
  5783. * Defines the blue component (between 0 and 1, default is 0)
  5784. */
  5785. b?: number,
  5786. /**
  5787. * Defines the alpha component (between 0 and 1, default is 1)
  5788. */
  5789. a?: number);
  5790. /**
  5791. * Adds in place the given Color4 values to the current Color4 object
  5792. * @param right defines the second operand
  5793. * @returns the current updated Color4 object
  5794. */
  5795. addInPlace(right: DeepImmutable<Color4>): Color4;
  5796. /**
  5797. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5798. * @returns the new array
  5799. */
  5800. asArray(): number[];
  5801. /**
  5802. * Stores from the starting index in the given array the Color4 successive values
  5803. * @param array defines the array where to store the r,g,b components
  5804. * @param index defines an optional index in the target array to define where to start storing values
  5805. * @returns the current Color4 object
  5806. */
  5807. toArray(array: number[], index?: number): Color4;
  5808. /**
  5809. * Determines equality between Color4 objects
  5810. * @param otherColor defines the second operand
  5811. * @returns true if the rgba values are equal to the given ones
  5812. */
  5813. equals(otherColor: DeepImmutable<Color4>): boolean;
  5814. /**
  5815. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5816. * @param right defines the second operand
  5817. * @returns a new Color4 object
  5818. */
  5819. add(right: DeepImmutable<Color4>): Color4;
  5820. /**
  5821. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5822. * @param right defines the second operand
  5823. * @returns a new Color4 object
  5824. */
  5825. subtract(right: DeepImmutable<Color4>): Color4;
  5826. /**
  5827. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5828. * @param right defines the second operand
  5829. * @param result defines the Color4 object where to store the result
  5830. * @returns the current Color4 object
  5831. */
  5832. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5833. /**
  5834. * Creates a new Color4 with the current Color4 values multiplied by scale
  5835. * @param scale defines the scaling factor to apply
  5836. * @returns a new Color4 object
  5837. */
  5838. scale(scale: number): Color4;
  5839. /**
  5840. * Multiplies the current Color4 values by scale and stores the result in "result"
  5841. * @param scale defines the scaling factor to apply
  5842. * @param result defines the Color4 object where to store the result
  5843. * @returns the current unmodified Color4
  5844. */
  5845. scaleToRef(scale: number, result: Color4): Color4;
  5846. /**
  5847. * Scale the current Color4 values by a factor and add the result to a given Color4
  5848. * @param scale defines the scale factor
  5849. * @param result defines the Color4 object where to store the result
  5850. * @returns the unmodified current Color4
  5851. */
  5852. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5853. /**
  5854. * Clamps the rgb values by the min and max values and stores the result into "result"
  5855. * @param min defines minimum clamping value (default is 0)
  5856. * @param max defines maximum clamping value (default is 1)
  5857. * @param result defines color to store the result into.
  5858. * @returns the cuurent Color4
  5859. */
  5860. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5861. /**
  5862. * Multipy an Color4 value by another and return a new Color4 object
  5863. * @param color defines the Color4 value to multiply by
  5864. * @returns a new Color4 object
  5865. */
  5866. multiply(color: Color4): Color4;
  5867. /**
  5868. * Multipy a Color4 value by another and push the result in a reference value
  5869. * @param color defines the Color4 value to multiply by
  5870. * @param result defines the Color4 to fill the result in
  5871. * @returns the result Color4
  5872. */
  5873. multiplyToRef(color: Color4, result: Color4): Color4;
  5874. /**
  5875. * Creates a string with the Color4 current values
  5876. * @returns the string representation of the Color4 object
  5877. */
  5878. toString(): string;
  5879. /**
  5880. * Returns the string "Color4"
  5881. * @returns "Color4"
  5882. */
  5883. getClassName(): string;
  5884. /**
  5885. * Compute the Color4 hash code
  5886. * @returns an unique number that can be used to hash Color4 objects
  5887. */
  5888. getHashCode(): number;
  5889. /**
  5890. * Creates a new Color4 copied from the current one
  5891. * @returns a new Color4 object
  5892. */
  5893. clone(): Color4;
  5894. /**
  5895. * Copies the given Color4 values into the current one
  5896. * @param source defines the source Color4 object
  5897. * @returns the current updated Color4 object
  5898. */
  5899. copyFrom(source: Color4): Color4;
  5900. /**
  5901. * Copies the given float values into the current one
  5902. * @param r defines the red component to read from
  5903. * @param g defines the green component to read from
  5904. * @param b defines the blue component to read from
  5905. * @param a defines the alpha component to read from
  5906. * @returns the current updated Color4 object
  5907. */
  5908. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5909. /**
  5910. * Copies the given float values into the current one
  5911. * @param r defines the red component to read from
  5912. * @param g defines the green component to read from
  5913. * @param b defines the blue component to read from
  5914. * @param a defines the alpha component to read from
  5915. * @returns the current updated Color4 object
  5916. */
  5917. set(r: number, g: number, b: number, a: number): Color4;
  5918. /**
  5919. * Compute the Color4 hexadecimal code as a string
  5920. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  5921. * @returns a string containing the hexadecimal representation of the Color4 object
  5922. */
  5923. toHexString(returnAsColor3?: boolean): string;
  5924. /**
  5925. * Computes a new Color4 converted from the current one to linear space
  5926. * @returns a new Color4 object
  5927. */
  5928. toLinearSpace(): Color4;
  5929. /**
  5930. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5931. * @param convertedColor defines the Color4 object where to store the linear space version
  5932. * @returns the unmodified Color4
  5933. */
  5934. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5935. /**
  5936. * Computes a new Color4 converted from the current one to gamma space
  5937. * @returns a new Color4 object
  5938. */
  5939. toGammaSpace(): Color4;
  5940. /**
  5941. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5942. * @param convertedColor defines the Color4 object where to store the gamma space version
  5943. * @returns the unmodified Color4
  5944. */
  5945. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5946. /**
  5947. * Creates a new Color4 from the string containing valid hexadecimal values
  5948. * @param hex defines a string containing valid hexadecimal values
  5949. * @returns a new Color4 object
  5950. */
  5951. static FromHexString(hex: string): Color4;
  5952. /**
  5953. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5954. * @param left defines the start value
  5955. * @param right defines the end value
  5956. * @param amount defines the gradient factor
  5957. * @returns a new Color4 object
  5958. */
  5959. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5960. /**
  5961. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5962. * @param left defines the start value
  5963. * @param right defines the end value
  5964. * @param amount defines the gradient factor
  5965. * @param result defines the Color4 object where to store data
  5966. */
  5967. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5968. /**
  5969. * Creates a new Color4 from a Color3 and an alpha value
  5970. * @param color3 defines the source Color3 to read from
  5971. * @param alpha defines the alpha component (1.0 by default)
  5972. * @returns a new Color4 object
  5973. */
  5974. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5975. /**
  5976. * Creates a new Color4 from the starting index element of the given array
  5977. * @param array defines the source array to read from
  5978. * @param offset defines the offset in the source array
  5979. * @returns a new Color4 object
  5980. */
  5981. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5982. /**
  5983. * Creates a new Color3 from integer values (< 256)
  5984. * @param r defines the red component to read from (value between 0 and 255)
  5985. * @param g defines the green component to read from (value between 0 and 255)
  5986. * @param b defines the blue component to read from (value between 0 and 255)
  5987. * @param a defines the alpha component to read from (value between 0 and 255)
  5988. * @returns a new Color3 object
  5989. */
  5990. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5991. /**
  5992. * Check the content of a given array and convert it to an array containing RGBA data
  5993. * If the original array was already containing count * 4 values then it is returned directly
  5994. * @param colors defines the array to check
  5995. * @param count defines the number of RGBA data to expect
  5996. * @returns an array containing count * 4 values (RGBA)
  5997. */
  5998. static CheckColors4(colors: number[], count: number): number[];
  5999. }
  6000. /**
  6001. * @hidden
  6002. */
  6003. export class TmpColors {
  6004. static Color3: Color3[];
  6005. static Color4: Color4[];
  6006. }
  6007. }
  6008. declare module BABYLON {
  6009. /**
  6010. * Defines an interface which represents an animation key frame
  6011. */
  6012. export interface IAnimationKey {
  6013. /**
  6014. * Frame of the key frame
  6015. */
  6016. frame: number;
  6017. /**
  6018. * Value at the specifies key frame
  6019. */
  6020. value: any;
  6021. /**
  6022. * The input tangent for the cubic hermite spline
  6023. */
  6024. inTangent?: any;
  6025. /**
  6026. * The output tangent for the cubic hermite spline
  6027. */
  6028. outTangent?: any;
  6029. /**
  6030. * The animation interpolation type
  6031. */
  6032. interpolation?: AnimationKeyInterpolation;
  6033. }
  6034. /**
  6035. * Enum for the animation key frame interpolation type
  6036. */
  6037. export enum AnimationKeyInterpolation {
  6038. /**
  6039. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6040. */
  6041. STEP = 1
  6042. }
  6043. }
  6044. declare module BABYLON {
  6045. /**
  6046. * Represents the range of an animation
  6047. */
  6048. export class AnimationRange {
  6049. /**The name of the animation range**/
  6050. name: string;
  6051. /**The starting frame of the animation */
  6052. from: number;
  6053. /**The ending frame of the animation*/
  6054. to: number;
  6055. /**
  6056. * Initializes the range of an animation
  6057. * @param name The name of the animation range
  6058. * @param from The starting frame of the animation
  6059. * @param to The ending frame of the animation
  6060. */
  6061. constructor(
  6062. /**The name of the animation range**/
  6063. name: string,
  6064. /**The starting frame of the animation */
  6065. from: number,
  6066. /**The ending frame of the animation*/
  6067. to: number);
  6068. /**
  6069. * Makes a copy of the animation range
  6070. * @returns A copy of the animation range
  6071. */
  6072. clone(): AnimationRange;
  6073. }
  6074. }
  6075. declare module BABYLON {
  6076. /**
  6077. * Composed of a frame, and an action function
  6078. */
  6079. export class AnimationEvent {
  6080. /** The frame for which the event is triggered **/
  6081. frame: number;
  6082. /** The event to perform when triggered **/
  6083. action: (currentFrame: number) => void;
  6084. /** Specifies if the event should be triggered only once**/
  6085. onlyOnce?: boolean | undefined;
  6086. /**
  6087. * Specifies if the animation event is done
  6088. */
  6089. isDone: boolean;
  6090. /**
  6091. * Initializes the animation event
  6092. * @param frame The frame for which the event is triggered
  6093. * @param action The event to perform when triggered
  6094. * @param onlyOnce Specifies if the event should be triggered only once
  6095. */
  6096. constructor(
  6097. /** The frame for which the event is triggered **/
  6098. frame: number,
  6099. /** The event to perform when triggered **/
  6100. action: (currentFrame: number) => void,
  6101. /** Specifies if the event should be triggered only once**/
  6102. onlyOnce?: boolean | undefined);
  6103. /** @hidden */
  6104. _clone(): AnimationEvent;
  6105. }
  6106. }
  6107. declare module BABYLON {
  6108. /**
  6109. * Interface used to define a behavior
  6110. */
  6111. export interface Behavior<T> {
  6112. /** gets or sets behavior's name */
  6113. name: string;
  6114. /**
  6115. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6116. */
  6117. init(): void;
  6118. /**
  6119. * Called when the behavior is attached to a target
  6120. * @param target defines the target where the behavior is attached to
  6121. */
  6122. attach(target: T): void;
  6123. /**
  6124. * Called when the behavior is detached from its target
  6125. */
  6126. detach(): void;
  6127. }
  6128. /**
  6129. * Interface implemented by classes supporting behaviors
  6130. */
  6131. export interface IBehaviorAware<T> {
  6132. /**
  6133. * Attach a behavior
  6134. * @param behavior defines the behavior to attach
  6135. * @returns the current host
  6136. */
  6137. addBehavior(behavior: Behavior<T>): T;
  6138. /**
  6139. * Remove a behavior from the current object
  6140. * @param behavior defines the behavior to detach
  6141. * @returns the current host
  6142. */
  6143. removeBehavior(behavior: Behavior<T>): T;
  6144. /**
  6145. * Gets a behavior using its name to search
  6146. * @param name defines the name to search
  6147. * @returns the behavior or null if not found
  6148. */
  6149. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6150. }
  6151. }
  6152. declare module BABYLON {
  6153. /**
  6154. * Defines an array and its length.
  6155. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6156. */
  6157. export interface ISmartArrayLike<T> {
  6158. /**
  6159. * The data of the array.
  6160. */
  6161. data: Array<T>;
  6162. /**
  6163. * The active length of the array.
  6164. */
  6165. length: number;
  6166. }
  6167. /**
  6168. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6169. */
  6170. export class SmartArray<T> implements ISmartArrayLike<T> {
  6171. /**
  6172. * The full set of data from the array.
  6173. */
  6174. data: Array<T>;
  6175. /**
  6176. * The active length of the array.
  6177. */
  6178. length: number;
  6179. protected _id: number;
  6180. /**
  6181. * Instantiates a Smart Array.
  6182. * @param capacity defines the default capacity of the array.
  6183. */
  6184. constructor(capacity: number);
  6185. /**
  6186. * Pushes a value at the end of the active data.
  6187. * @param value defines the object to push in the array.
  6188. */
  6189. push(value: T): void;
  6190. /**
  6191. * Iterates over the active data and apply the lambda to them.
  6192. * @param func defines the action to apply on each value.
  6193. */
  6194. forEach(func: (content: T) => void): void;
  6195. /**
  6196. * Sorts the full sets of data.
  6197. * @param compareFn defines the comparison function to apply.
  6198. */
  6199. sort(compareFn: (a: T, b: T) => number): void;
  6200. /**
  6201. * Resets the active data to an empty array.
  6202. */
  6203. reset(): void;
  6204. /**
  6205. * Releases all the data from the array as well as the array.
  6206. */
  6207. dispose(): void;
  6208. /**
  6209. * Concats the active data with a given array.
  6210. * @param array defines the data to concatenate with.
  6211. */
  6212. concat(array: any): void;
  6213. /**
  6214. * Returns the position of a value in the active data.
  6215. * @param value defines the value to find the index for
  6216. * @returns the index if found in the active data otherwise -1
  6217. */
  6218. indexOf(value: T): number;
  6219. /**
  6220. * Returns whether an element is part of the active data.
  6221. * @param value defines the value to look for
  6222. * @returns true if found in the active data otherwise false
  6223. */
  6224. contains(value: T): boolean;
  6225. private static _GlobalId;
  6226. }
  6227. /**
  6228. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6229. * The data in this array can only be present once
  6230. */
  6231. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6232. private _duplicateId;
  6233. /**
  6234. * Pushes a value at the end of the active data.
  6235. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6236. * @param value defines the object to push in the array.
  6237. */
  6238. push(value: T): void;
  6239. /**
  6240. * Pushes a value at the end of the active data.
  6241. * If the data is already present, it won t be added again
  6242. * @param value defines the object to push in the array.
  6243. * @returns true if added false if it was already present
  6244. */
  6245. pushNoDuplicate(value: T): boolean;
  6246. /**
  6247. * Resets the active data to an empty array.
  6248. */
  6249. reset(): void;
  6250. /**
  6251. * Concats the active data with a given array.
  6252. * This ensures no dupplicate will be present in the result.
  6253. * @param array defines the data to concatenate with.
  6254. */
  6255. concatWithNoDuplicate(array: any): void;
  6256. }
  6257. }
  6258. declare module BABYLON {
  6259. /**
  6260. * @ignore
  6261. * This is a list of all the different input types that are available in the application.
  6262. * Fo instance: ArcRotateCameraGamepadInput...
  6263. */
  6264. export var CameraInputTypes: {};
  6265. /**
  6266. * This is the contract to implement in order to create a new input class.
  6267. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6268. */
  6269. export interface ICameraInput<TCamera extends Camera> {
  6270. /**
  6271. * Defines the camera the input is attached to.
  6272. */
  6273. camera: Nullable<TCamera>;
  6274. /**
  6275. * Gets the class name of the current intput.
  6276. * @returns the class name
  6277. */
  6278. getClassName(): string;
  6279. /**
  6280. * Get the friendly name associated with the input class.
  6281. * @returns the input friendly name
  6282. */
  6283. getSimpleName(): string;
  6284. /**
  6285. * Attach the input controls to a specific dom element to get the input from.
  6286. * @param element Defines the element the controls should be listened from
  6287. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6288. */
  6289. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6290. /**
  6291. * Detach the current controls from the specified dom element.
  6292. * @param element Defines the element to stop listening the inputs from
  6293. */
  6294. detachControl(element: Nullable<HTMLElement>): void;
  6295. /**
  6296. * Update the current camera state depending on the inputs that have been used this frame.
  6297. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6298. */
  6299. checkInputs?: () => void;
  6300. }
  6301. /**
  6302. * Represents a map of input types to input instance or input index to input instance.
  6303. */
  6304. export interface CameraInputsMap<TCamera extends Camera> {
  6305. /**
  6306. * Accessor to the input by input type.
  6307. */
  6308. [name: string]: ICameraInput<TCamera>;
  6309. /**
  6310. * Accessor to the input by input index.
  6311. */
  6312. [idx: number]: ICameraInput<TCamera>;
  6313. }
  6314. /**
  6315. * This represents the input manager used within a camera.
  6316. * It helps dealing with all the different kind of input attached to a camera.
  6317. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6318. */
  6319. export class CameraInputsManager<TCamera extends Camera> {
  6320. /**
  6321. * Defines the list of inputs attahed to the camera.
  6322. */
  6323. attached: CameraInputsMap<TCamera>;
  6324. /**
  6325. * Defines the dom element the camera is collecting inputs from.
  6326. * This is null if the controls have not been attached.
  6327. */
  6328. attachedElement: Nullable<HTMLElement>;
  6329. /**
  6330. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6331. */
  6332. noPreventDefault: boolean;
  6333. /**
  6334. * Defined the camera the input manager belongs to.
  6335. */
  6336. camera: TCamera;
  6337. /**
  6338. * Update the current camera state depending on the inputs that have been used this frame.
  6339. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6340. */
  6341. checkInputs: () => void;
  6342. /**
  6343. * Instantiate a new Camera Input Manager.
  6344. * @param camera Defines the camera the input manager blongs to
  6345. */
  6346. constructor(camera: TCamera);
  6347. /**
  6348. * Add an input method to a camera
  6349. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6350. * @param input camera input method
  6351. */
  6352. add(input: ICameraInput<TCamera>): void;
  6353. /**
  6354. * Remove a specific input method from a camera
  6355. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6356. * @param inputToRemove camera input method
  6357. */
  6358. remove(inputToRemove: ICameraInput<TCamera>): void;
  6359. /**
  6360. * Remove a specific input type from a camera
  6361. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6362. * @param inputType the type of the input to remove
  6363. */
  6364. removeByType(inputType: string): void;
  6365. private _addCheckInputs;
  6366. /**
  6367. * Attach the input controls to the currently attached dom element to listen the events from.
  6368. * @param input Defines the input to attach
  6369. */
  6370. attachInput(input: ICameraInput<TCamera>): void;
  6371. /**
  6372. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6373. * @param element Defines the dom element to collect the events from
  6374. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6375. */
  6376. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6377. /**
  6378. * Detach the current manager inputs controls from a specific dom element.
  6379. * @param element Defines the dom element to collect the events from
  6380. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6381. */
  6382. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6383. /**
  6384. * Rebuild the dynamic inputCheck function from the current list of
  6385. * defined inputs in the manager.
  6386. */
  6387. rebuildInputCheck(): void;
  6388. /**
  6389. * Remove all attached input methods from a camera
  6390. */
  6391. clear(): void;
  6392. /**
  6393. * Serialize the current input manager attached to a camera.
  6394. * This ensures than once parsed,
  6395. * the input associated to the camera will be identical to the current ones
  6396. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6397. */
  6398. serialize(serializedCamera: any): void;
  6399. /**
  6400. * Parses an input manager serialized JSON to restore the previous list of inputs
  6401. * and states associated to a camera.
  6402. * @param parsedCamera Defines the JSON to parse
  6403. */
  6404. parse(parsedCamera: any): void;
  6405. }
  6406. }
  6407. declare module BABYLON {
  6408. /**
  6409. * Class used to store data that will be store in GPU memory
  6410. */
  6411. export class Buffer {
  6412. private _engine;
  6413. private _buffer;
  6414. /** @hidden */
  6415. _data: Nullable<DataArray>;
  6416. private _updatable;
  6417. private _instanced;
  6418. private _divisor;
  6419. /**
  6420. * Gets the byte stride.
  6421. */
  6422. readonly byteStride: number;
  6423. /**
  6424. * Constructor
  6425. * @param engine the engine
  6426. * @param data the data to use for this buffer
  6427. * @param updatable whether the data is updatable
  6428. * @param stride the stride (optional)
  6429. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6430. * @param instanced whether the buffer is instanced (optional)
  6431. * @param useBytes set to true if the stride in in bytes (optional)
  6432. * @param divisor sets an optional divisor for instances (1 by default)
  6433. */
  6434. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6435. /**
  6436. * Create a new VertexBuffer based on the current buffer
  6437. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6438. * @param offset defines offset in the buffer (0 by default)
  6439. * @param size defines the size in floats of attributes (position is 3 for instance)
  6440. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6441. * @param instanced defines if the vertex buffer contains indexed data
  6442. * @param useBytes defines if the offset and stride are in bytes *
  6443. * @param divisor sets an optional divisor for instances (1 by default)
  6444. * @returns the new vertex buffer
  6445. */
  6446. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6447. /**
  6448. * Gets a boolean indicating if the Buffer is updatable?
  6449. * @returns true if the buffer is updatable
  6450. */
  6451. isUpdatable(): boolean;
  6452. /**
  6453. * Gets current buffer's data
  6454. * @returns a DataArray or null
  6455. */
  6456. getData(): Nullable<DataArray>;
  6457. /**
  6458. * Gets underlying native buffer
  6459. * @returns underlying native buffer
  6460. */
  6461. getBuffer(): Nullable<DataBuffer>;
  6462. /**
  6463. * Gets the stride in float32 units (i.e. byte stride / 4).
  6464. * May not be an integer if the byte stride is not divisible by 4.
  6465. * @returns the stride in float32 units
  6466. * @deprecated Please use byteStride instead.
  6467. */
  6468. getStrideSize(): number;
  6469. /**
  6470. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6471. * @param data defines the data to store
  6472. */
  6473. create(data?: Nullable<DataArray>): void;
  6474. /** @hidden */
  6475. _rebuild(): void;
  6476. /**
  6477. * Update current buffer data
  6478. * @param data defines the data to store
  6479. */
  6480. update(data: DataArray): void;
  6481. /**
  6482. * Updates the data directly.
  6483. * @param data the new data
  6484. * @param offset the new offset
  6485. * @param vertexCount the vertex count (optional)
  6486. * @param useBytes set to true if the offset is in bytes
  6487. */
  6488. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6489. /**
  6490. * Release all resources
  6491. */
  6492. dispose(): void;
  6493. }
  6494. /**
  6495. * Specialized buffer used to store vertex data
  6496. */
  6497. export class VertexBuffer {
  6498. /** @hidden */
  6499. _buffer: Buffer;
  6500. private _kind;
  6501. private _size;
  6502. private _ownsBuffer;
  6503. private _instanced;
  6504. private _instanceDivisor;
  6505. /**
  6506. * The byte type.
  6507. */
  6508. static readonly BYTE: number;
  6509. /**
  6510. * The unsigned byte type.
  6511. */
  6512. static readonly UNSIGNED_BYTE: number;
  6513. /**
  6514. * The short type.
  6515. */
  6516. static readonly SHORT: number;
  6517. /**
  6518. * The unsigned short type.
  6519. */
  6520. static readonly UNSIGNED_SHORT: number;
  6521. /**
  6522. * The integer type.
  6523. */
  6524. static readonly INT: number;
  6525. /**
  6526. * The unsigned integer type.
  6527. */
  6528. static readonly UNSIGNED_INT: number;
  6529. /**
  6530. * The float type.
  6531. */
  6532. static readonly FLOAT: number;
  6533. /**
  6534. * Gets or sets the instance divisor when in instanced mode
  6535. */
  6536. get instanceDivisor(): number;
  6537. set instanceDivisor(value: number);
  6538. /**
  6539. * Gets the byte stride.
  6540. */
  6541. readonly byteStride: number;
  6542. /**
  6543. * Gets the byte offset.
  6544. */
  6545. readonly byteOffset: number;
  6546. /**
  6547. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6548. */
  6549. readonly normalized: boolean;
  6550. /**
  6551. * Gets the data type of each component in the array.
  6552. */
  6553. readonly type: number;
  6554. /**
  6555. * Constructor
  6556. * @param engine the engine
  6557. * @param data the data to use for this vertex buffer
  6558. * @param kind the vertex buffer kind
  6559. * @param updatable whether the data is updatable
  6560. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6561. * @param stride the stride (optional)
  6562. * @param instanced whether the buffer is instanced (optional)
  6563. * @param offset the offset of the data (optional)
  6564. * @param size the number of components (optional)
  6565. * @param type the type of the component (optional)
  6566. * @param normalized whether the data contains normalized data (optional)
  6567. * @param useBytes set to true if stride and offset are in bytes (optional)
  6568. * @param divisor defines the instance divisor to use (1 by default)
  6569. */
  6570. 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);
  6571. /** @hidden */
  6572. _rebuild(): void;
  6573. /**
  6574. * Returns the kind of the VertexBuffer (string)
  6575. * @returns a string
  6576. */
  6577. getKind(): string;
  6578. /**
  6579. * Gets a boolean indicating if the VertexBuffer is updatable?
  6580. * @returns true if the buffer is updatable
  6581. */
  6582. isUpdatable(): boolean;
  6583. /**
  6584. * Gets current buffer's data
  6585. * @returns a DataArray or null
  6586. */
  6587. getData(): Nullable<DataArray>;
  6588. /**
  6589. * Gets underlying native buffer
  6590. * @returns underlying native buffer
  6591. */
  6592. getBuffer(): Nullable<DataBuffer>;
  6593. /**
  6594. * Gets the stride in float32 units (i.e. byte stride / 4).
  6595. * May not be an integer if the byte stride is not divisible by 4.
  6596. * @returns the stride in float32 units
  6597. * @deprecated Please use byteStride instead.
  6598. */
  6599. getStrideSize(): number;
  6600. /**
  6601. * Returns the offset as a multiple of the type byte length.
  6602. * @returns the offset in bytes
  6603. * @deprecated Please use byteOffset instead.
  6604. */
  6605. getOffset(): number;
  6606. /**
  6607. * Returns the number of components per vertex attribute (integer)
  6608. * @returns the size in float
  6609. */
  6610. getSize(): number;
  6611. /**
  6612. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6613. * @returns true if this buffer is instanced
  6614. */
  6615. getIsInstanced(): boolean;
  6616. /**
  6617. * Returns the instancing divisor, zero for non-instanced (integer).
  6618. * @returns a number
  6619. */
  6620. getInstanceDivisor(): number;
  6621. /**
  6622. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6623. * @param data defines the data to store
  6624. */
  6625. create(data?: DataArray): void;
  6626. /**
  6627. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6628. * This function will create a new buffer if the current one is not updatable
  6629. * @param data defines the data to store
  6630. */
  6631. update(data: DataArray): void;
  6632. /**
  6633. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6634. * Returns the directly updated WebGLBuffer.
  6635. * @param data the new data
  6636. * @param offset the new offset
  6637. * @param useBytes set to true if the offset is in bytes
  6638. */
  6639. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6640. /**
  6641. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6642. */
  6643. dispose(): void;
  6644. /**
  6645. * Enumerates each value of this vertex buffer as numbers.
  6646. * @param count the number of values to enumerate
  6647. * @param callback the callback function called for each value
  6648. */
  6649. forEach(count: number, callback: (value: number, index: number) => void): void;
  6650. /**
  6651. * Positions
  6652. */
  6653. static readonly PositionKind: string;
  6654. /**
  6655. * Normals
  6656. */
  6657. static readonly NormalKind: string;
  6658. /**
  6659. * Tangents
  6660. */
  6661. static readonly TangentKind: string;
  6662. /**
  6663. * Texture coordinates
  6664. */
  6665. static readonly UVKind: string;
  6666. /**
  6667. * Texture coordinates 2
  6668. */
  6669. static readonly UV2Kind: string;
  6670. /**
  6671. * Texture coordinates 3
  6672. */
  6673. static readonly UV3Kind: string;
  6674. /**
  6675. * Texture coordinates 4
  6676. */
  6677. static readonly UV4Kind: string;
  6678. /**
  6679. * Texture coordinates 5
  6680. */
  6681. static readonly UV5Kind: string;
  6682. /**
  6683. * Texture coordinates 6
  6684. */
  6685. static readonly UV6Kind: string;
  6686. /**
  6687. * Colors
  6688. */
  6689. static readonly ColorKind: string;
  6690. /**
  6691. * Matrix indices (for bones)
  6692. */
  6693. static readonly MatricesIndicesKind: string;
  6694. /**
  6695. * Matrix weights (for bones)
  6696. */
  6697. static readonly MatricesWeightsKind: string;
  6698. /**
  6699. * Additional matrix indices (for bones)
  6700. */
  6701. static readonly MatricesIndicesExtraKind: string;
  6702. /**
  6703. * Additional matrix weights (for bones)
  6704. */
  6705. static readonly MatricesWeightsExtraKind: string;
  6706. /**
  6707. * Deduces the stride given a kind.
  6708. * @param kind The kind string to deduce
  6709. * @returns The deduced stride
  6710. */
  6711. static DeduceStride(kind: string): number;
  6712. /**
  6713. * Gets the byte length of the given type.
  6714. * @param type the type
  6715. * @returns the number of bytes
  6716. */
  6717. static GetTypeByteLength(type: number): number;
  6718. /**
  6719. * Enumerates each value of the given parameters as numbers.
  6720. * @param data the data to enumerate
  6721. * @param byteOffset the byte offset of the data
  6722. * @param byteStride the byte stride of the data
  6723. * @param componentCount the number of components per element
  6724. * @param componentType the type of the component
  6725. * @param count the number of values to enumerate
  6726. * @param normalized whether the data is normalized
  6727. * @param callback the callback function called for each value
  6728. */
  6729. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6730. private static _GetFloatValue;
  6731. }
  6732. }
  6733. declare module BABYLON {
  6734. /**
  6735. * @hidden
  6736. */
  6737. export class IntersectionInfo {
  6738. bu: Nullable<number>;
  6739. bv: Nullable<number>;
  6740. distance: number;
  6741. faceId: number;
  6742. subMeshId: number;
  6743. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6744. }
  6745. }
  6746. declare module BABYLON {
  6747. /**
  6748. * Class used to store bounding sphere information
  6749. */
  6750. export class BoundingSphere {
  6751. /**
  6752. * Gets the center of the bounding sphere in local space
  6753. */
  6754. readonly center: Vector3;
  6755. /**
  6756. * Radius of the bounding sphere in local space
  6757. */
  6758. radius: number;
  6759. /**
  6760. * Gets the center of the bounding sphere in world space
  6761. */
  6762. readonly centerWorld: Vector3;
  6763. /**
  6764. * Radius of the bounding sphere in world space
  6765. */
  6766. radiusWorld: number;
  6767. /**
  6768. * Gets the minimum vector in local space
  6769. */
  6770. readonly minimum: Vector3;
  6771. /**
  6772. * Gets the maximum vector in local space
  6773. */
  6774. readonly maximum: Vector3;
  6775. private _worldMatrix;
  6776. private static readonly TmpVector3;
  6777. /**
  6778. * Creates a new bounding sphere
  6779. * @param min defines the minimum vector (in local space)
  6780. * @param max defines the maximum vector (in local space)
  6781. * @param worldMatrix defines the new world matrix
  6782. */
  6783. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6784. /**
  6785. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6786. * @param min defines the new minimum vector (in local space)
  6787. * @param max defines the new maximum vector (in local space)
  6788. * @param worldMatrix defines the new world matrix
  6789. */
  6790. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6791. /**
  6792. * Scale the current bounding sphere by applying a scale factor
  6793. * @param factor defines the scale factor to apply
  6794. * @returns the current bounding box
  6795. */
  6796. scale(factor: number): BoundingSphere;
  6797. /**
  6798. * Gets the world matrix of the bounding box
  6799. * @returns a matrix
  6800. */
  6801. getWorldMatrix(): DeepImmutable<Matrix>;
  6802. /** @hidden */
  6803. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6804. /**
  6805. * Tests if the bounding sphere is intersecting the frustum planes
  6806. * @param frustumPlanes defines the frustum planes to test
  6807. * @returns true if there is an intersection
  6808. */
  6809. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6810. /**
  6811. * Tests if the bounding sphere center is in between the frustum planes.
  6812. * Used for optimistic fast inclusion.
  6813. * @param frustumPlanes defines the frustum planes to test
  6814. * @returns true if the sphere center is in between the frustum planes
  6815. */
  6816. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6817. /**
  6818. * Tests if a point is inside the bounding sphere
  6819. * @param point defines the point to test
  6820. * @returns true if the point is inside the bounding sphere
  6821. */
  6822. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6823. /**
  6824. * Checks if two sphere intersct
  6825. * @param sphere0 sphere 0
  6826. * @param sphere1 sphere 1
  6827. * @returns true if the speres intersect
  6828. */
  6829. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6830. }
  6831. }
  6832. declare module BABYLON {
  6833. /**
  6834. * Class used to store bounding box information
  6835. */
  6836. export class BoundingBox implements ICullable {
  6837. /**
  6838. * Gets the 8 vectors representing the bounding box in local space
  6839. */
  6840. readonly vectors: Vector3[];
  6841. /**
  6842. * Gets the center of the bounding box in local space
  6843. */
  6844. readonly center: Vector3;
  6845. /**
  6846. * Gets the center of the bounding box in world space
  6847. */
  6848. readonly centerWorld: Vector3;
  6849. /**
  6850. * Gets the extend size in local space
  6851. */
  6852. readonly extendSize: Vector3;
  6853. /**
  6854. * Gets the extend size in world space
  6855. */
  6856. readonly extendSizeWorld: Vector3;
  6857. /**
  6858. * Gets the OBB (object bounding box) directions
  6859. */
  6860. readonly directions: Vector3[];
  6861. /**
  6862. * Gets the 8 vectors representing the bounding box in world space
  6863. */
  6864. readonly vectorsWorld: Vector3[];
  6865. /**
  6866. * Gets the minimum vector in world space
  6867. */
  6868. readonly minimumWorld: Vector3;
  6869. /**
  6870. * Gets the maximum vector in world space
  6871. */
  6872. readonly maximumWorld: Vector3;
  6873. /**
  6874. * Gets the minimum vector in local space
  6875. */
  6876. readonly minimum: Vector3;
  6877. /**
  6878. * Gets the maximum vector in local space
  6879. */
  6880. readonly maximum: Vector3;
  6881. private _worldMatrix;
  6882. private static readonly TmpVector3;
  6883. /**
  6884. * @hidden
  6885. */
  6886. _tag: number;
  6887. /**
  6888. * Creates a new bounding box
  6889. * @param min defines the minimum vector (in local space)
  6890. * @param max defines the maximum vector (in local space)
  6891. * @param worldMatrix defines the new world matrix
  6892. */
  6893. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6894. /**
  6895. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6896. * @param min defines the new minimum vector (in local space)
  6897. * @param max defines the new maximum vector (in local space)
  6898. * @param worldMatrix defines the new world matrix
  6899. */
  6900. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6901. /**
  6902. * Scale the current bounding box by applying a scale factor
  6903. * @param factor defines the scale factor to apply
  6904. * @returns the current bounding box
  6905. */
  6906. scale(factor: number): BoundingBox;
  6907. /**
  6908. * Gets the world matrix of the bounding box
  6909. * @returns a matrix
  6910. */
  6911. getWorldMatrix(): DeepImmutable<Matrix>;
  6912. /** @hidden */
  6913. _update(world: DeepImmutable<Matrix>): void;
  6914. /**
  6915. * Tests if the bounding box is intersecting the frustum planes
  6916. * @param frustumPlanes defines the frustum planes to test
  6917. * @returns true if there is an intersection
  6918. */
  6919. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6920. /**
  6921. * Tests if the bounding box is entirely inside the frustum planes
  6922. * @param frustumPlanes defines the frustum planes to test
  6923. * @returns true if there is an inclusion
  6924. */
  6925. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6926. /**
  6927. * Tests if a point is inside the bounding box
  6928. * @param point defines the point to test
  6929. * @returns true if the point is inside the bounding box
  6930. */
  6931. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6932. /**
  6933. * Tests if the bounding box intersects with a bounding sphere
  6934. * @param sphere defines the sphere to test
  6935. * @returns true if there is an intersection
  6936. */
  6937. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6938. /**
  6939. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6940. * @param min defines the min vector to use
  6941. * @param max defines the max vector to use
  6942. * @returns true if there is an intersection
  6943. */
  6944. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6945. /**
  6946. * Tests if two bounding boxes are intersections
  6947. * @param box0 defines the first box to test
  6948. * @param box1 defines the second box to test
  6949. * @returns true if there is an intersection
  6950. */
  6951. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6952. /**
  6953. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6954. * @param minPoint defines the minimum vector of the bounding box
  6955. * @param maxPoint defines the maximum vector of the bounding box
  6956. * @param sphereCenter defines the sphere center
  6957. * @param sphereRadius defines the sphere radius
  6958. * @returns true if there is an intersection
  6959. */
  6960. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6961. /**
  6962. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6963. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6964. * @param frustumPlanes defines the frustum planes to test
  6965. * @return true if there is an inclusion
  6966. */
  6967. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6968. /**
  6969. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6970. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6971. * @param frustumPlanes defines the frustum planes to test
  6972. * @return true if there is an intersection
  6973. */
  6974. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6975. }
  6976. }
  6977. declare module BABYLON {
  6978. /** @hidden */
  6979. export class Collider {
  6980. /** Define if a collision was found */
  6981. collisionFound: boolean;
  6982. /**
  6983. * Define last intersection point in local space
  6984. */
  6985. intersectionPoint: Vector3;
  6986. /**
  6987. * Define last collided mesh
  6988. */
  6989. collidedMesh: Nullable<AbstractMesh>;
  6990. private _collisionPoint;
  6991. private _planeIntersectionPoint;
  6992. private _tempVector;
  6993. private _tempVector2;
  6994. private _tempVector3;
  6995. private _tempVector4;
  6996. private _edge;
  6997. private _baseToVertex;
  6998. private _destinationPoint;
  6999. private _slidePlaneNormal;
  7000. private _displacementVector;
  7001. /** @hidden */
  7002. _radius: Vector3;
  7003. /** @hidden */
  7004. _retry: number;
  7005. private _velocity;
  7006. private _basePoint;
  7007. private _epsilon;
  7008. /** @hidden */
  7009. _velocityWorldLength: number;
  7010. /** @hidden */
  7011. _basePointWorld: Vector3;
  7012. private _velocityWorld;
  7013. private _normalizedVelocity;
  7014. /** @hidden */
  7015. _initialVelocity: Vector3;
  7016. /** @hidden */
  7017. _initialPosition: Vector3;
  7018. private _nearestDistance;
  7019. private _collisionMask;
  7020. get collisionMask(): number;
  7021. set collisionMask(mask: number);
  7022. /**
  7023. * Gets the plane normal used to compute the sliding response (in local space)
  7024. */
  7025. get slidePlaneNormal(): Vector3;
  7026. /** @hidden */
  7027. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7028. /** @hidden */
  7029. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7030. /** @hidden */
  7031. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7032. /** @hidden */
  7033. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7034. /** @hidden */
  7035. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7036. /** @hidden */
  7037. _getResponse(pos: Vector3, vel: Vector3): void;
  7038. }
  7039. }
  7040. declare module BABYLON {
  7041. /**
  7042. * Interface for cullable objects
  7043. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7044. */
  7045. export interface ICullable {
  7046. /**
  7047. * Checks if the object or part of the object is in the frustum
  7048. * @param frustumPlanes Camera near/planes
  7049. * @returns true if the object is in frustum otherwise false
  7050. */
  7051. isInFrustum(frustumPlanes: Plane[]): boolean;
  7052. /**
  7053. * Checks if a cullable object (mesh...) is in the camera frustum
  7054. * Unlike isInFrustum this cheks the full bounding box
  7055. * @param frustumPlanes Camera near/planes
  7056. * @returns true if the object is in frustum otherwise false
  7057. */
  7058. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7059. }
  7060. /**
  7061. * Info for a bounding data of a mesh
  7062. */
  7063. export class BoundingInfo implements ICullable {
  7064. /**
  7065. * Bounding box for the mesh
  7066. */
  7067. readonly boundingBox: BoundingBox;
  7068. /**
  7069. * Bounding sphere for the mesh
  7070. */
  7071. readonly boundingSphere: BoundingSphere;
  7072. private _isLocked;
  7073. private static readonly TmpVector3;
  7074. /**
  7075. * Constructs bounding info
  7076. * @param minimum min vector of the bounding box/sphere
  7077. * @param maximum max vector of the bounding box/sphere
  7078. * @param worldMatrix defines the new world matrix
  7079. */
  7080. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7081. /**
  7082. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7083. * @param min defines the new minimum vector (in local space)
  7084. * @param max defines the new maximum vector (in local space)
  7085. * @param worldMatrix defines the new world matrix
  7086. */
  7087. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7088. /**
  7089. * min vector of the bounding box/sphere
  7090. */
  7091. get minimum(): Vector3;
  7092. /**
  7093. * max vector of the bounding box/sphere
  7094. */
  7095. get maximum(): Vector3;
  7096. /**
  7097. * If the info is locked and won't be updated to avoid perf overhead
  7098. */
  7099. get isLocked(): boolean;
  7100. set isLocked(value: boolean);
  7101. /**
  7102. * Updates the bounding sphere and box
  7103. * @param world world matrix to be used to update
  7104. */
  7105. update(world: DeepImmutable<Matrix>): void;
  7106. /**
  7107. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7108. * @param center New center of the bounding info
  7109. * @param extend New extend of the bounding info
  7110. * @returns the current bounding info
  7111. */
  7112. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7113. /**
  7114. * Scale the current bounding info by applying a scale factor
  7115. * @param factor defines the scale factor to apply
  7116. * @returns the current bounding info
  7117. */
  7118. scale(factor: number): BoundingInfo;
  7119. /**
  7120. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7121. * @param frustumPlanes defines the frustum to test
  7122. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7123. * @returns true if the bounding info is in the frustum planes
  7124. */
  7125. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7126. /**
  7127. * Gets the world distance between the min and max points of the bounding box
  7128. */
  7129. get diagonalLength(): number;
  7130. /**
  7131. * Checks if a cullable object (mesh...) is in the camera frustum
  7132. * Unlike isInFrustum this cheks the full bounding box
  7133. * @param frustumPlanes Camera near/planes
  7134. * @returns true if the object is in frustum otherwise false
  7135. */
  7136. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7137. /** @hidden */
  7138. _checkCollision(collider: Collider): boolean;
  7139. /**
  7140. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7141. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7142. * @param point the point to check intersection with
  7143. * @returns if the point intersects
  7144. */
  7145. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7146. /**
  7147. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7148. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7149. * @param boundingInfo the bounding info to check intersection with
  7150. * @param precise if the intersection should be done using OBB
  7151. * @returns if the bounding info intersects
  7152. */
  7153. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7154. }
  7155. }
  7156. declare module BABYLON {
  7157. /**
  7158. * Extracts minimum and maximum values from a list of indexed positions
  7159. * @param positions defines the positions to use
  7160. * @param indices defines the indices to the positions
  7161. * @param indexStart defines the start index
  7162. * @param indexCount defines the end index
  7163. * @param bias defines bias value to add to the result
  7164. * @return minimum and maximum values
  7165. */
  7166. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7167. minimum: Vector3;
  7168. maximum: Vector3;
  7169. };
  7170. /**
  7171. * Extracts minimum and maximum values from a list of positions
  7172. * @param positions defines the positions to use
  7173. * @param start defines the start index in the positions array
  7174. * @param count defines the number of positions to handle
  7175. * @param bias defines bias value to add to the result
  7176. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7177. * @return minimum and maximum values
  7178. */
  7179. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7180. minimum: Vector3;
  7181. maximum: Vector3;
  7182. };
  7183. }
  7184. declare module BABYLON {
  7185. /** @hidden */
  7186. export class WebGLDataBuffer extends DataBuffer {
  7187. private _buffer;
  7188. constructor(resource: WebGLBuffer);
  7189. get underlyingResource(): any;
  7190. }
  7191. }
  7192. declare module BABYLON {
  7193. /** @hidden */
  7194. export class WebGLPipelineContext implements IPipelineContext {
  7195. engine: ThinEngine;
  7196. program: Nullable<WebGLProgram>;
  7197. context?: WebGLRenderingContext;
  7198. vertexShader?: WebGLShader;
  7199. fragmentShader?: WebGLShader;
  7200. isParallelCompiled: boolean;
  7201. onCompiled?: () => void;
  7202. transformFeedback?: WebGLTransformFeedback | null;
  7203. vertexCompilationError: Nullable<string>;
  7204. fragmentCompilationError: Nullable<string>;
  7205. programLinkError: Nullable<string>;
  7206. programValidationError: Nullable<string>;
  7207. get isAsync(): boolean;
  7208. get isReady(): boolean;
  7209. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7210. _getVertexShaderCode(): string | null;
  7211. _getFragmentShaderCode(): string | null;
  7212. }
  7213. }
  7214. declare module BABYLON {
  7215. interface ThinEngine {
  7216. /**
  7217. * Create an uniform buffer
  7218. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7219. * @param elements defines the content of the uniform buffer
  7220. * @returns the webGL uniform buffer
  7221. */
  7222. createUniformBuffer(elements: FloatArray): DataBuffer;
  7223. /**
  7224. * Create a dynamic uniform buffer
  7225. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7226. * @param elements defines the content of the uniform buffer
  7227. * @returns the webGL uniform buffer
  7228. */
  7229. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7230. /**
  7231. * Update an existing uniform buffer
  7232. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7233. * @param uniformBuffer defines the target uniform buffer
  7234. * @param elements defines the content to update
  7235. * @param offset defines the offset in the uniform buffer where update should start
  7236. * @param count defines the size of the data to update
  7237. */
  7238. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7239. /**
  7240. * Bind an uniform buffer to the current webGL context
  7241. * @param buffer defines the buffer to bind
  7242. */
  7243. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7244. /**
  7245. * Bind a buffer to the current webGL context at a given location
  7246. * @param buffer defines the buffer to bind
  7247. * @param location defines the index where to bind the buffer
  7248. */
  7249. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7250. /**
  7251. * Bind a specific block at a given index in a specific shader program
  7252. * @param pipelineContext defines the pipeline context to use
  7253. * @param blockName defines the block name
  7254. * @param index defines the index where to bind the block
  7255. */
  7256. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7257. }
  7258. }
  7259. declare module BABYLON {
  7260. /**
  7261. * Uniform buffer objects.
  7262. *
  7263. * Handles blocks of uniform on the GPU.
  7264. *
  7265. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7266. *
  7267. * For more information, please refer to :
  7268. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7269. */
  7270. export class UniformBuffer {
  7271. private _engine;
  7272. private _buffer;
  7273. private _data;
  7274. private _bufferData;
  7275. private _dynamic?;
  7276. private _uniformLocations;
  7277. private _uniformSizes;
  7278. private _uniformLocationPointer;
  7279. private _needSync;
  7280. private _noUBO;
  7281. private _currentEffect;
  7282. /** @hidden */
  7283. _alreadyBound: boolean;
  7284. private static _MAX_UNIFORM_SIZE;
  7285. private static _tempBuffer;
  7286. /**
  7287. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7288. * This is dynamic to allow compat with webgl 1 and 2.
  7289. * You will need to pass the name of the uniform as well as the value.
  7290. */
  7291. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7292. /**
  7293. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7294. * This is dynamic to allow compat with webgl 1 and 2.
  7295. * You will need to pass the name of the uniform as well as the value.
  7296. */
  7297. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7298. /**
  7299. * Lambda to Update a single float in a uniform buffer.
  7300. * This is dynamic to allow compat with webgl 1 and 2.
  7301. * You will need to pass the name of the uniform as well as the value.
  7302. */
  7303. updateFloat: (name: string, x: number) => void;
  7304. /**
  7305. * Lambda to Update a vec2 of float in a uniform buffer.
  7306. * This is dynamic to allow compat with webgl 1 and 2.
  7307. * You will need to pass the name of the uniform as well as the value.
  7308. */
  7309. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7310. /**
  7311. * Lambda to Update a vec3 of float in a uniform buffer.
  7312. * This is dynamic to allow compat with webgl 1 and 2.
  7313. * You will need to pass the name of the uniform as well as the value.
  7314. */
  7315. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7316. /**
  7317. * Lambda to Update a vec4 of float in a uniform buffer.
  7318. * This is dynamic to allow compat with webgl 1 and 2.
  7319. * You will need to pass the name of the uniform as well as the value.
  7320. */
  7321. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7322. /**
  7323. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7324. * This is dynamic to allow compat with webgl 1 and 2.
  7325. * You will need to pass the name of the uniform as well as the value.
  7326. */
  7327. updateMatrix: (name: string, mat: Matrix) => void;
  7328. /**
  7329. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7330. * This is dynamic to allow compat with webgl 1 and 2.
  7331. * You will need to pass the name of the uniform as well as the value.
  7332. */
  7333. updateVector3: (name: string, vector: Vector3) => void;
  7334. /**
  7335. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7336. * This is dynamic to allow compat with webgl 1 and 2.
  7337. * You will need to pass the name of the uniform as well as the value.
  7338. */
  7339. updateVector4: (name: string, vector: Vector4) => void;
  7340. /**
  7341. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7342. * This is dynamic to allow compat with webgl 1 and 2.
  7343. * You will need to pass the name of the uniform as well as the value.
  7344. */
  7345. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7346. /**
  7347. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7348. * This is dynamic to allow compat with webgl 1 and 2.
  7349. * You will need to pass the name of the uniform as well as the value.
  7350. */
  7351. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7352. /**
  7353. * Instantiates a new Uniform buffer objects.
  7354. *
  7355. * Handles blocks of uniform on the GPU.
  7356. *
  7357. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7358. *
  7359. * For more information, please refer to :
  7360. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7361. * @param engine Define the engine the buffer is associated with
  7362. * @param data Define the data contained in the buffer
  7363. * @param dynamic Define if the buffer is updatable
  7364. */
  7365. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7366. /**
  7367. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7368. * or just falling back on setUniformXXX calls.
  7369. */
  7370. get useUbo(): boolean;
  7371. /**
  7372. * Indicates if the WebGL underlying uniform buffer is in sync
  7373. * with the javascript cache data.
  7374. */
  7375. get isSync(): boolean;
  7376. /**
  7377. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7378. * Also, a dynamic UniformBuffer will disable cache verification and always
  7379. * update the underlying WebGL uniform buffer to the GPU.
  7380. * @returns if Dynamic, otherwise false
  7381. */
  7382. isDynamic(): boolean;
  7383. /**
  7384. * The data cache on JS side.
  7385. * @returns the underlying data as a float array
  7386. */
  7387. getData(): Float32Array;
  7388. /**
  7389. * The underlying WebGL Uniform buffer.
  7390. * @returns the webgl buffer
  7391. */
  7392. getBuffer(): Nullable<DataBuffer>;
  7393. /**
  7394. * std140 layout specifies how to align data within an UBO structure.
  7395. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7396. * for specs.
  7397. */
  7398. private _fillAlignment;
  7399. /**
  7400. * Adds an uniform in the buffer.
  7401. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7402. * for the layout to be correct !
  7403. * @param name Name of the uniform, as used in the uniform block in the shader.
  7404. * @param size Data size, or data directly.
  7405. */
  7406. addUniform(name: string, size: number | number[]): void;
  7407. /**
  7408. * Adds a Matrix 4x4 to the uniform buffer.
  7409. * @param name Name of the uniform, as used in the uniform block in the shader.
  7410. * @param mat A 4x4 matrix.
  7411. */
  7412. addMatrix(name: string, mat: Matrix): void;
  7413. /**
  7414. * Adds a vec2 to the uniform buffer.
  7415. * @param name Name of the uniform, as used in the uniform block in the shader.
  7416. * @param x Define the x component value of the vec2
  7417. * @param y Define the y component value of the vec2
  7418. */
  7419. addFloat2(name: string, x: number, y: number): void;
  7420. /**
  7421. * Adds a vec3 to the uniform buffer.
  7422. * @param name Name of the uniform, as used in the uniform block in the shader.
  7423. * @param x Define the x component value of the vec3
  7424. * @param y Define the y component value of the vec3
  7425. * @param z Define the z component value of the vec3
  7426. */
  7427. addFloat3(name: string, x: number, y: number, z: number): void;
  7428. /**
  7429. * Adds a vec3 to the uniform buffer.
  7430. * @param name Name of the uniform, as used in the uniform block in the shader.
  7431. * @param color Define the vec3 from a Color
  7432. */
  7433. addColor3(name: string, color: Color3): void;
  7434. /**
  7435. * Adds a vec4 to the uniform buffer.
  7436. * @param name Name of the uniform, as used in the uniform block in the shader.
  7437. * @param color Define the rgb components from a Color
  7438. * @param alpha Define the a component of the vec4
  7439. */
  7440. addColor4(name: string, color: Color3, alpha: number): void;
  7441. /**
  7442. * Adds a vec3 to the uniform buffer.
  7443. * @param name Name of the uniform, as used in the uniform block in the shader.
  7444. * @param vector Define the vec3 components from a Vector
  7445. */
  7446. addVector3(name: string, vector: Vector3): void;
  7447. /**
  7448. * Adds a Matrix 3x3 to the uniform buffer.
  7449. * @param name Name of the uniform, as used in the uniform block in the shader.
  7450. */
  7451. addMatrix3x3(name: string): void;
  7452. /**
  7453. * Adds a Matrix 2x2 to the uniform buffer.
  7454. * @param name Name of the uniform, as used in the uniform block in the shader.
  7455. */
  7456. addMatrix2x2(name: string): void;
  7457. /**
  7458. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7459. */
  7460. create(): void;
  7461. /** @hidden */
  7462. _rebuild(): void;
  7463. /**
  7464. * Updates the WebGL Uniform Buffer on the GPU.
  7465. * If the `dynamic` flag is set to true, no cache comparison is done.
  7466. * Otherwise, the buffer will be updated only if the cache differs.
  7467. */
  7468. update(): void;
  7469. /**
  7470. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7471. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7472. * @param data Define the flattened data
  7473. * @param size Define the size of the data.
  7474. */
  7475. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7476. private _valueCache;
  7477. private _cacheMatrix;
  7478. private _updateMatrix3x3ForUniform;
  7479. private _updateMatrix3x3ForEffect;
  7480. private _updateMatrix2x2ForEffect;
  7481. private _updateMatrix2x2ForUniform;
  7482. private _updateFloatForEffect;
  7483. private _updateFloatForUniform;
  7484. private _updateFloat2ForEffect;
  7485. private _updateFloat2ForUniform;
  7486. private _updateFloat3ForEffect;
  7487. private _updateFloat3ForUniform;
  7488. private _updateFloat4ForEffect;
  7489. private _updateFloat4ForUniform;
  7490. private _updateMatrixForEffect;
  7491. private _updateMatrixForUniform;
  7492. private _updateVector3ForEffect;
  7493. private _updateVector3ForUniform;
  7494. private _updateVector4ForEffect;
  7495. private _updateVector4ForUniform;
  7496. private _updateColor3ForEffect;
  7497. private _updateColor3ForUniform;
  7498. private _updateColor4ForEffect;
  7499. private _updateColor4ForUniform;
  7500. /**
  7501. * Sets a sampler uniform on the effect.
  7502. * @param name Define the name of the sampler.
  7503. * @param texture Define the texture to set in the sampler
  7504. */
  7505. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7506. /**
  7507. * Directly updates the value of the uniform in the cache AND on the GPU.
  7508. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7509. * @param data Define the flattened data
  7510. */
  7511. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7512. /**
  7513. * Binds this uniform buffer to an effect.
  7514. * @param effect Define the effect to bind the buffer to
  7515. * @param name Name of the uniform block in the shader.
  7516. */
  7517. bindToEffect(effect: Effect, name: string): void;
  7518. /**
  7519. * Disposes the uniform buffer.
  7520. */
  7521. dispose(): void;
  7522. }
  7523. }
  7524. declare module BABYLON {
  7525. /**
  7526. * Enum that determines the text-wrapping mode to use.
  7527. */
  7528. export enum InspectableType {
  7529. /**
  7530. * Checkbox for booleans
  7531. */
  7532. Checkbox = 0,
  7533. /**
  7534. * Sliders for numbers
  7535. */
  7536. Slider = 1,
  7537. /**
  7538. * Vector3
  7539. */
  7540. Vector3 = 2,
  7541. /**
  7542. * Quaternions
  7543. */
  7544. Quaternion = 3,
  7545. /**
  7546. * Color3
  7547. */
  7548. Color3 = 4,
  7549. /**
  7550. * String
  7551. */
  7552. String = 5
  7553. }
  7554. /**
  7555. * Interface used to define custom inspectable properties.
  7556. * This interface is used by the inspector to display custom property grids
  7557. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7558. */
  7559. export interface IInspectable {
  7560. /**
  7561. * Gets the label to display
  7562. */
  7563. label: string;
  7564. /**
  7565. * Gets the name of the property to edit
  7566. */
  7567. propertyName: string;
  7568. /**
  7569. * Gets the type of the editor to use
  7570. */
  7571. type: InspectableType;
  7572. /**
  7573. * Gets the minimum value of the property when using in "slider" mode
  7574. */
  7575. min?: number;
  7576. /**
  7577. * Gets the maximum value of the property when using in "slider" mode
  7578. */
  7579. max?: number;
  7580. /**
  7581. * Gets the setp to use when using in "slider" mode
  7582. */
  7583. step?: number;
  7584. }
  7585. }
  7586. declare module BABYLON {
  7587. /**
  7588. * Class used to provide helper for timing
  7589. */
  7590. export class TimingTools {
  7591. /**
  7592. * Polyfill for setImmediate
  7593. * @param action defines the action to execute after the current execution block
  7594. */
  7595. static SetImmediate(action: () => void): void;
  7596. }
  7597. }
  7598. declare module BABYLON {
  7599. /**
  7600. * Class used to enable instatition of objects by class name
  7601. */
  7602. export class InstantiationTools {
  7603. /**
  7604. * Use this object to register external classes like custom textures or material
  7605. * to allow the laoders to instantiate them
  7606. */
  7607. static RegisteredExternalClasses: {
  7608. [key: string]: Object;
  7609. };
  7610. /**
  7611. * Tries to instantiate a new object from a given class name
  7612. * @param className defines the class name to instantiate
  7613. * @returns the new object or null if the system was not able to do the instantiation
  7614. */
  7615. static Instantiate(className: string): any;
  7616. }
  7617. }
  7618. declare module BABYLON {
  7619. /**
  7620. * Define options used to create a depth texture
  7621. */
  7622. export class DepthTextureCreationOptions {
  7623. /** Specifies whether or not a stencil should be allocated in the texture */
  7624. generateStencil?: boolean;
  7625. /** Specifies whether or not bilinear filtering is enable on the texture */
  7626. bilinearFiltering?: boolean;
  7627. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7628. comparisonFunction?: number;
  7629. /** Specifies if the created texture is a cube texture */
  7630. isCube?: boolean;
  7631. }
  7632. }
  7633. declare module BABYLON {
  7634. interface ThinEngine {
  7635. /**
  7636. * Creates a depth stencil cube texture.
  7637. * This is only available in WebGL 2.
  7638. * @param size The size of face edge in the cube texture.
  7639. * @param options The options defining the cube texture.
  7640. * @returns The cube texture
  7641. */
  7642. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7643. /**
  7644. * Creates a cube texture
  7645. * @param rootUrl defines the url where the files to load is located
  7646. * @param scene defines the current scene
  7647. * @param files defines the list of files to load (1 per face)
  7648. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7649. * @param onLoad defines an optional callback raised when the texture is loaded
  7650. * @param onError defines an optional callback raised if there is an issue to load the texture
  7651. * @param format defines the format of the data
  7652. * @param forcedExtension defines the extension to use to pick the right loader
  7653. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7654. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7655. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7656. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7657. * @returns the cube texture as an InternalTexture
  7658. */
  7659. 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>): InternalTexture;
  7660. /**
  7661. * Creates a cube texture
  7662. * @param rootUrl defines the url where the files to load is located
  7663. * @param scene defines the current scene
  7664. * @param files defines the list of files to load (1 per face)
  7665. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7666. * @param onLoad defines an optional callback raised when the texture is loaded
  7667. * @param onError defines an optional callback raised if there is an issue to load the texture
  7668. * @param format defines the format of the data
  7669. * @param forcedExtension defines the extension to use to pick the right loader
  7670. * @returns the cube texture as an InternalTexture
  7671. */
  7672. 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;
  7673. /**
  7674. * Creates a cube texture
  7675. * @param rootUrl defines the url where the files to load is located
  7676. * @param scene defines the current scene
  7677. * @param files defines the list of files to load (1 per face)
  7678. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7679. * @param onLoad defines an optional callback raised when the texture is loaded
  7680. * @param onError defines an optional callback raised if there is an issue to load the texture
  7681. * @param format defines the format of the data
  7682. * @param forcedExtension defines the extension to use to pick the right loader
  7683. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7684. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7685. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7686. * @returns the cube texture as an InternalTexture
  7687. */
  7688. 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;
  7689. /** @hidden */
  7690. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7691. /** @hidden */
  7692. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7693. /** @hidden */
  7694. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7695. /** @hidden */
  7696. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7697. /**
  7698. * @hidden
  7699. */
  7700. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7701. }
  7702. }
  7703. declare module BABYLON {
  7704. /**
  7705. * Class for creating a cube texture
  7706. */
  7707. export class CubeTexture extends BaseTexture {
  7708. private _delayedOnLoad;
  7709. /**
  7710. * Observable triggered once the texture has been loaded.
  7711. */
  7712. onLoadObservable: Observable<CubeTexture>;
  7713. /**
  7714. * The url of the texture
  7715. */
  7716. url: string;
  7717. /**
  7718. * Gets or sets the center of the bounding box associated with the cube texture.
  7719. * It must define where the camera used to render the texture was set
  7720. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7721. */
  7722. boundingBoxPosition: Vector3;
  7723. private _boundingBoxSize;
  7724. /**
  7725. * Gets or sets the size of the bounding box associated with the cube texture
  7726. * When defined, the cubemap will switch to local mode
  7727. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7728. * @example https://www.babylonjs-playground.com/#RNASML
  7729. */
  7730. set boundingBoxSize(value: Vector3);
  7731. /**
  7732. * Returns the bounding box size
  7733. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7734. */
  7735. get boundingBoxSize(): Vector3;
  7736. protected _rotationY: number;
  7737. /**
  7738. * Sets texture matrix rotation angle around Y axis in radians.
  7739. */
  7740. set rotationY(value: number);
  7741. /**
  7742. * Gets texture matrix rotation angle around Y axis radians.
  7743. */
  7744. get rotationY(): number;
  7745. /**
  7746. * Are mip maps generated for this texture or not.
  7747. */
  7748. get noMipmap(): boolean;
  7749. private _noMipmap;
  7750. private _files;
  7751. protected _forcedExtension: Nullable<string>;
  7752. private _extensions;
  7753. private _textureMatrix;
  7754. private _format;
  7755. private _createPolynomials;
  7756. /** @hidden */
  7757. _prefiltered: boolean;
  7758. /**
  7759. * Creates a cube texture from an array of image urls
  7760. * @param files defines an array of image urls
  7761. * @param scene defines the hosting scene
  7762. * @param noMipmap specifies if mip maps are not used
  7763. * @returns a cube texture
  7764. */
  7765. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7766. /**
  7767. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7768. * @param url defines the url of the prefiltered texture
  7769. * @param scene defines the scene the texture is attached to
  7770. * @param forcedExtension defines the extension of the file if different from the url
  7771. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7772. * @return the prefiltered texture
  7773. */
  7774. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7775. /**
  7776. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7777. * as prefiltered data.
  7778. * @param rootUrl defines the url of the texture or the root name of the six images
  7779. * @param null defines the scene or engine the texture is attached to
  7780. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7781. * @param noMipmap defines if mipmaps should be created or not
  7782. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7783. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7784. * @param onError defines a callback triggered in case of error during load
  7785. * @param format defines the internal format to use for the texture once loaded
  7786. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7787. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7788. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7789. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7790. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7791. * @return the cube texture
  7792. */
  7793. constructor(rootUrl: string, sceneOrEngine: Scene | ThinEngine, 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);
  7794. /**
  7795. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7796. */
  7797. get isPrefiltered(): boolean;
  7798. /**
  7799. * Get the current class name of the texture useful for serialization or dynamic coding.
  7800. * @returns "CubeTexture"
  7801. */
  7802. getClassName(): string;
  7803. /**
  7804. * Update the url (and optional buffer) of this texture if url was null during construction.
  7805. * @param url the url of the texture
  7806. * @param forcedExtension defines the extension to use
  7807. * @param onLoad callback called when the texture is loaded (defaults to null)
  7808. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7809. */
  7810. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7811. /**
  7812. * Delays loading of the cube texture
  7813. * @param forcedExtension defines the extension to use
  7814. */
  7815. delayLoad(forcedExtension?: string): void;
  7816. /**
  7817. * Returns the reflection texture matrix
  7818. * @returns the reflection texture matrix
  7819. */
  7820. getReflectionTextureMatrix(): Matrix;
  7821. /**
  7822. * Sets the reflection texture matrix
  7823. * @param value Reflection texture matrix
  7824. */
  7825. setReflectionTextureMatrix(value: Matrix): void;
  7826. /**
  7827. * Parses text to create a cube texture
  7828. * @param parsedTexture define the serialized text to read from
  7829. * @param scene defines the hosting scene
  7830. * @param rootUrl defines the root url of the cube texture
  7831. * @returns a cube texture
  7832. */
  7833. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7834. /**
  7835. * Makes a clone, or deep copy, of the cube texture
  7836. * @returns a new cube texture
  7837. */
  7838. clone(): CubeTexture;
  7839. }
  7840. }
  7841. declare module BABYLON {
  7842. /**
  7843. * Manages the defines for the Material
  7844. */
  7845. export class MaterialDefines {
  7846. /** @hidden */
  7847. protected _keys: string[];
  7848. private _isDirty;
  7849. /** @hidden */
  7850. _renderId: number;
  7851. /** @hidden */
  7852. _areLightsDirty: boolean;
  7853. /** @hidden */
  7854. _areLightsDisposed: boolean;
  7855. /** @hidden */
  7856. _areAttributesDirty: boolean;
  7857. /** @hidden */
  7858. _areTexturesDirty: boolean;
  7859. /** @hidden */
  7860. _areFresnelDirty: boolean;
  7861. /** @hidden */
  7862. _areMiscDirty: boolean;
  7863. /** @hidden */
  7864. _areImageProcessingDirty: boolean;
  7865. /** @hidden */
  7866. _normals: boolean;
  7867. /** @hidden */
  7868. _uvs: boolean;
  7869. /** @hidden */
  7870. _needNormals: boolean;
  7871. /** @hidden */
  7872. _needUVs: boolean;
  7873. [id: string]: any;
  7874. /**
  7875. * Specifies if the material needs to be re-calculated
  7876. */
  7877. get isDirty(): boolean;
  7878. /**
  7879. * Marks the material to indicate that it has been re-calculated
  7880. */
  7881. markAsProcessed(): void;
  7882. /**
  7883. * Marks the material to indicate that it needs to be re-calculated
  7884. */
  7885. markAsUnprocessed(): void;
  7886. /**
  7887. * Marks the material to indicate all of its defines need to be re-calculated
  7888. */
  7889. markAllAsDirty(): void;
  7890. /**
  7891. * Marks the material to indicate that image processing needs to be re-calculated
  7892. */
  7893. markAsImageProcessingDirty(): void;
  7894. /**
  7895. * Marks the material to indicate the lights need to be re-calculated
  7896. * @param disposed Defines whether the light is dirty due to dispose or not
  7897. */
  7898. markAsLightDirty(disposed?: boolean): void;
  7899. /**
  7900. * Marks the attribute state as changed
  7901. */
  7902. markAsAttributesDirty(): void;
  7903. /**
  7904. * Marks the texture state as changed
  7905. */
  7906. markAsTexturesDirty(): void;
  7907. /**
  7908. * Marks the fresnel state as changed
  7909. */
  7910. markAsFresnelDirty(): void;
  7911. /**
  7912. * Marks the misc state as changed
  7913. */
  7914. markAsMiscDirty(): void;
  7915. /**
  7916. * Rebuilds the material defines
  7917. */
  7918. rebuild(): void;
  7919. /**
  7920. * Specifies if two material defines are equal
  7921. * @param other - A material define instance to compare to
  7922. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7923. */
  7924. isEqual(other: MaterialDefines): boolean;
  7925. /**
  7926. * Clones this instance's defines to another instance
  7927. * @param other - material defines to clone values to
  7928. */
  7929. cloneTo(other: MaterialDefines): void;
  7930. /**
  7931. * Resets the material define values
  7932. */
  7933. reset(): void;
  7934. /**
  7935. * Converts the material define values to a string
  7936. * @returns - String of material define information
  7937. */
  7938. toString(): string;
  7939. }
  7940. }
  7941. declare module BABYLON {
  7942. /**
  7943. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7944. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7945. * 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;
  7946. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7947. */
  7948. export class ColorCurves {
  7949. private _dirty;
  7950. private _tempColor;
  7951. private _globalCurve;
  7952. private _highlightsCurve;
  7953. private _midtonesCurve;
  7954. private _shadowsCurve;
  7955. private _positiveCurve;
  7956. private _negativeCurve;
  7957. private _globalHue;
  7958. private _globalDensity;
  7959. private _globalSaturation;
  7960. private _globalExposure;
  7961. /**
  7962. * Gets the global Hue value.
  7963. * 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).
  7964. */
  7965. get globalHue(): number;
  7966. /**
  7967. * Sets the global Hue value.
  7968. * 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).
  7969. */
  7970. set globalHue(value: number);
  7971. /**
  7972. * Gets the global Density value.
  7973. * 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.
  7974. * Values less than zero provide a filter of opposite hue.
  7975. */
  7976. get globalDensity(): number;
  7977. /**
  7978. * Sets the global Density value.
  7979. * 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.
  7980. * Values less than zero provide a filter of opposite hue.
  7981. */
  7982. set globalDensity(value: number);
  7983. /**
  7984. * Gets the global Saturation value.
  7985. * 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.
  7986. */
  7987. get globalSaturation(): number;
  7988. /**
  7989. * Sets the global Saturation value.
  7990. * 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.
  7991. */
  7992. set globalSaturation(value: number);
  7993. /**
  7994. * Gets the global Exposure value.
  7995. * 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.
  7996. */
  7997. get globalExposure(): number;
  7998. /**
  7999. * Sets the global Exposure value.
  8000. * 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.
  8001. */
  8002. set globalExposure(value: number);
  8003. private _highlightsHue;
  8004. private _highlightsDensity;
  8005. private _highlightsSaturation;
  8006. private _highlightsExposure;
  8007. /**
  8008. * Gets the highlights Hue value.
  8009. * 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).
  8010. */
  8011. get highlightsHue(): number;
  8012. /**
  8013. * Sets the highlights Hue value.
  8014. * 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).
  8015. */
  8016. set highlightsHue(value: number);
  8017. /**
  8018. * Gets the highlights Density value.
  8019. * 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.
  8020. * Values less than zero provide a filter of opposite hue.
  8021. */
  8022. get highlightsDensity(): number;
  8023. /**
  8024. * Sets the highlights Density value.
  8025. * 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.
  8026. * Values less than zero provide a filter of opposite hue.
  8027. */
  8028. set highlightsDensity(value: number);
  8029. /**
  8030. * Gets the highlights Saturation value.
  8031. * 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.
  8032. */
  8033. get highlightsSaturation(): number;
  8034. /**
  8035. * Sets the highlights Saturation value.
  8036. * 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.
  8037. */
  8038. set highlightsSaturation(value: number);
  8039. /**
  8040. * Gets the highlights Exposure value.
  8041. * 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.
  8042. */
  8043. get highlightsExposure(): number;
  8044. /**
  8045. * Sets the highlights Exposure value.
  8046. * 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.
  8047. */
  8048. set highlightsExposure(value: number);
  8049. private _midtonesHue;
  8050. private _midtonesDensity;
  8051. private _midtonesSaturation;
  8052. private _midtonesExposure;
  8053. /**
  8054. * Gets the midtones Hue value.
  8055. * 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).
  8056. */
  8057. get midtonesHue(): number;
  8058. /**
  8059. * Sets the midtones Hue value.
  8060. * 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).
  8061. */
  8062. set midtonesHue(value: number);
  8063. /**
  8064. * Gets the midtones Density value.
  8065. * 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.
  8066. * Values less than zero provide a filter of opposite hue.
  8067. */
  8068. get midtonesDensity(): number;
  8069. /**
  8070. * Sets the midtones Density value.
  8071. * 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.
  8072. * Values less than zero provide a filter of opposite hue.
  8073. */
  8074. set midtonesDensity(value: number);
  8075. /**
  8076. * Gets the midtones Saturation value.
  8077. * 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.
  8078. */
  8079. get midtonesSaturation(): number;
  8080. /**
  8081. * Sets the midtones Saturation value.
  8082. * 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.
  8083. */
  8084. set midtonesSaturation(value: number);
  8085. /**
  8086. * Gets the midtones Exposure value.
  8087. * 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.
  8088. */
  8089. get midtonesExposure(): number;
  8090. /**
  8091. * Sets the midtones Exposure value.
  8092. * 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.
  8093. */
  8094. set midtonesExposure(value: number);
  8095. private _shadowsHue;
  8096. private _shadowsDensity;
  8097. private _shadowsSaturation;
  8098. private _shadowsExposure;
  8099. /**
  8100. * Gets the shadows Hue value.
  8101. * 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).
  8102. */
  8103. get shadowsHue(): number;
  8104. /**
  8105. * Sets the shadows Hue value.
  8106. * 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).
  8107. */
  8108. set shadowsHue(value: number);
  8109. /**
  8110. * Gets the shadows Density value.
  8111. * 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.
  8112. * Values less than zero provide a filter of opposite hue.
  8113. */
  8114. get shadowsDensity(): number;
  8115. /**
  8116. * Sets the shadows Density value.
  8117. * 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.
  8118. * Values less than zero provide a filter of opposite hue.
  8119. */
  8120. set shadowsDensity(value: number);
  8121. /**
  8122. * Gets the shadows Saturation value.
  8123. * 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.
  8124. */
  8125. get shadowsSaturation(): number;
  8126. /**
  8127. * Sets the shadows Saturation value.
  8128. * 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.
  8129. */
  8130. set shadowsSaturation(value: number);
  8131. /**
  8132. * Gets the shadows Exposure value.
  8133. * 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.
  8134. */
  8135. get shadowsExposure(): number;
  8136. /**
  8137. * Sets the shadows Exposure value.
  8138. * 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.
  8139. */
  8140. set shadowsExposure(value: number);
  8141. /**
  8142. * Returns the class name
  8143. * @returns The class name
  8144. */
  8145. getClassName(): string;
  8146. /**
  8147. * Binds the color curves to the shader.
  8148. * @param colorCurves The color curve to bind
  8149. * @param effect The effect to bind to
  8150. * @param positiveUniform The positive uniform shader parameter
  8151. * @param neutralUniform The neutral uniform shader parameter
  8152. * @param negativeUniform The negative uniform shader parameter
  8153. */
  8154. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8155. /**
  8156. * Prepare the list of uniforms associated with the ColorCurves effects.
  8157. * @param uniformsList The list of uniforms used in the effect
  8158. */
  8159. static PrepareUniforms(uniformsList: string[]): void;
  8160. /**
  8161. * Returns color grading data based on a hue, density, saturation and exposure value.
  8162. * @param filterHue The hue of the color filter.
  8163. * @param filterDensity The density of the color filter.
  8164. * @param saturation The saturation.
  8165. * @param exposure The exposure.
  8166. * @param result The result data container.
  8167. */
  8168. private getColorGradingDataToRef;
  8169. /**
  8170. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8171. * @param value The input slider value in range [-100,100].
  8172. * @returns Adjusted value.
  8173. */
  8174. private static applyColorGradingSliderNonlinear;
  8175. /**
  8176. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8177. * @param hue The hue (H) input.
  8178. * @param saturation The saturation (S) input.
  8179. * @param brightness The brightness (B) input.
  8180. * @result An RGBA color represented as Vector4.
  8181. */
  8182. private static fromHSBToRef;
  8183. /**
  8184. * Returns a value clamped between min and max
  8185. * @param value The value to clamp
  8186. * @param min The minimum of value
  8187. * @param max The maximum of value
  8188. * @returns The clamped value.
  8189. */
  8190. private static clamp;
  8191. /**
  8192. * Clones the current color curve instance.
  8193. * @return The cloned curves
  8194. */
  8195. clone(): ColorCurves;
  8196. /**
  8197. * Serializes the current color curve instance to a json representation.
  8198. * @return a JSON representation
  8199. */
  8200. serialize(): any;
  8201. /**
  8202. * Parses the color curve from a json representation.
  8203. * @param source the JSON source to parse
  8204. * @return The parsed curves
  8205. */
  8206. static Parse(source: any): ColorCurves;
  8207. }
  8208. }
  8209. declare module BABYLON {
  8210. /**
  8211. * Interface to follow in your material defines to integrate easily the
  8212. * Image proccessing functions.
  8213. * @hidden
  8214. */
  8215. export interface IImageProcessingConfigurationDefines {
  8216. IMAGEPROCESSING: boolean;
  8217. VIGNETTE: boolean;
  8218. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8219. VIGNETTEBLENDMODEOPAQUE: boolean;
  8220. TONEMAPPING: boolean;
  8221. TONEMAPPING_ACES: boolean;
  8222. CONTRAST: boolean;
  8223. EXPOSURE: boolean;
  8224. COLORCURVES: boolean;
  8225. COLORGRADING: boolean;
  8226. COLORGRADING3D: boolean;
  8227. SAMPLER3DGREENDEPTH: boolean;
  8228. SAMPLER3DBGRMAP: boolean;
  8229. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8230. }
  8231. /**
  8232. * @hidden
  8233. */
  8234. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8235. IMAGEPROCESSING: boolean;
  8236. VIGNETTE: boolean;
  8237. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8238. VIGNETTEBLENDMODEOPAQUE: boolean;
  8239. TONEMAPPING: boolean;
  8240. TONEMAPPING_ACES: boolean;
  8241. CONTRAST: boolean;
  8242. COLORCURVES: boolean;
  8243. COLORGRADING: boolean;
  8244. COLORGRADING3D: boolean;
  8245. SAMPLER3DGREENDEPTH: boolean;
  8246. SAMPLER3DBGRMAP: boolean;
  8247. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8248. EXPOSURE: boolean;
  8249. constructor();
  8250. }
  8251. /**
  8252. * This groups together the common properties used for image processing either in direct forward pass
  8253. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8254. * or not.
  8255. */
  8256. export class ImageProcessingConfiguration {
  8257. /**
  8258. * Default tone mapping applied in BabylonJS.
  8259. */
  8260. static readonly TONEMAPPING_STANDARD: number;
  8261. /**
  8262. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8263. * to other engines rendering to increase portability.
  8264. */
  8265. static readonly TONEMAPPING_ACES: number;
  8266. /**
  8267. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8268. */
  8269. colorCurves: Nullable<ColorCurves>;
  8270. private _colorCurvesEnabled;
  8271. /**
  8272. * Gets wether the color curves effect is enabled.
  8273. */
  8274. get colorCurvesEnabled(): boolean;
  8275. /**
  8276. * Sets wether the color curves effect is enabled.
  8277. */
  8278. set colorCurvesEnabled(value: boolean);
  8279. private _colorGradingTexture;
  8280. /**
  8281. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8282. */
  8283. get colorGradingTexture(): Nullable<BaseTexture>;
  8284. /**
  8285. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8286. */
  8287. set colorGradingTexture(value: Nullable<BaseTexture>);
  8288. private _colorGradingEnabled;
  8289. /**
  8290. * Gets wether the color grading effect is enabled.
  8291. */
  8292. get colorGradingEnabled(): boolean;
  8293. /**
  8294. * Sets wether the color grading effect is enabled.
  8295. */
  8296. set colorGradingEnabled(value: boolean);
  8297. private _colorGradingWithGreenDepth;
  8298. /**
  8299. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8300. */
  8301. get colorGradingWithGreenDepth(): boolean;
  8302. /**
  8303. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8304. */
  8305. set colorGradingWithGreenDepth(value: boolean);
  8306. private _colorGradingBGR;
  8307. /**
  8308. * Gets wether the color grading texture contains BGR values.
  8309. */
  8310. get colorGradingBGR(): boolean;
  8311. /**
  8312. * Sets wether the color grading texture contains BGR values.
  8313. */
  8314. set colorGradingBGR(value: boolean);
  8315. /** @hidden */
  8316. _exposure: number;
  8317. /**
  8318. * Gets the Exposure used in the effect.
  8319. */
  8320. get exposure(): number;
  8321. /**
  8322. * Sets the Exposure used in the effect.
  8323. */
  8324. set exposure(value: number);
  8325. private _toneMappingEnabled;
  8326. /**
  8327. * Gets wether the tone mapping effect is enabled.
  8328. */
  8329. get toneMappingEnabled(): boolean;
  8330. /**
  8331. * Sets wether the tone mapping effect is enabled.
  8332. */
  8333. set toneMappingEnabled(value: boolean);
  8334. private _toneMappingType;
  8335. /**
  8336. * Gets the type of tone mapping effect.
  8337. */
  8338. get toneMappingType(): number;
  8339. /**
  8340. * Sets the type of tone mapping effect used in BabylonJS.
  8341. */
  8342. set toneMappingType(value: number);
  8343. protected _contrast: number;
  8344. /**
  8345. * Gets the contrast used in the effect.
  8346. */
  8347. get contrast(): number;
  8348. /**
  8349. * Sets the contrast used in the effect.
  8350. */
  8351. set contrast(value: number);
  8352. /**
  8353. * Vignette stretch size.
  8354. */
  8355. vignetteStretch: number;
  8356. /**
  8357. * Vignette centre X Offset.
  8358. */
  8359. vignetteCentreX: number;
  8360. /**
  8361. * Vignette centre Y Offset.
  8362. */
  8363. vignetteCentreY: number;
  8364. /**
  8365. * Vignette weight or intensity of the vignette effect.
  8366. */
  8367. vignetteWeight: number;
  8368. /**
  8369. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8370. * if vignetteEnabled is set to true.
  8371. */
  8372. vignetteColor: Color4;
  8373. /**
  8374. * Camera field of view used by the Vignette effect.
  8375. */
  8376. vignetteCameraFov: number;
  8377. private _vignetteBlendMode;
  8378. /**
  8379. * Gets the vignette blend mode allowing different kind of effect.
  8380. */
  8381. get vignetteBlendMode(): number;
  8382. /**
  8383. * Sets the vignette blend mode allowing different kind of effect.
  8384. */
  8385. set vignetteBlendMode(value: number);
  8386. private _vignetteEnabled;
  8387. /**
  8388. * Gets wether the vignette effect is enabled.
  8389. */
  8390. get vignetteEnabled(): boolean;
  8391. /**
  8392. * Sets wether the vignette effect is enabled.
  8393. */
  8394. set vignetteEnabled(value: boolean);
  8395. private _applyByPostProcess;
  8396. /**
  8397. * Gets wether the image processing is applied through a post process or not.
  8398. */
  8399. get applyByPostProcess(): boolean;
  8400. /**
  8401. * Sets wether the image processing is applied through a post process or not.
  8402. */
  8403. set applyByPostProcess(value: boolean);
  8404. private _isEnabled;
  8405. /**
  8406. * Gets wether the image processing is enabled or not.
  8407. */
  8408. get isEnabled(): boolean;
  8409. /**
  8410. * Sets wether the image processing is enabled or not.
  8411. */
  8412. set isEnabled(value: boolean);
  8413. /**
  8414. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8415. */
  8416. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8417. /**
  8418. * Method called each time the image processing information changes requires to recompile the effect.
  8419. */
  8420. protected _updateParameters(): void;
  8421. /**
  8422. * Gets the current class name.
  8423. * @return "ImageProcessingConfiguration"
  8424. */
  8425. getClassName(): string;
  8426. /**
  8427. * Prepare the list of uniforms associated with the Image Processing effects.
  8428. * @param uniforms The list of uniforms used in the effect
  8429. * @param defines the list of defines currently in use
  8430. */
  8431. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8432. /**
  8433. * Prepare the list of samplers associated with the Image Processing effects.
  8434. * @param samplersList The list of uniforms used in the effect
  8435. * @param defines the list of defines currently in use
  8436. */
  8437. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8438. /**
  8439. * Prepare the list of defines associated to the shader.
  8440. * @param defines the list of defines to complete
  8441. * @param forPostProcess Define if we are currently in post process mode or not
  8442. */
  8443. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8444. /**
  8445. * Returns true if all the image processing information are ready.
  8446. * @returns True if ready, otherwise, false
  8447. */
  8448. isReady(): boolean;
  8449. /**
  8450. * Binds the image processing to the shader.
  8451. * @param effect The effect to bind to
  8452. * @param overrideAspectRatio Override the aspect ratio of the effect
  8453. */
  8454. bind(effect: Effect, overrideAspectRatio?: number): void;
  8455. /**
  8456. * Clones the current image processing instance.
  8457. * @return The cloned image processing
  8458. */
  8459. clone(): ImageProcessingConfiguration;
  8460. /**
  8461. * Serializes the current image processing instance to a json representation.
  8462. * @return a JSON representation
  8463. */
  8464. serialize(): any;
  8465. /**
  8466. * Parses the image processing from a json representation.
  8467. * @param source the JSON source to parse
  8468. * @return The parsed image processing
  8469. */
  8470. static Parse(source: any): ImageProcessingConfiguration;
  8471. private static _VIGNETTEMODE_MULTIPLY;
  8472. private static _VIGNETTEMODE_OPAQUE;
  8473. /**
  8474. * Used to apply the vignette as a mix with the pixel color.
  8475. */
  8476. static get VIGNETTEMODE_MULTIPLY(): number;
  8477. /**
  8478. * Used to apply the vignette as a replacement of the pixel color.
  8479. */
  8480. static get VIGNETTEMODE_OPAQUE(): number;
  8481. }
  8482. }
  8483. declare module BABYLON {
  8484. /** @hidden */
  8485. export var postprocessVertexShader: {
  8486. name: string;
  8487. shader: string;
  8488. };
  8489. }
  8490. declare module BABYLON {
  8491. interface ThinEngine {
  8492. /**
  8493. * Creates a new render target texture
  8494. * @param size defines the size of the texture
  8495. * @param options defines the options used to create the texture
  8496. * @returns a new render target texture stored in an InternalTexture
  8497. */
  8498. createRenderTargetTexture(size: number | {
  8499. width: number;
  8500. height: number;
  8501. layers?: number;
  8502. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8503. /**
  8504. * Creates a depth stencil texture.
  8505. * This is only available in WebGL 2 or with the depth texture extension available.
  8506. * @param size The size of face edge in the texture.
  8507. * @param options The options defining the texture.
  8508. * @returns The texture
  8509. */
  8510. createDepthStencilTexture(size: number | {
  8511. width: number;
  8512. height: number;
  8513. layers?: number;
  8514. }, options: DepthTextureCreationOptions): InternalTexture;
  8515. /** @hidden */
  8516. _createDepthStencilTexture(size: number | {
  8517. width: number;
  8518. height: number;
  8519. layers?: number;
  8520. }, options: DepthTextureCreationOptions): InternalTexture;
  8521. }
  8522. }
  8523. declare module BABYLON {
  8524. /**
  8525. * Defines the kind of connection point for node based material
  8526. */
  8527. export enum NodeMaterialBlockConnectionPointTypes {
  8528. /** Float */
  8529. Float = 1,
  8530. /** Int */
  8531. Int = 2,
  8532. /** Vector2 */
  8533. Vector2 = 4,
  8534. /** Vector3 */
  8535. Vector3 = 8,
  8536. /** Vector4 */
  8537. Vector4 = 16,
  8538. /** Color3 */
  8539. Color3 = 32,
  8540. /** Color4 */
  8541. Color4 = 64,
  8542. /** Matrix */
  8543. Matrix = 128,
  8544. /** Custom object */
  8545. Object = 256,
  8546. /** Detect type based on connection */
  8547. AutoDetect = 1024,
  8548. /** Output type that will be defined by input type */
  8549. BasedOnInput = 2048
  8550. }
  8551. }
  8552. declare module BABYLON {
  8553. /**
  8554. * Enum used to define the target of a block
  8555. */
  8556. export enum NodeMaterialBlockTargets {
  8557. /** Vertex shader */
  8558. Vertex = 1,
  8559. /** Fragment shader */
  8560. Fragment = 2,
  8561. /** Neutral */
  8562. Neutral = 4,
  8563. /** Vertex and Fragment */
  8564. VertexAndFragment = 3
  8565. }
  8566. }
  8567. declare module BABYLON {
  8568. /**
  8569. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8570. */
  8571. export enum NodeMaterialBlockConnectionPointMode {
  8572. /** Value is an uniform */
  8573. Uniform = 0,
  8574. /** Value is a mesh attribute */
  8575. Attribute = 1,
  8576. /** Value is a varying between vertex and fragment shaders */
  8577. Varying = 2,
  8578. /** Mode is undefined */
  8579. Undefined = 3
  8580. }
  8581. }
  8582. declare module BABYLON {
  8583. /**
  8584. * Enum used to define system values e.g. values automatically provided by the system
  8585. */
  8586. export enum NodeMaterialSystemValues {
  8587. /** World */
  8588. World = 1,
  8589. /** View */
  8590. View = 2,
  8591. /** Projection */
  8592. Projection = 3,
  8593. /** ViewProjection */
  8594. ViewProjection = 4,
  8595. /** WorldView */
  8596. WorldView = 5,
  8597. /** WorldViewProjection */
  8598. WorldViewProjection = 6,
  8599. /** CameraPosition */
  8600. CameraPosition = 7,
  8601. /** Fog Color */
  8602. FogColor = 8,
  8603. /** Delta time */
  8604. DeltaTime = 9
  8605. }
  8606. }
  8607. declare module BABYLON {
  8608. /** Defines supported spaces */
  8609. export enum Space {
  8610. /** Local (object) space */
  8611. LOCAL = 0,
  8612. /** World space */
  8613. WORLD = 1,
  8614. /** Bone space */
  8615. BONE = 2
  8616. }
  8617. /** Defines the 3 main axes */
  8618. export class Axis {
  8619. /** X axis */
  8620. static X: Vector3;
  8621. /** Y axis */
  8622. static Y: Vector3;
  8623. /** Z axis */
  8624. static Z: Vector3;
  8625. }
  8626. }
  8627. declare module BABYLON {
  8628. /**
  8629. * Represents a camera frustum
  8630. */
  8631. export class Frustum {
  8632. /**
  8633. * Gets the planes representing the frustum
  8634. * @param transform matrix to be applied to the returned planes
  8635. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8636. */
  8637. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8638. /**
  8639. * Gets the near frustum plane transformed by the transform matrix
  8640. * @param transform transformation matrix to be applied to the resulting frustum plane
  8641. * @param frustumPlane the resuling frustum plane
  8642. */
  8643. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8644. /**
  8645. * Gets the far frustum plane transformed by the transform matrix
  8646. * @param transform transformation matrix to be applied to the resulting frustum plane
  8647. * @param frustumPlane the resuling frustum plane
  8648. */
  8649. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8650. /**
  8651. * Gets the left frustum plane transformed by the transform matrix
  8652. * @param transform transformation matrix to be applied to the resulting frustum plane
  8653. * @param frustumPlane the resuling frustum plane
  8654. */
  8655. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8656. /**
  8657. * Gets the right frustum plane transformed by the transform matrix
  8658. * @param transform transformation matrix to be applied to the resulting frustum plane
  8659. * @param frustumPlane the resuling frustum plane
  8660. */
  8661. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8662. /**
  8663. * Gets the top frustum plane transformed by the transform matrix
  8664. * @param transform transformation matrix to be applied to the resulting frustum plane
  8665. * @param frustumPlane the resuling frustum plane
  8666. */
  8667. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8668. /**
  8669. * Gets the bottom frustum plane transformed by the transform matrix
  8670. * @param transform transformation matrix to be applied to the resulting frustum plane
  8671. * @param frustumPlane the resuling frustum plane
  8672. */
  8673. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8674. /**
  8675. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8676. * @param transform transformation matrix to be applied to the resulting frustum planes
  8677. * @param frustumPlanes the resuling frustum planes
  8678. */
  8679. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8680. }
  8681. }
  8682. declare module BABYLON {
  8683. /**
  8684. * Interface for the size containing width and height
  8685. */
  8686. export interface ISize {
  8687. /**
  8688. * Width
  8689. */
  8690. width: number;
  8691. /**
  8692. * Heighht
  8693. */
  8694. height: number;
  8695. }
  8696. /**
  8697. * Size containing widht and height
  8698. */
  8699. export class Size implements ISize {
  8700. /**
  8701. * Width
  8702. */
  8703. width: number;
  8704. /**
  8705. * Height
  8706. */
  8707. height: number;
  8708. /**
  8709. * Creates a Size object from the given width and height (floats).
  8710. * @param width width of the new size
  8711. * @param height height of the new size
  8712. */
  8713. constructor(width: number, height: number);
  8714. /**
  8715. * Returns a string with the Size width and height
  8716. * @returns a string with the Size width and height
  8717. */
  8718. toString(): string;
  8719. /**
  8720. * "Size"
  8721. * @returns the string "Size"
  8722. */
  8723. getClassName(): string;
  8724. /**
  8725. * Returns the Size hash code.
  8726. * @returns a hash code for a unique width and height
  8727. */
  8728. getHashCode(): number;
  8729. /**
  8730. * Updates the current size from the given one.
  8731. * @param src the given size
  8732. */
  8733. copyFrom(src: Size): void;
  8734. /**
  8735. * Updates in place the current Size from the given floats.
  8736. * @param width width of the new size
  8737. * @param height height of the new size
  8738. * @returns the updated Size.
  8739. */
  8740. copyFromFloats(width: number, height: number): Size;
  8741. /**
  8742. * Updates in place the current Size from the given floats.
  8743. * @param width width to set
  8744. * @param height height to set
  8745. * @returns the updated Size.
  8746. */
  8747. set(width: number, height: number): Size;
  8748. /**
  8749. * Multiplies the width and height by numbers
  8750. * @param w factor to multiple the width by
  8751. * @param h factor to multiple the height by
  8752. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  8753. */
  8754. multiplyByFloats(w: number, h: number): Size;
  8755. /**
  8756. * Clones the size
  8757. * @returns a new Size copied from the given one.
  8758. */
  8759. clone(): Size;
  8760. /**
  8761. * True if the current Size and the given one width and height are strictly equal.
  8762. * @param other the other size to compare against
  8763. * @returns True if the current Size and the given one width and height are strictly equal.
  8764. */
  8765. equals(other: Size): boolean;
  8766. /**
  8767. * The surface of the Size : width * height (float).
  8768. */
  8769. get surface(): number;
  8770. /**
  8771. * Create a new size of zero
  8772. * @returns a new Size set to (0.0, 0.0)
  8773. */
  8774. static Zero(): Size;
  8775. /**
  8776. * Sums the width and height of two sizes
  8777. * @param otherSize size to add to this size
  8778. * @returns a new Size set as the addition result of the current Size and the given one.
  8779. */
  8780. add(otherSize: Size): Size;
  8781. /**
  8782. * Subtracts the width and height of two
  8783. * @param otherSize size to subtract to this size
  8784. * @returns a new Size set as the subtraction result of the given one from the current Size.
  8785. */
  8786. subtract(otherSize: Size): Size;
  8787. /**
  8788. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  8789. * @param start starting size to lerp between
  8790. * @param end end size to lerp between
  8791. * @param amount amount to lerp between the start and end values
  8792. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  8793. */
  8794. static Lerp(start: Size, end: Size, amount: number): Size;
  8795. }
  8796. }
  8797. declare module BABYLON {
  8798. /**
  8799. * Contains position and normal vectors for a vertex
  8800. */
  8801. export class PositionNormalVertex {
  8802. /** the position of the vertex (defaut: 0,0,0) */
  8803. position: Vector3;
  8804. /** the normal of the vertex (defaut: 0,1,0) */
  8805. normal: Vector3;
  8806. /**
  8807. * Creates a PositionNormalVertex
  8808. * @param position the position of the vertex (defaut: 0,0,0)
  8809. * @param normal the normal of the vertex (defaut: 0,1,0)
  8810. */
  8811. constructor(
  8812. /** the position of the vertex (defaut: 0,0,0) */
  8813. position?: Vector3,
  8814. /** the normal of the vertex (defaut: 0,1,0) */
  8815. normal?: Vector3);
  8816. /**
  8817. * Clones the PositionNormalVertex
  8818. * @returns the cloned PositionNormalVertex
  8819. */
  8820. clone(): PositionNormalVertex;
  8821. }
  8822. /**
  8823. * Contains position, normal and uv vectors for a vertex
  8824. */
  8825. export class PositionNormalTextureVertex {
  8826. /** the position of the vertex (defaut: 0,0,0) */
  8827. position: Vector3;
  8828. /** the normal of the vertex (defaut: 0,1,0) */
  8829. normal: Vector3;
  8830. /** the uv of the vertex (default: 0,0) */
  8831. uv: Vector2;
  8832. /**
  8833. * Creates a PositionNormalTextureVertex
  8834. * @param position the position of the vertex (defaut: 0,0,0)
  8835. * @param normal the normal of the vertex (defaut: 0,1,0)
  8836. * @param uv the uv of the vertex (default: 0,0)
  8837. */
  8838. constructor(
  8839. /** the position of the vertex (defaut: 0,0,0) */
  8840. position?: Vector3,
  8841. /** the normal of the vertex (defaut: 0,1,0) */
  8842. normal?: Vector3,
  8843. /** the uv of the vertex (default: 0,0) */
  8844. uv?: Vector2);
  8845. /**
  8846. * Clones the PositionNormalTextureVertex
  8847. * @returns the cloned PositionNormalTextureVertex
  8848. */
  8849. clone(): PositionNormalTextureVertex;
  8850. }
  8851. }
  8852. declare module BABYLON {
  8853. /**
  8854. * Enum defining the type of animations supported by InputBlock
  8855. */
  8856. export enum AnimatedInputBlockTypes {
  8857. /** No animation */
  8858. None = 0,
  8859. /** Time based animation. Will only work for floats */
  8860. Time = 1
  8861. }
  8862. }
  8863. declare module BABYLON {
  8864. /**
  8865. * Interface describing all the common properties and methods a shadow light needs to implement.
  8866. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8867. * as well as binding the different shadow properties to the effects.
  8868. */
  8869. export interface IShadowLight extends Light {
  8870. /**
  8871. * The light id in the scene (used in scene.findLighById for instance)
  8872. */
  8873. id: string;
  8874. /**
  8875. * The position the shdow will be casted from.
  8876. */
  8877. position: Vector3;
  8878. /**
  8879. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8880. */
  8881. direction: Vector3;
  8882. /**
  8883. * The transformed position. Position of the light in world space taking parenting in account.
  8884. */
  8885. transformedPosition: Vector3;
  8886. /**
  8887. * The transformed direction. Direction of the light in world space taking parenting in account.
  8888. */
  8889. transformedDirection: Vector3;
  8890. /**
  8891. * The friendly name of the light in the scene.
  8892. */
  8893. name: string;
  8894. /**
  8895. * Defines the shadow projection clipping minimum z value.
  8896. */
  8897. shadowMinZ: number;
  8898. /**
  8899. * Defines the shadow projection clipping maximum z value.
  8900. */
  8901. shadowMaxZ: number;
  8902. /**
  8903. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8904. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8905. */
  8906. computeTransformedInformation(): boolean;
  8907. /**
  8908. * Gets the scene the light belongs to.
  8909. * @returns The scene
  8910. */
  8911. getScene(): Scene;
  8912. /**
  8913. * Callback defining a custom Projection Matrix Builder.
  8914. * This can be used to override the default projection matrix computation.
  8915. */
  8916. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8917. /**
  8918. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8919. * @param matrix The materix to updated with the projection information
  8920. * @param viewMatrix The transform matrix of the light
  8921. * @param renderList The list of mesh to render in the map
  8922. * @returns The current light
  8923. */
  8924. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8925. /**
  8926. * Gets the current depth scale used in ESM.
  8927. * @returns The scale
  8928. */
  8929. getDepthScale(): number;
  8930. /**
  8931. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8932. * @returns true if a cube texture needs to be use
  8933. */
  8934. needCube(): boolean;
  8935. /**
  8936. * Detects if the projection matrix requires to be recomputed this frame.
  8937. * @returns true if it requires to be recomputed otherwise, false.
  8938. */
  8939. needProjectionMatrixCompute(): boolean;
  8940. /**
  8941. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8942. */
  8943. forceProjectionMatrixCompute(): void;
  8944. /**
  8945. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8946. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8947. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8948. */
  8949. getShadowDirection(faceIndex?: number): Vector3;
  8950. /**
  8951. * Gets the minZ used for shadow according to both the scene and the light.
  8952. * @param activeCamera The camera we are returning the min for
  8953. * @returns the depth min z
  8954. */
  8955. getDepthMinZ(activeCamera: Camera): number;
  8956. /**
  8957. * Gets the maxZ used for shadow according to both the scene and the light.
  8958. * @param activeCamera The camera we are returning the max for
  8959. * @returns the depth max z
  8960. */
  8961. getDepthMaxZ(activeCamera: Camera): number;
  8962. }
  8963. /**
  8964. * Base implementation IShadowLight
  8965. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8966. */
  8967. export abstract class ShadowLight extends Light implements IShadowLight {
  8968. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8969. protected _position: Vector3;
  8970. protected _setPosition(value: Vector3): void;
  8971. /**
  8972. * Sets the position the shadow will be casted from. Also use as the light position for both
  8973. * point and spot lights.
  8974. */
  8975. get position(): Vector3;
  8976. /**
  8977. * Sets the position the shadow will be casted from. Also use as the light position for both
  8978. * point and spot lights.
  8979. */
  8980. set position(value: Vector3);
  8981. protected _direction: Vector3;
  8982. protected _setDirection(value: Vector3): void;
  8983. /**
  8984. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8985. * Also use as the light direction on spot and directional lights.
  8986. */
  8987. get direction(): Vector3;
  8988. /**
  8989. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8990. * Also use as the light direction on spot and directional lights.
  8991. */
  8992. set direction(value: Vector3);
  8993. protected _shadowMinZ: number;
  8994. /**
  8995. * Gets the shadow projection clipping minimum z value.
  8996. */
  8997. get shadowMinZ(): number;
  8998. /**
  8999. * Sets the shadow projection clipping minimum z value.
  9000. */
  9001. set shadowMinZ(value: number);
  9002. protected _shadowMaxZ: number;
  9003. /**
  9004. * Sets the shadow projection clipping maximum z value.
  9005. */
  9006. get shadowMaxZ(): number;
  9007. /**
  9008. * Gets the shadow projection clipping maximum z value.
  9009. */
  9010. set shadowMaxZ(value: number);
  9011. /**
  9012. * Callback defining a custom Projection Matrix Builder.
  9013. * This can be used to override the default projection matrix computation.
  9014. */
  9015. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9016. /**
  9017. * The transformed position. Position of the light in world space taking parenting in account.
  9018. */
  9019. transformedPosition: Vector3;
  9020. /**
  9021. * The transformed direction. Direction of the light in world space taking parenting in account.
  9022. */
  9023. transformedDirection: Vector3;
  9024. private _needProjectionMatrixCompute;
  9025. /**
  9026. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9027. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9028. */
  9029. computeTransformedInformation(): boolean;
  9030. /**
  9031. * Return the depth scale used for the shadow map.
  9032. * @returns the depth scale.
  9033. */
  9034. getDepthScale(): number;
  9035. /**
  9036. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9037. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9038. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9039. */
  9040. getShadowDirection(faceIndex?: number): Vector3;
  9041. /**
  9042. * Returns the ShadowLight absolute position in the World.
  9043. * @returns the position vector in world space
  9044. */
  9045. getAbsolutePosition(): Vector3;
  9046. /**
  9047. * Sets the ShadowLight direction toward the passed target.
  9048. * @param target The point to target in local space
  9049. * @returns the updated ShadowLight direction
  9050. */
  9051. setDirectionToTarget(target: Vector3): Vector3;
  9052. /**
  9053. * Returns the light rotation in euler definition.
  9054. * @returns the x y z rotation in local space.
  9055. */
  9056. getRotation(): Vector3;
  9057. /**
  9058. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9059. * @returns true if a cube texture needs to be use
  9060. */
  9061. needCube(): boolean;
  9062. /**
  9063. * Detects if the projection matrix requires to be recomputed this frame.
  9064. * @returns true if it requires to be recomputed otherwise, false.
  9065. */
  9066. needProjectionMatrixCompute(): boolean;
  9067. /**
  9068. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9069. */
  9070. forceProjectionMatrixCompute(): void;
  9071. /** @hidden */
  9072. _initCache(): void;
  9073. /** @hidden */
  9074. _isSynchronized(): boolean;
  9075. /**
  9076. * Computes the world matrix of the node
  9077. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9078. * @returns the world matrix
  9079. */
  9080. computeWorldMatrix(force?: boolean): Matrix;
  9081. /**
  9082. * Gets the minZ used for shadow according to both the scene and the light.
  9083. * @param activeCamera The camera we are returning the min for
  9084. * @returns the depth min z
  9085. */
  9086. getDepthMinZ(activeCamera: Camera): number;
  9087. /**
  9088. * Gets the maxZ used for shadow according to both the scene and the light.
  9089. * @param activeCamera The camera we are returning the max for
  9090. * @returns the depth max z
  9091. */
  9092. getDepthMaxZ(activeCamera: Camera): number;
  9093. /**
  9094. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9095. * @param matrix The materix to updated with the projection information
  9096. * @param viewMatrix The transform matrix of the light
  9097. * @param renderList The list of mesh to render in the map
  9098. * @returns The current light
  9099. */
  9100. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9101. }
  9102. }
  9103. declare module BABYLON {
  9104. /** @hidden */
  9105. export var packingFunctions: {
  9106. name: string;
  9107. shader: string;
  9108. };
  9109. }
  9110. declare module BABYLON {
  9111. /** @hidden */
  9112. export var bayerDitherFunctions: {
  9113. name: string;
  9114. shader: string;
  9115. };
  9116. }
  9117. declare module BABYLON {
  9118. /** @hidden */
  9119. export var shadowMapFragmentDeclaration: {
  9120. name: string;
  9121. shader: string;
  9122. };
  9123. }
  9124. declare module BABYLON {
  9125. /** @hidden */
  9126. export var clipPlaneFragmentDeclaration: {
  9127. name: string;
  9128. shader: string;
  9129. };
  9130. }
  9131. declare module BABYLON {
  9132. /** @hidden */
  9133. export var clipPlaneFragment: {
  9134. name: string;
  9135. shader: string;
  9136. };
  9137. }
  9138. declare module BABYLON {
  9139. /** @hidden */
  9140. export var shadowMapFragment: {
  9141. name: string;
  9142. shader: string;
  9143. };
  9144. }
  9145. declare module BABYLON {
  9146. /** @hidden */
  9147. export var shadowMapPixelShader: {
  9148. name: string;
  9149. shader: string;
  9150. };
  9151. }
  9152. declare module BABYLON {
  9153. /** @hidden */
  9154. export var bonesDeclaration: {
  9155. name: string;
  9156. shader: string;
  9157. };
  9158. }
  9159. declare module BABYLON {
  9160. /** @hidden */
  9161. export var morphTargetsVertexGlobalDeclaration: {
  9162. name: string;
  9163. shader: string;
  9164. };
  9165. }
  9166. declare module BABYLON {
  9167. /** @hidden */
  9168. export var morphTargetsVertexDeclaration: {
  9169. name: string;
  9170. shader: string;
  9171. };
  9172. }
  9173. declare module BABYLON {
  9174. /** @hidden */
  9175. export var instancesDeclaration: {
  9176. name: string;
  9177. shader: string;
  9178. };
  9179. }
  9180. declare module BABYLON {
  9181. /** @hidden */
  9182. export var helperFunctions: {
  9183. name: string;
  9184. shader: string;
  9185. };
  9186. }
  9187. declare module BABYLON {
  9188. /** @hidden */
  9189. export var shadowMapVertexDeclaration: {
  9190. name: string;
  9191. shader: string;
  9192. };
  9193. }
  9194. declare module BABYLON {
  9195. /** @hidden */
  9196. export var clipPlaneVertexDeclaration: {
  9197. name: string;
  9198. shader: string;
  9199. };
  9200. }
  9201. declare module BABYLON {
  9202. /** @hidden */
  9203. export var morphTargetsVertex: {
  9204. name: string;
  9205. shader: string;
  9206. };
  9207. }
  9208. declare module BABYLON {
  9209. /** @hidden */
  9210. export var instancesVertex: {
  9211. name: string;
  9212. shader: string;
  9213. };
  9214. }
  9215. declare module BABYLON {
  9216. /** @hidden */
  9217. export var bonesVertex: {
  9218. name: string;
  9219. shader: string;
  9220. };
  9221. }
  9222. declare module BABYLON {
  9223. /** @hidden */
  9224. export var shadowMapVertexNormalBias: {
  9225. name: string;
  9226. shader: string;
  9227. };
  9228. }
  9229. declare module BABYLON {
  9230. /** @hidden */
  9231. export var shadowMapVertexMetric: {
  9232. name: string;
  9233. shader: string;
  9234. };
  9235. }
  9236. declare module BABYLON {
  9237. /** @hidden */
  9238. export var clipPlaneVertex: {
  9239. name: string;
  9240. shader: string;
  9241. };
  9242. }
  9243. declare module BABYLON {
  9244. /** @hidden */
  9245. export var shadowMapVertexShader: {
  9246. name: string;
  9247. shader: string;
  9248. };
  9249. }
  9250. declare module BABYLON {
  9251. /** @hidden */
  9252. export var depthBoxBlurPixelShader: {
  9253. name: string;
  9254. shader: string;
  9255. };
  9256. }
  9257. declare module BABYLON {
  9258. /** @hidden */
  9259. export var shadowMapFragmentSoftTransparentShadow: {
  9260. name: string;
  9261. shader: string;
  9262. };
  9263. }
  9264. declare module BABYLON {
  9265. /**
  9266. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9267. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9268. */
  9269. export class EffectFallbacks implements IEffectFallbacks {
  9270. private _defines;
  9271. private _currentRank;
  9272. private _maxRank;
  9273. private _mesh;
  9274. /**
  9275. * Removes the fallback from the bound mesh.
  9276. */
  9277. unBindMesh(): void;
  9278. /**
  9279. * Adds a fallback on the specified property.
  9280. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9281. * @param define The name of the define in the shader
  9282. */
  9283. addFallback(rank: number, define: string): void;
  9284. /**
  9285. * Sets the mesh to use CPU skinning when needing to fallback.
  9286. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9287. * @param mesh The mesh to use the fallbacks.
  9288. */
  9289. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9290. /**
  9291. * Checks to see if more fallbacks are still availible.
  9292. */
  9293. get hasMoreFallbacks(): boolean;
  9294. /**
  9295. * Removes the defines that should be removed when falling back.
  9296. * @param currentDefines defines the current define statements for the shader.
  9297. * @param effect defines the current effect we try to compile
  9298. * @returns The resulting defines with defines of the current rank removed.
  9299. */
  9300. reduce(currentDefines: string, effect: Effect): string;
  9301. }
  9302. }
  9303. declare module BABYLON {
  9304. /**
  9305. * Interface used to define Action
  9306. */
  9307. export interface IAction {
  9308. /**
  9309. * Trigger for the action
  9310. */
  9311. trigger: number;
  9312. /** Options of the trigger */
  9313. triggerOptions: any;
  9314. /**
  9315. * Gets the trigger parameters
  9316. * @returns the trigger parameters
  9317. */
  9318. getTriggerParameter(): any;
  9319. /**
  9320. * Internal only - executes current action event
  9321. * @hidden
  9322. */
  9323. _executeCurrent(evt?: ActionEvent): void;
  9324. /**
  9325. * Serialize placeholder for child classes
  9326. * @param parent of child
  9327. * @returns the serialized object
  9328. */
  9329. serialize(parent: any): any;
  9330. /**
  9331. * Internal only
  9332. * @hidden
  9333. */
  9334. _prepare(): void;
  9335. /**
  9336. * Internal only - manager for action
  9337. * @hidden
  9338. */
  9339. _actionManager: AbstractActionManager;
  9340. /**
  9341. * Adds action to chain of actions, may be a DoNothingAction
  9342. * @param action defines the next action to execute
  9343. * @returns The action passed in
  9344. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9345. */
  9346. then(action: IAction): IAction;
  9347. }
  9348. /**
  9349. * The action to be carried out following a trigger
  9350. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9351. */
  9352. export class Action implements IAction {
  9353. /** the trigger, with or without parameters, for the action */
  9354. triggerOptions: any;
  9355. /**
  9356. * Trigger for the action
  9357. */
  9358. trigger: number;
  9359. /**
  9360. * Internal only - manager for action
  9361. * @hidden
  9362. */
  9363. _actionManager: ActionManager;
  9364. private _nextActiveAction;
  9365. private _child;
  9366. private _condition?;
  9367. private _triggerParameter;
  9368. /**
  9369. * An event triggered prior to action being executed.
  9370. */
  9371. onBeforeExecuteObservable: Observable<Action>;
  9372. /**
  9373. * Creates a new Action
  9374. * @param triggerOptions the trigger, with or without parameters, for the action
  9375. * @param condition an optional determinant of action
  9376. */
  9377. constructor(
  9378. /** the trigger, with or without parameters, for the action */
  9379. triggerOptions: any, condition?: Condition);
  9380. /**
  9381. * Internal only
  9382. * @hidden
  9383. */
  9384. _prepare(): void;
  9385. /**
  9386. * Gets the trigger parameters
  9387. * @returns the trigger parameters
  9388. */
  9389. getTriggerParameter(): any;
  9390. /**
  9391. * Internal only - executes current action event
  9392. * @hidden
  9393. */
  9394. _executeCurrent(evt?: ActionEvent): void;
  9395. /**
  9396. * Execute placeholder for child classes
  9397. * @param evt optional action event
  9398. */
  9399. execute(evt?: ActionEvent): void;
  9400. /**
  9401. * Skips to next active action
  9402. */
  9403. skipToNextActiveAction(): void;
  9404. /**
  9405. * Adds action to chain of actions, may be a DoNothingAction
  9406. * @param action defines the next action to execute
  9407. * @returns The action passed in
  9408. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9409. */
  9410. then(action: Action): Action;
  9411. /**
  9412. * Internal only
  9413. * @hidden
  9414. */
  9415. _getProperty(propertyPath: string): string;
  9416. /**
  9417. * Internal only
  9418. * @hidden
  9419. */
  9420. _getEffectiveTarget(target: any, propertyPath: string): any;
  9421. /**
  9422. * Serialize placeholder for child classes
  9423. * @param parent of child
  9424. * @returns the serialized object
  9425. */
  9426. serialize(parent: any): any;
  9427. /**
  9428. * Internal only called by serialize
  9429. * @hidden
  9430. */
  9431. protected _serialize(serializedAction: any, parent?: any): any;
  9432. /**
  9433. * Internal only
  9434. * @hidden
  9435. */
  9436. static _SerializeValueAsString: (value: any) => string;
  9437. /**
  9438. * Internal only
  9439. * @hidden
  9440. */
  9441. static _GetTargetProperty: (target: Node | Scene) => {
  9442. name: string;
  9443. targetType: string;
  9444. value: string;
  9445. };
  9446. }
  9447. }
  9448. declare module BABYLON {
  9449. /**
  9450. * A Condition applied to an Action
  9451. */
  9452. export class Condition {
  9453. /**
  9454. * Internal only - manager for action
  9455. * @hidden
  9456. */
  9457. _actionManager: ActionManager;
  9458. /**
  9459. * Internal only
  9460. * @hidden
  9461. */
  9462. _evaluationId: number;
  9463. /**
  9464. * Internal only
  9465. * @hidden
  9466. */
  9467. _currentResult: boolean;
  9468. /**
  9469. * Creates a new Condition
  9470. * @param actionManager the manager of the action the condition is applied to
  9471. */
  9472. constructor(actionManager: ActionManager);
  9473. /**
  9474. * Check if the current condition is valid
  9475. * @returns a boolean
  9476. */
  9477. isValid(): boolean;
  9478. /**
  9479. * Internal only
  9480. * @hidden
  9481. */
  9482. _getProperty(propertyPath: string): string;
  9483. /**
  9484. * Internal only
  9485. * @hidden
  9486. */
  9487. _getEffectiveTarget(target: any, propertyPath: string): any;
  9488. /**
  9489. * Serialize placeholder for child classes
  9490. * @returns the serialized object
  9491. */
  9492. serialize(): any;
  9493. /**
  9494. * Internal only
  9495. * @hidden
  9496. */
  9497. protected _serialize(serializedCondition: any): any;
  9498. }
  9499. /**
  9500. * Defines specific conditional operators as extensions of Condition
  9501. */
  9502. export class ValueCondition extends Condition {
  9503. /** path to specify the property of the target the conditional operator uses */
  9504. propertyPath: string;
  9505. /** the value compared by the conditional operator against the current value of the property */
  9506. value: any;
  9507. /** the conditional operator, default ValueCondition.IsEqual */
  9508. operator: number;
  9509. /**
  9510. * Internal only
  9511. * @hidden
  9512. */
  9513. private static _IsEqual;
  9514. /**
  9515. * Internal only
  9516. * @hidden
  9517. */
  9518. private static _IsDifferent;
  9519. /**
  9520. * Internal only
  9521. * @hidden
  9522. */
  9523. private static _IsGreater;
  9524. /**
  9525. * Internal only
  9526. * @hidden
  9527. */
  9528. private static _IsLesser;
  9529. /**
  9530. * returns the number for IsEqual
  9531. */
  9532. static get IsEqual(): number;
  9533. /**
  9534. * Returns the number for IsDifferent
  9535. */
  9536. static get IsDifferent(): number;
  9537. /**
  9538. * Returns the number for IsGreater
  9539. */
  9540. static get IsGreater(): number;
  9541. /**
  9542. * Returns the number for IsLesser
  9543. */
  9544. static get IsLesser(): number;
  9545. /**
  9546. * Internal only The action manager for the condition
  9547. * @hidden
  9548. */
  9549. _actionManager: ActionManager;
  9550. /**
  9551. * Internal only
  9552. * @hidden
  9553. */
  9554. private _target;
  9555. /**
  9556. * Internal only
  9557. * @hidden
  9558. */
  9559. private _effectiveTarget;
  9560. /**
  9561. * Internal only
  9562. * @hidden
  9563. */
  9564. private _property;
  9565. /**
  9566. * Creates a new ValueCondition
  9567. * @param actionManager manager for the action the condition applies to
  9568. * @param target for the action
  9569. * @param propertyPath path to specify the property of the target the conditional operator uses
  9570. * @param value the value compared by the conditional operator against the current value of the property
  9571. * @param operator the conditional operator, default ValueCondition.IsEqual
  9572. */
  9573. constructor(actionManager: ActionManager, target: any,
  9574. /** path to specify the property of the target the conditional operator uses */
  9575. propertyPath: string,
  9576. /** the value compared by the conditional operator against the current value of the property */
  9577. value: any,
  9578. /** the conditional operator, default ValueCondition.IsEqual */
  9579. operator?: number);
  9580. /**
  9581. * Compares the given value with the property value for the specified conditional operator
  9582. * @returns the result of the comparison
  9583. */
  9584. isValid(): boolean;
  9585. /**
  9586. * Serialize the ValueCondition into a JSON compatible object
  9587. * @returns serialization object
  9588. */
  9589. serialize(): any;
  9590. /**
  9591. * Gets the name of the conditional operator for the ValueCondition
  9592. * @param operator the conditional operator
  9593. * @returns the name
  9594. */
  9595. static GetOperatorName(operator: number): string;
  9596. }
  9597. /**
  9598. * Defines a predicate condition as an extension of Condition
  9599. */
  9600. export class PredicateCondition extends Condition {
  9601. /** defines the predicate function used to validate the condition */
  9602. predicate: () => boolean;
  9603. /**
  9604. * Internal only - manager for action
  9605. * @hidden
  9606. */
  9607. _actionManager: ActionManager;
  9608. /**
  9609. * Creates a new PredicateCondition
  9610. * @param actionManager manager for the action the condition applies to
  9611. * @param predicate defines the predicate function used to validate the condition
  9612. */
  9613. constructor(actionManager: ActionManager,
  9614. /** defines the predicate function used to validate the condition */
  9615. predicate: () => boolean);
  9616. /**
  9617. * @returns the validity of the predicate condition
  9618. */
  9619. isValid(): boolean;
  9620. }
  9621. /**
  9622. * Defines a state condition as an extension of Condition
  9623. */
  9624. export class StateCondition extends Condition {
  9625. /** Value to compare with target state */
  9626. value: string;
  9627. /**
  9628. * Internal only - manager for action
  9629. * @hidden
  9630. */
  9631. _actionManager: ActionManager;
  9632. /**
  9633. * Internal only
  9634. * @hidden
  9635. */
  9636. private _target;
  9637. /**
  9638. * Creates a new StateCondition
  9639. * @param actionManager manager for the action the condition applies to
  9640. * @param target of the condition
  9641. * @param value to compare with target state
  9642. */
  9643. constructor(actionManager: ActionManager, target: any,
  9644. /** Value to compare with target state */
  9645. value: string);
  9646. /**
  9647. * Gets a boolean indicating if the current condition is met
  9648. * @returns the validity of the state
  9649. */
  9650. isValid(): boolean;
  9651. /**
  9652. * Serialize the StateCondition into a JSON compatible object
  9653. * @returns serialization object
  9654. */
  9655. serialize(): any;
  9656. }
  9657. }
  9658. declare module BABYLON {
  9659. /**
  9660. * This defines an action responsible to toggle a boolean once triggered.
  9661. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9662. */
  9663. export class SwitchBooleanAction extends Action {
  9664. /**
  9665. * The path to the boolean property in the target object
  9666. */
  9667. propertyPath: string;
  9668. private _target;
  9669. private _effectiveTarget;
  9670. private _property;
  9671. /**
  9672. * Instantiate the action
  9673. * @param triggerOptions defines the trigger options
  9674. * @param target defines the object containing the boolean
  9675. * @param propertyPath defines the path to the boolean property in the target object
  9676. * @param condition defines the trigger related conditions
  9677. */
  9678. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9679. /** @hidden */
  9680. _prepare(): void;
  9681. /**
  9682. * Execute the action toggle the boolean value.
  9683. */
  9684. execute(): void;
  9685. /**
  9686. * Serializes the actions and its related information.
  9687. * @param parent defines the object to serialize in
  9688. * @returns the serialized object
  9689. */
  9690. serialize(parent: any): any;
  9691. }
  9692. /**
  9693. * This defines an action responsible to set a the state field of the target
  9694. * to a desired value once triggered.
  9695. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9696. */
  9697. export class SetStateAction extends Action {
  9698. /**
  9699. * The value to store in the state field.
  9700. */
  9701. value: string;
  9702. private _target;
  9703. /**
  9704. * Instantiate the action
  9705. * @param triggerOptions defines the trigger options
  9706. * @param target defines the object containing the state property
  9707. * @param value defines the value to store in the state field
  9708. * @param condition defines the trigger related conditions
  9709. */
  9710. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9711. /**
  9712. * Execute the action and store the value on the target state property.
  9713. */
  9714. execute(): void;
  9715. /**
  9716. * Serializes the actions and its related information.
  9717. * @param parent defines the object to serialize in
  9718. * @returns the serialized object
  9719. */
  9720. serialize(parent: any): any;
  9721. }
  9722. /**
  9723. * This defines an action responsible to set a property of the target
  9724. * to a desired value once triggered.
  9725. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9726. */
  9727. export class SetValueAction extends Action {
  9728. /**
  9729. * The path of the property to set in the target.
  9730. */
  9731. propertyPath: string;
  9732. /**
  9733. * The value to set in the property
  9734. */
  9735. value: any;
  9736. private _target;
  9737. private _effectiveTarget;
  9738. private _property;
  9739. /**
  9740. * Instantiate the action
  9741. * @param triggerOptions defines the trigger options
  9742. * @param target defines the object containing the property
  9743. * @param propertyPath defines the path of the property to set in the target
  9744. * @param value defines the value to set in the property
  9745. * @param condition defines the trigger related conditions
  9746. */
  9747. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9748. /** @hidden */
  9749. _prepare(): void;
  9750. /**
  9751. * Execute the action and set the targetted property to the desired value.
  9752. */
  9753. execute(): void;
  9754. /**
  9755. * Serializes the actions and its related information.
  9756. * @param parent defines the object to serialize in
  9757. * @returns the serialized object
  9758. */
  9759. serialize(parent: any): any;
  9760. }
  9761. /**
  9762. * This defines an action responsible to increment the target value
  9763. * to a desired value once triggered.
  9764. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9765. */
  9766. export class IncrementValueAction extends Action {
  9767. /**
  9768. * The path of the property to increment in the target.
  9769. */
  9770. propertyPath: string;
  9771. /**
  9772. * The value we should increment the property by.
  9773. */
  9774. value: any;
  9775. private _target;
  9776. private _effectiveTarget;
  9777. private _property;
  9778. /**
  9779. * Instantiate the action
  9780. * @param triggerOptions defines the trigger options
  9781. * @param target defines the object containing the property
  9782. * @param propertyPath defines the path of the property to increment in the target
  9783. * @param value defines the value value we should increment the property by
  9784. * @param condition defines the trigger related conditions
  9785. */
  9786. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9787. /** @hidden */
  9788. _prepare(): void;
  9789. /**
  9790. * Execute the action and increment the target of the value amount.
  9791. */
  9792. execute(): void;
  9793. /**
  9794. * Serializes the actions and its related information.
  9795. * @param parent defines the object to serialize in
  9796. * @returns the serialized object
  9797. */
  9798. serialize(parent: any): any;
  9799. }
  9800. /**
  9801. * This defines an action responsible to start an animation once triggered.
  9802. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9803. */
  9804. export class PlayAnimationAction extends Action {
  9805. /**
  9806. * Where the animation should start (animation frame)
  9807. */
  9808. from: number;
  9809. /**
  9810. * Where the animation should stop (animation frame)
  9811. */
  9812. to: number;
  9813. /**
  9814. * Define if the animation should loop or stop after the first play.
  9815. */
  9816. loop?: boolean;
  9817. private _target;
  9818. /**
  9819. * Instantiate the action
  9820. * @param triggerOptions defines the trigger options
  9821. * @param target defines the target animation or animation name
  9822. * @param from defines from where the animation should start (animation frame)
  9823. * @param end defines where the animation should stop (animation frame)
  9824. * @param loop defines if the animation should loop or stop after the first play
  9825. * @param condition defines the trigger related conditions
  9826. */
  9827. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  9828. /** @hidden */
  9829. _prepare(): void;
  9830. /**
  9831. * Execute the action and play the animation.
  9832. */
  9833. execute(): void;
  9834. /**
  9835. * Serializes the actions and its related information.
  9836. * @param parent defines the object to serialize in
  9837. * @returns the serialized object
  9838. */
  9839. serialize(parent: any): any;
  9840. }
  9841. /**
  9842. * This defines an action responsible to stop an animation once triggered.
  9843. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9844. */
  9845. export class StopAnimationAction extends Action {
  9846. private _target;
  9847. /**
  9848. * Instantiate the action
  9849. * @param triggerOptions defines the trigger options
  9850. * @param target defines the target animation or animation name
  9851. * @param condition defines the trigger related conditions
  9852. */
  9853. constructor(triggerOptions: any, target: any, condition?: Condition);
  9854. /** @hidden */
  9855. _prepare(): void;
  9856. /**
  9857. * Execute the action and stop the animation.
  9858. */
  9859. execute(): void;
  9860. /**
  9861. * Serializes the actions and its related information.
  9862. * @param parent defines the object to serialize in
  9863. * @returns the serialized object
  9864. */
  9865. serialize(parent: any): any;
  9866. }
  9867. /**
  9868. * This defines an action responsible that does nothing once triggered.
  9869. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9870. */
  9871. export class DoNothingAction extends Action {
  9872. /**
  9873. * Instantiate the action
  9874. * @param triggerOptions defines the trigger options
  9875. * @param condition defines the trigger related conditions
  9876. */
  9877. constructor(triggerOptions?: any, condition?: Condition);
  9878. /**
  9879. * Execute the action and do nothing.
  9880. */
  9881. execute(): void;
  9882. /**
  9883. * Serializes the actions and its related information.
  9884. * @param parent defines the object to serialize in
  9885. * @returns the serialized object
  9886. */
  9887. serialize(parent: any): any;
  9888. }
  9889. /**
  9890. * This defines an action responsible to trigger several actions once triggered.
  9891. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9892. */
  9893. export class CombineAction extends Action {
  9894. /**
  9895. * The list of aggregated animations to run.
  9896. */
  9897. children: Action[];
  9898. /**
  9899. * Instantiate the action
  9900. * @param triggerOptions defines the trigger options
  9901. * @param children defines the list of aggregated animations to run
  9902. * @param condition defines the trigger related conditions
  9903. */
  9904. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  9905. /** @hidden */
  9906. _prepare(): void;
  9907. /**
  9908. * Execute the action and executes all the aggregated actions.
  9909. */
  9910. execute(evt: ActionEvent): void;
  9911. /**
  9912. * Serializes the actions and its related information.
  9913. * @param parent defines the object to serialize in
  9914. * @returns the serialized object
  9915. */
  9916. serialize(parent: any): any;
  9917. }
  9918. /**
  9919. * This defines an action responsible to run code (external event) once triggered.
  9920. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9921. */
  9922. export class ExecuteCodeAction extends Action {
  9923. /**
  9924. * The callback function to run.
  9925. */
  9926. func: (evt: ActionEvent) => void;
  9927. /**
  9928. * Instantiate the action
  9929. * @param triggerOptions defines the trigger options
  9930. * @param func defines the callback function to run
  9931. * @param condition defines the trigger related conditions
  9932. */
  9933. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  9934. /**
  9935. * Execute the action and run the attached code.
  9936. */
  9937. execute(evt: ActionEvent): void;
  9938. }
  9939. /**
  9940. * This defines an action responsible to set the parent property of the target once triggered.
  9941. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9942. */
  9943. export class SetParentAction extends Action {
  9944. private _parent;
  9945. private _target;
  9946. /**
  9947. * Instantiate the action
  9948. * @param triggerOptions defines the trigger options
  9949. * @param target defines the target containing the parent property
  9950. * @param parent defines from where the animation should start (animation frame)
  9951. * @param condition defines the trigger related conditions
  9952. */
  9953. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  9954. /** @hidden */
  9955. _prepare(): void;
  9956. /**
  9957. * Execute the action and set the parent property.
  9958. */
  9959. execute(): void;
  9960. /**
  9961. * Serializes the actions and its related information.
  9962. * @param parent defines the object to serialize in
  9963. * @returns the serialized object
  9964. */
  9965. serialize(parent: any): any;
  9966. }
  9967. }
  9968. declare module BABYLON {
  9969. /**
  9970. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  9971. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  9972. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9973. */
  9974. export class ActionManager extends AbstractActionManager {
  9975. /**
  9976. * Nothing
  9977. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9978. */
  9979. static readonly NothingTrigger: number;
  9980. /**
  9981. * On pick
  9982. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9983. */
  9984. static readonly OnPickTrigger: number;
  9985. /**
  9986. * On left pick
  9987. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9988. */
  9989. static readonly OnLeftPickTrigger: number;
  9990. /**
  9991. * On right pick
  9992. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9993. */
  9994. static readonly OnRightPickTrigger: number;
  9995. /**
  9996. * On center pick
  9997. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9998. */
  9999. static readonly OnCenterPickTrigger: number;
  10000. /**
  10001. * On pick down
  10002. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10003. */
  10004. static readonly OnPickDownTrigger: number;
  10005. /**
  10006. * On double pick
  10007. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10008. */
  10009. static readonly OnDoublePickTrigger: number;
  10010. /**
  10011. * On pick up
  10012. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10013. */
  10014. static readonly OnPickUpTrigger: number;
  10015. /**
  10016. * On pick out.
  10017. * This trigger will only be raised if you also declared a OnPickDown
  10018. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10019. */
  10020. static readonly OnPickOutTrigger: number;
  10021. /**
  10022. * On long press
  10023. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10024. */
  10025. static readonly OnLongPressTrigger: number;
  10026. /**
  10027. * On pointer over
  10028. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10029. */
  10030. static readonly OnPointerOverTrigger: number;
  10031. /**
  10032. * On pointer out
  10033. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10034. */
  10035. static readonly OnPointerOutTrigger: number;
  10036. /**
  10037. * On every frame
  10038. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10039. */
  10040. static readonly OnEveryFrameTrigger: number;
  10041. /**
  10042. * On intersection enter
  10043. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10044. */
  10045. static readonly OnIntersectionEnterTrigger: number;
  10046. /**
  10047. * On intersection exit
  10048. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10049. */
  10050. static readonly OnIntersectionExitTrigger: number;
  10051. /**
  10052. * On key down
  10053. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10054. */
  10055. static readonly OnKeyDownTrigger: number;
  10056. /**
  10057. * On key up
  10058. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10059. */
  10060. static readonly OnKeyUpTrigger: number;
  10061. private _scene;
  10062. /**
  10063. * Creates a new action manager
  10064. * @param scene defines the hosting scene
  10065. */
  10066. constructor(scene: Scene);
  10067. /**
  10068. * Releases all associated resources
  10069. */
  10070. dispose(): void;
  10071. /**
  10072. * Gets hosting scene
  10073. * @returns the hosting scene
  10074. */
  10075. getScene(): Scene;
  10076. /**
  10077. * Does this action manager handles actions of any of the given triggers
  10078. * @param triggers defines the triggers to be tested
  10079. * @return a boolean indicating whether one (or more) of the triggers is handled
  10080. */
  10081. hasSpecificTriggers(triggers: number[]): boolean;
  10082. /**
  10083. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10084. * speed.
  10085. * @param triggerA defines the trigger to be tested
  10086. * @param triggerB defines the trigger to be tested
  10087. * @return a boolean indicating whether one (or more) of the triggers is handled
  10088. */
  10089. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10090. /**
  10091. * Does this action manager handles actions of a given trigger
  10092. * @param trigger defines the trigger to be tested
  10093. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10094. * @return whether the trigger is handled
  10095. */
  10096. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10097. /**
  10098. * Does this action manager has pointer triggers
  10099. */
  10100. get hasPointerTriggers(): boolean;
  10101. /**
  10102. * Does this action manager has pick triggers
  10103. */
  10104. get hasPickTriggers(): boolean;
  10105. /**
  10106. * Registers an action to this action manager
  10107. * @param action defines the action to be registered
  10108. * @return the action amended (prepared) after registration
  10109. */
  10110. registerAction(action: IAction): Nullable<IAction>;
  10111. /**
  10112. * Unregisters an action to this action manager
  10113. * @param action defines the action to be unregistered
  10114. * @return a boolean indicating whether the action has been unregistered
  10115. */
  10116. unregisterAction(action: IAction): Boolean;
  10117. /**
  10118. * Process a specific trigger
  10119. * @param trigger defines the trigger to process
  10120. * @param evt defines the event details to be processed
  10121. */
  10122. processTrigger(trigger: number, evt?: IActionEvent): void;
  10123. /** @hidden */
  10124. _getEffectiveTarget(target: any, propertyPath: string): any;
  10125. /** @hidden */
  10126. _getProperty(propertyPath: string): string;
  10127. /**
  10128. * Serialize this manager to a JSON object
  10129. * @param name defines the property name to store this manager
  10130. * @returns a JSON representation of this manager
  10131. */
  10132. serialize(name: string): any;
  10133. /**
  10134. * Creates a new ActionManager from a JSON data
  10135. * @param parsedActions defines the JSON data to read from
  10136. * @param object defines the hosting mesh
  10137. * @param scene defines the hosting scene
  10138. */
  10139. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10140. /**
  10141. * Get a trigger name by index
  10142. * @param trigger defines the trigger index
  10143. * @returns a trigger name
  10144. */
  10145. static GetTriggerName(trigger: number): string;
  10146. }
  10147. }
  10148. declare module BABYLON {
  10149. /**
  10150. * Class used to represent a sprite
  10151. * @see http://doc.babylonjs.com/babylon101/sprites
  10152. */
  10153. export class Sprite implements IAnimatable {
  10154. /** defines the name */
  10155. name: string;
  10156. /** Gets or sets the current world position */
  10157. position: Vector3;
  10158. /** Gets or sets the main color */
  10159. color: Color4;
  10160. /** Gets or sets the width */
  10161. width: number;
  10162. /** Gets or sets the height */
  10163. height: number;
  10164. /** Gets or sets rotation angle */
  10165. angle: number;
  10166. /** Gets or sets the cell index in the sprite sheet */
  10167. cellIndex: number;
  10168. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10169. cellRef: string;
  10170. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10171. invertU: boolean;
  10172. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10173. invertV: boolean;
  10174. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10175. disposeWhenFinishedAnimating: boolean;
  10176. /** Gets the list of attached animations */
  10177. animations: Nullable<Array<Animation>>;
  10178. /** Gets or sets a boolean indicating if the sprite can be picked */
  10179. isPickable: boolean;
  10180. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10181. useAlphaForPicking: boolean;
  10182. /** @hidden */
  10183. _xOffset: number;
  10184. /** @hidden */
  10185. _yOffset: number;
  10186. /** @hidden */
  10187. _xSize: number;
  10188. /** @hidden */
  10189. _ySize: number;
  10190. /**
  10191. * Gets or sets the associated action manager
  10192. */
  10193. actionManager: Nullable<ActionManager>;
  10194. /**
  10195. * An event triggered when the control has been disposed
  10196. */
  10197. onDisposeObservable: Observable<Sprite>;
  10198. private _animationStarted;
  10199. private _loopAnimation;
  10200. private _fromIndex;
  10201. private _toIndex;
  10202. private _delay;
  10203. private _direction;
  10204. private _manager;
  10205. private _time;
  10206. private _onAnimationEnd;
  10207. /**
  10208. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10209. */
  10210. isVisible: boolean;
  10211. /**
  10212. * Gets or sets the sprite size
  10213. */
  10214. get size(): number;
  10215. set size(value: number);
  10216. /**
  10217. * Returns a boolean indicating if the animation is started
  10218. */
  10219. get animationStarted(): boolean;
  10220. /**
  10221. * Gets or sets the unique id of the sprite
  10222. */
  10223. uniqueId: number;
  10224. /**
  10225. * Gets the manager of this sprite
  10226. */
  10227. get manager(): ISpriteManager;
  10228. /**
  10229. * Creates a new Sprite
  10230. * @param name defines the name
  10231. * @param manager defines the manager
  10232. */
  10233. constructor(
  10234. /** defines the name */
  10235. name: string, manager: ISpriteManager);
  10236. /**
  10237. * Returns the string "Sprite"
  10238. * @returns "Sprite"
  10239. */
  10240. getClassName(): string;
  10241. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10242. get fromIndex(): number;
  10243. set fromIndex(value: number);
  10244. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10245. get toIndex(): number;
  10246. set toIndex(value: number);
  10247. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10248. get loopAnimation(): boolean;
  10249. set loopAnimation(value: boolean);
  10250. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10251. get delay(): number;
  10252. set delay(value: number);
  10253. /**
  10254. * Starts an animation
  10255. * @param from defines the initial key
  10256. * @param to defines the end key
  10257. * @param loop defines if the animation must loop
  10258. * @param delay defines the start delay (in ms)
  10259. * @param onAnimationEnd defines a callback to call when animation ends
  10260. */
  10261. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  10262. /** Stops current animation (if any) */
  10263. stopAnimation(): void;
  10264. /** @hidden */
  10265. _animate(deltaTime: number): void;
  10266. /** Release associated resources */
  10267. dispose(): void;
  10268. }
  10269. }
  10270. declare module BABYLON {
  10271. /**
  10272. * Information about the result of picking within a scene
  10273. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10274. */
  10275. export class PickingInfo {
  10276. /** @hidden */
  10277. _pickingUnavailable: boolean;
  10278. /**
  10279. * If the pick collided with an object
  10280. */
  10281. hit: boolean;
  10282. /**
  10283. * Distance away where the pick collided
  10284. */
  10285. distance: number;
  10286. /**
  10287. * The location of pick collision
  10288. */
  10289. pickedPoint: Nullable<Vector3>;
  10290. /**
  10291. * The mesh corresponding the the pick collision
  10292. */
  10293. pickedMesh: Nullable<AbstractMesh>;
  10294. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10295. bu: number;
  10296. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10297. bv: number;
  10298. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10299. faceId: number;
  10300. /** Id of the the submesh that was picked */
  10301. subMeshId: number;
  10302. /** If a sprite was picked, this will be the sprite the pick collided with */
  10303. pickedSprite: Nullable<Sprite>;
  10304. /**
  10305. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10306. */
  10307. originMesh: Nullable<AbstractMesh>;
  10308. /**
  10309. * The ray that was used to perform the picking.
  10310. */
  10311. ray: Nullable<Ray>;
  10312. /**
  10313. * Gets the normal correspodning to the face the pick collided with
  10314. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10315. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10316. * @returns The normal correspodning to the face the pick collided with
  10317. */
  10318. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10319. /**
  10320. * Gets the texture coordinates of where the pick occured
  10321. * @returns the vector containing the coordnates of the texture
  10322. */
  10323. getTextureCoordinates(): Nullable<Vector2>;
  10324. }
  10325. }
  10326. declare module BABYLON {
  10327. /**
  10328. * Class representing a ray with position and direction
  10329. */
  10330. export class Ray {
  10331. /** origin point */
  10332. origin: Vector3;
  10333. /** direction */
  10334. direction: Vector3;
  10335. /** length of the ray */
  10336. length: number;
  10337. private static readonly TmpVector3;
  10338. private _tmpRay;
  10339. /**
  10340. * Creates a new ray
  10341. * @param origin origin point
  10342. * @param direction direction
  10343. * @param length length of the ray
  10344. */
  10345. constructor(
  10346. /** origin point */
  10347. origin: Vector3,
  10348. /** direction */
  10349. direction: Vector3,
  10350. /** length of the ray */
  10351. length?: number);
  10352. /**
  10353. * Checks if the ray intersects a box
  10354. * This does not account for the ray lenght by design to improve perfs.
  10355. * @param minimum bound of the box
  10356. * @param maximum bound of the box
  10357. * @param intersectionTreshold extra extend to be added to the box in all direction
  10358. * @returns if the box was hit
  10359. */
  10360. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10361. /**
  10362. * Checks if the ray intersects a box
  10363. * This does not account for the ray lenght by design to improve perfs.
  10364. * @param box the bounding box to check
  10365. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10366. * @returns if the box was hit
  10367. */
  10368. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10369. /**
  10370. * If the ray hits a sphere
  10371. * @param sphere the bounding sphere to check
  10372. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10373. * @returns true if it hits the sphere
  10374. */
  10375. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10376. /**
  10377. * If the ray hits a triange
  10378. * @param vertex0 triangle vertex
  10379. * @param vertex1 triangle vertex
  10380. * @param vertex2 triangle vertex
  10381. * @returns intersection information if hit
  10382. */
  10383. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10384. /**
  10385. * Checks if ray intersects a plane
  10386. * @param plane the plane to check
  10387. * @returns the distance away it was hit
  10388. */
  10389. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10390. /**
  10391. * Calculate the intercept of a ray on a given axis
  10392. * @param axis to check 'x' | 'y' | 'z'
  10393. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10394. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10395. */
  10396. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10397. /**
  10398. * Checks if ray intersects a mesh
  10399. * @param mesh the mesh to check
  10400. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10401. * @returns picking info of the intersecton
  10402. */
  10403. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10404. /**
  10405. * Checks if ray intersects a mesh
  10406. * @param meshes the meshes to check
  10407. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10408. * @param results array to store result in
  10409. * @returns Array of picking infos
  10410. */
  10411. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10412. private _comparePickingInfo;
  10413. private static smallnum;
  10414. private static rayl;
  10415. /**
  10416. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10417. * @param sega the first point of the segment to test the intersection against
  10418. * @param segb the second point of the segment to test the intersection against
  10419. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10420. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10421. */
  10422. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10423. /**
  10424. * Update the ray from viewport position
  10425. * @param x position
  10426. * @param y y position
  10427. * @param viewportWidth viewport width
  10428. * @param viewportHeight viewport height
  10429. * @param world world matrix
  10430. * @param view view matrix
  10431. * @param projection projection matrix
  10432. * @returns this ray updated
  10433. */
  10434. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10435. /**
  10436. * Creates a ray with origin and direction of 0,0,0
  10437. * @returns the new ray
  10438. */
  10439. static Zero(): Ray;
  10440. /**
  10441. * Creates a new ray from screen space and viewport
  10442. * @param x position
  10443. * @param y y position
  10444. * @param viewportWidth viewport width
  10445. * @param viewportHeight viewport height
  10446. * @param world world matrix
  10447. * @param view view matrix
  10448. * @param projection projection matrix
  10449. * @returns new ray
  10450. */
  10451. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10452. /**
  10453. * 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
  10454. * transformed to the given world matrix.
  10455. * @param origin The origin point
  10456. * @param end The end point
  10457. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10458. * @returns the new ray
  10459. */
  10460. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  10461. /**
  10462. * Transforms a ray by a matrix
  10463. * @param ray ray to transform
  10464. * @param matrix matrix to apply
  10465. * @returns the resulting new ray
  10466. */
  10467. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10468. /**
  10469. * Transforms a ray by a matrix
  10470. * @param ray ray to transform
  10471. * @param matrix matrix to apply
  10472. * @param result ray to store result in
  10473. */
  10474. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10475. /**
  10476. * Unproject a ray from screen space to object space
  10477. * @param sourceX defines the screen space x coordinate to use
  10478. * @param sourceY defines the screen space y coordinate to use
  10479. * @param viewportWidth defines the current width of the viewport
  10480. * @param viewportHeight defines the current height of the viewport
  10481. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10482. * @param view defines the view matrix to use
  10483. * @param projection defines the projection matrix to use
  10484. */
  10485. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10486. }
  10487. /**
  10488. * Type used to define predicate used to select faces when a mesh intersection is detected
  10489. */
  10490. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10491. interface Scene {
  10492. /** @hidden */
  10493. _tempPickingRay: Nullable<Ray>;
  10494. /** @hidden */
  10495. _cachedRayForTransform: Ray;
  10496. /** @hidden */
  10497. _pickWithRayInverseMatrix: Matrix;
  10498. /** @hidden */
  10499. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10500. /** @hidden */
  10501. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10502. }
  10503. }
  10504. declare module BABYLON {
  10505. /**
  10506. * Groups all the scene component constants in one place to ease maintenance.
  10507. * @hidden
  10508. */
  10509. export class SceneComponentConstants {
  10510. static readonly NAME_EFFECTLAYER: string;
  10511. static readonly NAME_LAYER: string;
  10512. static readonly NAME_LENSFLARESYSTEM: string;
  10513. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10514. static readonly NAME_PARTICLESYSTEM: string;
  10515. static readonly NAME_GAMEPAD: string;
  10516. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10517. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10518. static readonly NAME_DEPTHRENDERER: string;
  10519. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10520. static readonly NAME_SPRITE: string;
  10521. static readonly NAME_OUTLINERENDERER: string;
  10522. static readonly NAME_PROCEDURALTEXTURE: string;
  10523. static readonly NAME_SHADOWGENERATOR: string;
  10524. static readonly NAME_OCTREE: string;
  10525. static readonly NAME_PHYSICSENGINE: string;
  10526. static readonly NAME_AUDIO: string;
  10527. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10528. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10529. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10530. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10531. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10532. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10533. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10534. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10535. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10536. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10537. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10538. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10539. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10540. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10541. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10542. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10543. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10544. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10545. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10546. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10547. static readonly STEP_AFTERRENDER_AUDIO: number;
  10548. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10549. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10550. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10551. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10552. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10553. static readonly STEP_POINTERMOVE_SPRITE: number;
  10554. static readonly STEP_POINTERDOWN_SPRITE: number;
  10555. static readonly STEP_POINTERUP_SPRITE: number;
  10556. }
  10557. /**
  10558. * This represents a scene component.
  10559. *
  10560. * This is used to decouple the dependency the scene is having on the different workloads like
  10561. * layers, post processes...
  10562. */
  10563. export interface ISceneComponent {
  10564. /**
  10565. * The name of the component. Each component must have a unique name.
  10566. */
  10567. name: string;
  10568. /**
  10569. * The scene the component belongs to.
  10570. */
  10571. scene: Scene;
  10572. /**
  10573. * Register the component to one instance of a scene.
  10574. */
  10575. register(): void;
  10576. /**
  10577. * Rebuilds the elements related to this component in case of
  10578. * context lost for instance.
  10579. */
  10580. rebuild(): void;
  10581. /**
  10582. * Disposes the component and the associated ressources.
  10583. */
  10584. dispose(): void;
  10585. }
  10586. /**
  10587. * This represents a SERIALIZABLE scene component.
  10588. *
  10589. * This extends Scene Component to add Serialization methods on top.
  10590. */
  10591. export interface ISceneSerializableComponent extends ISceneComponent {
  10592. /**
  10593. * Adds all the elements from the container to the scene
  10594. * @param container the container holding the elements
  10595. */
  10596. addFromContainer(container: AbstractScene): void;
  10597. /**
  10598. * Removes all the elements in the container from the scene
  10599. * @param container contains the elements to remove
  10600. * @param dispose if the removed element should be disposed (default: false)
  10601. */
  10602. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10603. /**
  10604. * Serializes the component data to the specified json object
  10605. * @param serializationObject The object to serialize to
  10606. */
  10607. serialize(serializationObject: any): void;
  10608. }
  10609. /**
  10610. * Strong typing of a Mesh related stage step action
  10611. */
  10612. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10613. /**
  10614. * Strong typing of a Evaluate Sub Mesh related stage step action
  10615. */
  10616. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10617. /**
  10618. * Strong typing of a Active Mesh related stage step action
  10619. */
  10620. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10621. /**
  10622. * Strong typing of a Camera related stage step action
  10623. */
  10624. export type CameraStageAction = (camera: Camera) => void;
  10625. /**
  10626. * Strong typing of a Camera Frame buffer related stage step action
  10627. */
  10628. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10629. /**
  10630. * Strong typing of a Render Target related stage step action
  10631. */
  10632. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10633. /**
  10634. * Strong typing of a RenderingGroup related stage step action
  10635. */
  10636. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10637. /**
  10638. * Strong typing of a Mesh Render related stage step action
  10639. */
  10640. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10641. /**
  10642. * Strong typing of a simple stage step action
  10643. */
  10644. export type SimpleStageAction = () => void;
  10645. /**
  10646. * Strong typing of a render target action.
  10647. */
  10648. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10649. /**
  10650. * Strong typing of a pointer move action.
  10651. */
  10652. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10653. /**
  10654. * Strong typing of a pointer up/down action.
  10655. */
  10656. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10657. /**
  10658. * Representation of a stage in the scene (Basically a list of ordered steps)
  10659. * @hidden
  10660. */
  10661. export class Stage<T extends Function> extends Array<{
  10662. index: number;
  10663. component: ISceneComponent;
  10664. action: T;
  10665. }> {
  10666. /**
  10667. * Hide ctor from the rest of the world.
  10668. * @param items The items to add.
  10669. */
  10670. private constructor();
  10671. /**
  10672. * Creates a new Stage.
  10673. * @returns A new instance of a Stage
  10674. */
  10675. static Create<T extends Function>(): Stage<T>;
  10676. /**
  10677. * Registers a step in an ordered way in the targeted stage.
  10678. * @param index Defines the position to register the step in
  10679. * @param component Defines the component attached to the step
  10680. * @param action Defines the action to launch during the step
  10681. */
  10682. registerStep(index: number, component: ISceneComponent, action: T): void;
  10683. /**
  10684. * Clears all the steps from the stage.
  10685. */
  10686. clear(): void;
  10687. }
  10688. }
  10689. declare module BABYLON {
  10690. interface Scene {
  10691. /** @hidden */
  10692. _pointerOverSprite: Nullable<Sprite>;
  10693. /** @hidden */
  10694. _pickedDownSprite: Nullable<Sprite>;
  10695. /** @hidden */
  10696. _tempSpritePickingRay: Nullable<Ray>;
  10697. /**
  10698. * All of the sprite managers added to this scene
  10699. * @see http://doc.babylonjs.com/babylon101/sprites
  10700. */
  10701. spriteManagers: Array<ISpriteManager>;
  10702. /**
  10703. * An event triggered when sprites rendering is about to start
  10704. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10705. */
  10706. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10707. /**
  10708. * An event triggered when sprites rendering is done
  10709. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10710. */
  10711. onAfterSpritesRenderingObservable: Observable<Scene>;
  10712. /** @hidden */
  10713. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10714. /** Launch a ray to try to pick a sprite in the scene
  10715. * @param x position on screen
  10716. * @param y position on screen
  10717. * @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
  10718. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10719. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10720. * @returns a PickingInfo
  10721. */
  10722. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10723. /** Use the given ray to pick a sprite in the scene
  10724. * @param ray The ray (in world space) to use to pick meshes
  10725. * @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
  10726. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10727. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10728. * @returns a PickingInfo
  10729. */
  10730. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10731. /** @hidden */
  10732. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10733. /** Launch a ray to try to pick sprites in the scene
  10734. * @param x position on screen
  10735. * @param y position on screen
  10736. * @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
  10737. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10738. * @returns a PickingInfo array
  10739. */
  10740. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10741. /** Use the given ray to pick sprites in the scene
  10742. * @param ray The ray (in world space) to use to pick meshes
  10743. * @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
  10744. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10745. * @returns a PickingInfo array
  10746. */
  10747. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10748. /**
  10749. * Force the sprite under the pointer
  10750. * @param sprite defines the sprite to use
  10751. */
  10752. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10753. /**
  10754. * Gets the sprite under the pointer
  10755. * @returns a Sprite or null if no sprite is under the pointer
  10756. */
  10757. getPointerOverSprite(): Nullable<Sprite>;
  10758. }
  10759. /**
  10760. * Defines the sprite scene component responsible to manage sprites
  10761. * in a given scene.
  10762. */
  10763. export class SpriteSceneComponent implements ISceneComponent {
  10764. /**
  10765. * The component name helpfull to identify the component in the list of scene components.
  10766. */
  10767. readonly name: string;
  10768. /**
  10769. * The scene the component belongs to.
  10770. */
  10771. scene: Scene;
  10772. /** @hidden */
  10773. private _spritePredicate;
  10774. /**
  10775. * Creates a new instance of the component for the given scene
  10776. * @param scene Defines the scene to register the component in
  10777. */
  10778. constructor(scene: Scene);
  10779. /**
  10780. * Registers the component in a given scene
  10781. */
  10782. register(): void;
  10783. /**
  10784. * Rebuilds the elements related to this component in case of
  10785. * context lost for instance.
  10786. */
  10787. rebuild(): void;
  10788. /**
  10789. * Disposes the component and the associated ressources.
  10790. */
  10791. dispose(): void;
  10792. private _pickSpriteButKeepRay;
  10793. private _pointerMove;
  10794. private _pointerDown;
  10795. private _pointerUp;
  10796. }
  10797. }
  10798. declare module BABYLON {
  10799. /** @hidden */
  10800. export var fogFragmentDeclaration: {
  10801. name: string;
  10802. shader: string;
  10803. };
  10804. }
  10805. declare module BABYLON {
  10806. /** @hidden */
  10807. export var fogFragment: {
  10808. name: string;
  10809. shader: string;
  10810. };
  10811. }
  10812. declare module BABYLON {
  10813. /** @hidden */
  10814. export var spritesPixelShader: {
  10815. name: string;
  10816. shader: string;
  10817. };
  10818. }
  10819. declare module BABYLON {
  10820. /** @hidden */
  10821. export var fogVertexDeclaration: {
  10822. name: string;
  10823. shader: string;
  10824. };
  10825. }
  10826. declare module BABYLON {
  10827. /** @hidden */
  10828. export var spritesVertexShader: {
  10829. name: string;
  10830. shader: string;
  10831. };
  10832. }
  10833. declare module BABYLON {
  10834. /**
  10835. * Defines the minimum interface to fullfil in order to be a sprite manager.
  10836. */
  10837. export interface ISpriteManager extends IDisposable {
  10838. /**
  10839. * Gets manager's name
  10840. */
  10841. name: string;
  10842. /**
  10843. * Restricts the camera to viewing objects with the same layerMask.
  10844. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  10845. */
  10846. layerMask: number;
  10847. /**
  10848. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  10849. */
  10850. isPickable: boolean;
  10851. /**
  10852. * Gets the hosting scene
  10853. */
  10854. scene: Scene;
  10855. /**
  10856. * Specifies the rendering group id for this mesh (0 by default)
  10857. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  10858. */
  10859. renderingGroupId: number;
  10860. /**
  10861. * Defines the list of sprites managed by the manager.
  10862. */
  10863. sprites: Array<Sprite>;
  10864. /**
  10865. * Gets or sets the spritesheet texture
  10866. */
  10867. texture: Texture;
  10868. /** Defines the default width of a cell in the spritesheet */
  10869. cellWidth: number;
  10870. /** Defines the default height of a cell in the spritesheet */
  10871. cellHeight: number;
  10872. /**
  10873. * Tests the intersection of a sprite with a specific ray.
  10874. * @param ray The ray we are sending to test the collision
  10875. * @param camera The camera space we are sending rays in
  10876. * @param predicate A predicate allowing excluding sprites from the list of object to test
  10877. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10878. * @returns picking info or null.
  10879. */
  10880. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10881. /**
  10882. * Intersects the sprites with a ray
  10883. * @param ray defines the ray to intersect with
  10884. * @param camera defines the current active camera
  10885. * @param predicate defines a predicate used to select candidate sprites
  10886. * @returns null if no hit or a PickingInfo array
  10887. */
  10888. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10889. /**
  10890. * Renders the list of sprites on screen.
  10891. */
  10892. render(): void;
  10893. }
  10894. /**
  10895. * Class used to manage multiple sprites on the same spritesheet
  10896. * @see http://doc.babylonjs.com/babylon101/sprites
  10897. */
  10898. export class SpriteManager implements ISpriteManager {
  10899. /** defines the manager's name */
  10900. name: string;
  10901. /** Gets the list of sprites */
  10902. sprites: Sprite[];
  10903. /** Gets or sets the rendering group id (0 by default) */
  10904. renderingGroupId: number;
  10905. /** Gets or sets camera layer mask */
  10906. layerMask: number;
  10907. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  10908. fogEnabled: boolean;
  10909. /** Gets or sets a boolean indicating if the sprites are pickable */
  10910. isPickable: boolean;
  10911. /** Defines the default width of a cell in the spritesheet */
  10912. cellWidth: number;
  10913. /** Defines the default height of a cell in the spritesheet */
  10914. cellHeight: number;
  10915. /** Associative array from JSON sprite data file */
  10916. private _cellData;
  10917. /** Array of sprite names from JSON sprite data file */
  10918. private _spriteMap;
  10919. /** True when packed cell data from JSON file is ready*/
  10920. private _packedAndReady;
  10921. private _textureContent;
  10922. /**
  10923. * An event triggered when the manager is disposed.
  10924. */
  10925. onDisposeObservable: Observable<SpriteManager>;
  10926. private _onDisposeObserver;
  10927. /**
  10928. * Callback called when the manager is disposed
  10929. */
  10930. set onDispose(callback: () => void);
  10931. private _capacity;
  10932. private _fromPacked;
  10933. private _spriteTexture;
  10934. private _epsilon;
  10935. private _scene;
  10936. private _vertexData;
  10937. private _buffer;
  10938. private _vertexBuffers;
  10939. private _indexBuffer;
  10940. private _effectBase;
  10941. private _effectFog;
  10942. /**
  10943. * Gets or sets the unique id of the sprite
  10944. */
  10945. uniqueId: number;
  10946. /**
  10947. * Gets the array of sprites
  10948. */
  10949. get children(): Sprite[];
  10950. /**
  10951. * Gets the hosting scene
  10952. */
  10953. get scene(): Scene;
  10954. /**
  10955. * Gets or sets the capacity of the manager
  10956. */
  10957. get capacity(): number;
  10958. set capacity(value: number);
  10959. /**
  10960. * Gets or sets the spritesheet texture
  10961. */
  10962. get texture(): Texture;
  10963. set texture(value: Texture);
  10964. private _blendMode;
  10965. /**
  10966. * Blend mode use to render the particle, it can be any of
  10967. * the static Constants.ALPHA_x properties provided in this class.
  10968. * Default value is Constants.ALPHA_COMBINE
  10969. */
  10970. get blendMode(): number;
  10971. set blendMode(blendMode: number);
  10972. /** Disables writing to the depth buffer when rendering the sprites.
  10973. * It can be handy to disable depth writing when using textures without alpha channel
  10974. * and setting some specific blend modes.
  10975. */
  10976. disableDepthWrite: boolean;
  10977. /**
  10978. * Creates a new sprite manager
  10979. * @param name defines the manager's name
  10980. * @param imgUrl defines the sprite sheet url
  10981. * @param capacity defines the maximum allowed number of sprites
  10982. * @param cellSize defines the size of a sprite cell
  10983. * @param scene defines the hosting scene
  10984. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  10985. * @param samplingMode defines the smapling mode to use with spritesheet
  10986. * @param fromPacked set to false; do not alter
  10987. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  10988. */
  10989. constructor(
  10990. /** defines the manager's name */
  10991. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  10992. /**
  10993. * Returns the string "SpriteManager"
  10994. * @returns "SpriteManager"
  10995. */
  10996. getClassName(): string;
  10997. private _makePacked;
  10998. private _appendSpriteVertex;
  10999. private _checkTextureAlpha;
  11000. /**
  11001. * Intersects the sprites with a ray
  11002. * @param ray defines the ray to intersect with
  11003. * @param camera defines the current active camera
  11004. * @param predicate defines a predicate used to select candidate sprites
  11005. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11006. * @returns null if no hit or a PickingInfo
  11007. */
  11008. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11009. /**
  11010. * Intersects the sprites with a ray
  11011. * @param ray defines the ray to intersect with
  11012. * @param camera defines the current active camera
  11013. * @param predicate defines a predicate used to select candidate sprites
  11014. * @returns null if no hit or a PickingInfo array
  11015. */
  11016. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11017. /**
  11018. * Render all child sprites
  11019. */
  11020. render(): void;
  11021. /**
  11022. * Release associated resources
  11023. */
  11024. dispose(): void;
  11025. }
  11026. }
  11027. declare module BABYLON {
  11028. /** Interface used by value gradients (color, factor, ...) */
  11029. export interface IValueGradient {
  11030. /**
  11031. * Gets or sets the gradient value (between 0 and 1)
  11032. */
  11033. gradient: number;
  11034. }
  11035. /** Class used to store color4 gradient */
  11036. export class ColorGradient implements IValueGradient {
  11037. /**
  11038. * Gets or sets the gradient value (between 0 and 1)
  11039. */
  11040. gradient: number;
  11041. /**
  11042. * Gets or sets first associated color
  11043. */
  11044. color1: Color4;
  11045. /**
  11046. * Gets or sets second associated color
  11047. */
  11048. color2?: Color4 | undefined;
  11049. /**
  11050. * Creates a new color4 gradient
  11051. * @param gradient gets or sets the gradient value (between 0 and 1)
  11052. * @param color1 gets or sets first associated color
  11053. * @param color2 gets or sets first second color
  11054. */
  11055. constructor(
  11056. /**
  11057. * Gets or sets the gradient value (between 0 and 1)
  11058. */
  11059. gradient: number,
  11060. /**
  11061. * Gets or sets first associated color
  11062. */
  11063. color1: Color4,
  11064. /**
  11065. * Gets or sets second associated color
  11066. */
  11067. color2?: Color4 | undefined);
  11068. /**
  11069. * Will get a color picked randomly between color1 and color2.
  11070. * If color2 is undefined then color1 will be used
  11071. * @param result defines the target Color4 to store the result in
  11072. */
  11073. getColorToRef(result: Color4): void;
  11074. }
  11075. /** Class used to store color 3 gradient */
  11076. export class Color3Gradient implements IValueGradient {
  11077. /**
  11078. * Gets or sets the gradient value (between 0 and 1)
  11079. */
  11080. gradient: number;
  11081. /**
  11082. * Gets or sets the associated color
  11083. */
  11084. color: Color3;
  11085. /**
  11086. * Creates a new color3 gradient
  11087. * @param gradient gets or sets the gradient value (between 0 and 1)
  11088. * @param color gets or sets associated color
  11089. */
  11090. constructor(
  11091. /**
  11092. * Gets or sets the gradient value (between 0 and 1)
  11093. */
  11094. gradient: number,
  11095. /**
  11096. * Gets or sets the associated color
  11097. */
  11098. color: Color3);
  11099. }
  11100. /** Class used to store factor gradient */
  11101. export class FactorGradient implements IValueGradient {
  11102. /**
  11103. * Gets or sets the gradient value (between 0 and 1)
  11104. */
  11105. gradient: number;
  11106. /**
  11107. * Gets or sets first associated factor
  11108. */
  11109. factor1: number;
  11110. /**
  11111. * Gets or sets second associated factor
  11112. */
  11113. factor2?: number | undefined;
  11114. /**
  11115. * Creates a new factor gradient
  11116. * @param gradient gets or sets the gradient value (between 0 and 1)
  11117. * @param factor1 gets or sets first associated factor
  11118. * @param factor2 gets or sets second associated factor
  11119. */
  11120. constructor(
  11121. /**
  11122. * Gets or sets the gradient value (between 0 and 1)
  11123. */
  11124. gradient: number,
  11125. /**
  11126. * Gets or sets first associated factor
  11127. */
  11128. factor1: number,
  11129. /**
  11130. * Gets or sets second associated factor
  11131. */
  11132. factor2?: number | undefined);
  11133. /**
  11134. * Will get a number picked randomly between factor1 and factor2.
  11135. * If factor2 is undefined then factor1 will be used
  11136. * @returns the picked number
  11137. */
  11138. getFactor(): number;
  11139. }
  11140. /**
  11141. * Helper used to simplify some generic gradient tasks
  11142. */
  11143. export class GradientHelper {
  11144. /**
  11145. * Gets the current gradient from an array of IValueGradient
  11146. * @param ratio defines the current ratio to get
  11147. * @param gradients defines the array of IValueGradient
  11148. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11149. */
  11150. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11151. }
  11152. }
  11153. declare module BABYLON {
  11154. interface ThinEngine {
  11155. /**
  11156. * Creates a dynamic texture
  11157. * @param width defines the width of the texture
  11158. * @param height defines the height of the texture
  11159. * @param generateMipMaps defines if the engine should generate the mip levels
  11160. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11161. * @returns the dynamic texture inside an InternalTexture
  11162. */
  11163. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  11164. /**
  11165. * Update the content of a dynamic texture
  11166. * @param texture defines the texture to update
  11167. * @param canvas defines the canvas containing the source
  11168. * @param invertY defines if data must be stored with Y axis inverted
  11169. * @param premulAlpha defines if alpha is stored as premultiplied
  11170. * @param format defines the format of the data
  11171. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  11172. */
  11173. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  11174. }
  11175. }
  11176. declare module BABYLON {
  11177. /**
  11178. * Helper class used to generate a canvas to manipulate images
  11179. */
  11180. export class CanvasGenerator {
  11181. /**
  11182. * Create a new canvas (or offscreen canvas depending on the context)
  11183. * @param width defines the expected width
  11184. * @param height defines the expected height
  11185. * @return a new canvas or offscreen canvas
  11186. */
  11187. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  11188. }
  11189. }
  11190. declare module BABYLON {
  11191. /**
  11192. * A class extending Texture allowing drawing on a texture
  11193. * @see http://doc.babylonjs.com/how_to/dynamictexture
  11194. */
  11195. export class DynamicTexture extends Texture {
  11196. private _generateMipMaps;
  11197. private _canvas;
  11198. private _context;
  11199. /**
  11200. * Creates a DynamicTexture
  11201. * @param name defines the name of the texture
  11202. * @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
  11203. * @param scene defines the scene where you want the texture
  11204. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  11205. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  11206. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  11207. */
  11208. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  11209. /**
  11210. * Get the current class name of the texture useful for serialization or dynamic coding.
  11211. * @returns "DynamicTexture"
  11212. */
  11213. getClassName(): string;
  11214. /**
  11215. * Gets the current state of canRescale
  11216. */
  11217. get canRescale(): boolean;
  11218. private _recreate;
  11219. /**
  11220. * Scales the texture
  11221. * @param ratio the scale factor to apply to both width and height
  11222. */
  11223. scale(ratio: number): void;
  11224. /**
  11225. * Resizes the texture
  11226. * @param width the new width
  11227. * @param height the new height
  11228. */
  11229. scaleTo(width: number, height: number): void;
  11230. /**
  11231. * Gets the context of the canvas used by the texture
  11232. * @returns the canvas context of the dynamic texture
  11233. */
  11234. getContext(): CanvasRenderingContext2D;
  11235. /**
  11236. * Clears the texture
  11237. */
  11238. clear(): void;
  11239. /**
  11240. * Updates the texture
  11241. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  11242. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  11243. */
  11244. update(invertY?: boolean, premulAlpha?: boolean): void;
  11245. /**
  11246. * Draws text onto the texture
  11247. * @param text defines the text to be drawn
  11248. * @param x defines the placement of the text from the left
  11249. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  11250. * @param font defines the font to be used with font-style, font-size, font-name
  11251. * @param color defines the color used for the text
  11252. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  11253. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  11254. * @param update defines whether texture is immediately update (default is true)
  11255. */
  11256. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  11257. /**
  11258. * Clones the texture
  11259. * @returns the clone of the texture.
  11260. */
  11261. clone(): DynamicTexture;
  11262. /**
  11263. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  11264. * @returns a serialized dynamic texture object
  11265. */
  11266. serialize(): any;
  11267. /** @hidden */
  11268. _rebuild(): void;
  11269. }
  11270. }
  11271. declare module BABYLON {
  11272. interface ThinEngine {
  11273. /**
  11274. * Creates a raw texture
  11275. * @param data defines the data to store in the texture
  11276. * @param width defines the width of the texture
  11277. * @param height defines the height of the texture
  11278. * @param format defines the format of the data
  11279. * @param generateMipMaps defines if the engine should generate the mip levels
  11280. * @param invertY defines if data must be stored with Y axis inverted
  11281. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11282. * @param compression defines the compression used (null by default)
  11283. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11284. * @returns the raw texture inside an InternalTexture
  11285. */
  11286. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11287. /**
  11288. * Update a raw texture
  11289. * @param texture defines the texture to update
  11290. * @param data defines the data to store in the texture
  11291. * @param format defines the format of the data
  11292. * @param invertY defines if data must be stored with Y axis inverted
  11293. */
  11294. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11295. /**
  11296. * Update a raw texture
  11297. * @param texture defines the texture to update
  11298. * @param data defines the data to store in the texture
  11299. * @param format defines the format of the data
  11300. * @param invertY defines if data must be stored with Y axis inverted
  11301. * @param compression defines the compression used (null by default)
  11302. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11303. */
  11304. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11305. /**
  11306. * Creates a new raw cube texture
  11307. * @param data defines the array of data to use to create each face
  11308. * @param size defines the size of the textures
  11309. * @param format defines the format of the data
  11310. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11311. * @param generateMipMaps defines if the engine should generate the mip levels
  11312. * @param invertY defines if data must be stored with Y axis inverted
  11313. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11314. * @param compression defines the compression used (null by default)
  11315. * @returns the cube texture as an InternalTexture
  11316. */
  11317. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11318. /**
  11319. * Update a raw cube texture
  11320. * @param texture defines the texture to udpdate
  11321. * @param data defines the data to store
  11322. * @param format defines the data format
  11323. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11324. * @param invertY defines if data must be stored with Y axis inverted
  11325. */
  11326. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11327. /**
  11328. * Update a raw cube texture
  11329. * @param texture defines the texture to udpdate
  11330. * @param data defines the data to store
  11331. * @param format defines the data format
  11332. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11333. * @param invertY defines if data must be stored with Y axis inverted
  11334. * @param compression defines the compression used (null by default)
  11335. */
  11336. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11337. /**
  11338. * Update a raw cube texture
  11339. * @param texture defines the texture to udpdate
  11340. * @param data defines the data to store
  11341. * @param format defines the data format
  11342. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11343. * @param invertY defines if data must be stored with Y axis inverted
  11344. * @param compression defines the compression used (null by default)
  11345. * @param level defines which level of the texture to update
  11346. */
  11347. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11348. /**
  11349. * Creates a new raw cube texture from a specified url
  11350. * @param url defines the url where the data is located
  11351. * @param scene defines the current scene
  11352. * @param size defines the size of the textures
  11353. * @param format defines the format of the data
  11354. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11355. * @param noMipmap defines if the engine should avoid generating the mip levels
  11356. * @param callback defines a callback used to extract texture data from loaded data
  11357. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11358. * @param onLoad defines a callback called when texture is loaded
  11359. * @param onError defines a callback called if there is an error
  11360. * @returns the cube texture as an InternalTexture
  11361. */
  11362. createRawCubeTextureFromUrl(url: string, scene: Nullable<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;
  11363. /**
  11364. * Creates a new raw cube texture from a specified url
  11365. * @param url defines the url where the data is located
  11366. * @param scene defines the current scene
  11367. * @param size defines the size of the textures
  11368. * @param format defines the format of the data
  11369. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11370. * @param noMipmap defines if the engine should avoid generating the mip levels
  11371. * @param callback defines a callback used to extract texture data from loaded data
  11372. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11373. * @param onLoad defines a callback called when texture is loaded
  11374. * @param onError defines a callback called if there is an error
  11375. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11376. * @param invertY defines if data must be stored with Y axis inverted
  11377. * @returns the cube texture as an InternalTexture
  11378. */
  11379. createRawCubeTextureFromUrl(url: string, scene: Nullable<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;
  11380. /**
  11381. * Creates a new raw 3D texture
  11382. * @param data defines the data used to create the texture
  11383. * @param width defines the width of the texture
  11384. * @param height defines the height of the texture
  11385. * @param depth defines the depth of the texture
  11386. * @param format defines the format of the texture
  11387. * @param generateMipMaps defines if the engine must generate mip levels
  11388. * @param invertY defines if data must be stored with Y axis inverted
  11389. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11390. * @param compression defines the compressed used (can be null)
  11391. * @param textureType defines the compressed used (can be null)
  11392. * @returns a new raw 3D texture (stored in an InternalTexture)
  11393. */
  11394. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11395. /**
  11396. * Update a raw 3D texture
  11397. * @param texture defines the texture to update
  11398. * @param data defines the data to store
  11399. * @param format defines the data format
  11400. * @param invertY defines if data must be stored with Y axis inverted
  11401. */
  11402. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11403. /**
  11404. * Update a raw 3D texture
  11405. * @param texture defines the texture to update
  11406. * @param data defines the data to store
  11407. * @param format defines the data format
  11408. * @param invertY defines if data must be stored with Y axis inverted
  11409. * @param compression defines the used compression (can be null)
  11410. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11411. */
  11412. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11413. /**
  11414. * Creates a new raw 2D array texture
  11415. * @param data defines the data used to create the texture
  11416. * @param width defines the width of the texture
  11417. * @param height defines the height of the texture
  11418. * @param depth defines the number of layers of the texture
  11419. * @param format defines the format of the texture
  11420. * @param generateMipMaps defines if the engine must generate mip levels
  11421. * @param invertY defines if data must be stored with Y axis inverted
  11422. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11423. * @param compression defines the compressed used (can be null)
  11424. * @param textureType defines the compressed used (can be null)
  11425. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11426. */
  11427. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11428. /**
  11429. * Update a raw 2D array texture
  11430. * @param texture defines the texture to update
  11431. * @param data defines the data to store
  11432. * @param format defines the data format
  11433. * @param invertY defines if data must be stored with Y axis inverted
  11434. */
  11435. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11436. /**
  11437. * Update a raw 2D array texture
  11438. * @param texture defines the texture to update
  11439. * @param data defines the data to store
  11440. * @param format defines the data format
  11441. * @param invertY defines if data must be stored with Y axis inverted
  11442. * @param compression defines the used compression (can be null)
  11443. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11444. */
  11445. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11446. }
  11447. }
  11448. declare module BABYLON {
  11449. /**
  11450. * Raw texture can help creating a texture directly from an array of data.
  11451. * This can be super useful if you either get the data from an uncompressed source or
  11452. * if you wish to create your texture pixel by pixel.
  11453. */
  11454. export class RawTexture extends Texture {
  11455. /**
  11456. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11457. */
  11458. format: number;
  11459. /**
  11460. * Instantiates a new RawTexture.
  11461. * Raw texture can help creating a texture directly from an array of data.
  11462. * This can be super useful if you either get the data from an uncompressed source or
  11463. * if you wish to create your texture pixel by pixel.
  11464. * @param data define the array of data to use to create the texture
  11465. * @param width define the width of the texture
  11466. * @param height define the height of the texture
  11467. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11468. * @param scene define the scene the texture belongs to
  11469. * @param generateMipMaps define whether mip maps should be generated or not
  11470. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11471. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11472. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11473. */
  11474. constructor(data: ArrayBufferView, width: number, height: number,
  11475. /**
  11476. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11477. */
  11478. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11479. /**
  11480. * Updates the texture underlying data.
  11481. * @param data Define the new data of the texture
  11482. */
  11483. update(data: ArrayBufferView): void;
  11484. /**
  11485. * Creates a luminance texture from some data.
  11486. * @param data Define the texture data
  11487. * @param width Define the width of the texture
  11488. * @param height Define the height of the texture
  11489. * @param scene Define the scene the texture belongs to
  11490. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11491. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11492. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11493. * @returns the luminance texture
  11494. */
  11495. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11496. /**
  11497. * Creates a luminance alpha texture from some data.
  11498. * @param data Define the texture data
  11499. * @param width Define the width of the texture
  11500. * @param height Define the height of the texture
  11501. * @param scene Define the scene the texture belongs to
  11502. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11503. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11504. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11505. * @returns the luminance alpha texture
  11506. */
  11507. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11508. /**
  11509. * Creates an alpha texture from some data.
  11510. * @param data Define the texture data
  11511. * @param width Define the width of the texture
  11512. * @param height Define the height of the texture
  11513. * @param scene Define the scene the texture belongs to
  11514. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11515. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11516. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11517. * @returns the alpha texture
  11518. */
  11519. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11520. /**
  11521. * Creates a RGB texture from some data.
  11522. * @param data Define the texture data
  11523. * @param width Define the width of the texture
  11524. * @param height Define the height of the texture
  11525. * @param scene Define the scene the texture belongs to
  11526. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11527. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11528. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11529. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11530. * @returns the RGB alpha texture
  11531. */
  11532. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11533. /**
  11534. * Creates a RGBA texture from some data.
  11535. * @param data Define the texture data
  11536. * @param width Define the width of the texture
  11537. * @param height Define the height of the texture
  11538. * @param scene Define the scene the texture belongs to
  11539. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11540. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11541. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11542. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11543. * @returns the RGBA texture
  11544. */
  11545. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11546. /**
  11547. * Creates a R texture from some data.
  11548. * @param data Define the texture data
  11549. * @param width Define the width of the texture
  11550. * @param height Define the height of the texture
  11551. * @param scene Define the scene the texture belongs to
  11552. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11553. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11554. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11555. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11556. * @returns the R texture
  11557. */
  11558. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11559. }
  11560. }
  11561. declare module BABYLON {
  11562. interface AbstractScene {
  11563. /**
  11564. * The list of procedural textures added to the scene
  11565. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11566. */
  11567. proceduralTextures: Array<ProceduralTexture>;
  11568. }
  11569. /**
  11570. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11571. * in a given scene.
  11572. */
  11573. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11574. /**
  11575. * The component name helpfull to identify the component in the list of scene components.
  11576. */
  11577. readonly name: string;
  11578. /**
  11579. * The scene the component belongs to.
  11580. */
  11581. scene: Scene;
  11582. /**
  11583. * Creates a new instance of the component for the given scene
  11584. * @param scene Defines the scene to register the component in
  11585. */
  11586. constructor(scene: Scene);
  11587. /**
  11588. * Registers the component in a given scene
  11589. */
  11590. register(): void;
  11591. /**
  11592. * Rebuilds the elements related to this component in case of
  11593. * context lost for instance.
  11594. */
  11595. rebuild(): void;
  11596. /**
  11597. * Disposes the component and the associated ressources.
  11598. */
  11599. dispose(): void;
  11600. private _beforeClear;
  11601. }
  11602. }
  11603. declare module BABYLON {
  11604. interface ThinEngine {
  11605. /**
  11606. * Creates a new render target cube texture
  11607. * @param size defines the size of the texture
  11608. * @param options defines the options used to create the texture
  11609. * @returns a new render target cube texture stored in an InternalTexture
  11610. */
  11611. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11612. }
  11613. }
  11614. declare module BABYLON {
  11615. /** @hidden */
  11616. export var proceduralVertexShader: {
  11617. name: string;
  11618. shader: string;
  11619. };
  11620. }
  11621. declare module BABYLON {
  11622. /**
  11623. * 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.
  11624. * This is the base class of any Procedural texture and contains most of the shareable code.
  11625. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11626. */
  11627. export class ProceduralTexture extends Texture {
  11628. isCube: boolean;
  11629. /**
  11630. * Define if the texture is enabled or not (disabled texture will not render)
  11631. */
  11632. isEnabled: boolean;
  11633. /**
  11634. * Define if the texture must be cleared before rendering (default is true)
  11635. */
  11636. autoClear: boolean;
  11637. /**
  11638. * Callback called when the texture is generated
  11639. */
  11640. onGenerated: () => void;
  11641. /**
  11642. * Event raised when the texture is generated
  11643. */
  11644. onGeneratedObservable: Observable<ProceduralTexture>;
  11645. /** @hidden */
  11646. _generateMipMaps: boolean;
  11647. /** @hidden **/
  11648. _effect: Effect;
  11649. /** @hidden */
  11650. _textures: {
  11651. [key: string]: Texture;
  11652. };
  11653. /** @hidden */
  11654. protected _fallbackTexture: Nullable<Texture>;
  11655. private _size;
  11656. private _currentRefreshId;
  11657. private _frameId;
  11658. private _refreshRate;
  11659. private _vertexBuffers;
  11660. private _indexBuffer;
  11661. private _uniforms;
  11662. private _samplers;
  11663. private _fragment;
  11664. private _floats;
  11665. private _ints;
  11666. private _floatsArrays;
  11667. private _colors3;
  11668. private _colors4;
  11669. private _vectors2;
  11670. private _vectors3;
  11671. private _matrices;
  11672. private _fallbackTextureUsed;
  11673. private _fullEngine;
  11674. private _cachedDefines;
  11675. private _contentUpdateId;
  11676. private _contentData;
  11677. /**
  11678. * Instantiates a new procedural texture.
  11679. * 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.
  11680. * This is the base class of any Procedural texture and contains most of the shareable code.
  11681. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11682. * @param name Define the name of the texture
  11683. * @param size Define the size of the texture to create
  11684. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11685. * @param scene Define the scene the texture belongs to
  11686. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11687. * @param generateMipMaps Define if the texture should creates mip maps or not
  11688. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11689. */
  11690. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11691. /**
  11692. * The effect that is created when initializing the post process.
  11693. * @returns The created effect corresponding the the postprocess.
  11694. */
  11695. getEffect(): Effect;
  11696. /**
  11697. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11698. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11699. */
  11700. getContent(): Nullable<ArrayBufferView>;
  11701. private _createIndexBuffer;
  11702. /** @hidden */
  11703. _rebuild(): void;
  11704. /**
  11705. * Resets the texture in order to recreate its associated resources.
  11706. * This can be called in case of context loss
  11707. */
  11708. reset(): void;
  11709. protected _getDefines(): string;
  11710. /**
  11711. * Is the texture ready to be used ? (rendered at least once)
  11712. * @returns true if ready, otherwise, false.
  11713. */
  11714. isReady(): boolean;
  11715. /**
  11716. * Resets the refresh counter of the texture and start bak from scratch.
  11717. * Could be useful to regenerate the texture if it is setup to render only once.
  11718. */
  11719. resetRefreshCounter(): void;
  11720. /**
  11721. * Set the fragment shader to use in order to render the texture.
  11722. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11723. */
  11724. setFragment(fragment: any): void;
  11725. /**
  11726. * Define the refresh rate of the texture or the rendering frequency.
  11727. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11728. */
  11729. get refreshRate(): number;
  11730. set refreshRate(value: number);
  11731. /** @hidden */
  11732. _shouldRender(): boolean;
  11733. /**
  11734. * Get the size the texture is rendering at.
  11735. * @returns the size (texture is always squared)
  11736. */
  11737. getRenderSize(): number;
  11738. /**
  11739. * Resize the texture to new value.
  11740. * @param size Define the new size the texture should have
  11741. * @param generateMipMaps Define whether the new texture should create mip maps
  11742. */
  11743. resize(size: number, generateMipMaps: boolean): void;
  11744. private _checkUniform;
  11745. /**
  11746. * Set a texture in the shader program used to render.
  11747. * @param name Define the name of the uniform samplers as defined in the shader
  11748. * @param texture Define the texture to bind to this sampler
  11749. * @return the texture itself allowing "fluent" like uniform updates
  11750. */
  11751. setTexture(name: string, texture: Texture): ProceduralTexture;
  11752. /**
  11753. * Set a float in the shader.
  11754. * @param name Define the name of the uniform as defined in the shader
  11755. * @param value Define the value to give to the uniform
  11756. * @return the texture itself allowing "fluent" like uniform updates
  11757. */
  11758. setFloat(name: string, value: number): ProceduralTexture;
  11759. /**
  11760. * Set a int in the shader.
  11761. * @param name Define the name of the uniform as defined in the shader
  11762. * @param value Define the value to give to the uniform
  11763. * @return the texture itself allowing "fluent" like uniform updates
  11764. */
  11765. setInt(name: string, value: number): ProceduralTexture;
  11766. /**
  11767. * Set an array of floats in the shader.
  11768. * @param name Define the name of the uniform as defined in the shader
  11769. * @param value Define the value to give to the uniform
  11770. * @return the texture itself allowing "fluent" like uniform updates
  11771. */
  11772. setFloats(name: string, value: number[]): ProceduralTexture;
  11773. /**
  11774. * Set a vec3 in the shader from a Color3.
  11775. * @param name Define the name of the uniform as defined in the shader
  11776. * @param value Define the value to give to the uniform
  11777. * @return the texture itself allowing "fluent" like uniform updates
  11778. */
  11779. setColor3(name: string, value: Color3): ProceduralTexture;
  11780. /**
  11781. * Set a vec4 in the shader from a Color4.
  11782. * @param name Define the name of the uniform as defined in the shader
  11783. * @param value Define the value to give to the uniform
  11784. * @return the texture itself allowing "fluent" like uniform updates
  11785. */
  11786. setColor4(name: string, value: Color4): ProceduralTexture;
  11787. /**
  11788. * Set a vec2 in the shader from a Vector2.
  11789. * @param name Define the name of the uniform as defined in the shader
  11790. * @param value Define the value to give to the uniform
  11791. * @return the texture itself allowing "fluent" like uniform updates
  11792. */
  11793. setVector2(name: string, value: Vector2): ProceduralTexture;
  11794. /**
  11795. * Set a vec3 in the shader from a Vector3.
  11796. * @param name Define the name of the uniform as defined in the shader
  11797. * @param value Define the value to give to the uniform
  11798. * @return the texture itself allowing "fluent" like uniform updates
  11799. */
  11800. setVector3(name: string, value: Vector3): ProceduralTexture;
  11801. /**
  11802. * Set a mat4 in the shader from a MAtrix.
  11803. * @param name Define the name of the uniform as defined in the shader
  11804. * @param value Define the value to give to the uniform
  11805. * @return the texture itself allowing "fluent" like uniform updates
  11806. */
  11807. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11808. /**
  11809. * Render the texture to its associated render target.
  11810. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11811. */
  11812. render(useCameraPostProcess?: boolean): void;
  11813. /**
  11814. * Clone the texture.
  11815. * @returns the cloned texture
  11816. */
  11817. clone(): ProceduralTexture;
  11818. /**
  11819. * Dispose the texture and release its asoociated resources.
  11820. */
  11821. dispose(): void;
  11822. }
  11823. }
  11824. declare module BABYLON {
  11825. /**
  11826. * This represents the base class for particle system in Babylon.
  11827. * 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.
  11828. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11829. * @example https://doc.babylonjs.com/babylon101/particles
  11830. */
  11831. export class BaseParticleSystem {
  11832. /**
  11833. * Source color is added to the destination color without alpha affecting the result
  11834. */
  11835. static BLENDMODE_ONEONE: number;
  11836. /**
  11837. * Blend current color and particle color using particle’s alpha
  11838. */
  11839. static BLENDMODE_STANDARD: number;
  11840. /**
  11841. * Add current color and particle color multiplied by particle’s alpha
  11842. */
  11843. static BLENDMODE_ADD: number;
  11844. /**
  11845. * Multiply current color with particle color
  11846. */
  11847. static BLENDMODE_MULTIPLY: number;
  11848. /**
  11849. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11850. */
  11851. static BLENDMODE_MULTIPLYADD: number;
  11852. /**
  11853. * List of animations used by the particle system.
  11854. */
  11855. animations: Animation[];
  11856. /**
  11857. * Gets or sets the unique id of the particle system
  11858. */
  11859. uniqueId: number;
  11860. /**
  11861. * The id of the Particle system.
  11862. */
  11863. id: string;
  11864. /**
  11865. * The friendly name of the Particle system.
  11866. */
  11867. name: string;
  11868. /**
  11869. * Snippet ID if the particle system was created from the snippet server
  11870. */
  11871. snippetId: string;
  11872. /**
  11873. * The rendering group used by the Particle system to chose when to render.
  11874. */
  11875. renderingGroupId: number;
  11876. /**
  11877. * The emitter represents the Mesh or position we are attaching the particle system to.
  11878. */
  11879. emitter: Nullable<AbstractMesh | Vector3>;
  11880. /**
  11881. * The maximum number of particles to emit per frame
  11882. */
  11883. emitRate: number;
  11884. /**
  11885. * If you want to launch only a few particles at once, that can be done, as well.
  11886. */
  11887. manualEmitCount: number;
  11888. /**
  11889. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11890. */
  11891. updateSpeed: number;
  11892. /**
  11893. * The amount of time the particle system is running (depends of the overall update speed).
  11894. */
  11895. targetStopDuration: number;
  11896. /**
  11897. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11898. */
  11899. disposeOnStop: boolean;
  11900. /**
  11901. * Minimum power of emitting particles.
  11902. */
  11903. minEmitPower: number;
  11904. /**
  11905. * Maximum power of emitting particles.
  11906. */
  11907. maxEmitPower: number;
  11908. /**
  11909. * Minimum life time of emitting particles.
  11910. */
  11911. minLifeTime: number;
  11912. /**
  11913. * Maximum life time of emitting particles.
  11914. */
  11915. maxLifeTime: number;
  11916. /**
  11917. * Minimum Size of emitting particles.
  11918. */
  11919. minSize: number;
  11920. /**
  11921. * Maximum Size of emitting particles.
  11922. */
  11923. maxSize: number;
  11924. /**
  11925. * Minimum scale of emitting particles on X axis.
  11926. */
  11927. minScaleX: number;
  11928. /**
  11929. * Maximum scale of emitting particles on X axis.
  11930. */
  11931. maxScaleX: number;
  11932. /**
  11933. * Minimum scale of emitting particles on Y axis.
  11934. */
  11935. minScaleY: number;
  11936. /**
  11937. * Maximum scale of emitting particles on Y axis.
  11938. */
  11939. maxScaleY: number;
  11940. /**
  11941. * Gets or sets the minimal initial rotation in radians.
  11942. */
  11943. minInitialRotation: number;
  11944. /**
  11945. * Gets or sets the maximal initial rotation in radians.
  11946. */
  11947. maxInitialRotation: number;
  11948. /**
  11949. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11950. */
  11951. minAngularSpeed: number;
  11952. /**
  11953. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11954. */
  11955. maxAngularSpeed: number;
  11956. /**
  11957. * The texture used to render each particle. (this can be a spritesheet)
  11958. */
  11959. particleTexture: Nullable<Texture>;
  11960. /**
  11961. * The layer mask we are rendering the particles through.
  11962. */
  11963. layerMask: number;
  11964. /**
  11965. * This can help using your own shader to render the particle system.
  11966. * The according effect will be created
  11967. */
  11968. customShader: any;
  11969. /**
  11970. * By default particle system starts as soon as they are created. This prevents the
  11971. * automatic start to happen and let you decide when to start emitting particles.
  11972. */
  11973. preventAutoStart: boolean;
  11974. private _noiseTexture;
  11975. /**
  11976. * Gets or sets a texture used to add random noise to particle positions
  11977. */
  11978. get noiseTexture(): Nullable<ProceduralTexture>;
  11979. set noiseTexture(value: Nullable<ProceduralTexture>);
  11980. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  11981. noiseStrength: Vector3;
  11982. /**
  11983. * Callback triggered when the particle animation is ending.
  11984. */
  11985. onAnimationEnd: Nullable<() => void>;
  11986. /**
  11987. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  11988. */
  11989. blendMode: number;
  11990. /**
  11991. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  11992. * to override the particles.
  11993. */
  11994. forceDepthWrite: boolean;
  11995. /** 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 */
  11996. preWarmCycles: number;
  11997. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  11998. preWarmStepOffset: number;
  11999. /**
  12000. * 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)
  12001. */
  12002. spriteCellChangeSpeed: number;
  12003. /**
  12004. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12005. */
  12006. startSpriteCellID: number;
  12007. /**
  12008. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12009. */
  12010. endSpriteCellID: number;
  12011. /**
  12012. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12013. */
  12014. spriteCellWidth: number;
  12015. /**
  12016. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12017. */
  12018. spriteCellHeight: number;
  12019. /**
  12020. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12021. */
  12022. spriteRandomStartCell: boolean;
  12023. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12024. translationPivot: Vector2;
  12025. /** @hidden */
  12026. protected _isAnimationSheetEnabled: boolean;
  12027. /**
  12028. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12029. */
  12030. beginAnimationOnStart: boolean;
  12031. /**
  12032. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12033. */
  12034. beginAnimationFrom: number;
  12035. /**
  12036. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12037. */
  12038. beginAnimationTo: number;
  12039. /**
  12040. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12041. */
  12042. beginAnimationLoop: boolean;
  12043. /**
  12044. * Gets or sets a world offset applied to all particles
  12045. */
  12046. worldOffset: Vector3;
  12047. /**
  12048. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12049. */
  12050. get isAnimationSheetEnabled(): boolean;
  12051. set isAnimationSheetEnabled(value: boolean);
  12052. /**
  12053. * Get hosting scene
  12054. * @returns the scene
  12055. */
  12056. getScene(): Scene;
  12057. /**
  12058. * You can use gravity if you want to give an orientation to your particles.
  12059. */
  12060. gravity: Vector3;
  12061. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12062. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12063. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12064. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12065. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12066. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12067. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12068. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12069. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12070. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12071. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12072. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12073. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12074. /**
  12075. * Defines the delay in milliseconds before starting the system (0 by default)
  12076. */
  12077. startDelay: number;
  12078. /**
  12079. * Gets the current list of drag gradients.
  12080. * You must use addDragGradient and removeDragGradient to udpate this list
  12081. * @returns the list of drag gradients
  12082. */
  12083. getDragGradients(): Nullable<Array<FactorGradient>>;
  12084. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12085. limitVelocityDamping: number;
  12086. /**
  12087. * Gets the current list of limit velocity gradients.
  12088. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12089. * @returns the list of limit velocity gradients
  12090. */
  12091. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12092. /**
  12093. * Gets the current list of color gradients.
  12094. * You must use addColorGradient and removeColorGradient to udpate this list
  12095. * @returns the list of color gradients
  12096. */
  12097. getColorGradients(): Nullable<Array<ColorGradient>>;
  12098. /**
  12099. * Gets the current list of size gradients.
  12100. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12101. * @returns the list of size gradients
  12102. */
  12103. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12104. /**
  12105. * Gets the current list of color remap gradients.
  12106. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12107. * @returns the list of color remap gradients
  12108. */
  12109. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12110. /**
  12111. * Gets the current list of alpha remap gradients.
  12112. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12113. * @returns the list of alpha remap gradients
  12114. */
  12115. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12116. /**
  12117. * Gets the current list of life time gradients.
  12118. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12119. * @returns the list of life time gradients
  12120. */
  12121. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12122. /**
  12123. * Gets the current list of angular speed gradients.
  12124. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12125. * @returns the list of angular speed gradients
  12126. */
  12127. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12128. /**
  12129. * Gets the current list of velocity gradients.
  12130. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12131. * @returns the list of velocity gradients
  12132. */
  12133. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12134. /**
  12135. * Gets the current list of start size gradients.
  12136. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12137. * @returns the list of start size gradients
  12138. */
  12139. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12140. /**
  12141. * Gets the current list of emit rate gradients.
  12142. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12143. * @returns the list of emit rate gradients
  12144. */
  12145. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12146. /**
  12147. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12148. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12149. */
  12150. get direction1(): Vector3;
  12151. set direction1(value: Vector3);
  12152. /**
  12153. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12154. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12155. */
  12156. get direction2(): Vector3;
  12157. set direction2(value: Vector3);
  12158. /**
  12159. * 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.
  12160. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12161. */
  12162. get minEmitBox(): Vector3;
  12163. set minEmitBox(value: Vector3);
  12164. /**
  12165. * 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.
  12166. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12167. */
  12168. get maxEmitBox(): Vector3;
  12169. set maxEmitBox(value: Vector3);
  12170. /**
  12171. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12172. */
  12173. color1: Color4;
  12174. /**
  12175. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12176. */
  12177. color2: Color4;
  12178. /**
  12179. * Color the particle will have at the end of its lifetime
  12180. */
  12181. colorDead: Color4;
  12182. /**
  12183. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12184. */
  12185. textureMask: Color4;
  12186. /**
  12187. * The particle emitter type defines the emitter used by the particle system.
  12188. * It can be for example box, sphere, or cone...
  12189. */
  12190. particleEmitterType: IParticleEmitterType;
  12191. /** @hidden */
  12192. _isSubEmitter: boolean;
  12193. /**
  12194. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12195. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12196. */
  12197. billboardMode: number;
  12198. protected _isBillboardBased: boolean;
  12199. /**
  12200. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12201. */
  12202. get isBillboardBased(): boolean;
  12203. set isBillboardBased(value: boolean);
  12204. /**
  12205. * The scene the particle system belongs to.
  12206. */
  12207. protected _scene: Scene;
  12208. /**
  12209. * Local cache of defines for image processing.
  12210. */
  12211. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12212. /**
  12213. * Default configuration related to image processing available in the standard Material.
  12214. */
  12215. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  12216. /**
  12217. * Gets the image processing configuration used either in this material.
  12218. */
  12219. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  12220. /**
  12221. * Sets the Default image processing configuration used either in the this material.
  12222. *
  12223. * If sets to null, the scene one is in use.
  12224. */
  12225. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  12226. /**
  12227. * Attaches a new image processing configuration to the Standard Material.
  12228. * @param configuration
  12229. */
  12230. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12231. /** @hidden */
  12232. protected _reset(): void;
  12233. /** @hidden */
  12234. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12235. /**
  12236. * Instantiates a particle system.
  12237. * 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.
  12238. * @param name The name of the particle system
  12239. */
  12240. constructor(name: string);
  12241. /**
  12242. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12243. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12244. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12245. * @returns the emitter
  12246. */
  12247. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12248. /**
  12249. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12250. * @param radius The radius of the hemisphere to emit from
  12251. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12252. * @returns the emitter
  12253. */
  12254. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12255. /**
  12256. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12257. * @param radius The radius of the sphere to emit from
  12258. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12259. * @returns the emitter
  12260. */
  12261. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12262. /**
  12263. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12264. * @param radius The radius of the sphere to emit from
  12265. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12266. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12267. * @returns the emitter
  12268. */
  12269. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12270. /**
  12271. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12272. * @param radius The radius of the emission cylinder
  12273. * @param height The height of the emission cylinder
  12274. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12275. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12276. * @returns the emitter
  12277. */
  12278. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12279. /**
  12280. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12281. * @param radius The radius of the cylinder to emit from
  12282. * @param height The height of the emission cylinder
  12283. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12284. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12285. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12286. * @returns the emitter
  12287. */
  12288. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12289. /**
  12290. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12291. * @param radius The radius of the cone to emit from
  12292. * @param angle The base angle of the cone
  12293. * @returns the emitter
  12294. */
  12295. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12296. /**
  12297. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12298. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12299. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12300. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12301. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12302. * @returns the emitter
  12303. */
  12304. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12305. }
  12306. }
  12307. declare module BABYLON {
  12308. /**
  12309. * Type of sub emitter
  12310. */
  12311. export enum SubEmitterType {
  12312. /**
  12313. * Attached to the particle over it's lifetime
  12314. */
  12315. ATTACHED = 0,
  12316. /**
  12317. * Created when the particle dies
  12318. */
  12319. END = 1
  12320. }
  12321. /**
  12322. * Sub emitter class used to emit particles from an existing particle
  12323. */
  12324. export class SubEmitter {
  12325. /**
  12326. * the particle system to be used by the sub emitter
  12327. */
  12328. particleSystem: ParticleSystem;
  12329. /**
  12330. * Type of the submitter (Default: END)
  12331. */
  12332. type: SubEmitterType;
  12333. /**
  12334. * 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)
  12335. * Note: This only is supported when using an emitter of type Mesh
  12336. */
  12337. inheritDirection: boolean;
  12338. /**
  12339. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12340. */
  12341. inheritedVelocityAmount: number;
  12342. /**
  12343. * Creates a sub emitter
  12344. * @param particleSystem the particle system to be used by the sub emitter
  12345. */
  12346. constructor(
  12347. /**
  12348. * the particle system to be used by the sub emitter
  12349. */
  12350. particleSystem: ParticleSystem);
  12351. /**
  12352. * Clones the sub emitter
  12353. * @returns the cloned sub emitter
  12354. */
  12355. clone(): SubEmitter;
  12356. /**
  12357. * Serialize current object to a JSON object
  12358. * @returns the serialized object
  12359. */
  12360. serialize(): any;
  12361. /** @hidden */
  12362. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  12363. /**
  12364. * Creates a new SubEmitter from a serialized JSON version
  12365. * @param serializationObject defines the JSON object to read from
  12366. * @param scene defines the hosting scene
  12367. * @param rootUrl defines the rootUrl for data loading
  12368. * @returns a new SubEmitter
  12369. */
  12370. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  12371. /** Release associated resources */
  12372. dispose(): void;
  12373. }
  12374. }
  12375. declare module BABYLON {
  12376. /** @hidden */
  12377. export var imageProcessingDeclaration: {
  12378. name: string;
  12379. shader: string;
  12380. };
  12381. }
  12382. declare module BABYLON {
  12383. /** @hidden */
  12384. export var imageProcessingFunctions: {
  12385. name: string;
  12386. shader: string;
  12387. };
  12388. }
  12389. declare module BABYLON {
  12390. /** @hidden */
  12391. export var particlesPixelShader: {
  12392. name: string;
  12393. shader: string;
  12394. };
  12395. }
  12396. declare module BABYLON {
  12397. /** @hidden */
  12398. export var particlesVertexShader: {
  12399. name: string;
  12400. shader: string;
  12401. };
  12402. }
  12403. declare module BABYLON {
  12404. /**
  12405. * This represents a particle system in Babylon.
  12406. * 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.
  12407. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12408. * @example https://doc.babylonjs.com/babylon101/particles
  12409. */
  12410. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12411. /**
  12412. * Billboard mode will only apply to Y axis
  12413. */
  12414. static readonly BILLBOARDMODE_Y: number;
  12415. /**
  12416. * Billboard mode will apply to all axes
  12417. */
  12418. static readonly BILLBOARDMODE_ALL: number;
  12419. /**
  12420. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12421. */
  12422. static readonly BILLBOARDMODE_STRETCHED: number;
  12423. /**
  12424. * This function can be defined to provide custom update for active particles.
  12425. * This function will be called instead of regular update (age, position, color, etc.).
  12426. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12427. */
  12428. updateFunction: (particles: Particle[]) => void;
  12429. private _emitterWorldMatrix;
  12430. /**
  12431. * This function can be defined to specify initial direction for every new particle.
  12432. * It by default use the emitterType defined function
  12433. */
  12434. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12435. /**
  12436. * This function can be defined to specify initial position for every new particle.
  12437. * It by default use the emitterType defined function
  12438. */
  12439. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12440. /**
  12441. * @hidden
  12442. */
  12443. _inheritedVelocityOffset: Vector3;
  12444. /**
  12445. * An event triggered when the system is disposed
  12446. */
  12447. onDisposeObservable: Observable<IParticleSystem>;
  12448. private _onDisposeObserver;
  12449. /**
  12450. * Sets a callback that will be triggered when the system is disposed
  12451. */
  12452. set onDispose(callback: () => void);
  12453. private _particles;
  12454. private _epsilon;
  12455. private _capacity;
  12456. private _stockParticles;
  12457. private _newPartsExcess;
  12458. private _vertexData;
  12459. private _vertexBuffer;
  12460. private _vertexBuffers;
  12461. private _spriteBuffer;
  12462. private _indexBuffer;
  12463. private _effect;
  12464. private _customEffect;
  12465. private _cachedDefines;
  12466. private _scaledColorStep;
  12467. private _colorDiff;
  12468. private _scaledDirection;
  12469. private _scaledGravity;
  12470. private _currentRenderId;
  12471. private _alive;
  12472. private _useInstancing;
  12473. private _started;
  12474. private _stopped;
  12475. private _actualFrame;
  12476. private _scaledUpdateSpeed;
  12477. private _vertexBufferSize;
  12478. /** @hidden */
  12479. _currentEmitRateGradient: Nullable<FactorGradient>;
  12480. /** @hidden */
  12481. _currentEmitRate1: number;
  12482. /** @hidden */
  12483. _currentEmitRate2: number;
  12484. /** @hidden */
  12485. _currentStartSizeGradient: Nullable<FactorGradient>;
  12486. /** @hidden */
  12487. _currentStartSize1: number;
  12488. /** @hidden */
  12489. _currentStartSize2: number;
  12490. private readonly _rawTextureWidth;
  12491. private _rampGradientsTexture;
  12492. private _useRampGradients;
  12493. /** Gets or sets a boolean indicating that ramp gradients must be used
  12494. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12495. */
  12496. get useRampGradients(): boolean;
  12497. set useRampGradients(value: boolean);
  12498. /**
  12499. * 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.
  12500. * 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: [])
  12501. */
  12502. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12503. private _subEmitters;
  12504. /**
  12505. * @hidden
  12506. * If the particle systems emitter should be disposed when the particle system is disposed
  12507. */
  12508. _disposeEmitterOnDispose: boolean;
  12509. /**
  12510. * The current active Sub-systems, this property is used by the root particle system only.
  12511. */
  12512. activeSubSystems: Array<ParticleSystem>;
  12513. /**
  12514. * Specifies if the particles are updated in emitter local space or world space
  12515. */
  12516. isLocal: boolean;
  12517. private _rootParticleSystem;
  12518. /**
  12519. * Gets the current list of active particles
  12520. */
  12521. get particles(): Particle[];
  12522. /**
  12523. * Gets the number of particles active at the same time.
  12524. * @returns The number of active particles.
  12525. */
  12526. getActiveCount(): number;
  12527. /**
  12528. * Returns the string "ParticleSystem"
  12529. * @returns a string containing the class name
  12530. */
  12531. getClassName(): string;
  12532. /**
  12533. * Gets a boolean indicating that the system is stopping
  12534. * @returns true if the system is currently stopping
  12535. */
  12536. isStopping(): boolean;
  12537. /**
  12538. * Gets the custom effect used to render the particles
  12539. * @param blendMode Blend mode for which the effect should be retrieved
  12540. * @returns The effect
  12541. */
  12542. getCustomEffect(blendMode?: number): Nullable<Effect>;
  12543. /**
  12544. * Sets the custom effect used to render the particles
  12545. * @param effect The effect to set
  12546. * @param blendMode Blend mode for which the effect should be set
  12547. */
  12548. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  12549. /** @hidden */
  12550. private _onBeforeDrawParticlesObservable;
  12551. /**
  12552. * Observable that will be called just before the particles are drawn
  12553. */
  12554. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  12555. /**
  12556. * Gets the name of the particle vertex shader
  12557. */
  12558. get vertexShaderName(): string;
  12559. /**
  12560. * Instantiates a particle system.
  12561. * 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.
  12562. * @param name The name of the particle system
  12563. * @param capacity The max number of particles alive at the same time
  12564. * @param scene The scene the particle system belongs to
  12565. * @param customEffect a custom effect used to change the way particles are rendered by default
  12566. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  12567. * @param epsilon Offset used to render the particles
  12568. */
  12569. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12570. private _addFactorGradient;
  12571. private _removeFactorGradient;
  12572. /**
  12573. * Adds a new life time gradient
  12574. * @param gradient defines the gradient to use (between 0 and 1)
  12575. * @param factor defines the life time factor to affect to the specified gradient
  12576. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12577. * @returns the current particle system
  12578. */
  12579. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12580. /**
  12581. * Remove a specific life time gradient
  12582. * @param gradient defines the gradient to remove
  12583. * @returns the current particle system
  12584. */
  12585. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12586. /**
  12587. * Adds a new size gradient
  12588. * @param gradient defines the gradient to use (between 0 and 1)
  12589. * @param factor defines the size factor to affect to the specified gradient
  12590. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12591. * @returns the current particle system
  12592. */
  12593. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12594. /**
  12595. * Remove a specific size gradient
  12596. * @param gradient defines the gradient to remove
  12597. * @returns the current particle system
  12598. */
  12599. removeSizeGradient(gradient: number): IParticleSystem;
  12600. /**
  12601. * Adds a new color remap gradient
  12602. * @param gradient defines the gradient to use (between 0 and 1)
  12603. * @param min defines the color remap minimal range
  12604. * @param max defines the color remap maximal range
  12605. * @returns the current particle system
  12606. */
  12607. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12608. /**
  12609. * Remove a specific color remap gradient
  12610. * @param gradient defines the gradient to remove
  12611. * @returns the current particle system
  12612. */
  12613. removeColorRemapGradient(gradient: number): IParticleSystem;
  12614. /**
  12615. * Adds a new alpha remap gradient
  12616. * @param gradient defines the gradient to use (between 0 and 1)
  12617. * @param min defines the alpha remap minimal range
  12618. * @param max defines the alpha remap maximal range
  12619. * @returns the current particle system
  12620. */
  12621. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12622. /**
  12623. * Remove a specific alpha remap gradient
  12624. * @param gradient defines the gradient to remove
  12625. * @returns the current particle system
  12626. */
  12627. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12628. /**
  12629. * Adds a new angular speed gradient
  12630. * @param gradient defines the gradient to use (between 0 and 1)
  12631. * @param factor defines the angular speed to affect to the specified gradient
  12632. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12633. * @returns the current particle system
  12634. */
  12635. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12636. /**
  12637. * Remove a specific angular speed gradient
  12638. * @param gradient defines the gradient to remove
  12639. * @returns the current particle system
  12640. */
  12641. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12642. /**
  12643. * Adds a new velocity gradient
  12644. * @param gradient defines the gradient to use (between 0 and 1)
  12645. * @param factor defines the velocity to affect to the specified gradient
  12646. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12647. * @returns the current particle system
  12648. */
  12649. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12650. /**
  12651. * Remove a specific velocity gradient
  12652. * @param gradient defines the gradient to remove
  12653. * @returns the current particle system
  12654. */
  12655. removeVelocityGradient(gradient: number): IParticleSystem;
  12656. /**
  12657. * Adds a new limit velocity gradient
  12658. * @param gradient defines the gradient to use (between 0 and 1)
  12659. * @param factor defines the limit velocity value to affect to the specified gradient
  12660. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12661. * @returns the current particle system
  12662. */
  12663. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12664. /**
  12665. * Remove a specific limit velocity gradient
  12666. * @param gradient defines the gradient to remove
  12667. * @returns the current particle system
  12668. */
  12669. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  12670. /**
  12671. * Adds a new drag gradient
  12672. * @param gradient defines the gradient to use (between 0 and 1)
  12673. * @param factor defines the drag value to affect to the specified gradient
  12674. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12675. * @returns the current particle system
  12676. */
  12677. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12678. /**
  12679. * Remove a specific drag gradient
  12680. * @param gradient defines the gradient to remove
  12681. * @returns the current particle system
  12682. */
  12683. removeDragGradient(gradient: number): IParticleSystem;
  12684. /**
  12685. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12686. * @param gradient defines the gradient to use (between 0 and 1)
  12687. * @param factor defines the emit rate value to affect to the specified gradient
  12688. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12689. * @returns the current particle system
  12690. */
  12691. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12692. /**
  12693. * Remove a specific emit rate gradient
  12694. * @param gradient defines the gradient to remove
  12695. * @returns the current particle system
  12696. */
  12697. removeEmitRateGradient(gradient: number): IParticleSystem;
  12698. /**
  12699. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12700. * @param gradient defines the gradient to use (between 0 and 1)
  12701. * @param factor defines the start size value to affect to the specified gradient
  12702. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12703. * @returns the current particle system
  12704. */
  12705. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12706. /**
  12707. * Remove a specific start size gradient
  12708. * @param gradient defines the gradient to remove
  12709. * @returns the current particle system
  12710. */
  12711. removeStartSizeGradient(gradient: number): IParticleSystem;
  12712. private _createRampGradientTexture;
  12713. /**
  12714. * Gets the current list of ramp gradients.
  12715. * You must use addRampGradient and removeRampGradient to udpate this list
  12716. * @returns the list of ramp gradients
  12717. */
  12718. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12719. /** Force the system to rebuild all gradients that need to be resync */
  12720. forceRefreshGradients(): void;
  12721. private _syncRampGradientTexture;
  12722. /**
  12723. * Adds a new ramp gradient used to remap particle colors
  12724. * @param gradient defines the gradient to use (between 0 and 1)
  12725. * @param color defines the color to affect to the specified gradient
  12726. * @returns the current particle system
  12727. */
  12728. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12729. /**
  12730. * Remove a specific ramp gradient
  12731. * @param gradient defines the gradient to remove
  12732. * @returns the current particle system
  12733. */
  12734. removeRampGradient(gradient: number): ParticleSystem;
  12735. /**
  12736. * Adds a new color gradient
  12737. * @param gradient defines the gradient to use (between 0 and 1)
  12738. * @param color1 defines the color to affect to the specified gradient
  12739. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12740. * @returns this particle system
  12741. */
  12742. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12743. /**
  12744. * Remove a specific color gradient
  12745. * @param gradient defines the gradient to remove
  12746. * @returns this particle system
  12747. */
  12748. removeColorGradient(gradient: number): IParticleSystem;
  12749. private _fetchR;
  12750. protected _reset(): void;
  12751. private _resetEffect;
  12752. private _createVertexBuffers;
  12753. private _createIndexBuffer;
  12754. /**
  12755. * Gets the maximum number of particles active at the same time.
  12756. * @returns The max number of active particles.
  12757. */
  12758. getCapacity(): number;
  12759. /**
  12760. * Gets whether there are still active particles in the system.
  12761. * @returns True if it is alive, otherwise false.
  12762. */
  12763. isAlive(): boolean;
  12764. /**
  12765. * Gets if the system has been started. (Note: this will still be true after stop is called)
  12766. * @returns True if it has been started, otherwise false.
  12767. */
  12768. isStarted(): boolean;
  12769. private _prepareSubEmitterInternalArray;
  12770. /**
  12771. * Starts the particle system and begins to emit
  12772. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  12773. */
  12774. start(delay?: number): void;
  12775. /**
  12776. * Stops the particle system.
  12777. * @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.
  12778. */
  12779. stop(stopSubEmitters?: boolean): void;
  12780. /**
  12781. * Remove all active particles
  12782. */
  12783. reset(): void;
  12784. /**
  12785. * @hidden (for internal use only)
  12786. */
  12787. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  12788. /**
  12789. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  12790. * Its lifetime will start back at 0.
  12791. */
  12792. recycleParticle: (particle: Particle) => void;
  12793. private _stopSubEmitters;
  12794. private _createParticle;
  12795. private _removeFromRoot;
  12796. private _emitFromParticle;
  12797. private _update;
  12798. /** @hidden */
  12799. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  12800. /** @hidden */
  12801. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  12802. /**
  12803. * Fill the defines array according to the current settings of the particle system
  12804. * @param defines Array to be updated
  12805. * @param blendMode blend mode to take into account when updating the array
  12806. */
  12807. fillDefines(defines: Array<string>, blendMode: number): void;
  12808. /**
  12809. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  12810. * @param uniforms Uniforms array to fill
  12811. * @param attributes Attributes array to fill
  12812. * @param samplers Samplers array to fill
  12813. */
  12814. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  12815. /** @hidden */
  12816. private _getEffect;
  12817. /**
  12818. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  12819. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  12820. */
  12821. animate(preWarmOnly?: boolean): void;
  12822. private _appendParticleVertices;
  12823. /**
  12824. * Rebuilds the particle system.
  12825. */
  12826. rebuild(): void;
  12827. /**
  12828. * Is this system ready to be used/rendered
  12829. * @return true if the system is ready
  12830. */
  12831. isReady(): boolean;
  12832. private _render;
  12833. /**
  12834. * Renders the particle system in its current state.
  12835. * @returns the current number of particles
  12836. */
  12837. render(): number;
  12838. /**
  12839. * Disposes the particle system and free the associated resources
  12840. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  12841. */
  12842. dispose(disposeTexture?: boolean): void;
  12843. /**
  12844. * Clones the particle system.
  12845. * @param name The name of the cloned object
  12846. * @param newEmitter The new emitter to use
  12847. * @returns the cloned particle system
  12848. */
  12849. clone(name: string, newEmitter: any): ParticleSystem;
  12850. /**
  12851. * Serializes the particle system to a JSON object
  12852. * @param serializeTexture defines if the texture must be serialized as well
  12853. * @returns the JSON object
  12854. */
  12855. serialize(serializeTexture?: boolean): any;
  12856. /** @hidden */
  12857. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  12858. /** @hidden */
  12859. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  12860. /**
  12861. * Parses a JSON object to create a particle system.
  12862. * @param parsedParticleSystem The JSON object to parse
  12863. * @param scene The scene to create the particle system in
  12864. * @param rootUrl The root url to use to load external dependencies like texture
  12865. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  12866. * @returns the Parsed particle system
  12867. */
  12868. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  12869. }
  12870. }
  12871. declare module BABYLON {
  12872. /**
  12873. * A particle represents one of the element emitted by a particle system.
  12874. * This is mainly define by its coordinates, direction, velocity and age.
  12875. */
  12876. export class Particle {
  12877. /**
  12878. * The particle system the particle belongs to.
  12879. */
  12880. particleSystem: ParticleSystem;
  12881. private static _Count;
  12882. /**
  12883. * Unique ID of the particle
  12884. */
  12885. id: number;
  12886. /**
  12887. * The world position of the particle in the scene.
  12888. */
  12889. position: Vector3;
  12890. /**
  12891. * The world direction of the particle in the scene.
  12892. */
  12893. direction: Vector3;
  12894. /**
  12895. * The color of the particle.
  12896. */
  12897. color: Color4;
  12898. /**
  12899. * The color change of the particle per step.
  12900. */
  12901. colorStep: Color4;
  12902. /**
  12903. * Defines how long will the life of the particle be.
  12904. */
  12905. lifeTime: number;
  12906. /**
  12907. * The current age of the particle.
  12908. */
  12909. age: number;
  12910. /**
  12911. * The current size of the particle.
  12912. */
  12913. size: number;
  12914. /**
  12915. * The current scale of the particle.
  12916. */
  12917. scale: Vector2;
  12918. /**
  12919. * The current angle of the particle.
  12920. */
  12921. angle: number;
  12922. /**
  12923. * Defines how fast is the angle changing.
  12924. */
  12925. angularSpeed: number;
  12926. /**
  12927. * Defines the cell index used by the particle to be rendered from a sprite.
  12928. */
  12929. cellIndex: number;
  12930. /**
  12931. * The information required to support color remapping
  12932. */
  12933. remapData: Vector4;
  12934. /** @hidden */
  12935. _randomCellOffset?: number;
  12936. /** @hidden */
  12937. _initialDirection: Nullable<Vector3>;
  12938. /** @hidden */
  12939. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  12940. /** @hidden */
  12941. _initialStartSpriteCellID: number;
  12942. /** @hidden */
  12943. _initialEndSpriteCellID: number;
  12944. /** @hidden */
  12945. _currentColorGradient: Nullable<ColorGradient>;
  12946. /** @hidden */
  12947. _currentColor1: Color4;
  12948. /** @hidden */
  12949. _currentColor2: Color4;
  12950. /** @hidden */
  12951. _currentSizeGradient: Nullable<FactorGradient>;
  12952. /** @hidden */
  12953. _currentSize1: number;
  12954. /** @hidden */
  12955. _currentSize2: number;
  12956. /** @hidden */
  12957. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  12958. /** @hidden */
  12959. _currentAngularSpeed1: number;
  12960. /** @hidden */
  12961. _currentAngularSpeed2: number;
  12962. /** @hidden */
  12963. _currentVelocityGradient: Nullable<FactorGradient>;
  12964. /** @hidden */
  12965. _currentVelocity1: number;
  12966. /** @hidden */
  12967. _currentVelocity2: number;
  12968. /** @hidden */
  12969. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  12970. /** @hidden */
  12971. _currentLimitVelocity1: number;
  12972. /** @hidden */
  12973. _currentLimitVelocity2: number;
  12974. /** @hidden */
  12975. _currentDragGradient: Nullable<FactorGradient>;
  12976. /** @hidden */
  12977. _currentDrag1: number;
  12978. /** @hidden */
  12979. _currentDrag2: number;
  12980. /** @hidden */
  12981. _randomNoiseCoordinates1: Vector3;
  12982. /** @hidden */
  12983. _randomNoiseCoordinates2: Vector3;
  12984. /** @hidden */
  12985. _localPosition?: Vector3;
  12986. /**
  12987. * Creates a new instance Particle
  12988. * @param particleSystem the particle system the particle belongs to
  12989. */
  12990. constructor(
  12991. /**
  12992. * The particle system the particle belongs to.
  12993. */
  12994. particleSystem: ParticleSystem);
  12995. private updateCellInfoFromSystem;
  12996. /**
  12997. * Defines how the sprite cell index is updated for the particle
  12998. */
  12999. updateCellIndex(): void;
  13000. /** @hidden */
  13001. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13002. /** @hidden */
  13003. _inheritParticleInfoToSubEmitters(): void;
  13004. /** @hidden */
  13005. _reset(): void;
  13006. /**
  13007. * Copy the properties of particle to another one.
  13008. * @param other the particle to copy the information to.
  13009. */
  13010. copyTo(other: Particle): void;
  13011. }
  13012. }
  13013. declare module BABYLON {
  13014. /**
  13015. * Particle emitter represents a volume emitting particles.
  13016. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13017. */
  13018. export interface IParticleEmitterType {
  13019. /**
  13020. * Called by the particle System when the direction is computed for the created particle.
  13021. * @param worldMatrix is the world matrix of the particle system
  13022. * @param directionToUpdate is the direction vector to update with the result
  13023. * @param particle is the particle we are computed the direction for
  13024. * @param isLocal defines if the direction should be set in local space
  13025. */
  13026. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13027. /**
  13028. * Called by the particle System when the position is computed for the created particle.
  13029. * @param worldMatrix is the world matrix of the particle system
  13030. * @param positionToUpdate is the position vector to update with the result
  13031. * @param particle is the particle we are computed the position for
  13032. * @param isLocal defines if the position should be set in local space
  13033. */
  13034. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13035. /**
  13036. * Clones the current emitter and returns a copy of it
  13037. * @returns the new emitter
  13038. */
  13039. clone(): IParticleEmitterType;
  13040. /**
  13041. * Called by the GPUParticleSystem to setup the update shader
  13042. * @param effect defines the update shader
  13043. */
  13044. applyToShader(effect: Effect): void;
  13045. /**
  13046. * Returns a string to use to update the GPU particles update shader
  13047. * @returns the effect defines string
  13048. */
  13049. getEffectDefines(): string;
  13050. /**
  13051. * Returns a string representing the class name
  13052. * @returns a string containing the class name
  13053. */
  13054. getClassName(): string;
  13055. /**
  13056. * Serializes the particle system to a JSON object.
  13057. * @returns the JSON object
  13058. */
  13059. serialize(): any;
  13060. /**
  13061. * Parse properties from a JSON object
  13062. * @param serializationObject defines the JSON object
  13063. * @param scene defines the hosting scene
  13064. */
  13065. parse(serializationObject: any, scene: Scene): void;
  13066. }
  13067. }
  13068. declare module BABYLON {
  13069. /**
  13070. * Particle emitter emitting particles from the inside of a box.
  13071. * It emits the particles randomly between 2 given directions.
  13072. */
  13073. export class BoxParticleEmitter implements IParticleEmitterType {
  13074. /**
  13075. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13076. */
  13077. direction1: Vector3;
  13078. /**
  13079. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13080. */
  13081. direction2: Vector3;
  13082. /**
  13083. * 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.
  13084. */
  13085. minEmitBox: Vector3;
  13086. /**
  13087. * 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.
  13088. */
  13089. maxEmitBox: Vector3;
  13090. /**
  13091. * Creates a new instance BoxParticleEmitter
  13092. */
  13093. constructor();
  13094. /**
  13095. * Called by the particle System when the direction is computed for the created particle.
  13096. * @param worldMatrix is the world matrix of the particle system
  13097. * @param directionToUpdate is the direction vector to update with the result
  13098. * @param particle is the particle we are computed the direction for
  13099. * @param isLocal defines if the direction should be set in local space
  13100. */
  13101. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13102. /**
  13103. * Called by the particle System when the position is computed for the created particle.
  13104. * @param worldMatrix is the world matrix of the particle system
  13105. * @param positionToUpdate is the position vector to update with the result
  13106. * @param particle is the particle we are computed the position for
  13107. * @param isLocal defines if the position should be set in local space
  13108. */
  13109. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13110. /**
  13111. * Clones the current emitter and returns a copy of it
  13112. * @returns the new emitter
  13113. */
  13114. clone(): BoxParticleEmitter;
  13115. /**
  13116. * Called by the GPUParticleSystem to setup the update shader
  13117. * @param effect defines the update shader
  13118. */
  13119. applyToShader(effect: Effect): void;
  13120. /**
  13121. * Returns a string to use to update the GPU particles update shader
  13122. * @returns a string containng the defines string
  13123. */
  13124. getEffectDefines(): string;
  13125. /**
  13126. * Returns the string "BoxParticleEmitter"
  13127. * @returns a string containing the class name
  13128. */
  13129. getClassName(): string;
  13130. /**
  13131. * Serializes the particle system to a JSON object.
  13132. * @returns the JSON object
  13133. */
  13134. serialize(): any;
  13135. /**
  13136. * Parse properties from a JSON object
  13137. * @param serializationObject defines the JSON object
  13138. */
  13139. parse(serializationObject: any): void;
  13140. }
  13141. }
  13142. declare module BABYLON {
  13143. /**
  13144. * Particle emitter emitting particles from the inside of a cone.
  13145. * It emits the particles alongside the cone volume from the base to the particle.
  13146. * The emission direction might be randomized.
  13147. */
  13148. export class ConeParticleEmitter implements IParticleEmitterType {
  13149. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13150. directionRandomizer: number;
  13151. private _radius;
  13152. private _angle;
  13153. private _height;
  13154. /**
  13155. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13156. */
  13157. radiusRange: number;
  13158. /**
  13159. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13160. */
  13161. heightRange: number;
  13162. /**
  13163. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13164. */
  13165. emitFromSpawnPointOnly: boolean;
  13166. /**
  13167. * Gets or sets the radius of the emission cone
  13168. */
  13169. get radius(): number;
  13170. set radius(value: number);
  13171. /**
  13172. * Gets or sets the angle of the emission cone
  13173. */
  13174. get angle(): number;
  13175. set angle(value: number);
  13176. private _buildHeight;
  13177. /**
  13178. * Creates a new instance ConeParticleEmitter
  13179. * @param radius the radius of the emission cone (1 by default)
  13180. * @param angle the cone base angle (PI by default)
  13181. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13182. */
  13183. constructor(radius?: number, angle?: number,
  13184. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13185. directionRandomizer?: number);
  13186. /**
  13187. * Called by the particle System when the direction is computed for the created particle.
  13188. * @param worldMatrix is the world matrix of the particle system
  13189. * @param directionToUpdate is the direction vector to update with the result
  13190. * @param particle is the particle we are computed the direction for
  13191. * @param isLocal defines if the direction should be set in local space
  13192. */
  13193. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13194. /**
  13195. * Called by the particle System when the position is computed for the created particle.
  13196. * @param worldMatrix is the world matrix of the particle system
  13197. * @param positionToUpdate is the position vector to update with the result
  13198. * @param particle is the particle we are computed the position for
  13199. * @param isLocal defines if the position should be set in local space
  13200. */
  13201. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13202. /**
  13203. * Clones the current emitter and returns a copy of it
  13204. * @returns the new emitter
  13205. */
  13206. clone(): ConeParticleEmitter;
  13207. /**
  13208. * Called by the GPUParticleSystem to setup the update shader
  13209. * @param effect defines the update shader
  13210. */
  13211. applyToShader(effect: Effect): void;
  13212. /**
  13213. * Returns a string to use to update the GPU particles update shader
  13214. * @returns a string containng the defines string
  13215. */
  13216. getEffectDefines(): string;
  13217. /**
  13218. * Returns the string "ConeParticleEmitter"
  13219. * @returns a string containing the class name
  13220. */
  13221. getClassName(): string;
  13222. /**
  13223. * Serializes the particle system to a JSON object.
  13224. * @returns the JSON object
  13225. */
  13226. serialize(): any;
  13227. /**
  13228. * Parse properties from a JSON object
  13229. * @param serializationObject defines the JSON object
  13230. */
  13231. parse(serializationObject: any): void;
  13232. }
  13233. }
  13234. declare module BABYLON {
  13235. /**
  13236. * Particle emitter emitting particles from the inside of a cylinder.
  13237. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13238. */
  13239. export class CylinderParticleEmitter implements IParticleEmitterType {
  13240. /**
  13241. * The radius of the emission cylinder.
  13242. */
  13243. radius: number;
  13244. /**
  13245. * The height of the emission cylinder.
  13246. */
  13247. height: number;
  13248. /**
  13249. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13250. */
  13251. radiusRange: number;
  13252. /**
  13253. * How much to randomize the particle direction [0-1].
  13254. */
  13255. directionRandomizer: number;
  13256. /**
  13257. * Creates a new instance CylinderParticleEmitter
  13258. * @param radius the radius of the emission cylinder (1 by default)
  13259. * @param height the height of the emission cylinder (1 by default)
  13260. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13261. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13262. */
  13263. constructor(
  13264. /**
  13265. * The radius of the emission cylinder.
  13266. */
  13267. radius?: number,
  13268. /**
  13269. * The height of the emission cylinder.
  13270. */
  13271. height?: number,
  13272. /**
  13273. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13274. */
  13275. radiusRange?: number,
  13276. /**
  13277. * How much to randomize the particle direction [0-1].
  13278. */
  13279. directionRandomizer?: number);
  13280. /**
  13281. * Called by the particle System when the direction is computed for the created particle.
  13282. * @param worldMatrix is the world matrix of the particle system
  13283. * @param directionToUpdate is the direction vector to update with the result
  13284. * @param particle is the particle we are computed the direction for
  13285. * @param isLocal defines if the direction should be set in local space
  13286. */
  13287. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13288. /**
  13289. * Called by the particle System when the position is computed for the created particle.
  13290. * @param worldMatrix is the world matrix of the particle system
  13291. * @param positionToUpdate is the position vector to update with the result
  13292. * @param particle is the particle we are computed the position for
  13293. * @param isLocal defines if the position should be set in local space
  13294. */
  13295. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13296. /**
  13297. * Clones the current emitter and returns a copy of it
  13298. * @returns the new emitter
  13299. */
  13300. clone(): CylinderParticleEmitter;
  13301. /**
  13302. * Called by the GPUParticleSystem to setup the update shader
  13303. * @param effect defines the update shader
  13304. */
  13305. applyToShader(effect: Effect): void;
  13306. /**
  13307. * Returns a string to use to update the GPU particles update shader
  13308. * @returns a string containng the defines string
  13309. */
  13310. getEffectDefines(): string;
  13311. /**
  13312. * Returns the string "CylinderParticleEmitter"
  13313. * @returns a string containing the class name
  13314. */
  13315. getClassName(): string;
  13316. /**
  13317. * Serializes the particle system to a JSON object.
  13318. * @returns the JSON object
  13319. */
  13320. serialize(): any;
  13321. /**
  13322. * Parse properties from a JSON object
  13323. * @param serializationObject defines the JSON object
  13324. */
  13325. parse(serializationObject: any): void;
  13326. }
  13327. /**
  13328. * Particle emitter emitting particles from the inside of a cylinder.
  13329. * It emits the particles randomly between two vectors.
  13330. */
  13331. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13332. /**
  13333. * The min limit of the emission direction.
  13334. */
  13335. direction1: Vector3;
  13336. /**
  13337. * The max limit of the emission direction.
  13338. */
  13339. direction2: Vector3;
  13340. /**
  13341. * Creates a new instance CylinderDirectedParticleEmitter
  13342. * @param radius the radius of the emission cylinder (1 by default)
  13343. * @param height the height of the emission cylinder (1 by default)
  13344. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13345. * @param direction1 the min limit of the emission direction (up vector by default)
  13346. * @param direction2 the max limit of the emission direction (up vector by default)
  13347. */
  13348. constructor(radius?: number, height?: number, radiusRange?: number,
  13349. /**
  13350. * The min limit of the emission direction.
  13351. */
  13352. direction1?: Vector3,
  13353. /**
  13354. * The max limit of the emission direction.
  13355. */
  13356. direction2?: Vector3);
  13357. /**
  13358. * Called by the particle System when the direction is computed for the created particle.
  13359. * @param worldMatrix is the world matrix of the particle system
  13360. * @param directionToUpdate is the direction vector to update with the result
  13361. * @param particle is the particle we are computed the direction for
  13362. */
  13363. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13364. /**
  13365. * Clones the current emitter and returns a copy of it
  13366. * @returns the new emitter
  13367. */
  13368. clone(): CylinderDirectedParticleEmitter;
  13369. /**
  13370. * Called by the GPUParticleSystem to setup the update shader
  13371. * @param effect defines the update shader
  13372. */
  13373. applyToShader(effect: Effect): void;
  13374. /**
  13375. * Returns a string to use to update the GPU particles update shader
  13376. * @returns a string containng the defines string
  13377. */
  13378. getEffectDefines(): string;
  13379. /**
  13380. * Returns the string "CylinderDirectedParticleEmitter"
  13381. * @returns a string containing the class name
  13382. */
  13383. getClassName(): string;
  13384. /**
  13385. * Serializes the particle system to a JSON object.
  13386. * @returns the JSON object
  13387. */
  13388. serialize(): any;
  13389. /**
  13390. * Parse properties from a JSON object
  13391. * @param serializationObject defines the JSON object
  13392. */
  13393. parse(serializationObject: any): void;
  13394. }
  13395. }
  13396. declare module BABYLON {
  13397. /**
  13398. * Particle emitter emitting particles from the inside of a hemisphere.
  13399. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13400. */
  13401. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13402. /**
  13403. * The radius of the emission hemisphere.
  13404. */
  13405. radius: number;
  13406. /**
  13407. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13408. */
  13409. radiusRange: number;
  13410. /**
  13411. * How much to randomize the particle direction [0-1].
  13412. */
  13413. directionRandomizer: number;
  13414. /**
  13415. * Creates a new instance HemisphericParticleEmitter
  13416. * @param radius the radius of the emission hemisphere (1 by default)
  13417. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13418. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13419. */
  13420. constructor(
  13421. /**
  13422. * The radius of the emission hemisphere.
  13423. */
  13424. radius?: number,
  13425. /**
  13426. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13427. */
  13428. radiusRange?: number,
  13429. /**
  13430. * How much to randomize the particle direction [0-1].
  13431. */
  13432. directionRandomizer?: number);
  13433. /**
  13434. * Called by the particle System when the direction is computed for the created particle.
  13435. * @param worldMatrix is the world matrix of the particle system
  13436. * @param directionToUpdate is the direction vector to update with the result
  13437. * @param particle is the particle we are computed the direction for
  13438. * @param isLocal defines if the direction should be set in local space
  13439. */
  13440. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13441. /**
  13442. * Called by the particle System when the position is computed for the created particle.
  13443. * @param worldMatrix is the world matrix of the particle system
  13444. * @param positionToUpdate is the position vector to update with the result
  13445. * @param particle is the particle we are computed the position for
  13446. * @param isLocal defines if the position should be set in local space
  13447. */
  13448. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13449. /**
  13450. * Clones the current emitter and returns a copy of it
  13451. * @returns the new emitter
  13452. */
  13453. clone(): HemisphericParticleEmitter;
  13454. /**
  13455. * Called by the GPUParticleSystem to setup the update shader
  13456. * @param effect defines the update shader
  13457. */
  13458. applyToShader(effect: Effect): void;
  13459. /**
  13460. * Returns a string to use to update the GPU particles update shader
  13461. * @returns a string containng the defines string
  13462. */
  13463. getEffectDefines(): string;
  13464. /**
  13465. * Returns the string "HemisphericParticleEmitter"
  13466. * @returns a string containing the class name
  13467. */
  13468. getClassName(): string;
  13469. /**
  13470. * Serializes the particle system to a JSON object.
  13471. * @returns the JSON object
  13472. */
  13473. serialize(): any;
  13474. /**
  13475. * Parse properties from a JSON object
  13476. * @param serializationObject defines the JSON object
  13477. */
  13478. parse(serializationObject: any): void;
  13479. }
  13480. }
  13481. declare module BABYLON {
  13482. /**
  13483. * Particle emitter emitting particles from a point.
  13484. * It emits the particles randomly between 2 given directions.
  13485. */
  13486. export class PointParticleEmitter implements IParticleEmitterType {
  13487. /**
  13488. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13489. */
  13490. direction1: Vector3;
  13491. /**
  13492. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13493. */
  13494. direction2: Vector3;
  13495. /**
  13496. * Creates a new instance PointParticleEmitter
  13497. */
  13498. constructor();
  13499. /**
  13500. * Called by the particle System when the direction is computed for the created particle.
  13501. * @param worldMatrix is the world matrix of the particle system
  13502. * @param directionToUpdate is the direction vector to update with the result
  13503. * @param particle is the particle we are computed the direction for
  13504. * @param isLocal defines if the direction should be set in local space
  13505. */
  13506. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13507. /**
  13508. * Called by the particle System when the position is computed for the created particle.
  13509. * @param worldMatrix is the world matrix of the particle system
  13510. * @param positionToUpdate is the position vector to update with the result
  13511. * @param particle is the particle we are computed the position for
  13512. * @param isLocal defines if the position should be set in local space
  13513. */
  13514. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13515. /**
  13516. * Clones the current emitter and returns a copy of it
  13517. * @returns the new emitter
  13518. */
  13519. clone(): PointParticleEmitter;
  13520. /**
  13521. * Called by the GPUParticleSystem to setup the update shader
  13522. * @param effect defines the update shader
  13523. */
  13524. applyToShader(effect: Effect): void;
  13525. /**
  13526. * Returns a string to use to update the GPU particles update shader
  13527. * @returns a string containng the defines string
  13528. */
  13529. getEffectDefines(): string;
  13530. /**
  13531. * Returns the string "PointParticleEmitter"
  13532. * @returns a string containing the class name
  13533. */
  13534. getClassName(): string;
  13535. /**
  13536. * Serializes the particle system to a JSON object.
  13537. * @returns the JSON object
  13538. */
  13539. serialize(): any;
  13540. /**
  13541. * Parse properties from a JSON object
  13542. * @param serializationObject defines the JSON object
  13543. */
  13544. parse(serializationObject: any): void;
  13545. }
  13546. }
  13547. declare module BABYLON {
  13548. /**
  13549. * Particle emitter emitting particles from the inside of a sphere.
  13550. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13551. */
  13552. export class SphereParticleEmitter implements IParticleEmitterType {
  13553. /**
  13554. * The radius of the emission sphere.
  13555. */
  13556. radius: number;
  13557. /**
  13558. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13559. */
  13560. radiusRange: number;
  13561. /**
  13562. * How much to randomize the particle direction [0-1].
  13563. */
  13564. directionRandomizer: number;
  13565. /**
  13566. * Creates a new instance SphereParticleEmitter
  13567. * @param radius the radius of the emission sphere (1 by default)
  13568. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13569. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13570. */
  13571. constructor(
  13572. /**
  13573. * The radius of the emission sphere.
  13574. */
  13575. radius?: number,
  13576. /**
  13577. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13578. */
  13579. radiusRange?: number,
  13580. /**
  13581. * How much to randomize the particle direction [0-1].
  13582. */
  13583. directionRandomizer?: number);
  13584. /**
  13585. * Called by the particle System when the direction is computed for the created particle.
  13586. * @param worldMatrix is the world matrix of the particle system
  13587. * @param directionToUpdate is the direction vector to update with the result
  13588. * @param particle is the particle we are computed the direction for
  13589. * @param isLocal defines if the direction should be set in local space
  13590. */
  13591. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13592. /**
  13593. * Called by the particle System when the position is computed for the created particle.
  13594. * @param worldMatrix is the world matrix of the particle system
  13595. * @param positionToUpdate is the position vector to update with the result
  13596. * @param particle is the particle we are computed the position for
  13597. * @param isLocal defines if the position should be set in local space
  13598. */
  13599. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13600. /**
  13601. * Clones the current emitter and returns a copy of it
  13602. * @returns the new emitter
  13603. */
  13604. clone(): SphereParticleEmitter;
  13605. /**
  13606. * Called by the GPUParticleSystem to setup the update shader
  13607. * @param effect defines the update shader
  13608. */
  13609. applyToShader(effect: Effect): void;
  13610. /**
  13611. * Returns a string to use to update the GPU particles update shader
  13612. * @returns a string containng the defines string
  13613. */
  13614. getEffectDefines(): string;
  13615. /**
  13616. * Returns the string "SphereParticleEmitter"
  13617. * @returns a string containing the class name
  13618. */
  13619. getClassName(): string;
  13620. /**
  13621. * Serializes the particle system to a JSON object.
  13622. * @returns the JSON object
  13623. */
  13624. serialize(): any;
  13625. /**
  13626. * Parse properties from a JSON object
  13627. * @param serializationObject defines the JSON object
  13628. */
  13629. parse(serializationObject: any): void;
  13630. }
  13631. /**
  13632. * Particle emitter emitting particles from the inside of a sphere.
  13633. * It emits the particles randomly between two vectors.
  13634. */
  13635. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  13636. /**
  13637. * The min limit of the emission direction.
  13638. */
  13639. direction1: Vector3;
  13640. /**
  13641. * The max limit of the emission direction.
  13642. */
  13643. direction2: Vector3;
  13644. /**
  13645. * Creates a new instance SphereDirectedParticleEmitter
  13646. * @param radius the radius of the emission sphere (1 by default)
  13647. * @param direction1 the min limit of the emission direction (up vector by default)
  13648. * @param direction2 the max limit of the emission direction (up vector by default)
  13649. */
  13650. constructor(radius?: number,
  13651. /**
  13652. * The min limit of the emission direction.
  13653. */
  13654. direction1?: Vector3,
  13655. /**
  13656. * The max limit of the emission direction.
  13657. */
  13658. direction2?: Vector3);
  13659. /**
  13660. * Called by the particle System when the direction is computed for the created particle.
  13661. * @param worldMatrix is the world matrix of the particle system
  13662. * @param directionToUpdate is the direction vector to update with the result
  13663. * @param particle is the particle we are computed the direction for
  13664. */
  13665. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13666. /**
  13667. * Clones the current emitter and returns a copy of it
  13668. * @returns the new emitter
  13669. */
  13670. clone(): SphereDirectedParticleEmitter;
  13671. /**
  13672. * Called by the GPUParticleSystem to setup the update shader
  13673. * @param effect defines the update shader
  13674. */
  13675. applyToShader(effect: Effect): void;
  13676. /**
  13677. * Returns a string to use to update the GPU particles update shader
  13678. * @returns a string containng the defines string
  13679. */
  13680. getEffectDefines(): string;
  13681. /**
  13682. * Returns the string "SphereDirectedParticleEmitter"
  13683. * @returns a string containing the class name
  13684. */
  13685. getClassName(): string;
  13686. /**
  13687. * Serializes the particle system to a JSON object.
  13688. * @returns the JSON object
  13689. */
  13690. serialize(): any;
  13691. /**
  13692. * Parse properties from a JSON object
  13693. * @param serializationObject defines the JSON object
  13694. */
  13695. parse(serializationObject: any): void;
  13696. }
  13697. }
  13698. declare module BABYLON {
  13699. /**
  13700. * Particle emitter emitting particles from a custom list of positions.
  13701. */
  13702. export class CustomParticleEmitter implements IParticleEmitterType {
  13703. /**
  13704. * Gets or sets the position generator that will create the inital position of each particle.
  13705. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13706. */
  13707. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13708. /**
  13709. * Gets or sets the destination generator that will create the final destination of each particle.
  13710. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13711. */
  13712. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13713. /**
  13714. * Creates a new instance CustomParticleEmitter
  13715. */
  13716. constructor();
  13717. /**
  13718. * Called by the particle System when the direction is computed for the created particle.
  13719. * @param worldMatrix is the world matrix of the particle system
  13720. * @param directionToUpdate is the direction vector to update with the result
  13721. * @param particle is the particle we are computed the direction for
  13722. * @param isLocal defines if the direction should be set in local space
  13723. */
  13724. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13725. /**
  13726. * Called by the particle System when the position is computed for the created particle.
  13727. * @param worldMatrix is the world matrix of the particle system
  13728. * @param positionToUpdate is the position vector to update with the result
  13729. * @param particle is the particle we are computed the position for
  13730. * @param isLocal defines if the position should be set in local space
  13731. */
  13732. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13733. /**
  13734. * Clones the current emitter and returns a copy of it
  13735. * @returns the new emitter
  13736. */
  13737. clone(): CustomParticleEmitter;
  13738. /**
  13739. * Called by the GPUParticleSystem to setup the update shader
  13740. * @param effect defines the update shader
  13741. */
  13742. applyToShader(effect: Effect): void;
  13743. /**
  13744. * Returns a string to use to update the GPU particles update shader
  13745. * @returns a string containng the defines string
  13746. */
  13747. getEffectDefines(): string;
  13748. /**
  13749. * Returns the string "PointParticleEmitter"
  13750. * @returns a string containing the class name
  13751. */
  13752. getClassName(): string;
  13753. /**
  13754. * Serializes the particle system to a JSON object.
  13755. * @returns the JSON object
  13756. */
  13757. serialize(): any;
  13758. /**
  13759. * Parse properties from a JSON object
  13760. * @param serializationObject defines the JSON object
  13761. */
  13762. parse(serializationObject: any): void;
  13763. }
  13764. }
  13765. declare module BABYLON {
  13766. /**
  13767. * Particle emitter emitting particles from the inside of a box.
  13768. * It emits the particles randomly between 2 given directions.
  13769. */
  13770. export class MeshParticleEmitter implements IParticleEmitterType {
  13771. private _indices;
  13772. private _positions;
  13773. private _normals;
  13774. private _storedNormal;
  13775. private _mesh;
  13776. /**
  13777. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13778. */
  13779. direction1: Vector3;
  13780. /**
  13781. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13782. */
  13783. direction2: Vector3;
  13784. /**
  13785. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  13786. */
  13787. useMeshNormalsForDirection: boolean;
  13788. /** Defines the mesh to use as source */
  13789. get mesh(): Nullable<AbstractMesh>;
  13790. set mesh(value: Nullable<AbstractMesh>);
  13791. /**
  13792. * Creates a new instance MeshParticleEmitter
  13793. * @param mesh defines the mesh to use as source
  13794. */
  13795. constructor(mesh?: Nullable<AbstractMesh>);
  13796. /**
  13797. * Called by the particle System when the direction is computed for the created particle.
  13798. * @param worldMatrix is the world matrix of the particle system
  13799. * @param directionToUpdate is the direction vector to update with the result
  13800. * @param particle is the particle we are computed the direction for
  13801. * @param isLocal defines if the direction should be set in local space
  13802. */
  13803. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13804. /**
  13805. * Called by the particle System when the position is computed for the created particle.
  13806. * @param worldMatrix is the world matrix of the particle system
  13807. * @param positionToUpdate is the position vector to update with the result
  13808. * @param particle is the particle we are computed the position for
  13809. * @param isLocal defines if the position should be set in local space
  13810. */
  13811. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13812. /**
  13813. * Clones the current emitter and returns a copy of it
  13814. * @returns the new emitter
  13815. */
  13816. clone(): MeshParticleEmitter;
  13817. /**
  13818. * Called by the GPUParticleSystem to setup the update shader
  13819. * @param effect defines the update shader
  13820. */
  13821. applyToShader(effect: Effect): void;
  13822. /**
  13823. * Returns a string to use to update the GPU particles update shader
  13824. * @returns a string containng the defines string
  13825. */
  13826. getEffectDefines(): string;
  13827. /**
  13828. * Returns the string "BoxParticleEmitter"
  13829. * @returns a string containing the class name
  13830. */
  13831. getClassName(): string;
  13832. /**
  13833. * Serializes the particle system to a JSON object.
  13834. * @returns the JSON object
  13835. */
  13836. serialize(): any;
  13837. /**
  13838. * Parse properties from a JSON object
  13839. * @param serializationObject defines the JSON object
  13840. * @param scene defines the hosting scene
  13841. */
  13842. parse(serializationObject: any, scene: Scene): void;
  13843. }
  13844. }
  13845. declare module BABYLON {
  13846. /**
  13847. * Interface representing a particle system in Babylon.js.
  13848. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  13849. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  13850. */
  13851. export interface IParticleSystem {
  13852. /**
  13853. * List of animations used by the particle system.
  13854. */
  13855. animations: Animation[];
  13856. /**
  13857. * The id of the Particle system.
  13858. */
  13859. id: string;
  13860. /**
  13861. * The name of the Particle system.
  13862. */
  13863. name: string;
  13864. /**
  13865. * The emitter represents the Mesh or position we are attaching the particle system to.
  13866. */
  13867. emitter: Nullable<AbstractMesh | Vector3>;
  13868. /**
  13869. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13870. */
  13871. isBillboardBased: boolean;
  13872. /**
  13873. * The rendering group used by the Particle system to chose when to render.
  13874. */
  13875. renderingGroupId: number;
  13876. /**
  13877. * The layer mask we are rendering the particles through.
  13878. */
  13879. layerMask: number;
  13880. /**
  13881. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13882. */
  13883. updateSpeed: number;
  13884. /**
  13885. * The amount of time the particle system is running (depends of the overall update speed).
  13886. */
  13887. targetStopDuration: number;
  13888. /**
  13889. * The texture used to render each particle. (this can be a spritesheet)
  13890. */
  13891. particleTexture: Nullable<Texture>;
  13892. /**
  13893. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  13894. */
  13895. blendMode: number;
  13896. /**
  13897. * Minimum life time of emitting particles.
  13898. */
  13899. minLifeTime: number;
  13900. /**
  13901. * Maximum life time of emitting particles.
  13902. */
  13903. maxLifeTime: number;
  13904. /**
  13905. * Minimum Size of emitting particles.
  13906. */
  13907. minSize: number;
  13908. /**
  13909. * Maximum Size of emitting particles.
  13910. */
  13911. maxSize: number;
  13912. /**
  13913. * Minimum scale of emitting particles on X axis.
  13914. */
  13915. minScaleX: number;
  13916. /**
  13917. * Maximum scale of emitting particles on X axis.
  13918. */
  13919. maxScaleX: number;
  13920. /**
  13921. * Minimum scale of emitting particles on Y axis.
  13922. */
  13923. minScaleY: number;
  13924. /**
  13925. * Maximum scale of emitting particles on Y axis.
  13926. */
  13927. maxScaleY: number;
  13928. /**
  13929. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13930. */
  13931. color1: Color4;
  13932. /**
  13933. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13934. */
  13935. color2: Color4;
  13936. /**
  13937. * Color the particle will have at the end of its lifetime.
  13938. */
  13939. colorDead: Color4;
  13940. /**
  13941. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  13942. */
  13943. emitRate: number;
  13944. /**
  13945. * You can use gravity if you want to give an orientation to your particles.
  13946. */
  13947. gravity: Vector3;
  13948. /**
  13949. * Minimum power of emitting particles.
  13950. */
  13951. minEmitPower: number;
  13952. /**
  13953. * Maximum power of emitting particles.
  13954. */
  13955. maxEmitPower: number;
  13956. /**
  13957. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13958. */
  13959. minAngularSpeed: number;
  13960. /**
  13961. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13962. */
  13963. maxAngularSpeed: number;
  13964. /**
  13965. * Gets or sets the minimal initial rotation in radians.
  13966. */
  13967. minInitialRotation: number;
  13968. /**
  13969. * Gets or sets the maximal initial rotation in radians.
  13970. */
  13971. maxInitialRotation: number;
  13972. /**
  13973. * The particle emitter type defines the emitter used by the particle system.
  13974. * It can be for example box, sphere, or cone...
  13975. */
  13976. particleEmitterType: Nullable<IParticleEmitterType>;
  13977. /**
  13978. * Defines the delay in milliseconds before starting the system (0 by default)
  13979. */
  13980. startDelay: number;
  13981. /**
  13982. * 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
  13983. */
  13984. preWarmCycles: number;
  13985. /**
  13986. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  13987. */
  13988. preWarmStepOffset: number;
  13989. /**
  13990. * 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)
  13991. */
  13992. spriteCellChangeSpeed: number;
  13993. /**
  13994. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  13995. */
  13996. startSpriteCellID: number;
  13997. /**
  13998. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  13999. */
  14000. endSpriteCellID: number;
  14001. /**
  14002. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14003. */
  14004. spriteCellWidth: number;
  14005. /**
  14006. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14007. */
  14008. spriteCellHeight: number;
  14009. /**
  14010. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14011. */
  14012. spriteRandomStartCell: boolean;
  14013. /**
  14014. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14015. */
  14016. isAnimationSheetEnabled: boolean;
  14017. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14018. translationPivot: Vector2;
  14019. /**
  14020. * Gets or sets a texture used to add random noise to particle positions
  14021. */
  14022. noiseTexture: Nullable<BaseTexture>;
  14023. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14024. noiseStrength: Vector3;
  14025. /**
  14026. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14027. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14028. */
  14029. billboardMode: number;
  14030. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14031. limitVelocityDamping: number;
  14032. /**
  14033. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14034. */
  14035. beginAnimationOnStart: boolean;
  14036. /**
  14037. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14038. */
  14039. beginAnimationFrom: number;
  14040. /**
  14041. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14042. */
  14043. beginAnimationTo: number;
  14044. /**
  14045. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14046. */
  14047. beginAnimationLoop: boolean;
  14048. /**
  14049. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14050. */
  14051. disposeOnStop: boolean;
  14052. /**
  14053. * Specifies if the particles are updated in emitter local space or world space
  14054. */
  14055. isLocal: boolean;
  14056. /** Snippet ID if the particle system was created from the snippet server */
  14057. snippetId: string;
  14058. /**
  14059. * Gets the maximum number of particles active at the same time.
  14060. * @returns The max number of active particles.
  14061. */
  14062. getCapacity(): number;
  14063. /**
  14064. * Gets the number of particles active at the same time.
  14065. * @returns The number of active particles.
  14066. */
  14067. getActiveCount(): number;
  14068. /**
  14069. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14070. * @returns True if it has been started, otherwise false.
  14071. */
  14072. isStarted(): boolean;
  14073. /**
  14074. * Animates the particle system for this frame.
  14075. */
  14076. animate(): void;
  14077. /**
  14078. * Renders the particle system in its current state.
  14079. * @returns the current number of particles
  14080. */
  14081. render(): number;
  14082. /**
  14083. * Dispose the particle system and frees its associated resources.
  14084. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14085. */
  14086. dispose(disposeTexture?: boolean): void;
  14087. /**
  14088. * An event triggered when the system is disposed
  14089. */
  14090. onDisposeObservable: Observable<IParticleSystem>;
  14091. /**
  14092. * Clones the particle system.
  14093. * @param name The name of the cloned object
  14094. * @param newEmitter The new emitter to use
  14095. * @returns the cloned particle system
  14096. */
  14097. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14098. /**
  14099. * Serializes the particle system to a JSON object
  14100. * @param serializeTexture defines if the texture must be serialized as well
  14101. * @returns the JSON object
  14102. */
  14103. serialize(serializeTexture: boolean): any;
  14104. /**
  14105. * Rebuild the particle system
  14106. */
  14107. rebuild(): void;
  14108. /** Force the system to rebuild all gradients that need to be resync */
  14109. forceRefreshGradients(): void;
  14110. /**
  14111. * Starts the particle system and begins to emit
  14112. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14113. */
  14114. start(delay?: number): void;
  14115. /**
  14116. * Stops the particle system.
  14117. */
  14118. stop(): void;
  14119. /**
  14120. * Remove all active particles
  14121. */
  14122. reset(): void;
  14123. /**
  14124. * Gets a boolean indicating that the system is stopping
  14125. * @returns true if the system is currently stopping
  14126. */
  14127. isStopping(): boolean;
  14128. /**
  14129. * Is this system ready to be used/rendered
  14130. * @return true if the system is ready
  14131. */
  14132. isReady(): boolean;
  14133. /**
  14134. * Returns the string "ParticleSystem"
  14135. * @returns a string containing the class name
  14136. */
  14137. getClassName(): string;
  14138. /**
  14139. * Gets the custom effect used to render the particles
  14140. * @param blendMode Blend mode for which the effect should be retrieved
  14141. * @returns The effect
  14142. */
  14143. getCustomEffect(blendMode: number): Nullable<Effect>;
  14144. /**
  14145. * Sets the custom effect used to render the particles
  14146. * @param effect The effect to set
  14147. * @param blendMode Blend mode for which the effect should be set
  14148. */
  14149. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14150. /**
  14151. * Fill the defines array according to the current settings of the particle system
  14152. * @param defines Array to be updated
  14153. * @param blendMode blend mode to take into account when updating the array
  14154. */
  14155. fillDefines(defines: Array<string>, blendMode: number): void;
  14156. /**
  14157. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14158. * @param uniforms Uniforms array to fill
  14159. * @param attributes Attributes array to fill
  14160. * @param samplers Samplers array to fill
  14161. */
  14162. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14163. /**
  14164. * Observable that will be called just before the particles are drawn
  14165. */
  14166. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14167. /**
  14168. * Gets the name of the particle vertex shader
  14169. */
  14170. vertexShaderName: string;
  14171. /**
  14172. * Adds a new color gradient
  14173. * @param gradient defines the gradient to use (between 0 and 1)
  14174. * @param color1 defines the color to affect to the specified gradient
  14175. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14176. * @returns the current particle system
  14177. */
  14178. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14179. /**
  14180. * Remove a specific color gradient
  14181. * @param gradient defines the gradient to remove
  14182. * @returns the current particle system
  14183. */
  14184. removeColorGradient(gradient: number): IParticleSystem;
  14185. /**
  14186. * Adds a new size gradient
  14187. * @param gradient defines the gradient to use (between 0 and 1)
  14188. * @param factor defines the size factor to affect to the specified gradient
  14189. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14190. * @returns the current particle system
  14191. */
  14192. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14193. /**
  14194. * Remove a specific size gradient
  14195. * @param gradient defines the gradient to remove
  14196. * @returns the current particle system
  14197. */
  14198. removeSizeGradient(gradient: number): IParticleSystem;
  14199. /**
  14200. * Gets the current list of color gradients.
  14201. * You must use addColorGradient and removeColorGradient to udpate this list
  14202. * @returns the list of color gradients
  14203. */
  14204. getColorGradients(): Nullable<Array<ColorGradient>>;
  14205. /**
  14206. * Gets the current list of size gradients.
  14207. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14208. * @returns the list of size gradients
  14209. */
  14210. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14211. /**
  14212. * Gets the current list of angular speed gradients.
  14213. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14214. * @returns the list of angular speed gradients
  14215. */
  14216. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14217. /**
  14218. * Adds a new angular speed gradient
  14219. * @param gradient defines the gradient to use (between 0 and 1)
  14220. * @param factor defines the angular speed to affect to the specified gradient
  14221. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14222. * @returns the current particle system
  14223. */
  14224. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14225. /**
  14226. * Remove a specific angular speed gradient
  14227. * @param gradient defines the gradient to remove
  14228. * @returns the current particle system
  14229. */
  14230. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14231. /**
  14232. * Gets the current list of velocity gradients.
  14233. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14234. * @returns the list of velocity gradients
  14235. */
  14236. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14237. /**
  14238. * Adds a new velocity gradient
  14239. * @param gradient defines the gradient to use (between 0 and 1)
  14240. * @param factor defines the velocity to affect to the specified gradient
  14241. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14242. * @returns the current particle system
  14243. */
  14244. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14245. /**
  14246. * Remove a specific velocity gradient
  14247. * @param gradient defines the gradient to remove
  14248. * @returns the current particle system
  14249. */
  14250. removeVelocityGradient(gradient: number): IParticleSystem;
  14251. /**
  14252. * Gets the current list of limit velocity gradients.
  14253. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14254. * @returns the list of limit velocity gradients
  14255. */
  14256. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14257. /**
  14258. * Adds a new limit velocity gradient
  14259. * @param gradient defines the gradient to use (between 0 and 1)
  14260. * @param factor defines the limit velocity to affect to the specified gradient
  14261. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14262. * @returns the current particle system
  14263. */
  14264. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14265. /**
  14266. * Remove a specific limit velocity gradient
  14267. * @param gradient defines the gradient to remove
  14268. * @returns the current particle system
  14269. */
  14270. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14271. /**
  14272. * Adds a new drag gradient
  14273. * @param gradient defines the gradient to use (between 0 and 1)
  14274. * @param factor defines the drag to affect to the specified gradient
  14275. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14276. * @returns the current particle system
  14277. */
  14278. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14279. /**
  14280. * Remove a specific drag gradient
  14281. * @param gradient defines the gradient to remove
  14282. * @returns the current particle system
  14283. */
  14284. removeDragGradient(gradient: number): IParticleSystem;
  14285. /**
  14286. * Gets the current list of drag gradients.
  14287. * You must use addDragGradient and removeDragGradient to udpate this list
  14288. * @returns the list of drag gradients
  14289. */
  14290. getDragGradients(): Nullable<Array<FactorGradient>>;
  14291. /**
  14292. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14293. * @param gradient defines the gradient to use (between 0 and 1)
  14294. * @param factor defines the emit rate to affect to the specified gradient
  14295. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14296. * @returns the current particle system
  14297. */
  14298. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14299. /**
  14300. * Remove a specific emit rate gradient
  14301. * @param gradient defines the gradient to remove
  14302. * @returns the current particle system
  14303. */
  14304. removeEmitRateGradient(gradient: number): IParticleSystem;
  14305. /**
  14306. * Gets the current list of emit rate gradients.
  14307. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14308. * @returns the list of emit rate gradients
  14309. */
  14310. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14311. /**
  14312. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14313. * @param gradient defines the gradient to use (between 0 and 1)
  14314. * @param factor defines the start size to affect to the specified gradient
  14315. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14316. * @returns the current particle system
  14317. */
  14318. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14319. /**
  14320. * Remove a specific start size gradient
  14321. * @param gradient defines the gradient to remove
  14322. * @returns the current particle system
  14323. */
  14324. removeStartSizeGradient(gradient: number): IParticleSystem;
  14325. /**
  14326. * Gets the current list of start size gradients.
  14327. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14328. * @returns the list of start size gradients
  14329. */
  14330. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14331. /**
  14332. * Adds a new life time gradient
  14333. * @param gradient defines the gradient to use (between 0 and 1)
  14334. * @param factor defines the life time factor to affect to the specified gradient
  14335. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14336. * @returns the current particle system
  14337. */
  14338. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14339. /**
  14340. * Remove a specific life time gradient
  14341. * @param gradient defines the gradient to remove
  14342. * @returns the current particle system
  14343. */
  14344. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14345. /**
  14346. * Gets the current list of life time gradients.
  14347. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14348. * @returns the list of life time gradients
  14349. */
  14350. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14351. /**
  14352. * Gets the current list of color gradients.
  14353. * You must use addColorGradient and removeColorGradient to udpate this list
  14354. * @returns the list of color gradients
  14355. */
  14356. getColorGradients(): Nullable<Array<ColorGradient>>;
  14357. /**
  14358. * Adds a new ramp gradient used to remap particle colors
  14359. * @param gradient defines the gradient to use (between 0 and 1)
  14360. * @param color defines the color to affect to the specified gradient
  14361. * @returns the current particle system
  14362. */
  14363. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14364. /**
  14365. * Gets the current list of ramp gradients.
  14366. * You must use addRampGradient and removeRampGradient to udpate this list
  14367. * @returns the list of ramp gradients
  14368. */
  14369. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14370. /** Gets or sets a boolean indicating that ramp gradients must be used
  14371. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14372. */
  14373. useRampGradients: boolean;
  14374. /**
  14375. * Adds a new color remap gradient
  14376. * @param gradient defines the gradient to use (between 0 and 1)
  14377. * @param min defines the color remap minimal range
  14378. * @param max defines the color remap maximal range
  14379. * @returns the current particle system
  14380. */
  14381. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14382. /**
  14383. * Gets the current list of color remap gradients.
  14384. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14385. * @returns the list of color remap gradients
  14386. */
  14387. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14388. /**
  14389. * Adds a new alpha remap gradient
  14390. * @param gradient defines the gradient to use (between 0 and 1)
  14391. * @param min defines the alpha remap minimal range
  14392. * @param max defines the alpha remap maximal range
  14393. * @returns the current particle system
  14394. */
  14395. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14396. /**
  14397. * Gets the current list of alpha remap gradients.
  14398. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14399. * @returns the list of alpha remap gradients
  14400. */
  14401. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14402. /**
  14403. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14404. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14405. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14406. * @returns the emitter
  14407. */
  14408. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14409. /**
  14410. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14411. * @param radius The radius of the hemisphere to emit from
  14412. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14413. * @returns the emitter
  14414. */
  14415. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14416. /**
  14417. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14418. * @param radius The radius of the sphere to emit from
  14419. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14420. * @returns the emitter
  14421. */
  14422. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14423. /**
  14424. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14425. * @param radius The radius of the sphere to emit from
  14426. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14427. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14428. * @returns the emitter
  14429. */
  14430. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14431. /**
  14432. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14433. * @param radius The radius of the emission cylinder
  14434. * @param height The height of the emission cylinder
  14435. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14436. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14437. * @returns the emitter
  14438. */
  14439. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  14440. /**
  14441. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14442. * @param radius The radius of the cylinder to emit from
  14443. * @param height The height of the emission cylinder
  14444. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14445. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14446. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14447. * @returns the emitter
  14448. */
  14449. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14450. /**
  14451. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14452. * @param radius The radius of the cone to emit from
  14453. * @param angle The base angle of the cone
  14454. * @returns the emitter
  14455. */
  14456. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  14457. /**
  14458. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14459. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14460. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14461. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14462. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14463. * @returns the emitter
  14464. */
  14465. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14466. /**
  14467. * Get hosting scene
  14468. * @returns the scene
  14469. */
  14470. getScene(): Scene;
  14471. }
  14472. }
  14473. declare module BABYLON {
  14474. /**
  14475. * 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.
  14476. * @see https://doc.babylonjs.com/how_to/transformnode
  14477. */
  14478. export class TransformNode extends Node {
  14479. /**
  14480. * Object will not rotate to face the camera
  14481. */
  14482. static BILLBOARDMODE_NONE: number;
  14483. /**
  14484. * Object will rotate to face the camera but only on the x axis
  14485. */
  14486. static BILLBOARDMODE_X: number;
  14487. /**
  14488. * Object will rotate to face the camera but only on the y axis
  14489. */
  14490. static BILLBOARDMODE_Y: number;
  14491. /**
  14492. * Object will rotate to face the camera but only on the z axis
  14493. */
  14494. static BILLBOARDMODE_Z: number;
  14495. /**
  14496. * Object will rotate to face the camera
  14497. */
  14498. static BILLBOARDMODE_ALL: number;
  14499. /**
  14500. * Object will rotate to face the camera's position instead of orientation
  14501. */
  14502. static BILLBOARDMODE_USE_POSITION: number;
  14503. private _forward;
  14504. private _forwardInverted;
  14505. private _up;
  14506. private _right;
  14507. private _rightInverted;
  14508. private _position;
  14509. private _rotation;
  14510. private _rotationQuaternion;
  14511. protected _scaling: Vector3;
  14512. protected _isDirty: boolean;
  14513. private _transformToBoneReferal;
  14514. private _isAbsoluteSynced;
  14515. private _billboardMode;
  14516. /**
  14517. * Gets or sets the billboard mode. Default is 0.
  14518. *
  14519. * | Value | Type | Description |
  14520. * | --- | --- | --- |
  14521. * | 0 | BILLBOARDMODE_NONE | |
  14522. * | 1 | BILLBOARDMODE_X | |
  14523. * | 2 | BILLBOARDMODE_Y | |
  14524. * | 4 | BILLBOARDMODE_Z | |
  14525. * | 7 | BILLBOARDMODE_ALL | |
  14526. *
  14527. */
  14528. get billboardMode(): number;
  14529. set billboardMode(value: number);
  14530. private _preserveParentRotationForBillboard;
  14531. /**
  14532. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14533. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14534. */
  14535. get preserveParentRotationForBillboard(): boolean;
  14536. set preserveParentRotationForBillboard(value: boolean);
  14537. /**
  14538. * 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
  14539. */
  14540. scalingDeterminant: number;
  14541. private _infiniteDistance;
  14542. /**
  14543. * Gets or sets the distance of the object to max, often used by skybox
  14544. */
  14545. get infiniteDistance(): boolean;
  14546. set infiniteDistance(value: boolean);
  14547. /**
  14548. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14549. * By default the system will update normals to compensate
  14550. */
  14551. ignoreNonUniformScaling: boolean;
  14552. /**
  14553. * 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
  14554. */
  14555. reIntegrateRotationIntoRotationQuaternion: boolean;
  14556. /** @hidden */
  14557. _poseMatrix: Nullable<Matrix>;
  14558. /** @hidden */
  14559. _localMatrix: Matrix;
  14560. private _usePivotMatrix;
  14561. private _absolutePosition;
  14562. private _absoluteScaling;
  14563. private _absoluteRotationQuaternion;
  14564. private _pivotMatrix;
  14565. private _pivotMatrixInverse;
  14566. protected _postMultiplyPivotMatrix: boolean;
  14567. protected _isWorldMatrixFrozen: boolean;
  14568. /** @hidden */
  14569. _indexInSceneTransformNodesArray: number;
  14570. /**
  14571. * An event triggered after the world matrix is updated
  14572. */
  14573. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14574. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14575. /**
  14576. * Gets a string identifying the name of the class
  14577. * @returns "TransformNode" string
  14578. */
  14579. getClassName(): string;
  14580. /**
  14581. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14582. */
  14583. get position(): Vector3;
  14584. set position(newPosition: Vector3);
  14585. /**
  14586. * 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)).
  14587. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14588. */
  14589. get rotation(): Vector3;
  14590. set rotation(newRotation: Vector3);
  14591. /**
  14592. * 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)).
  14593. */
  14594. get scaling(): Vector3;
  14595. set scaling(newScaling: Vector3);
  14596. /**
  14597. * 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).
  14598. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14599. */
  14600. get rotationQuaternion(): Nullable<Quaternion>;
  14601. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14602. /**
  14603. * The forward direction of that transform in world space.
  14604. */
  14605. get forward(): Vector3;
  14606. /**
  14607. * The up direction of that transform in world space.
  14608. */
  14609. get up(): Vector3;
  14610. /**
  14611. * The right direction of that transform in world space.
  14612. */
  14613. get right(): Vector3;
  14614. /**
  14615. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14616. * @param matrix the matrix to copy the pose from
  14617. * @returns this TransformNode.
  14618. */
  14619. updatePoseMatrix(matrix: Matrix): TransformNode;
  14620. /**
  14621. * Returns the mesh Pose matrix.
  14622. * @returns the pose matrix
  14623. */
  14624. getPoseMatrix(): Matrix;
  14625. /** @hidden */
  14626. _isSynchronized(): boolean;
  14627. /** @hidden */
  14628. _initCache(): void;
  14629. /**
  14630. * Flag the transform node as dirty (Forcing it to update everything)
  14631. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14632. * @returns this transform node
  14633. */
  14634. markAsDirty(property: string): TransformNode;
  14635. /**
  14636. * Returns the current mesh absolute position.
  14637. * Returns a Vector3.
  14638. */
  14639. get absolutePosition(): Vector3;
  14640. /**
  14641. * Returns the current mesh absolute scaling.
  14642. * Returns a Vector3.
  14643. */
  14644. get absoluteScaling(): Vector3;
  14645. /**
  14646. * Returns the current mesh absolute rotation.
  14647. * Returns a Quaternion.
  14648. */
  14649. get absoluteRotationQuaternion(): Quaternion;
  14650. /**
  14651. * Sets a new matrix to apply before all other transformation
  14652. * @param matrix defines the transform matrix
  14653. * @returns the current TransformNode
  14654. */
  14655. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14656. /**
  14657. * Sets a new pivot matrix to the current node
  14658. * @param matrix defines the new pivot matrix to use
  14659. * @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
  14660. * @returns the current TransformNode
  14661. */
  14662. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14663. /**
  14664. * Returns the mesh pivot matrix.
  14665. * Default : Identity.
  14666. * @returns the matrix
  14667. */
  14668. getPivotMatrix(): Matrix;
  14669. /**
  14670. * Instantiate (when possible) or clone that node with its hierarchy
  14671. * @param newParent defines the new parent to use for the instance (or clone)
  14672. * @param options defines options to configure how copy is done
  14673. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14674. * @returns an instance (or a clone) of the current node with its hiearchy
  14675. */
  14676. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14677. doNotInstantiate: boolean;
  14678. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14679. /**
  14680. * Prevents the World matrix to be computed any longer
  14681. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14682. * @returns the TransformNode.
  14683. */
  14684. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14685. /**
  14686. * Allows back the World matrix computation.
  14687. * @returns the TransformNode.
  14688. */
  14689. unfreezeWorldMatrix(): this;
  14690. /**
  14691. * True if the World matrix has been frozen.
  14692. */
  14693. get isWorldMatrixFrozen(): boolean;
  14694. /**
  14695. * Retuns the mesh absolute position in the World.
  14696. * @returns a Vector3.
  14697. */
  14698. getAbsolutePosition(): Vector3;
  14699. /**
  14700. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14701. * @param absolutePosition the absolute position to set
  14702. * @returns the TransformNode.
  14703. */
  14704. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14705. /**
  14706. * Sets the mesh position in its local space.
  14707. * @param vector3 the position to set in localspace
  14708. * @returns the TransformNode.
  14709. */
  14710. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14711. /**
  14712. * Returns the mesh position in the local space from the current World matrix values.
  14713. * @returns a new Vector3.
  14714. */
  14715. getPositionExpressedInLocalSpace(): Vector3;
  14716. /**
  14717. * Translates the mesh along the passed Vector3 in its local space.
  14718. * @param vector3 the distance to translate in localspace
  14719. * @returns the TransformNode.
  14720. */
  14721. locallyTranslate(vector3: Vector3): TransformNode;
  14722. private static _lookAtVectorCache;
  14723. /**
  14724. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14725. * @param targetPoint the position (must be in same space as current mesh) to look at
  14726. * @param yawCor optional yaw (y-axis) correction in radians
  14727. * @param pitchCor optional pitch (x-axis) correction in radians
  14728. * @param rollCor optional roll (z-axis) correction in radians
  14729. * @param space the choosen space of the target
  14730. * @returns the TransformNode.
  14731. */
  14732. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14733. /**
  14734. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14735. * This Vector3 is expressed in the World space.
  14736. * @param localAxis axis to rotate
  14737. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14738. */
  14739. getDirection(localAxis: Vector3): Vector3;
  14740. /**
  14741. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14742. * localAxis is expressed in the mesh local space.
  14743. * result is computed in the Wordl space from the mesh World matrix.
  14744. * @param localAxis axis to rotate
  14745. * @param result the resulting transformnode
  14746. * @returns this TransformNode.
  14747. */
  14748. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14749. /**
  14750. * Sets this transform node rotation to the given local axis.
  14751. * @param localAxis the axis in local space
  14752. * @param yawCor optional yaw (y-axis) correction in radians
  14753. * @param pitchCor optional pitch (x-axis) correction in radians
  14754. * @param rollCor optional roll (z-axis) correction in radians
  14755. * @returns this TransformNode
  14756. */
  14757. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14758. /**
  14759. * Sets a new pivot point to the current node
  14760. * @param point defines the new pivot point to use
  14761. * @param space defines if the point is in world or local space (local by default)
  14762. * @returns the current TransformNode
  14763. */
  14764. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14765. /**
  14766. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14767. * @returns the pivot point
  14768. */
  14769. getPivotPoint(): Vector3;
  14770. /**
  14771. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14772. * @param result the vector3 to store the result
  14773. * @returns this TransformNode.
  14774. */
  14775. getPivotPointToRef(result: Vector3): TransformNode;
  14776. /**
  14777. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14778. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14779. */
  14780. getAbsolutePivotPoint(): Vector3;
  14781. /**
  14782. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14783. * @param result vector3 to store the result
  14784. * @returns this TransformNode.
  14785. */
  14786. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14787. /**
  14788. * Defines the passed node as the parent of the current node.
  14789. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14790. * @see https://doc.babylonjs.com/how_to/parenting
  14791. * @param node the node ot set as the parent
  14792. * @returns this TransformNode.
  14793. */
  14794. setParent(node: Nullable<Node>): TransformNode;
  14795. private _nonUniformScaling;
  14796. /**
  14797. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14798. */
  14799. get nonUniformScaling(): boolean;
  14800. /** @hidden */
  14801. _updateNonUniformScalingState(value: boolean): boolean;
  14802. /**
  14803. * Attach the current TransformNode to another TransformNode associated with a bone
  14804. * @param bone Bone affecting the TransformNode
  14805. * @param affectedTransformNode TransformNode associated with the bone
  14806. * @returns this object
  14807. */
  14808. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14809. /**
  14810. * Detach the transform node if its associated with a bone
  14811. * @returns this object
  14812. */
  14813. detachFromBone(): TransformNode;
  14814. private static _rotationAxisCache;
  14815. /**
  14816. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14817. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14818. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14819. * The passed axis is also normalized.
  14820. * @param axis the axis to rotate around
  14821. * @param amount the amount to rotate in radians
  14822. * @param space Space to rotate in (Default: local)
  14823. * @returns the TransformNode.
  14824. */
  14825. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14826. /**
  14827. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14828. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14829. * The passed axis is also normalized. .
  14830. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14831. * @param point the point to rotate around
  14832. * @param axis the axis to rotate around
  14833. * @param amount the amount to rotate in radians
  14834. * @returns the TransformNode
  14835. */
  14836. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14837. /**
  14838. * Translates the mesh along the axis vector for the passed distance in the given space.
  14839. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14840. * @param axis the axis to translate in
  14841. * @param distance the distance to translate
  14842. * @param space Space to rotate in (Default: local)
  14843. * @returns the TransformNode.
  14844. */
  14845. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14846. /**
  14847. * Adds a rotation step to the mesh current rotation.
  14848. * x, y, z are Euler angles expressed in radians.
  14849. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14850. * This means this rotation is made in the mesh local space only.
  14851. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14852. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14853. * ```javascript
  14854. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14855. * ```
  14856. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14857. * 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.
  14858. * @param x Rotation to add
  14859. * @param y Rotation to add
  14860. * @param z Rotation to add
  14861. * @returns the TransformNode.
  14862. */
  14863. addRotation(x: number, y: number, z: number): TransformNode;
  14864. /**
  14865. * @hidden
  14866. */
  14867. protected _getEffectiveParent(): Nullable<Node>;
  14868. /**
  14869. * Computes the world matrix of the node
  14870. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14871. * @returns the world matrix
  14872. */
  14873. computeWorldMatrix(force?: boolean): Matrix;
  14874. /**
  14875. * Resets this nodeTransform's local matrix to Matrix.Identity().
  14876. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  14877. */
  14878. resetLocalMatrix(independentOfChildren?: boolean): void;
  14879. protected _afterComputeWorldMatrix(): void;
  14880. /**
  14881. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14882. * @param func callback function to add
  14883. *
  14884. * @returns the TransformNode.
  14885. */
  14886. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14887. /**
  14888. * Removes a registered callback function.
  14889. * @param func callback function to remove
  14890. * @returns the TransformNode.
  14891. */
  14892. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14893. /**
  14894. * Gets the position of the current mesh in camera space
  14895. * @param camera defines the camera to use
  14896. * @returns a position
  14897. */
  14898. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14899. /**
  14900. * Returns the distance from the mesh to the active camera
  14901. * @param camera defines the camera to use
  14902. * @returns the distance
  14903. */
  14904. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14905. /**
  14906. * Clone the current transform node
  14907. * @param name Name of the new clone
  14908. * @param newParent New parent for the clone
  14909. * @param doNotCloneChildren Do not clone children hierarchy
  14910. * @returns the new transform node
  14911. */
  14912. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14913. /**
  14914. * Serializes the objects information.
  14915. * @param currentSerializationObject defines the object to serialize in
  14916. * @returns the serialized object
  14917. */
  14918. serialize(currentSerializationObject?: any): any;
  14919. /**
  14920. * Returns a new TransformNode object parsed from the source provided.
  14921. * @param parsedTransformNode is the source.
  14922. * @param scene the scne the object belongs to
  14923. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14924. * @returns a new TransformNode object parsed from the source provided.
  14925. */
  14926. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14927. /**
  14928. * Get all child-transformNodes of this node
  14929. * @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
  14930. * @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
  14931. * @returns an array of TransformNode
  14932. */
  14933. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14934. /**
  14935. * Releases resources associated with this transform node.
  14936. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14937. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14938. */
  14939. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14940. /**
  14941. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14942. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14943. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14944. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14945. * @returns the current mesh
  14946. */
  14947. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14948. private _syncAbsoluteScalingAndRotation;
  14949. }
  14950. }
  14951. declare module BABYLON {
  14952. /**
  14953. * Class used to override all child animations of a given target
  14954. */
  14955. export class AnimationPropertiesOverride {
  14956. /**
  14957. * Gets or sets a value indicating if animation blending must be used
  14958. */
  14959. enableBlending: boolean;
  14960. /**
  14961. * Gets or sets the blending speed to use when enableBlending is true
  14962. */
  14963. blendingSpeed: number;
  14964. /**
  14965. * Gets or sets the default loop mode to use
  14966. */
  14967. loopMode: number;
  14968. }
  14969. }
  14970. declare module BABYLON {
  14971. /**
  14972. * Class used to store bone information
  14973. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14974. */
  14975. export class Bone extends Node {
  14976. /**
  14977. * defines the bone name
  14978. */
  14979. name: string;
  14980. private static _tmpVecs;
  14981. private static _tmpQuat;
  14982. private static _tmpMats;
  14983. /**
  14984. * Gets the list of child bones
  14985. */
  14986. children: Bone[];
  14987. /** Gets the animations associated with this bone */
  14988. animations: Animation[];
  14989. /**
  14990. * Gets or sets bone length
  14991. */
  14992. length: number;
  14993. /**
  14994. * @hidden Internal only
  14995. * Set this value to map this bone to a different index in the transform matrices
  14996. * Set this value to -1 to exclude the bone from the transform matrices
  14997. */
  14998. _index: Nullable<number>;
  14999. private _skeleton;
  15000. private _localMatrix;
  15001. private _restPose;
  15002. private _baseMatrix;
  15003. private _absoluteTransform;
  15004. private _invertedAbsoluteTransform;
  15005. private _parent;
  15006. private _scalingDeterminant;
  15007. private _worldTransform;
  15008. private _localScaling;
  15009. private _localRotation;
  15010. private _localPosition;
  15011. private _needToDecompose;
  15012. private _needToCompose;
  15013. /** @hidden */
  15014. _linkedTransformNode: Nullable<TransformNode>;
  15015. /** @hidden */
  15016. _waitingTransformNodeId: Nullable<string>;
  15017. /** @hidden */
  15018. get _matrix(): Matrix;
  15019. /** @hidden */
  15020. set _matrix(value: Matrix);
  15021. /**
  15022. * Create a new bone
  15023. * @param name defines the bone name
  15024. * @param skeleton defines the parent skeleton
  15025. * @param parentBone defines the parent (can be null if the bone is the root)
  15026. * @param localMatrix defines the local matrix
  15027. * @param restPose defines the rest pose matrix
  15028. * @param baseMatrix defines the base matrix
  15029. * @param index defines index of the bone in the hiearchy
  15030. */
  15031. constructor(
  15032. /**
  15033. * defines the bone name
  15034. */
  15035. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15036. /**
  15037. * Gets the current object class name.
  15038. * @return the class name
  15039. */
  15040. getClassName(): string;
  15041. /**
  15042. * Gets the parent skeleton
  15043. * @returns a skeleton
  15044. */
  15045. getSkeleton(): Skeleton;
  15046. /**
  15047. * Gets parent bone
  15048. * @returns a bone or null if the bone is the root of the bone hierarchy
  15049. */
  15050. getParent(): Nullable<Bone>;
  15051. /**
  15052. * Returns an array containing the root bones
  15053. * @returns an array containing the root bones
  15054. */
  15055. getChildren(): Array<Bone>;
  15056. /**
  15057. * Gets the node index in matrix array generated for rendering
  15058. * @returns the node index
  15059. */
  15060. getIndex(): number;
  15061. /**
  15062. * Sets the parent bone
  15063. * @param parent defines the parent (can be null if the bone is the root)
  15064. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15065. */
  15066. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15067. /**
  15068. * Gets the local matrix
  15069. * @returns a matrix
  15070. */
  15071. getLocalMatrix(): Matrix;
  15072. /**
  15073. * Gets the base matrix (initial matrix which remains unchanged)
  15074. * @returns a matrix
  15075. */
  15076. getBaseMatrix(): Matrix;
  15077. /**
  15078. * Gets the rest pose matrix
  15079. * @returns a matrix
  15080. */
  15081. getRestPose(): Matrix;
  15082. /**
  15083. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15084. */
  15085. getWorldMatrix(): Matrix;
  15086. /**
  15087. * Sets the local matrix to rest pose matrix
  15088. */
  15089. returnToRest(): void;
  15090. /**
  15091. * Gets the inverse of the absolute transform matrix.
  15092. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15093. * @returns a matrix
  15094. */
  15095. getInvertedAbsoluteTransform(): Matrix;
  15096. /**
  15097. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15098. * @returns a matrix
  15099. */
  15100. getAbsoluteTransform(): Matrix;
  15101. /**
  15102. * Links with the given transform node.
  15103. * The local matrix of this bone is copied from the transform node every frame.
  15104. * @param transformNode defines the transform node to link to
  15105. */
  15106. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15107. /**
  15108. * Gets the node used to drive the bone's transformation
  15109. * @returns a transform node or null
  15110. */
  15111. getTransformNode(): Nullable<TransformNode>;
  15112. /** Gets or sets current position (in local space) */
  15113. get position(): Vector3;
  15114. set position(newPosition: Vector3);
  15115. /** Gets or sets current rotation (in local space) */
  15116. get rotation(): Vector3;
  15117. set rotation(newRotation: Vector3);
  15118. /** Gets or sets current rotation quaternion (in local space) */
  15119. get rotationQuaternion(): Quaternion;
  15120. set rotationQuaternion(newRotation: Quaternion);
  15121. /** Gets or sets current scaling (in local space) */
  15122. get scaling(): Vector3;
  15123. set scaling(newScaling: Vector3);
  15124. /**
  15125. * Gets the animation properties override
  15126. */
  15127. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15128. private _decompose;
  15129. private _compose;
  15130. /**
  15131. * Update the base and local matrices
  15132. * @param matrix defines the new base or local matrix
  15133. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15134. * @param updateLocalMatrix defines if the local matrix should be updated
  15135. */
  15136. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15137. /** @hidden */
  15138. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15139. /**
  15140. * Flag the bone as dirty (Forcing it to update everything)
  15141. */
  15142. markAsDirty(): void;
  15143. /** @hidden */
  15144. _markAsDirtyAndCompose(): void;
  15145. private _markAsDirtyAndDecompose;
  15146. /**
  15147. * Translate the bone in local or world space
  15148. * @param vec The amount to translate the bone
  15149. * @param space The space that the translation is in
  15150. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15151. */
  15152. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15153. /**
  15154. * Set the postion of the bone in local or world space
  15155. * @param position The position to set the bone
  15156. * @param space The space that the position is in
  15157. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15158. */
  15159. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15160. /**
  15161. * Set the absolute position of the bone (world space)
  15162. * @param position The position to set the bone
  15163. * @param mesh The mesh that this bone is attached to
  15164. */
  15165. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15166. /**
  15167. * Scale the bone on the x, y and z axes (in local space)
  15168. * @param x The amount to scale the bone on the x axis
  15169. * @param y The amount to scale the bone on the y axis
  15170. * @param z The amount to scale the bone on the z axis
  15171. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15172. */
  15173. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15174. /**
  15175. * Set the bone scaling in local space
  15176. * @param scale defines the scaling vector
  15177. */
  15178. setScale(scale: Vector3): void;
  15179. /**
  15180. * Gets the current scaling in local space
  15181. * @returns the current scaling vector
  15182. */
  15183. getScale(): Vector3;
  15184. /**
  15185. * Gets the current scaling in local space and stores it in a target vector
  15186. * @param result defines the target vector
  15187. */
  15188. getScaleToRef(result: Vector3): void;
  15189. /**
  15190. * Set the yaw, pitch, and roll of the bone in local or world space
  15191. * @param yaw The rotation of the bone on the y axis
  15192. * @param pitch The rotation of the bone on the x axis
  15193. * @param roll The rotation of the bone on the z axis
  15194. * @param space The space that the axes of rotation are in
  15195. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15196. */
  15197. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15198. /**
  15199. * Add a rotation to the bone on an axis in local or world space
  15200. * @param axis The axis to rotate the bone on
  15201. * @param amount The amount to rotate the bone
  15202. * @param space The space that the axis is in
  15203. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15204. */
  15205. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15206. /**
  15207. * Set the rotation of the bone to a particular axis angle in local or world space
  15208. * @param axis The axis to rotate the bone on
  15209. * @param angle The angle that the bone should be rotated to
  15210. * @param space The space that the axis is in
  15211. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15212. */
  15213. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15214. /**
  15215. * Set the euler rotation of the bone in local of world space
  15216. * @param rotation The euler rotation that the bone should be set to
  15217. * @param space The space that the rotation is in
  15218. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15219. */
  15220. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15221. /**
  15222. * Set the quaternion rotation of the bone in local of world space
  15223. * @param quat The quaternion rotation that the bone should be set to
  15224. * @param space The space that the rotation is in
  15225. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15226. */
  15227. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15228. /**
  15229. * Set the rotation matrix of the bone in local of world space
  15230. * @param rotMat The rotation matrix that the bone should be set to
  15231. * @param space The space that the rotation is in
  15232. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15233. */
  15234. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15235. private _rotateWithMatrix;
  15236. private _getNegativeRotationToRef;
  15237. /**
  15238. * Get the position of the bone in local or world space
  15239. * @param space The space that the returned position is in
  15240. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15241. * @returns The position of the bone
  15242. */
  15243. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15244. /**
  15245. * Copy the position of the bone to a vector3 in local or world space
  15246. * @param space The space that the returned position is in
  15247. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15248. * @param result The vector3 to copy the position to
  15249. */
  15250. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15251. /**
  15252. * Get the absolute position of the bone (world space)
  15253. * @param mesh The mesh that this bone is attached to
  15254. * @returns The absolute position of the bone
  15255. */
  15256. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15257. /**
  15258. * Copy the absolute position of the bone (world space) to the result param
  15259. * @param mesh The mesh that this bone is attached to
  15260. * @param result The vector3 to copy the absolute position to
  15261. */
  15262. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15263. /**
  15264. * Compute the absolute transforms of this bone and its children
  15265. */
  15266. computeAbsoluteTransforms(): void;
  15267. /**
  15268. * Get the world direction from an axis that is in the local space of the bone
  15269. * @param localAxis The local direction that is used to compute the world direction
  15270. * @param mesh The mesh that this bone is attached to
  15271. * @returns The world direction
  15272. */
  15273. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15274. /**
  15275. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15276. * @param localAxis The local direction that is used to compute the world direction
  15277. * @param mesh The mesh that this bone is attached to
  15278. * @param result The vector3 that the world direction will be copied to
  15279. */
  15280. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15281. /**
  15282. * Get the euler rotation of the bone in local or world space
  15283. * @param space The space that the rotation should be in
  15284. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15285. * @returns The euler rotation
  15286. */
  15287. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15288. /**
  15289. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15290. * @param space The space that the rotation should be in
  15291. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15292. * @param result The vector3 that the rotation should be copied to
  15293. */
  15294. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15295. /**
  15296. * Get the quaternion rotation of the bone in either local or world space
  15297. * @param space The space that the rotation should be in
  15298. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15299. * @returns The quaternion rotation
  15300. */
  15301. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15302. /**
  15303. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15304. * @param space The space that the rotation should be in
  15305. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15306. * @param result The quaternion that the rotation should be copied to
  15307. */
  15308. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15309. /**
  15310. * Get the rotation matrix of the bone in local or world space
  15311. * @param space The space that the rotation should be in
  15312. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15313. * @returns The rotation matrix
  15314. */
  15315. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15316. /**
  15317. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15318. * @param space The space that the rotation should be in
  15319. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15320. * @param result The quaternion that the rotation should be copied to
  15321. */
  15322. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15323. /**
  15324. * Get the world position of a point that is in the local space of the bone
  15325. * @param position The local position
  15326. * @param mesh The mesh that this bone is attached to
  15327. * @returns The world position
  15328. */
  15329. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15330. /**
  15331. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15332. * @param position The local position
  15333. * @param mesh The mesh that this bone is attached to
  15334. * @param result The vector3 that the world position should be copied to
  15335. */
  15336. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15337. /**
  15338. * Get the local position of a point that is in world space
  15339. * @param position The world position
  15340. * @param mesh The mesh that this bone is attached to
  15341. * @returns The local position
  15342. */
  15343. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15344. /**
  15345. * Get the local position of a point that is in world space and copy it to the result param
  15346. * @param position The world position
  15347. * @param mesh The mesh that this bone is attached to
  15348. * @param result The vector3 that the local position should be copied to
  15349. */
  15350. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15351. }
  15352. }
  15353. declare module BABYLON {
  15354. /**
  15355. * Defines a runtime animation
  15356. */
  15357. export class RuntimeAnimation {
  15358. private _events;
  15359. /**
  15360. * The current frame of the runtime animation
  15361. */
  15362. private _currentFrame;
  15363. /**
  15364. * The animation used by the runtime animation
  15365. */
  15366. private _animation;
  15367. /**
  15368. * The target of the runtime animation
  15369. */
  15370. private _target;
  15371. /**
  15372. * The initiating animatable
  15373. */
  15374. private _host;
  15375. /**
  15376. * The original value of the runtime animation
  15377. */
  15378. private _originalValue;
  15379. /**
  15380. * The original blend value of the runtime animation
  15381. */
  15382. private _originalBlendValue;
  15383. /**
  15384. * The offsets cache of the runtime animation
  15385. */
  15386. private _offsetsCache;
  15387. /**
  15388. * The high limits cache of the runtime animation
  15389. */
  15390. private _highLimitsCache;
  15391. /**
  15392. * Specifies if the runtime animation has been stopped
  15393. */
  15394. private _stopped;
  15395. /**
  15396. * The blending factor of the runtime animation
  15397. */
  15398. private _blendingFactor;
  15399. /**
  15400. * The BabylonJS scene
  15401. */
  15402. private _scene;
  15403. /**
  15404. * The current value of the runtime animation
  15405. */
  15406. private _currentValue;
  15407. /** @hidden */
  15408. _animationState: _IAnimationState;
  15409. /**
  15410. * The active target of the runtime animation
  15411. */
  15412. private _activeTargets;
  15413. private _currentActiveTarget;
  15414. private _directTarget;
  15415. /**
  15416. * The target path of the runtime animation
  15417. */
  15418. private _targetPath;
  15419. /**
  15420. * The weight of the runtime animation
  15421. */
  15422. private _weight;
  15423. /**
  15424. * The ratio offset of the runtime animation
  15425. */
  15426. private _ratioOffset;
  15427. /**
  15428. * The previous delay of the runtime animation
  15429. */
  15430. private _previousDelay;
  15431. /**
  15432. * The previous ratio of the runtime animation
  15433. */
  15434. private _previousRatio;
  15435. private _enableBlending;
  15436. private _keys;
  15437. private _minFrame;
  15438. private _maxFrame;
  15439. private _minValue;
  15440. private _maxValue;
  15441. private _targetIsArray;
  15442. /**
  15443. * Gets the current frame of the runtime animation
  15444. */
  15445. get currentFrame(): number;
  15446. /**
  15447. * Gets the weight of the runtime animation
  15448. */
  15449. get weight(): number;
  15450. /**
  15451. * Gets the current value of the runtime animation
  15452. */
  15453. get currentValue(): any;
  15454. /**
  15455. * Gets the target path of the runtime animation
  15456. */
  15457. get targetPath(): string;
  15458. /**
  15459. * Gets the actual target of the runtime animation
  15460. */
  15461. get target(): any;
  15462. /**
  15463. * Gets the additive state of the runtime animation
  15464. */
  15465. get isAdditive(): boolean;
  15466. /** @hidden */
  15467. _onLoop: () => void;
  15468. /**
  15469. * Create a new RuntimeAnimation object
  15470. * @param target defines the target of the animation
  15471. * @param animation defines the source animation object
  15472. * @param scene defines the hosting scene
  15473. * @param host defines the initiating Animatable
  15474. */
  15475. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  15476. private _preparePath;
  15477. /**
  15478. * Gets the animation from the runtime animation
  15479. */
  15480. get animation(): Animation;
  15481. /**
  15482. * Resets the runtime animation to the beginning
  15483. * @param restoreOriginal defines whether to restore the target property to the original value
  15484. */
  15485. reset(restoreOriginal?: boolean): void;
  15486. /**
  15487. * Specifies if the runtime animation is stopped
  15488. * @returns Boolean specifying if the runtime animation is stopped
  15489. */
  15490. isStopped(): boolean;
  15491. /**
  15492. * Disposes of the runtime animation
  15493. */
  15494. dispose(): void;
  15495. /**
  15496. * Apply the interpolated value to the target
  15497. * @param currentValue defines the value computed by the animation
  15498. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  15499. */
  15500. setValue(currentValue: any, weight: number): void;
  15501. private _getOriginalValues;
  15502. private _setValue;
  15503. /**
  15504. * Gets the loop pmode of the runtime animation
  15505. * @returns Loop Mode
  15506. */
  15507. private _getCorrectLoopMode;
  15508. /**
  15509. * Move the current animation to a given frame
  15510. * @param frame defines the frame to move to
  15511. */
  15512. goToFrame(frame: number): void;
  15513. /**
  15514. * @hidden Internal use only
  15515. */
  15516. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  15517. /**
  15518. * Execute the current animation
  15519. * @param delay defines the delay to add to the current frame
  15520. * @param from defines the lower bound of the animation range
  15521. * @param to defines the upper bound of the animation range
  15522. * @param loop defines if the current animation must loop
  15523. * @param speedRatio defines the current speed ratio
  15524. * @param weight defines the weight of the animation (default is -1 so no weight)
  15525. * @param onLoop optional callback called when animation loops
  15526. * @returns a boolean indicating if the animation is running
  15527. */
  15528. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  15529. }
  15530. }
  15531. declare module BABYLON {
  15532. /**
  15533. * Class used to store an actual running animation
  15534. */
  15535. export class Animatable {
  15536. /** defines the target object */
  15537. target: any;
  15538. /** defines the starting frame number (default is 0) */
  15539. fromFrame: number;
  15540. /** defines the ending frame number (default is 100) */
  15541. toFrame: number;
  15542. /** defines if the animation must loop (default is false) */
  15543. loopAnimation: boolean;
  15544. /** defines a callback to call when animation ends if it is not looping */
  15545. onAnimationEnd?: (() => void) | null | undefined;
  15546. /** defines a callback to call when animation loops */
  15547. onAnimationLoop?: (() => void) | null | undefined;
  15548. /** defines whether the animation should be evaluated additively */
  15549. isAdditive: boolean;
  15550. private _localDelayOffset;
  15551. private _pausedDelay;
  15552. private _runtimeAnimations;
  15553. private _paused;
  15554. private _scene;
  15555. private _speedRatio;
  15556. private _weight;
  15557. private _syncRoot;
  15558. /**
  15559. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15560. * This will only apply for non looping animation (default is true)
  15561. */
  15562. disposeOnEnd: boolean;
  15563. /**
  15564. * Gets a boolean indicating if the animation has started
  15565. */
  15566. animationStarted: boolean;
  15567. /**
  15568. * Observer raised when the animation ends
  15569. */
  15570. onAnimationEndObservable: Observable<Animatable>;
  15571. /**
  15572. * Observer raised when the animation loops
  15573. */
  15574. onAnimationLoopObservable: Observable<Animatable>;
  15575. /**
  15576. * Gets the root Animatable used to synchronize and normalize animations
  15577. */
  15578. get syncRoot(): Nullable<Animatable>;
  15579. /**
  15580. * Gets the current frame of the first RuntimeAnimation
  15581. * Used to synchronize Animatables
  15582. */
  15583. get masterFrame(): number;
  15584. /**
  15585. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  15586. */
  15587. get weight(): number;
  15588. set weight(value: number);
  15589. /**
  15590. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  15591. */
  15592. get speedRatio(): number;
  15593. set speedRatio(value: number);
  15594. /**
  15595. * Creates a new Animatable
  15596. * @param scene defines the hosting scene
  15597. * @param target defines the target object
  15598. * @param fromFrame defines the starting frame number (default is 0)
  15599. * @param toFrame defines the ending frame number (default is 100)
  15600. * @param loopAnimation defines if the animation must loop (default is false)
  15601. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  15602. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  15603. * @param animations defines a group of animation to add to the new Animatable
  15604. * @param onAnimationLoop defines a callback to call when animation loops
  15605. * @param isAdditive defines whether the animation should be evaluated additively
  15606. */
  15607. constructor(scene: Scene,
  15608. /** defines the target object */
  15609. target: any,
  15610. /** defines the starting frame number (default is 0) */
  15611. fromFrame?: number,
  15612. /** defines the ending frame number (default is 100) */
  15613. toFrame?: number,
  15614. /** defines if the animation must loop (default is false) */
  15615. loopAnimation?: boolean, speedRatio?: number,
  15616. /** defines a callback to call when animation ends if it is not looping */
  15617. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  15618. /** defines a callback to call when animation loops */
  15619. onAnimationLoop?: (() => void) | null | undefined,
  15620. /** defines whether the animation should be evaluated additively */
  15621. isAdditive?: boolean);
  15622. /**
  15623. * Synchronize and normalize current Animatable with a source Animatable
  15624. * This is useful when using animation weights and when animations are not of the same length
  15625. * @param root defines the root Animatable to synchronize with
  15626. * @returns the current Animatable
  15627. */
  15628. syncWith(root: Animatable): Animatable;
  15629. /**
  15630. * Gets the list of runtime animations
  15631. * @returns an array of RuntimeAnimation
  15632. */
  15633. getAnimations(): RuntimeAnimation[];
  15634. /**
  15635. * Adds more animations to the current animatable
  15636. * @param target defines the target of the animations
  15637. * @param animations defines the new animations to add
  15638. */
  15639. appendAnimations(target: any, animations: Animation[]): void;
  15640. /**
  15641. * Gets the source animation for a specific property
  15642. * @param property defines the propertyu to look for
  15643. * @returns null or the source animation for the given property
  15644. */
  15645. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  15646. /**
  15647. * Gets the runtime animation for a specific property
  15648. * @param property defines the propertyu to look for
  15649. * @returns null or the runtime animation for the given property
  15650. */
  15651. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  15652. /**
  15653. * Resets the animatable to its original state
  15654. */
  15655. reset(): void;
  15656. /**
  15657. * Allows the animatable to blend with current running animations
  15658. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15659. * @param blendingSpeed defines the blending speed to use
  15660. */
  15661. enableBlending(blendingSpeed: number): void;
  15662. /**
  15663. * Disable animation blending
  15664. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15665. */
  15666. disableBlending(): void;
  15667. /**
  15668. * Jump directly to a given frame
  15669. * @param frame defines the frame to jump to
  15670. */
  15671. goToFrame(frame: number): void;
  15672. /**
  15673. * Pause the animation
  15674. */
  15675. pause(): void;
  15676. /**
  15677. * Restart the animation
  15678. */
  15679. restart(): void;
  15680. private _raiseOnAnimationEnd;
  15681. /**
  15682. * Stop and delete the current animation
  15683. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  15684. * @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)
  15685. */
  15686. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  15687. /**
  15688. * Wait asynchronously for the animation to end
  15689. * @returns a promise which will be fullfilled when the animation ends
  15690. */
  15691. waitAsync(): Promise<Animatable>;
  15692. /** @hidden */
  15693. _animate(delay: number): boolean;
  15694. }
  15695. interface Scene {
  15696. /** @hidden */
  15697. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  15698. /** @hidden */
  15699. _processLateAnimationBindingsForMatrices(holder: {
  15700. totalWeight: number;
  15701. totalAdditiveWeight: number;
  15702. animations: RuntimeAnimation[];
  15703. additiveAnimations: RuntimeAnimation[];
  15704. originalValue: Matrix;
  15705. }): any;
  15706. /** @hidden */
  15707. _processLateAnimationBindingsForQuaternions(holder: {
  15708. totalWeight: number;
  15709. totalAdditiveWeight: number;
  15710. animations: RuntimeAnimation[];
  15711. additiveAnimations: RuntimeAnimation[];
  15712. originalValue: Quaternion;
  15713. }, refQuaternion: Quaternion): Quaternion;
  15714. /** @hidden */
  15715. _processLateAnimationBindings(): void;
  15716. /**
  15717. * Will start the animation sequence of a given target
  15718. * @param target defines the target
  15719. * @param from defines from which frame should animation start
  15720. * @param to defines until which frame should animation run.
  15721. * @param weight defines the weight to apply to the animation (1.0 by default)
  15722. * @param loop defines if the animation loops
  15723. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15724. * @param onAnimationEnd defines the function to be executed when the animation ends
  15725. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15726. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15727. * @param onAnimationLoop defines the callback to call when an animation loops
  15728. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15729. * @returns the animatable object created for this animation
  15730. */
  15731. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  15732. /**
  15733. * Will start the animation sequence of a given target
  15734. * @param target defines the target
  15735. * @param from defines from which frame should animation start
  15736. * @param to defines until which frame should animation run.
  15737. * @param loop defines if the animation loops
  15738. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15739. * @param onAnimationEnd defines the function to be executed when the animation ends
  15740. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15741. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15742. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  15743. * @param onAnimationLoop defines the callback to call when an animation loops
  15744. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15745. * @returns the animatable object created for this animation
  15746. */
  15747. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  15748. /**
  15749. * Will start the animation sequence of a given target and its hierarchy
  15750. * @param target defines the target
  15751. * @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.
  15752. * @param from defines from which frame should animation start
  15753. * @param to defines until which frame should animation run.
  15754. * @param loop defines if the animation loops
  15755. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15756. * @param onAnimationEnd defines the function to be executed when the animation ends
  15757. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15758. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15759. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15760. * @param onAnimationLoop defines the callback to call when an animation loops
  15761. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15762. * @returns the list of created animatables
  15763. */
  15764. 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, isAdditive?: boolean): Animatable[];
  15765. /**
  15766. * Begin a new animation on a given node
  15767. * @param target defines the target where the animation will take place
  15768. * @param animations defines the list of animations to start
  15769. * @param from defines the initial value
  15770. * @param to defines the final value
  15771. * @param loop defines if you want animation to loop (off by default)
  15772. * @param speedRatio defines the speed ratio to apply to all animations
  15773. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15774. * @param onAnimationLoop defines the callback to call when an animation loops
  15775. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15776. * @returns the list of created animatables
  15777. */
  15778. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  15779. /**
  15780. * Begin a new animation on a given node and its hierarchy
  15781. * @param target defines the root node where the animation will take place
  15782. * @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.
  15783. * @param animations defines the list of animations to start
  15784. * @param from defines the initial value
  15785. * @param to defines the final value
  15786. * @param loop defines if you want animation to loop (off by default)
  15787. * @param speedRatio defines the speed ratio to apply to all animations
  15788. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15789. * @param onAnimationLoop defines the callback to call when an animation loops
  15790. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15791. * @returns the list of animatables created for all nodes
  15792. */
  15793. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  15794. /**
  15795. * Gets the animatable associated with a specific target
  15796. * @param target defines the target of the animatable
  15797. * @returns the required animatable if found
  15798. */
  15799. getAnimatableByTarget(target: any): Nullable<Animatable>;
  15800. /**
  15801. * Gets all animatables associated with a given target
  15802. * @param target defines the target to look animatables for
  15803. * @returns an array of Animatables
  15804. */
  15805. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  15806. /**
  15807. * Stops and removes all animations that have been applied to the scene
  15808. */
  15809. stopAllAnimations(): void;
  15810. /**
  15811. * Gets the current delta time used by animation engine
  15812. */
  15813. deltaTime: number;
  15814. }
  15815. interface Bone {
  15816. /**
  15817. * Copy an animation range from another bone
  15818. * @param source defines the source bone
  15819. * @param rangeName defines the range name to copy
  15820. * @param frameOffset defines the frame offset
  15821. * @param rescaleAsRequired defines if rescaling must be applied if required
  15822. * @param skelDimensionsRatio defines the scaling ratio
  15823. * @returns true if operation was successful
  15824. */
  15825. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  15826. }
  15827. }
  15828. declare module BABYLON {
  15829. /**
  15830. * Class used to handle skinning animations
  15831. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15832. */
  15833. export class Skeleton implements IAnimatable {
  15834. /** defines the skeleton name */
  15835. name: string;
  15836. /** defines the skeleton Id */
  15837. id: string;
  15838. /**
  15839. * Defines the list of child bones
  15840. */
  15841. bones: Bone[];
  15842. /**
  15843. * Defines an estimate of the dimension of the skeleton at rest
  15844. */
  15845. dimensionsAtRest: Vector3;
  15846. /**
  15847. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  15848. */
  15849. needInitialSkinMatrix: boolean;
  15850. /**
  15851. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  15852. */
  15853. overrideMesh: Nullable<AbstractMesh>;
  15854. /**
  15855. * Gets the list of animations attached to this skeleton
  15856. */
  15857. animations: Array<Animation>;
  15858. private _scene;
  15859. private _isDirty;
  15860. private _transformMatrices;
  15861. private _transformMatrixTexture;
  15862. private _meshesWithPoseMatrix;
  15863. private _animatables;
  15864. private _identity;
  15865. private _synchronizedWithMesh;
  15866. private _ranges;
  15867. private _lastAbsoluteTransformsUpdateId;
  15868. private _canUseTextureForBones;
  15869. private _uniqueId;
  15870. /** @hidden */
  15871. _numBonesWithLinkedTransformNode: number;
  15872. /** @hidden */
  15873. _hasWaitingData: Nullable<boolean>;
  15874. /**
  15875. * Specifies if the skeleton should be serialized
  15876. */
  15877. doNotSerialize: boolean;
  15878. private _useTextureToStoreBoneMatrices;
  15879. /**
  15880. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  15881. * Please note that this option is not available if the hardware does not support it
  15882. */
  15883. get useTextureToStoreBoneMatrices(): boolean;
  15884. set useTextureToStoreBoneMatrices(value: boolean);
  15885. private _animationPropertiesOverride;
  15886. /**
  15887. * Gets or sets the animation properties override
  15888. */
  15889. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15890. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  15891. /**
  15892. * List of inspectable custom properties (used by the Inspector)
  15893. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15894. */
  15895. inspectableCustomProperties: IInspectable[];
  15896. /**
  15897. * An observable triggered before computing the skeleton's matrices
  15898. */
  15899. onBeforeComputeObservable: Observable<Skeleton>;
  15900. /**
  15901. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  15902. */
  15903. get isUsingTextureForMatrices(): boolean;
  15904. /**
  15905. * Gets the unique ID of this skeleton
  15906. */
  15907. get uniqueId(): number;
  15908. /**
  15909. * Creates a new skeleton
  15910. * @param name defines the skeleton name
  15911. * @param id defines the skeleton Id
  15912. * @param scene defines the hosting scene
  15913. */
  15914. constructor(
  15915. /** defines the skeleton name */
  15916. name: string,
  15917. /** defines the skeleton Id */
  15918. id: string, scene: Scene);
  15919. /**
  15920. * Gets the current object class name.
  15921. * @return the class name
  15922. */
  15923. getClassName(): string;
  15924. /**
  15925. * Returns an array containing the root bones
  15926. * @returns an array containing the root bones
  15927. */
  15928. getChildren(): Array<Bone>;
  15929. /**
  15930. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  15931. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15932. * @returns a Float32Array containing matrices data
  15933. */
  15934. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  15935. /**
  15936. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  15937. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15938. * @returns a raw texture containing the data
  15939. */
  15940. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  15941. /**
  15942. * Gets the current hosting scene
  15943. * @returns a scene object
  15944. */
  15945. getScene(): Scene;
  15946. /**
  15947. * Gets a string representing the current skeleton data
  15948. * @param fullDetails defines a boolean indicating if we want a verbose version
  15949. * @returns a string representing the current skeleton data
  15950. */
  15951. toString(fullDetails?: boolean): string;
  15952. /**
  15953. * Get bone's index searching by name
  15954. * @param name defines bone's name to search for
  15955. * @return the indice of the bone. Returns -1 if not found
  15956. */
  15957. getBoneIndexByName(name: string): number;
  15958. /**
  15959. * Creater a new animation range
  15960. * @param name defines the name of the range
  15961. * @param from defines the start key
  15962. * @param to defines the end key
  15963. */
  15964. createAnimationRange(name: string, from: number, to: number): void;
  15965. /**
  15966. * Delete a specific animation range
  15967. * @param name defines the name of the range
  15968. * @param deleteFrames defines if frames must be removed as well
  15969. */
  15970. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  15971. /**
  15972. * Gets a specific animation range
  15973. * @param name defines the name of the range to look for
  15974. * @returns the requested animation range or null if not found
  15975. */
  15976. getAnimationRange(name: string): Nullable<AnimationRange>;
  15977. /**
  15978. * Gets the list of all animation ranges defined on this skeleton
  15979. * @returns an array
  15980. */
  15981. getAnimationRanges(): Nullable<AnimationRange>[];
  15982. /**
  15983. * Copy animation range from a source skeleton.
  15984. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  15985. * @param source defines the source skeleton
  15986. * @param name defines the name of the range to copy
  15987. * @param rescaleAsRequired defines if rescaling must be applied if required
  15988. * @returns true if operation was successful
  15989. */
  15990. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  15991. /**
  15992. * Forces the skeleton to go to rest pose
  15993. */
  15994. returnToRest(): void;
  15995. private _getHighestAnimationFrame;
  15996. /**
  15997. * Begin a specific animation range
  15998. * @param name defines the name of the range to start
  15999. * @param loop defines if looping must be turned on (false by default)
  16000. * @param speedRatio defines the speed ratio to apply (1 by default)
  16001. * @param onAnimationEnd defines a callback which will be called when animation will end
  16002. * @returns a new animatable
  16003. */
  16004. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16005. /**
  16006. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16007. * @param skeleton defines the Skeleton containing the animation range to convert
  16008. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16009. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16010. * @returns the original skeleton
  16011. */
  16012. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16013. /** @hidden */
  16014. _markAsDirty(): void;
  16015. /** @hidden */
  16016. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16017. /** @hidden */
  16018. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16019. private _computeTransformMatrices;
  16020. /**
  16021. * Build all resources required to render a skeleton
  16022. */
  16023. prepare(): void;
  16024. /**
  16025. * Gets the list of animatables currently running for this skeleton
  16026. * @returns an array of animatables
  16027. */
  16028. getAnimatables(): IAnimatable[];
  16029. /**
  16030. * Clone the current skeleton
  16031. * @param name defines the name of the new skeleton
  16032. * @param id defines the id of the new skeleton
  16033. * @returns the new skeleton
  16034. */
  16035. clone(name: string, id?: string): Skeleton;
  16036. /**
  16037. * Enable animation blending for this skeleton
  16038. * @param blendingSpeed defines the blending speed to apply
  16039. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  16040. */
  16041. enableBlending(blendingSpeed?: number): void;
  16042. /**
  16043. * Releases all resources associated with the current skeleton
  16044. */
  16045. dispose(): void;
  16046. /**
  16047. * Serialize the skeleton in a JSON object
  16048. * @returns a JSON object
  16049. */
  16050. serialize(): any;
  16051. /**
  16052. * Creates a new skeleton from serialized data
  16053. * @param parsedSkeleton defines the serialized data
  16054. * @param scene defines the hosting scene
  16055. * @returns a new skeleton
  16056. */
  16057. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16058. /**
  16059. * Compute all node absolute transforms
  16060. * @param forceUpdate defines if computation must be done even if cache is up to date
  16061. */
  16062. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16063. /**
  16064. * Gets the root pose matrix
  16065. * @returns a matrix
  16066. */
  16067. getPoseMatrix(): Nullable<Matrix>;
  16068. /**
  16069. * Sorts bones per internal index
  16070. */
  16071. sortBones(): void;
  16072. private _sortBones;
  16073. }
  16074. }
  16075. declare module BABYLON {
  16076. /**
  16077. * Creates an instance based on a source mesh.
  16078. */
  16079. export class InstancedMesh extends AbstractMesh {
  16080. private _sourceMesh;
  16081. private _currentLOD;
  16082. /** @hidden */
  16083. _indexInSourceMeshInstanceArray: number;
  16084. constructor(name: string, source: Mesh);
  16085. /**
  16086. * Returns the string "InstancedMesh".
  16087. */
  16088. getClassName(): string;
  16089. /** Gets the list of lights affecting that mesh */
  16090. get lightSources(): Light[];
  16091. _resyncLightSources(): void;
  16092. _resyncLightSource(light: Light): void;
  16093. _removeLightSource(light: Light, dispose: boolean): void;
  16094. /**
  16095. * If the source mesh receives shadows
  16096. */
  16097. get receiveShadows(): boolean;
  16098. /**
  16099. * The material of the source mesh
  16100. */
  16101. get material(): Nullable<Material>;
  16102. /**
  16103. * Visibility of the source mesh
  16104. */
  16105. get visibility(): number;
  16106. /**
  16107. * Skeleton of the source mesh
  16108. */
  16109. get skeleton(): Nullable<Skeleton>;
  16110. /**
  16111. * Rendering ground id of the source mesh
  16112. */
  16113. get renderingGroupId(): number;
  16114. set renderingGroupId(value: number);
  16115. /**
  16116. * Returns the total number of vertices (integer).
  16117. */
  16118. getTotalVertices(): number;
  16119. /**
  16120. * Returns a positive integer : the total number of indices in this mesh geometry.
  16121. * @returns the numner of indices or zero if the mesh has no geometry.
  16122. */
  16123. getTotalIndices(): number;
  16124. /**
  16125. * The source mesh of the instance
  16126. */
  16127. get sourceMesh(): Mesh;
  16128. /**
  16129. * Is this node ready to be used/rendered
  16130. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16131. * @return {boolean} is it ready
  16132. */
  16133. isReady(completeCheck?: boolean): boolean;
  16134. /**
  16135. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16136. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16137. * @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.
  16138. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16139. */
  16140. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16141. /**
  16142. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16143. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16144. * The `data` are either a numeric array either a Float32Array.
  16145. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16146. * 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).
  16147. * Note that a new underlying VertexBuffer object is created each call.
  16148. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16149. *
  16150. * Possible `kind` values :
  16151. * - VertexBuffer.PositionKind
  16152. * - VertexBuffer.UVKind
  16153. * - VertexBuffer.UV2Kind
  16154. * - VertexBuffer.UV3Kind
  16155. * - VertexBuffer.UV4Kind
  16156. * - VertexBuffer.UV5Kind
  16157. * - VertexBuffer.UV6Kind
  16158. * - VertexBuffer.ColorKind
  16159. * - VertexBuffer.MatricesIndicesKind
  16160. * - VertexBuffer.MatricesIndicesExtraKind
  16161. * - VertexBuffer.MatricesWeightsKind
  16162. * - VertexBuffer.MatricesWeightsExtraKind
  16163. *
  16164. * Returns the Mesh.
  16165. */
  16166. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16167. /**
  16168. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16169. * If the mesh has no geometry, it is simply returned as it is.
  16170. * The `data` are either a numeric array either a Float32Array.
  16171. * No new underlying VertexBuffer object is created.
  16172. * 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.
  16173. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16174. *
  16175. * Possible `kind` values :
  16176. * - VertexBuffer.PositionKind
  16177. * - VertexBuffer.UVKind
  16178. * - VertexBuffer.UV2Kind
  16179. * - VertexBuffer.UV3Kind
  16180. * - VertexBuffer.UV4Kind
  16181. * - VertexBuffer.UV5Kind
  16182. * - VertexBuffer.UV6Kind
  16183. * - VertexBuffer.ColorKind
  16184. * - VertexBuffer.MatricesIndicesKind
  16185. * - VertexBuffer.MatricesIndicesExtraKind
  16186. * - VertexBuffer.MatricesWeightsKind
  16187. * - VertexBuffer.MatricesWeightsExtraKind
  16188. *
  16189. * Returns the Mesh.
  16190. */
  16191. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16192. /**
  16193. * Sets the mesh indices.
  16194. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16195. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16196. * This method creates a new index buffer each call.
  16197. * Returns the Mesh.
  16198. */
  16199. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16200. /**
  16201. * Boolean : True if the mesh owns the requested kind of data.
  16202. */
  16203. isVerticesDataPresent(kind: string): boolean;
  16204. /**
  16205. * Returns an array of indices (IndicesArray).
  16206. */
  16207. getIndices(): Nullable<IndicesArray>;
  16208. get _positions(): Nullable<Vector3[]>;
  16209. /**
  16210. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16211. * This means the mesh underlying bounding box and sphere are recomputed.
  16212. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16213. * @returns the current mesh
  16214. */
  16215. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16216. /** @hidden */
  16217. _preActivate(): InstancedMesh;
  16218. /** @hidden */
  16219. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16220. /** @hidden */
  16221. _postActivate(): void;
  16222. getWorldMatrix(): Matrix;
  16223. get isAnInstance(): boolean;
  16224. /**
  16225. * Returns the current associated LOD AbstractMesh.
  16226. */
  16227. getLOD(camera: Camera): AbstractMesh;
  16228. /** @hidden */
  16229. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16230. /** @hidden */
  16231. _syncSubMeshes(): InstancedMesh;
  16232. /** @hidden */
  16233. _generatePointsArray(): boolean;
  16234. /**
  16235. * Creates a new InstancedMesh from the current mesh.
  16236. * - name (string) : the cloned mesh name
  16237. * - newParent (optional Node) : the optional Node to parent the clone to.
  16238. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16239. *
  16240. * Returns the clone.
  16241. */
  16242. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16243. /**
  16244. * Disposes the InstancedMesh.
  16245. * Returns nothing.
  16246. */
  16247. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16248. }
  16249. interface Mesh {
  16250. /**
  16251. * Register a custom buffer that will be instanced
  16252. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16253. * @param kind defines the buffer kind
  16254. * @param stride defines the stride in floats
  16255. */
  16256. registerInstancedBuffer(kind: string, stride: number): void;
  16257. /** @hidden */
  16258. _userInstancedBuffersStorage: {
  16259. data: {
  16260. [key: string]: Float32Array;
  16261. };
  16262. sizes: {
  16263. [key: string]: number;
  16264. };
  16265. vertexBuffers: {
  16266. [key: string]: Nullable<VertexBuffer>;
  16267. };
  16268. strides: {
  16269. [key: string]: number;
  16270. };
  16271. };
  16272. }
  16273. interface AbstractMesh {
  16274. /**
  16275. * Object used to store instanced buffers defined by user
  16276. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16277. */
  16278. instancedBuffers: {
  16279. [key: string]: any;
  16280. };
  16281. }
  16282. }
  16283. declare module BABYLON {
  16284. /**
  16285. * Defines the options associated with the creation of a shader material.
  16286. */
  16287. export interface IShaderMaterialOptions {
  16288. /**
  16289. * Does the material work in alpha blend mode
  16290. */
  16291. needAlphaBlending: boolean;
  16292. /**
  16293. * Does the material work in alpha test mode
  16294. */
  16295. needAlphaTesting: boolean;
  16296. /**
  16297. * The list of attribute names used in the shader
  16298. */
  16299. attributes: string[];
  16300. /**
  16301. * The list of unifrom names used in the shader
  16302. */
  16303. uniforms: string[];
  16304. /**
  16305. * The list of UBO names used in the shader
  16306. */
  16307. uniformBuffers: string[];
  16308. /**
  16309. * The list of sampler names used in the shader
  16310. */
  16311. samplers: string[];
  16312. /**
  16313. * The list of defines used in the shader
  16314. */
  16315. defines: string[];
  16316. }
  16317. /**
  16318. * 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.
  16319. *
  16320. * This returned material effects how the mesh will look based on the code in the shaders.
  16321. *
  16322. * @see http://doc.babylonjs.com/how_to/shader_material
  16323. */
  16324. export class ShaderMaterial extends Material {
  16325. private _shaderPath;
  16326. private _options;
  16327. private _textures;
  16328. private _textureArrays;
  16329. private _floats;
  16330. private _ints;
  16331. private _floatsArrays;
  16332. private _colors3;
  16333. private _colors3Arrays;
  16334. private _colors4;
  16335. private _colors4Arrays;
  16336. private _vectors2;
  16337. private _vectors3;
  16338. private _vectors4;
  16339. private _matrices;
  16340. private _matrixArrays;
  16341. private _matrices3x3;
  16342. private _matrices2x2;
  16343. private _vectors2Arrays;
  16344. private _vectors3Arrays;
  16345. private _vectors4Arrays;
  16346. private _cachedWorldViewMatrix;
  16347. private _cachedWorldViewProjectionMatrix;
  16348. private _renderId;
  16349. private _multiview;
  16350. private _cachedDefines;
  16351. /**
  16352. * Instantiate a new shader material.
  16353. * 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.
  16354. * This returned material effects how the mesh will look based on the code in the shaders.
  16355. * @see http://doc.babylonjs.com/how_to/shader_material
  16356. * @param name Define the name of the material in the scene
  16357. * @param scene Define the scene the material belongs to
  16358. * @param shaderPath Defines the route to the shader code in one of three ways:
  16359. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16360. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  16361. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  16362. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16363. * @param options Define the options used to create the shader
  16364. */
  16365. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16366. /**
  16367. * Gets the shader path used to define the shader code
  16368. * It can be modified to trigger a new compilation
  16369. */
  16370. get shaderPath(): any;
  16371. /**
  16372. * Sets the shader path used to define the shader code
  16373. * It can be modified to trigger a new compilation
  16374. */
  16375. set shaderPath(shaderPath: any);
  16376. /**
  16377. * Gets the options used to compile the shader.
  16378. * They can be modified to trigger a new compilation
  16379. */
  16380. get options(): IShaderMaterialOptions;
  16381. /**
  16382. * Gets the current class name of the material e.g. "ShaderMaterial"
  16383. * Mainly use in serialization.
  16384. * @returns the class name
  16385. */
  16386. getClassName(): string;
  16387. /**
  16388. * Specifies if the material will require alpha blending
  16389. * @returns a boolean specifying if alpha blending is needed
  16390. */
  16391. needAlphaBlending(): boolean;
  16392. /**
  16393. * Specifies if this material should be rendered in alpha test mode
  16394. * @returns a boolean specifying if an alpha test is needed.
  16395. */
  16396. needAlphaTesting(): boolean;
  16397. private _checkUniform;
  16398. /**
  16399. * Set a texture in the shader.
  16400. * @param name Define the name of the uniform samplers as defined in the shader
  16401. * @param texture Define the texture to bind to this sampler
  16402. * @return the material itself allowing "fluent" like uniform updates
  16403. */
  16404. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  16405. /**
  16406. * Set a texture array in the shader.
  16407. * @param name Define the name of the uniform sampler array as defined in the shader
  16408. * @param textures Define the list of textures to bind to this sampler
  16409. * @return the material itself allowing "fluent" like uniform updates
  16410. */
  16411. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  16412. /**
  16413. * Set a float in the shader.
  16414. * @param name Define the name of the uniform as defined in the shader
  16415. * @param value Define the value to give to the uniform
  16416. * @return the material itself allowing "fluent" like uniform updates
  16417. */
  16418. setFloat(name: string, value: number): ShaderMaterial;
  16419. /**
  16420. * Set a int in the shader.
  16421. * @param name Define the name of the uniform as defined in the shader
  16422. * @param value Define the value to give to the uniform
  16423. * @return the material itself allowing "fluent" like uniform updates
  16424. */
  16425. setInt(name: string, value: number): ShaderMaterial;
  16426. /**
  16427. * Set an array of floats in the shader.
  16428. * @param name Define the name of the uniform as defined in the shader
  16429. * @param value Define the value to give to the uniform
  16430. * @return the material itself allowing "fluent" like uniform updates
  16431. */
  16432. setFloats(name: string, value: number[]): ShaderMaterial;
  16433. /**
  16434. * Set a vec3 in the shader from a Color3.
  16435. * @param name Define the name of the uniform as defined in the shader
  16436. * @param value Define the value to give to the uniform
  16437. * @return the material itself allowing "fluent" like uniform updates
  16438. */
  16439. setColor3(name: string, value: Color3): ShaderMaterial;
  16440. /**
  16441. * Set a vec3 array in the shader from a Color3 array.
  16442. * @param name Define the name of the uniform as defined in the shader
  16443. * @param value Define the value to give to the uniform
  16444. * @return the material itself allowing "fluent" like uniform updates
  16445. */
  16446. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16447. /**
  16448. * Set a vec4 in the shader from a Color4.
  16449. * @param name Define the name of the uniform as defined in the shader
  16450. * @param value Define the value to give to the uniform
  16451. * @return the material itself allowing "fluent" like uniform updates
  16452. */
  16453. setColor4(name: string, value: Color4): ShaderMaterial;
  16454. /**
  16455. * Set a vec4 array in the shader from a Color4 array.
  16456. * @param name Define the name of the uniform as defined in the shader
  16457. * @param value Define the value to give to the uniform
  16458. * @return the material itself allowing "fluent" like uniform updates
  16459. */
  16460. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  16461. /**
  16462. * Set a vec2 in the shader from a Vector2.
  16463. * @param name Define the name of the uniform as defined in the shader
  16464. * @param value Define the value to give to the uniform
  16465. * @return the material itself allowing "fluent" like uniform updates
  16466. */
  16467. setVector2(name: string, value: Vector2): ShaderMaterial;
  16468. /**
  16469. * Set a vec3 in the shader from a Vector3.
  16470. * @param name Define the name of the uniform as defined in the shader
  16471. * @param value Define the value to give to the uniform
  16472. * @return the material itself allowing "fluent" like uniform updates
  16473. */
  16474. setVector3(name: string, value: Vector3): ShaderMaterial;
  16475. /**
  16476. * Set a vec4 in the shader from a Vector4.
  16477. * @param name Define the name of the uniform as defined in the shader
  16478. * @param value Define the value to give to the uniform
  16479. * @return the material itself allowing "fluent" like uniform updates
  16480. */
  16481. setVector4(name: string, value: Vector4): ShaderMaterial;
  16482. /**
  16483. * Set a mat4 in the shader from a Matrix.
  16484. * @param name Define the name of the uniform as defined in the shader
  16485. * @param value Define the value to give to the uniform
  16486. * @return the material itself allowing "fluent" like uniform updates
  16487. */
  16488. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16489. /**
  16490. * Set a float32Array in the shader from a matrix array.
  16491. * @param name Define the name of the uniform as defined in the shader
  16492. * @param value Define the value to give to the uniform
  16493. * @return the material itself allowing "fluent" like uniform updates
  16494. */
  16495. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  16496. /**
  16497. * Set a mat3 in the shader from a Float32Array.
  16498. * @param name Define the name of the uniform as defined in the shader
  16499. * @param value Define the value to give to the uniform
  16500. * @return the material itself allowing "fluent" like uniform updates
  16501. */
  16502. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16503. /**
  16504. * Set a mat2 in the shader from a Float32Array.
  16505. * @param name Define the name of the uniform as defined in the shader
  16506. * @param value Define the value to give to the uniform
  16507. * @return the material itself allowing "fluent" like uniform updates
  16508. */
  16509. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16510. /**
  16511. * Set a vec2 array in the shader from a number array.
  16512. * @param name Define the name of the uniform as defined in the shader
  16513. * @param value Define the value to give to the uniform
  16514. * @return the material itself allowing "fluent" like uniform updates
  16515. */
  16516. setArray2(name: string, value: number[]): ShaderMaterial;
  16517. /**
  16518. * Set a vec3 array in the shader from a number array.
  16519. * @param name Define the name of the uniform as defined in the shader
  16520. * @param value Define the value to give to the uniform
  16521. * @return the material itself allowing "fluent" like uniform updates
  16522. */
  16523. setArray3(name: string, value: number[]): ShaderMaterial;
  16524. /**
  16525. * Set a vec4 array in the shader from a number array.
  16526. * @param name Define the name of the uniform as defined in the shader
  16527. * @param value Define the value to give to the uniform
  16528. * @return the material itself allowing "fluent" like uniform updates
  16529. */
  16530. setArray4(name: string, value: number[]): ShaderMaterial;
  16531. private _checkCache;
  16532. /**
  16533. * Specifies that the submesh is ready to be used
  16534. * @param mesh defines the mesh to check
  16535. * @param subMesh defines which submesh to check
  16536. * @param useInstances specifies that instances should be used
  16537. * @returns a boolean indicating that the submesh is ready or not
  16538. */
  16539. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  16540. /**
  16541. * Checks if the material is ready to render the requested mesh
  16542. * @param mesh Define the mesh to render
  16543. * @param useInstances Define whether or not the material is used with instances
  16544. * @returns true if ready, otherwise false
  16545. */
  16546. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16547. /**
  16548. * Binds the world matrix to the material
  16549. * @param world defines the world transformation matrix
  16550. * @param effectOverride - If provided, use this effect instead of internal effect
  16551. */
  16552. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  16553. /**
  16554. * Binds the submesh to this material by preparing the effect and shader to draw
  16555. * @param world defines the world transformation matrix
  16556. * @param mesh defines the mesh containing the submesh
  16557. * @param subMesh defines the submesh to bind the material to
  16558. */
  16559. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  16560. /**
  16561. * Binds the material to the mesh
  16562. * @param world defines the world transformation matrix
  16563. * @param mesh defines the mesh to bind the material to
  16564. * @param effectOverride - If provided, use this effect instead of internal effect
  16565. */
  16566. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  16567. protected _afterBind(mesh?: Mesh): void;
  16568. /**
  16569. * Gets the active textures from the material
  16570. * @returns an array of textures
  16571. */
  16572. getActiveTextures(): BaseTexture[];
  16573. /**
  16574. * Specifies if the material uses a texture
  16575. * @param texture defines the texture to check against the material
  16576. * @returns a boolean specifying if the material uses the texture
  16577. */
  16578. hasTexture(texture: BaseTexture): boolean;
  16579. /**
  16580. * Makes a duplicate of the material, and gives it a new name
  16581. * @param name defines the new name for the duplicated material
  16582. * @returns the cloned material
  16583. */
  16584. clone(name: string): ShaderMaterial;
  16585. /**
  16586. * Disposes the material
  16587. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16588. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16589. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16590. */
  16591. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16592. /**
  16593. * Serializes this material in a JSON representation
  16594. * @returns the serialized material object
  16595. */
  16596. serialize(): any;
  16597. /**
  16598. * Creates a shader material from parsed shader material data
  16599. * @param source defines the JSON represnetation of the material
  16600. * @param scene defines the hosting scene
  16601. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16602. * @returns a new material
  16603. */
  16604. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16605. }
  16606. }
  16607. declare module BABYLON {
  16608. /** @hidden */
  16609. export var colorPixelShader: {
  16610. name: string;
  16611. shader: string;
  16612. };
  16613. }
  16614. declare module BABYLON {
  16615. /** @hidden */
  16616. export var colorVertexShader: {
  16617. name: string;
  16618. shader: string;
  16619. };
  16620. }
  16621. declare module BABYLON {
  16622. /**
  16623. * Line mesh
  16624. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16625. */
  16626. export class LinesMesh extends Mesh {
  16627. /**
  16628. * If vertex color should be applied to the mesh
  16629. */
  16630. readonly useVertexColor?: boolean | undefined;
  16631. /**
  16632. * If vertex alpha should be applied to the mesh
  16633. */
  16634. readonly useVertexAlpha?: boolean | undefined;
  16635. /**
  16636. * Color of the line (Default: White)
  16637. */
  16638. color: Color3;
  16639. /**
  16640. * Alpha of the line (Default: 1)
  16641. */
  16642. alpha: number;
  16643. /**
  16644. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16645. * This margin is expressed in world space coordinates, so its value may vary.
  16646. * Default value is 0.1
  16647. */
  16648. intersectionThreshold: number;
  16649. private _colorShader;
  16650. private color4;
  16651. /**
  16652. * Creates a new LinesMesh
  16653. * @param name defines the name
  16654. * @param scene defines the hosting scene
  16655. * @param parent defines the parent mesh if any
  16656. * @param source defines the optional source LinesMesh used to clone data from
  16657. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16658. * When false, achieved by calling a clone(), also passing False.
  16659. * This will make creation of children, recursive.
  16660. * @param useVertexColor defines if this LinesMesh supports vertex color
  16661. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16662. */
  16663. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  16664. /**
  16665. * If vertex color should be applied to the mesh
  16666. */
  16667. useVertexColor?: boolean | undefined,
  16668. /**
  16669. * If vertex alpha should be applied to the mesh
  16670. */
  16671. useVertexAlpha?: boolean | undefined);
  16672. private _addClipPlaneDefine;
  16673. private _removeClipPlaneDefine;
  16674. isReady(): boolean;
  16675. /**
  16676. * Returns the string "LineMesh"
  16677. */
  16678. getClassName(): string;
  16679. /**
  16680. * @hidden
  16681. */
  16682. get material(): Material;
  16683. /**
  16684. * @hidden
  16685. */
  16686. set material(value: Material);
  16687. /**
  16688. * @hidden
  16689. */
  16690. get checkCollisions(): boolean;
  16691. /** @hidden */
  16692. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  16693. /** @hidden */
  16694. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  16695. /**
  16696. * Disposes of the line mesh
  16697. * @param doNotRecurse If children should be disposed
  16698. */
  16699. dispose(doNotRecurse?: boolean): void;
  16700. /**
  16701. * Returns a new LineMesh object cloned from the current one.
  16702. */
  16703. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  16704. /**
  16705. * Creates a new InstancedLinesMesh object from the mesh model.
  16706. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16707. * @param name defines the name of the new instance
  16708. * @returns a new InstancedLinesMesh
  16709. */
  16710. createInstance(name: string): InstancedLinesMesh;
  16711. }
  16712. /**
  16713. * Creates an instance based on a source LinesMesh
  16714. */
  16715. export class InstancedLinesMesh extends InstancedMesh {
  16716. /**
  16717. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16718. * This margin is expressed in world space coordinates, so its value may vary.
  16719. * Initilized with the intersectionThreshold value of the source LinesMesh
  16720. */
  16721. intersectionThreshold: number;
  16722. constructor(name: string, source: LinesMesh);
  16723. /**
  16724. * Returns the string "InstancedLinesMesh".
  16725. */
  16726. getClassName(): string;
  16727. }
  16728. }
  16729. declare module BABYLON {
  16730. /** @hidden */
  16731. export var linePixelShader: {
  16732. name: string;
  16733. shader: string;
  16734. };
  16735. }
  16736. declare module BABYLON {
  16737. /** @hidden */
  16738. export var lineVertexShader: {
  16739. name: string;
  16740. shader: string;
  16741. };
  16742. }
  16743. declare module BABYLON {
  16744. interface AbstractMesh {
  16745. /**
  16746. * Gets the edgesRenderer associated with the mesh
  16747. */
  16748. edgesRenderer: Nullable<EdgesRenderer>;
  16749. }
  16750. interface LinesMesh {
  16751. /**
  16752. * Enables the edge rendering mode on the mesh.
  16753. * This mode makes the mesh edges visible
  16754. * @param epsilon defines the maximal distance between two angles to detect a face
  16755. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16756. * @returns the currentAbstractMesh
  16757. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16758. */
  16759. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16760. }
  16761. interface InstancedLinesMesh {
  16762. /**
  16763. * Enables the edge rendering mode on the mesh.
  16764. * This mode makes the mesh edges visible
  16765. * @param epsilon defines the maximal distance between two angles to detect a face
  16766. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16767. * @returns the current InstancedLinesMesh
  16768. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16769. */
  16770. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16771. }
  16772. /**
  16773. * Defines the minimum contract an Edges renderer should follow.
  16774. */
  16775. export interface IEdgesRenderer extends IDisposable {
  16776. /**
  16777. * Gets or sets a boolean indicating if the edgesRenderer is active
  16778. */
  16779. isEnabled: boolean;
  16780. /**
  16781. * Renders the edges of the attached mesh,
  16782. */
  16783. render(): void;
  16784. /**
  16785. * Checks wether or not the edges renderer is ready to render.
  16786. * @return true if ready, otherwise false.
  16787. */
  16788. isReady(): boolean;
  16789. }
  16790. /**
  16791. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  16792. */
  16793. export class EdgesRenderer implements IEdgesRenderer {
  16794. /**
  16795. * Define the size of the edges with an orthographic camera
  16796. */
  16797. edgesWidthScalerForOrthographic: number;
  16798. /**
  16799. * Define the size of the edges with a perspective camera
  16800. */
  16801. edgesWidthScalerForPerspective: number;
  16802. protected _source: AbstractMesh;
  16803. protected _linesPositions: number[];
  16804. protected _linesNormals: number[];
  16805. protected _linesIndices: number[];
  16806. protected _epsilon: number;
  16807. protected _indicesCount: number;
  16808. protected _lineShader: ShaderMaterial;
  16809. protected _ib: DataBuffer;
  16810. protected _buffers: {
  16811. [key: string]: Nullable<VertexBuffer>;
  16812. };
  16813. protected _checkVerticesInsteadOfIndices: boolean;
  16814. private _meshRebuildObserver;
  16815. private _meshDisposeObserver;
  16816. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  16817. isEnabled: boolean;
  16818. /**
  16819. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  16820. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  16821. * @param source Mesh used to create edges
  16822. * @param epsilon sum of angles in adjacency to check for edge
  16823. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  16824. * @param generateEdgesLines - should generate Lines or only prepare resources.
  16825. */
  16826. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  16827. protected _prepareRessources(): void;
  16828. /** @hidden */
  16829. _rebuild(): void;
  16830. /**
  16831. * Releases the required resources for the edges renderer
  16832. */
  16833. dispose(): void;
  16834. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  16835. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  16836. /**
  16837. * Checks if the pair of p0 and p1 is en edge
  16838. * @param faceIndex
  16839. * @param edge
  16840. * @param faceNormals
  16841. * @param p0
  16842. * @param p1
  16843. * @private
  16844. */
  16845. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  16846. /**
  16847. * push line into the position, normal and index buffer
  16848. * @protected
  16849. */
  16850. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  16851. /**
  16852. * Generates lines edges from adjacencjes
  16853. * @private
  16854. */
  16855. _generateEdgesLines(): void;
  16856. /**
  16857. * Checks wether or not the edges renderer is ready to render.
  16858. * @return true if ready, otherwise false.
  16859. */
  16860. isReady(): boolean;
  16861. /**
  16862. * Renders the edges of the attached mesh,
  16863. */
  16864. render(): void;
  16865. }
  16866. /**
  16867. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  16868. */
  16869. export class LineEdgesRenderer extends EdgesRenderer {
  16870. /**
  16871. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  16872. * @param source LineMesh used to generate edges
  16873. * @param epsilon not important (specified angle for edge detection)
  16874. * @param checkVerticesInsteadOfIndices not important for LineMesh
  16875. */
  16876. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  16877. /**
  16878. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  16879. */
  16880. _generateEdgesLines(): void;
  16881. }
  16882. }
  16883. declare module BABYLON {
  16884. /**
  16885. * This represents the object necessary to create a rendering group.
  16886. * This is exclusively used and created by the rendering manager.
  16887. * To modify the behavior, you use the available helpers in your scene or meshes.
  16888. * @hidden
  16889. */
  16890. export class RenderingGroup {
  16891. index: number;
  16892. private static _zeroVector;
  16893. private _scene;
  16894. private _opaqueSubMeshes;
  16895. private _transparentSubMeshes;
  16896. private _alphaTestSubMeshes;
  16897. private _depthOnlySubMeshes;
  16898. private _particleSystems;
  16899. private _spriteManagers;
  16900. private _opaqueSortCompareFn;
  16901. private _alphaTestSortCompareFn;
  16902. private _transparentSortCompareFn;
  16903. private _renderOpaque;
  16904. private _renderAlphaTest;
  16905. private _renderTransparent;
  16906. /** @hidden */
  16907. _edgesRenderers: SmartArray<IEdgesRenderer>;
  16908. onBeforeTransparentRendering: () => void;
  16909. /**
  16910. * Set the opaque sort comparison function.
  16911. * If null the sub meshes will be render in the order they were created
  16912. */
  16913. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16914. /**
  16915. * Set the alpha test sort comparison function.
  16916. * If null the sub meshes will be render in the order they were created
  16917. */
  16918. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16919. /**
  16920. * Set the transparent sort comparison function.
  16921. * If null the sub meshes will be render in the order they were created
  16922. */
  16923. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16924. /**
  16925. * Creates a new rendering group.
  16926. * @param index The rendering group index
  16927. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  16928. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  16929. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  16930. */
  16931. 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>);
  16932. /**
  16933. * Render all the sub meshes contained in the group.
  16934. * @param customRenderFunction Used to override the default render behaviour of the group.
  16935. * @returns true if rendered some submeshes.
  16936. */
  16937. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  16938. /**
  16939. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  16940. * @param subMeshes The submeshes to render
  16941. */
  16942. private renderOpaqueSorted;
  16943. /**
  16944. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  16945. * @param subMeshes The submeshes to render
  16946. */
  16947. private renderAlphaTestSorted;
  16948. /**
  16949. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  16950. * @param subMeshes The submeshes to render
  16951. */
  16952. private renderTransparentSorted;
  16953. /**
  16954. * Renders the submeshes in a specified order.
  16955. * @param subMeshes The submeshes to sort before render
  16956. * @param sortCompareFn The comparison function use to sort
  16957. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  16958. * @param transparent Specifies to activate blending if true
  16959. */
  16960. private static renderSorted;
  16961. /**
  16962. * Renders the submeshes in the order they were dispatched (no sort applied).
  16963. * @param subMeshes The submeshes to render
  16964. */
  16965. private static renderUnsorted;
  16966. /**
  16967. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16968. * are rendered back to front if in the same alpha index.
  16969. *
  16970. * @param a The first submesh
  16971. * @param b The second submesh
  16972. * @returns The result of the comparison
  16973. */
  16974. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  16975. /**
  16976. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16977. * are rendered back to front.
  16978. *
  16979. * @param a The first submesh
  16980. * @param b The second submesh
  16981. * @returns The result of the comparison
  16982. */
  16983. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  16984. /**
  16985. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16986. * are rendered front to back (prevent overdraw).
  16987. *
  16988. * @param a The first submesh
  16989. * @param b The second submesh
  16990. * @returns The result of the comparison
  16991. */
  16992. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  16993. /**
  16994. * Resets the different lists of submeshes to prepare a new frame.
  16995. */
  16996. prepare(): void;
  16997. dispose(): void;
  16998. /**
  16999. * Inserts the submesh in its correct queue depending on its material.
  17000. * @param subMesh The submesh to dispatch
  17001. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17002. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17003. */
  17004. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17005. dispatchSprites(spriteManager: ISpriteManager): void;
  17006. dispatchParticles(particleSystem: IParticleSystem): void;
  17007. private _renderParticles;
  17008. private _renderSprites;
  17009. }
  17010. }
  17011. declare module BABYLON {
  17012. /**
  17013. * Interface describing the different options available in the rendering manager
  17014. * regarding Auto Clear between groups.
  17015. */
  17016. export interface IRenderingManagerAutoClearSetup {
  17017. /**
  17018. * Defines whether or not autoclear is enable.
  17019. */
  17020. autoClear: boolean;
  17021. /**
  17022. * Defines whether or not to autoclear the depth buffer.
  17023. */
  17024. depth: boolean;
  17025. /**
  17026. * Defines whether or not to autoclear the stencil buffer.
  17027. */
  17028. stencil: boolean;
  17029. }
  17030. /**
  17031. * This class is used by the onRenderingGroupObservable
  17032. */
  17033. export class RenderingGroupInfo {
  17034. /**
  17035. * The Scene that being rendered
  17036. */
  17037. scene: Scene;
  17038. /**
  17039. * The camera currently used for the rendering pass
  17040. */
  17041. camera: Nullable<Camera>;
  17042. /**
  17043. * The ID of the renderingGroup being processed
  17044. */
  17045. renderingGroupId: number;
  17046. }
  17047. /**
  17048. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17049. * It is enable to manage the different groups as well as the different necessary sort functions.
  17050. * This should not be used directly aside of the few static configurations
  17051. */
  17052. export class RenderingManager {
  17053. /**
  17054. * The max id used for rendering groups (not included)
  17055. */
  17056. static MAX_RENDERINGGROUPS: number;
  17057. /**
  17058. * The min id used for rendering groups (included)
  17059. */
  17060. static MIN_RENDERINGGROUPS: number;
  17061. /**
  17062. * Used to globally prevent autoclearing scenes.
  17063. */
  17064. static AUTOCLEAR: boolean;
  17065. /**
  17066. * @hidden
  17067. */
  17068. _useSceneAutoClearSetup: boolean;
  17069. private _scene;
  17070. private _renderingGroups;
  17071. private _depthStencilBufferAlreadyCleaned;
  17072. private _autoClearDepthStencil;
  17073. private _customOpaqueSortCompareFn;
  17074. private _customAlphaTestSortCompareFn;
  17075. private _customTransparentSortCompareFn;
  17076. private _renderingGroupInfo;
  17077. /**
  17078. * Instantiates a new rendering group for a particular scene
  17079. * @param scene Defines the scene the groups belongs to
  17080. */
  17081. constructor(scene: Scene);
  17082. private _clearDepthStencilBuffer;
  17083. /**
  17084. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17085. * @hidden
  17086. */
  17087. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17088. /**
  17089. * Resets the different information of the group to prepare a new frame
  17090. * @hidden
  17091. */
  17092. reset(): void;
  17093. /**
  17094. * Dispose and release the group and its associated resources.
  17095. * @hidden
  17096. */
  17097. dispose(): void;
  17098. /**
  17099. * Clear the info related to rendering groups preventing retention points during dispose.
  17100. */
  17101. freeRenderingGroups(): void;
  17102. private _prepareRenderingGroup;
  17103. /**
  17104. * Add a sprite manager to the rendering manager in order to render it this frame.
  17105. * @param spriteManager Define the sprite manager to render
  17106. */
  17107. dispatchSprites(spriteManager: ISpriteManager): void;
  17108. /**
  17109. * Add a particle system to the rendering manager in order to render it this frame.
  17110. * @param particleSystem Define the particle system to render
  17111. */
  17112. dispatchParticles(particleSystem: IParticleSystem): void;
  17113. /**
  17114. * Add a submesh to the manager in order to render it this frame
  17115. * @param subMesh The submesh to dispatch
  17116. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17117. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17118. */
  17119. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17120. /**
  17121. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17122. * This allowed control for front to back rendering or reversly depending of the special needs.
  17123. *
  17124. * @param renderingGroupId The rendering group id corresponding to its index
  17125. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17126. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17127. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17128. */
  17129. 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;
  17130. /**
  17131. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17132. *
  17133. * @param renderingGroupId The rendering group id corresponding to its index
  17134. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17135. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17136. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17137. */
  17138. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17139. /**
  17140. * Gets the current auto clear configuration for one rendering group of the rendering
  17141. * manager.
  17142. * @param index the rendering group index to get the information for
  17143. * @returns The auto clear setup for the requested rendering group
  17144. */
  17145. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17146. }
  17147. }
  17148. declare module BABYLON {
  17149. /**
  17150. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17151. */
  17152. export interface ICustomShaderOptions {
  17153. /**
  17154. * Gets or sets the custom shader name to use
  17155. */
  17156. shaderName: string;
  17157. /**
  17158. * The list of attribute names used in the shader
  17159. */
  17160. attributes?: string[];
  17161. /**
  17162. * The list of unifrom names used in the shader
  17163. */
  17164. uniforms?: string[];
  17165. /**
  17166. * The list of sampler names used in the shader
  17167. */
  17168. samplers?: string[];
  17169. /**
  17170. * The list of defines used in the shader
  17171. */
  17172. defines?: string[];
  17173. }
  17174. /**
  17175. * Interface to implement to create a shadow generator compatible with BJS.
  17176. */
  17177. export interface IShadowGenerator {
  17178. /**
  17179. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17180. * @returns The render target texture if present otherwise, null
  17181. */
  17182. getShadowMap(): Nullable<RenderTargetTexture>;
  17183. /**
  17184. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17185. * @param subMesh The submesh we want to render in the shadow map
  17186. * @param useInstances Defines wether will draw in the map using instances
  17187. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17188. * @returns true if ready otherwise, false
  17189. */
  17190. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17191. /**
  17192. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17193. * @param defines Defines of the material we want to update
  17194. * @param lightIndex Index of the light in the enabled light list of the material
  17195. */
  17196. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  17197. /**
  17198. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17199. * defined in the generator but impacting the effect).
  17200. * It implies the unifroms available on the materials are the standard BJS ones.
  17201. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17202. * @param effect The effect we are binfing the information for
  17203. */
  17204. bindShadowLight(lightIndex: string, effect: Effect): void;
  17205. /**
  17206. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17207. * (eq to shadow prjection matrix * light transform matrix)
  17208. * @returns The transform matrix used to create the shadow map
  17209. */
  17210. getTransformMatrix(): Matrix;
  17211. /**
  17212. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17213. * Cube and 2D textures for instance.
  17214. */
  17215. recreateShadowMap(): void;
  17216. /**
  17217. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17218. * @param onCompiled Callback triggered at the and of the effects compilation
  17219. * @param options Sets of optional options forcing the compilation with different modes
  17220. */
  17221. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17222. useInstances: boolean;
  17223. }>): void;
  17224. /**
  17225. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17226. * @param options Sets of optional options forcing the compilation with different modes
  17227. * @returns A promise that resolves when the compilation completes
  17228. */
  17229. forceCompilationAsync(options?: Partial<{
  17230. useInstances: boolean;
  17231. }>): Promise<void>;
  17232. /**
  17233. * Serializes the shadow generator setup to a json object.
  17234. * @returns The serialized JSON object
  17235. */
  17236. serialize(): any;
  17237. /**
  17238. * Disposes the Shadow map and related Textures and effects.
  17239. */
  17240. dispose(): void;
  17241. }
  17242. /**
  17243. * Default implementation IShadowGenerator.
  17244. * This is the main object responsible of generating shadows in the framework.
  17245. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  17246. */
  17247. export class ShadowGenerator implements IShadowGenerator {
  17248. /**
  17249. * Name of the shadow generator class
  17250. */
  17251. static CLASSNAME: string;
  17252. /**
  17253. * Shadow generator mode None: no filtering applied.
  17254. */
  17255. static readonly FILTER_NONE: number;
  17256. /**
  17257. * Shadow generator mode ESM: Exponential Shadow Mapping.
  17258. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17259. */
  17260. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  17261. /**
  17262. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  17263. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  17264. */
  17265. static readonly FILTER_POISSONSAMPLING: number;
  17266. /**
  17267. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  17268. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17269. */
  17270. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  17271. /**
  17272. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  17273. * edge artifacts on steep falloff.
  17274. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17275. */
  17276. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  17277. /**
  17278. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  17279. * edge artifacts on steep falloff.
  17280. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17281. */
  17282. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  17283. /**
  17284. * Shadow generator mode PCF: Percentage Closer Filtering
  17285. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17286. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  17287. */
  17288. static readonly FILTER_PCF: number;
  17289. /**
  17290. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  17291. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17292. * Contact Hardening
  17293. */
  17294. static readonly FILTER_PCSS: number;
  17295. /**
  17296. * Reserved for PCF and PCSS
  17297. * Highest Quality.
  17298. *
  17299. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  17300. *
  17301. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  17302. */
  17303. static readonly QUALITY_HIGH: number;
  17304. /**
  17305. * Reserved for PCF and PCSS
  17306. * Good tradeoff for quality/perf cross devices
  17307. *
  17308. * Execute PCF on a 3*3 kernel.
  17309. *
  17310. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  17311. */
  17312. static readonly QUALITY_MEDIUM: number;
  17313. /**
  17314. * Reserved for PCF and PCSS
  17315. * The lowest quality but the fastest.
  17316. *
  17317. * Execute PCF on a 1*1 kernel.
  17318. *
  17319. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  17320. */
  17321. static readonly QUALITY_LOW: number;
  17322. /** Gets or sets the custom shader name to use */
  17323. customShaderOptions: ICustomShaderOptions;
  17324. /**
  17325. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  17326. */
  17327. onBeforeShadowMapRenderObservable: Observable<Effect>;
  17328. /**
  17329. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  17330. */
  17331. onAfterShadowMapRenderObservable: Observable<Effect>;
  17332. /**
  17333. * Observable triggered before a mesh is rendered in the shadow map.
  17334. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  17335. */
  17336. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  17337. /**
  17338. * Observable triggered after a mesh is rendered in the shadow map.
  17339. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  17340. */
  17341. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  17342. protected _bias: number;
  17343. /**
  17344. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  17345. */
  17346. get bias(): number;
  17347. /**
  17348. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  17349. */
  17350. set bias(bias: number);
  17351. protected _normalBias: number;
  17352. /**
  17353. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17354. */
  17355. get normalBias(): number;
  17356. /**
  17357. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17358. */
  17359. set normalBias(normalBias: number);
  17360. protected _blurBoxOffset: number;
  17361. /**
  17362. * Gets the blur box offset: offset applied during the blur pass.
  17363. * Only useful if useKernelBlur = false
  17364. */
  17365. get blurBoxOffset(): number;
  17366. /**
  17367. * Sets the blur box offset: offset applied during the blur pass.
  17368. * Only useful if useKernelBlur = false
  17369. */
  17370. set blurBoxOffset(value: number);
  17371. protected _blurScale: number;
  17372. /**
  17373. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  17374. * 2 means half of the size.
  17375. */
  17376. get blurScale(): number;
  17377. /**
  17378. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  17379. * 2 means half of the size.
  17380. */
  17381. set blurScale(value: number);
  17382. protected _blurKernel: number;
  17383. /**
  17384. * Gets the blur kernel: kernel size of the blur pass.
  17385. * Only useful if useKernelBlur = true
  17386. */
  17387. get blurKernel(): number;
  17388. /**
  17389. * Sets the blur kernel: kernel size of the blur pass.
  17390. * Only useful if useKernelBlur = true
  17391. */
  17392. set blurKernel(value: number);
  17393. protected _useKernelBlur: boolean;
  17394. /**
  17395. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  17396. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17397. */
  17398. get useKernelBlur(): boolean;
  17399. /**
  17400. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  17401. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17402. */
  17403. set useKernelBlur(value: boolean);
  17404. protected _depthScale: number;
  17405. /**
  17406. * Gets the depth scale used in ESM mode.
  17407. */
  17408. get depthScale(): number;
  17409. /**
  17410. * Sets the depth scale used in ESM mode.
  17411. * This can override the scale stored on the light.
  17412. */
  17413. set depthScale(value: number);
  17414. protected _validateFilter(filter: number): number;
  17415. protected _filter: number;
  17416. /**
  17417. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  17418. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17419. */
  17420. get filter(): number;
  17421. /**
  17422. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  17423. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17424. */
  17425. set filter(value: number);
  17426. /**
  17427. * Gets if the current filter is set to Poisson Sampling.
  17428. */
  17429. get usePoissonSampling(): boolean;
  17430. /**
  17431. * Sets the current filter to Poisson Sampling.
  17432. */
  17433. set usePoissonSampling(value: boolean);
  17434. /**
  17435. * Gets if the current filter is set to ESM.
  17436. */
  17437. get useExponentialShadowMap(): boolean;
  17438. /**
  17439. * Sets the current filter is to ESM.
  17440. */
  17441. set useExponentialShadowMap(value: boolean);
  17442. /**
  17443. * Gets if the current filter is set to filtered ESM.
  17444. */
  17445. get useBlurExponentialShadowMap(): boolean;
  17446. /**
  17447. * Gets if the current filter is set to filtered ESM.
  17448. */
  17449. set useBlurExponentialShadowMap(value: boolean);
  17450. /**
  17451. * Gets if the current filter is set to "close ESM" (using the inverse of the
  17452. * exponential to prevent steep falloff artifacts).
  17453. */
  17454. get useCloseExponentialShadowMap(): boolean;
  17455. /**
  17456. * Sets the current filter to "close ESM" (using the inverse of the
  17457. * exponential to prevent steep falloff artifacts).
  17458. */
  17459. set useCloseExponentialShadowMap(value: boolean);
  17460. /**
  17461. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  17462. * exponential to prevent steep falloff artifacts).
  17463. */
  17464. get useBlurCloseExponentialShadowMap(): boolean;
  17465. /**
  17466. * Sets the current filter to filtered "close ESM" (using the inverse of the
  17467. * exponential to prevent steep falloff artifacts).
  17468. */
  17469. set useBlurCloseExponentialShadowMap(value: boolean);
  17470. /**
  17471. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  17472. */
  17473. get usePercentageCloserFiltering(): boolean;
  17474. /**
  17475. * Sets the current filter to "PCF" (percentage closer filtering).
  17476. */
  17477. set usePercentageCloserFiltering(value: boolean);
  17478. protected _filteringQuality: number;
  17479. /**
  17480. * Gets the PCF or PCSS Quality.
  17481. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17482. */
  17483. get filteringQuality(): number;
  17484. /**
  17485. * Sets the PCF or PCSS Quality.
  17486. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17487. */
  17488. set filteringQuality(filteringQuality: number);
  17489. /**
  17490. * Gets if the current filter is set to "PCSS" (contact hardening).
  17491. */
  17492. get useContactHardeningShadow(): boolean;
  17493. /**
  17494. * Sets the current filter to "PCSS" (contact hardening).
  17495. */
  17496. set useContactHardeningShadow(value: boolean);
  17497. protected _contactHardeningLightSizeUVRatio: number;
  17498. /**
  17499. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17500. * Using a ratio helps keeping shape stability independently of the map size.
  17501. *
  17502. * It does not account for the light projection as it was having too much
  17503. * instability during the light setup or during light position changes.
  17504. *
  17505. * Only valid if useContactHardeningShadow is true.
  17506. */
  17507. get contactHardeningLightSizeUVRatio(): number;
  17508. /**
  17509. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17510. * Using a ratio helps keeping shape stability independently of the map size.
  17511. *
  17512. * It does not account for the light projection as it was having too much
  17513. * instability during the light setup or during light position changes.
  17514. *
  17515. * Only valid if useContactHardeningShadow is true.
  17516. */
  17517. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  17518. protected _darkness: number;
  17519. /** Gets or sets the actual darkness of a shadow */
  17520. get darkness(): number;
  17521. set darkness(value: number);
  17522. /**
  17523. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  17524. * 0 means strongest and 1 would means no shadow.
  17525. * @returns the darkness.
  17526. */
  17527. getDarkness(): number;
  17528. /**
  17529. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  17530. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  17531. * @returns the shadow generator allowing fluent coding.
  17532. */
  17533. setDarkness(darkness: number): ShadowGenerator;
  17534. protected _transparencyShadow: boolean;
  17535. /** Gets or sets the ability to have transparent shadow */
  17536. get transparencyShadow(): boolean;
  17537. set transparencyShadow(value: boolean);
  17538. /**
  17539. * Sets the ability to have transparent shadow (boolean).
  17540. * @param transparent True if transparent else False
  17541. * @returns the shadow generator allowing fluent coding
  17542. */
  17543. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  17544. /**
  17545. * Enables or disables shadows with varying strength based on the transparency
  17546. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  17547. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  17548. * mesh.visibility * alphaTexture.a
  17549. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  17550. */
  17551. enableSoftTransparentShadow: boolean;
  17552. protected _shadowMap: Nullable<RenderTargetTexture>;
  17553. protected _shadowMap2: Nullable<RenderTargetTexture>;
  17554. /**
  17555. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17556. * @returns The render target texture if present otherwise, null
  17557. */
  17558. getShadowMap(): Nullable<RenderTargetTexture>;
  17559. /**
  17560. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  17561. * @returns The render target texture if the shadow map is present otherwise, null
  17562. */
  17563. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  17564. /**
  17565. * Gets the class name of that object
  17566. * @returns "ShadowGenerator"
  17567. */
  17568. getClassName(): string;
  17569. /**
  17570. * Helper function to add a mesh and its descendants to the list of shadow casters.
  17571. * @param mesh Mesh to add
  17572. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  17573. * @returns the Shadow Generator itself
  17574. */
  17575. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17576. /**
  17577. * Helper function to remove a mesh and its descendants from the list of shadow casters
  17578. * @param mesh Mesh to remove
  17579. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  17580. * @returns the Shadow Generator itself
  17581. */
  17582. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17583. /**
  17584. * Controls the extent to which the shadows fade out at the edge of the frustum
  17585. */
  17586. frustumEdgeFalloff: number;
  17587. protected _light: IShadowLight;
  17588. /**
  17589. * Returns the associated light object.
  17590. * @returns the light generating the shadow
  17591. */
  17592. getLight(): IShadowLight;
  17593. /**
  17594. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  17595. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  17596. * It might on the other hand introduce peter panning.
  17597. */
  17598. forceBackFacesOnly: boolean;
  17599. protected _scene: Scene;
  17600. protected _lightDirection: Vector3;
  17601. protected _effect: Effect;
  17602. protected _viewMatrix: Matrix;
  17603. protected _projectionMatrix: Matrix;
  17604. protected _transformMatrix: Matrix;
  17605. protected _cachedPosition: Vector3;
  17606. protected _cachedDirection: Vector3;
  17607. protected _cachedDefines: string;
  17608. protected _currentRenderID: number;
  17609. protected _boxBlurPostprocess: Nullable<PostProcess>;
  17610. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  17611. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  17612. protected _blurPostProcesses: PostProcess[];
  17613. protected _mapSize: number;
  17614. protected _currentFaceIndex: number;
  17615. protected _currentFaceIndexCache: number;
  17616. protected _textureType: number;
  17617. protected _defaultTextureMatrix: Matrix;
  17618. protected _storedUniqueId: Nullable<number>;
  17619. /** @hidden */
  17620. static _SceneComponentInitialization: (scene: Scene) => void;
  17621. /**
  17622. * Creates a ShadowGenerator object.
  17623. * A ShadowGenerator is the required tool to use the shadows.
  17624. * Each light casting shadows needs to use its own ShadowGenerator.
  17625. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  17626. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  17627. * @param light The light object generating the shadows.
  17628. * @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.
  17629. */
  17630. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  17631. protected _initializeGenerator(): void;
  17632. protected _createTargetRenderTexture(): void;
  17633. protected _initializeShadowMap(): void;
  17634. protected _initializeBlurRTTAndPostProcesses(): void;
  17635. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  17636. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  17637. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  17638. protected _applyFilterValues(): void;
  17639. /**
  17640. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17641. * @param onCompiled Callback triggered at the and of the effects compilation
  17642. * @param options Sets of optional options forcing the compilation with different modes
  17643. */
  17644. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17645. useInstances: boolean;
  17646. }>): void;
  17647. /**
  17648. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17649. * @param options Sets of optional options forcing the compilation with different modes
  17650. * @returns A promise that resolves when the compilation completes
  17651. */
  17652. forceCompilationAsync(options?: Partial<{
  17653. useInstances: boolean;
  17654. }>): Promise<void>;
  17655. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  17656. private _prepareShadowDefines;
  17657. /**
  17658. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17659. * @param subMesh The submesh we want to render in the shadow map
  17660. * @param useInstances Defines wether will draw in the map using instances
  17661. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17662. * @returns true if ready otherwise, false
  17663. */
  17664. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17665. /**
  17666. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17667. * @param defines Defines of the material we want to update
  17668. * @param lightIndex Index of the light in the enabled light list of the material
  17669. */
  17670. prepareDefines(defines: any, lightIndex: number): void;
  17671. /**
  17672. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17673. * defined in the generator but impacting the effect).
  17674. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17675. * @param effect The effect we are binfing the information for
  17676. */
  17677. bindShadowLight(lightIndex: string, effect: Effect): void;
  17678. /**
  17679. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17680. * (eq to shadow prjection matrix * light transform matrix)
  17681. * @returns The transform matrix used to create the shadow map
  17682. */
  17683. getTransformMatrix(): Matrix;
  17684. /**
  17685. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17686. * Cube and 2D textures for instance.
  17687. */
  17688. recreateShadowMap(): void;
  17689. protected _disposeBlurPostProcesses(): void;
  17690. protected _disposeRTTandPostProcesses(): void;
  17691. /**
  17692. * Disposes the ShadowGenerator.
  17693. * Returns nothing.
  17694. */
  17695. dispose(): void;
  17696. /**
  17697. * Serializes the shadow generator setup to a json object.
  17698. * @returns The serialized JSON object
  17699. */
  17700. serialize(): any;
  17701. /**
  17702. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  17703. * @param parsedShadowGenerator The JSON object to parse
  17704. * @param scene The scene to create the shadow map for
  17705. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  17706. * @returns The parsed shadow generator
  17707. */
  17708. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  17709. }
  17710. }
  17711. declare module BABYLON {
  17712. /**
  17713. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  17714. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  17715. * 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.
  17716. */
  17717. export abstract class Light extends Node {
  17718. /**
  17719. * Falloff Default: light is falling off following the material specification:
  17720. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  17721. */
  17722. static readonly FALLOFF_DEFAULT: number;
  17723. /**
  17724. * Falloff Physical: light is falling off following the inverse squared distance law.
  17725. */
  17726. static readonly FALLOFF_PHYSICAL: number;
  17727. /**
  17728. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  17729. * to enhance interoperability with other engines.
  17730. */
  17731. static readonly FALLOFF_GLTF: number;
  17732. /**
  17733. * Falloff Standard: light is falling off like in the standard material
  17734. * to enhance interoperability with other materials.
  17735. */
  17736. static readonly FALLOFF_STANDARD: number;
  17737. /**
  17738. * If every light affecting the material is in this lightmapMode,
  17739. * material.lightmapTexture adds or multiplies
  17740. * (depends on material.useLightmapAsShadowmap)
  17741. * after every other light calculations.
  17742. */
  17743. static readonly LIGHTMAP_DEFAULT: number;
  17744. /**
  17745. * material.lightmapTexture as only diffuse lighting from this light
  17746. * adds only specular lighting from this light
  17747. * adds dynamic shadows
  17748. */
  17749. static readonly LIGHTMAP_SPECULAR: number;
  17750. /**
  17751. * material.lightmapTexture as only lighting
  17752. * no light calculation from this light
  17753. * only adds dynamic shadows from this light
  17754. */
  17755. static readonly LIGHTMAP_SHADOWSONLY: number;
  17756. /**
  17757. * Each light type uses the default quantity according to its type:
  17758. * point/spot lights use luminous intensity
  17759. * directional lights use illuminance
  17760. */
  17761. static readonly INTENSITYMODE_AUTOMATIC: number;
  17762. /**
  17763. * lumen (lm)
  17764. */
  17765. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  17766. /**
  17767. * candela (lm/sr)
  17768. */
  17769. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  17770. /**
  17771. * lux (lm/m^2)
  17772. */
  17773. static readonly INTENSITYMODE_ILLUMINANCE: number;
  17774. /**
  17775. * nit (cd/m^2)
  17776. */
  17777. static readonly INTENSITYMODE_LUMINANCE: number;
  17778. /**
  17779. * Light type const id of the point light.
  17780. */
  17781. static readonly LIGHTTYPEID_POINTLIGHT: number;
  17782. /**
  17783. * Light type const id of the directional light.
  17784. */
  17785. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  17786. /**
  17787. * Light type const id of the spot light.
  17788. */
  17789. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  17790. /**
  17791. * Light type const id of the hemispheric light.
  17792. */
  17793. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  17794. /**
  17795. * Diffuse gives the basic color to an object.
  17796. */
  17797. diffuse: Color3;
  17798. /**
  17799. * Specular produces a highlight color on an object.
  17800. * Note: This is note affecting PBR materials.
  17801. */
  17802. specular: Color3;
  17803. /**
  17804. * Defines the falloff type for this light. This lets overrriding how punctual light are
  17805. * falling off base on range or angle.
  17806. * This can be set to any values in Light.FALLOFF_x.
  17807. *
  17808. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  17809. * other types of materials.
  17810. */
  17811. falloffType: number;
  17812. /**
  17813. * Strength of the light.
  17814. * Note: By default it is define in the framework own unit.
  17815. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  17816. */
  17817. intensity: number;
  17818. private _range;
  17819. protected _inverseSquaredRange: number;
  17820. /**
  17821. * Defines how far from the source the light is impacting in scene units.
  17822. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17823. */
  17824. get range(): number;
  17825. /**
  17826. * Defines how far from the source the light is impacting in scene units.
  17827. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17828. */
  17829. set range(value: number);
  17830. /**
  17831. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  17832. * of light.
  17833. */
  17834. private _photometricScale;
  17835. private _intensityMode;
  17836. /**
  17837. * Gets the photometric scale used to interpret the intensity.
  17838. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17839. */
  17840. get intensityMode(): number;
  17841. /**
  17842. * Sets the photometric scale used to interpret the intensity.
  17843. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17844. */
  17845. set intensityMode(value: number);
  17846. private _radius;
  17847. /**
  17848. * Gets the light radius used by PBR Materials to simulate soft area lights.
  17849. */
  17850. get radius(): number;
  17851. /**
  17852. * sets the light radius used by PBR Materials to simulate soft area lights.
  17853. */
  17854. set radius(value: number);
  17855. private _renderPriority;
  17856. /**
  17857. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  17858. * exceeding the number allowed of the materials.
  17859. */
  17860. renderPriority: number;
  17861. private _shadowEnabled;
  17862. /**
  17863. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17864. * the current shadow generator.
  17865. */
  17866. get shadowEnabled(): boolean;
  17867. /**
  17868. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17869. * the current shadow generator.
  17870. */
  17871. set shadowEnabled(value: boolean);
  17872. private _includedOnlyMeshes;
  17873. /**
  17874. * Gets the only meshes impacted by this light.
  17875. */
  17876. get includedOnlyMeshes(): AbstractMesh[];
  17877. /**
  17878. * Sets the only meshes impacted by this light.
  17879. */
  17880. set includedOnlyMeshes(value: AbstractMesh[]);
  17881. private _excludedMeshes;
  17882. /**
  17883. * Gets the meshes not impacted by this light.
  17884. */
  17885. get excludedMeshes(): AbstractMesh[];
  17886. /**
  17887. * Sets the meshes not impacted by this light.
  17888. */
  17889. set excludedMeshes(value: AbstractMesh[]);
  17890. private _excludeWithLayerMask;
  17891. /**
  17892. * Gets the layer id use to find what meshes are not impacted by the light.
  17893. * Inactive if 0
  17894. */
  17895. get excludeWithLayerMask(): number;
  17896. /**
  17897. * Sets the layer id use to find what meshes are not impacted by the light.
  17898. * Inactive if 0
  17899. */
  17900. set excludeWithLayerMask(value: number);
  17901. private _includeOnlyWithLayerMask;
  17902. /**
  17903. * Gets the layer id use to find what meshes are impacted by the light.
  17904. * Inactive if 0
  17905. */
  17906. get includeOnlyWithLayerMask(): number;
  17907. /**
  17908. * Sets the layer id use to find what meshes are impacted by the light.
  17909. * Inactive if 0
  17910. */
  17911. set includeOnlyWithLayerMask(value: number);
  17912. private _lightmapMode;
  17913. /**
  17914. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17915. */
  17916. get lightmapMode(): number;
  17917. /**
  17918. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17919. */
  17920. set lightmapMode(value: number);
  17921. /**
  17922. * Shadow generator associted to the light.
  17923. * @hidden Internal use only.
  17924. */
  17925. _shadowGenerator: Nullable<IShadowGenerator>;
  17926. /**
  17927. * @hidden Internal use only.
  17928. */
  17929. _excludedMeshesIds: string[];
  17930. /**
  17931. * @hidden Internal use only.
  17932. */
  17933. _includedOnlyMeshesIds: string[];
  17934. /**
  17935. * The current light unifom buffer.
  17936. * @hidden Internal use only.
  17937. */
  17938. _uniformBuffer: UniformBuffer;
  17939. /** @hidden */
  17940. _renderId: number;
  17941. /**
  17942. * Creates a Light object in the scene.
  17943. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17944. * @param name The firendly name of the light
  17945. * @param scene The scene the light belongs too
  17946. */
  17947. constructor(name: string, scene: Scene);
  17948. protected abstract _buildUniformLayout(): void;
  17949. /**
  17950. * Sets the passed Effect "effect" with the Light information.
  17951. * @param effect The effect to update
  17952. * @param lightIndex The index of the light in the effect to update
  17953. * @returns The light
  17954. */
  17955. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  17956. /**
  17957. * Sets the passed Effect "effect" with the Light textures.
  17958. * @param effect The effect to update
  17959. * @param lightIndex The index of the light in the effect to update
  17960. * @returns The light
  17961. */
  17962. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  17963. /**
  17964. * Binds the lights information from the scene to the effect for the given mesh.
  17965. * @param lightIndex Light index
  17966. * @param scene The scene where the light belongs to
  17967. * @param effect The effect we are binding the data to
  17968. * @param useSpecular Defines if specular is supported
  17969. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  17970. */
  17971. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  17972. /**
  17973. * Sets the passed Effect "effect" with the Light information.
  17974. * @param effect The effect to update
  17975. * @param lightDataUniformName The uniform used to store light data (position or direction)
  17976. * @returns The light
  17977. */
  17978. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  17979. /**
  17980. * Returns the string "Light".
  17981. * @returns the class name
  17982. */
  17983. getClassName(): string;
  17984. /** @hidden */
  17985. readonly _isLight: boolean;
  17986. /**
  17987. * Converts the light information to a readable string for debug purpose.
  17988. * @param fullDetails Supports for multiple levels of logging within scene loading
  17989. * @returns the human readable light info
  17990. */
  17991. toString(fullDetails?: boolean): string;
  17992. /** @hidden */
  17993. protected _syncParentEnabledState(): void;
  17994. /**
  17995. * Set the enabled state of this node.
  17996. * @param value - the new enabled state
  17997. */
  17998. setEnabled(value: boolean): void;
  17999. /**
  18000. * Returns the Light associated shadow generator if any.
  18001. * @return the associated shadow generator.
  18002. */
  18003. getShadowGenerator(): Nullable<IShadowGenerator>;
  18004. /**
  18005. * Returns a Vector3, the absolute light position in the World.
  18006. * @returns the world space position of the light
  18007. */
  18008. getAbsolutePosition(): Vector3;
  18009. /**
  18010. * Specifies if the light will affect the passed mesh.
  18011. * @param mesh The mesh to test against the light
  18012. * @return true the mesh is affected otherwise, false.
  18013. */
  18014. canAffectMesh(mesh: AbstractMesh): boolean;
  18015. /**
  18016. * Sort function to order lights for rendering.
  18017. * @param a First Light object to compare to second.
  18018. * @param b Second Light object to compare first.
  18019. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18020. */
  18021. static CompareLightsPriority(a: Light, b: Light): number;
  18022. /**
  18023. * Releases resources associated with this node.
  18024. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18025. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18026. */
  18027. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18028. /**
  18029. * Returns the light type ID (integer).
  18030. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18031. */
  18032. getTypeID(): number;
  18033. /**
  18034. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18035. * @returns the scaled intensity in intensity mode unit
  18036. */
  18037. getScaledIntensity(): number;
  18038. /**
  18039. * Returns a new Light object, named "name", from the current one.
  18040. * @param name The name of the cloned light
  18041. * @param newParent The parent of this light, if it has one
  18042. * @returns the new created light
  18043. */
  18044. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18045. /**
  18046. * Serializes the current light into a Serialization object.
  18047. * @returns the serialized object.
  18048. */
  18049. serialize(): any;
  18050. /**
  18051. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18052. * This new light is named "name" and added to the passed scene.
  18053. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18054. * @param name The friendly name of the light
  18055. * @param scene The scene the new light will belong to
  18056. * @returns the constructor function
  18057. */
  18058. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18059. /**
  18060. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18061. * @param parsedLight The JSON representation of the light
  18062. * @param scene The scene to create the parsed light in
  18063. * @returns the created light after parsing
  18064. */
  18065. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18066. private _hookArrayForExcluded;
  18067. private _hookArrayForIncludedOnly;
  18068. private _resyncMeshes;
  18069. /**
  18070. * Forces the meshes to update their light related information in their rendering used effects
  18071. * @hidden Internal Use Only
  18072. */
  18073. _markMeshesAsLightDirty(): void;
  18074. /**
  18075. * Recomputes the cached photometric scale if needed.
  18076. */
  18077. private _computePhotometricScale;
  18078. /**
  18079. * Returns the Photometric Scale according to the light type and intensity mode.
  18080. */
  18081. private _getPhotometricScale;
  18082. /**
  18083. * Reorder the light in the scene according to their defined priority.
  18084. * @hidden Internal Use Only
  18085. */
  18086. _reorderLightsInScene(): void;
  18087. /**
  18088. * Prepares the list of defines specific to the light type.
  18089. * @param defines the list of defines
  18090. * @param lightIndex defines the index of the light for the effect
  18091. */
  18092. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18093. }
  18094. }
  18095. declare module BABYLON {
  18096. /**
  18097. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18098. * This is the base of the follow, arc rotate cameras and Free camera
  18099. * @see http://doc.babylonjs.com/features/cameras
  18100. */
  18101. export class TargetCamera extends Camera {
  18102. private static _RigCamTransformMatrix;
  18103. private static _TargetTransformMatrix;
  18104. private static _TargetFocalPoint;
  18105. /**
  18106. * Define the current direction the camera is moving to
  18107. */
  18108. cameraDirection: Vector3;
  18109. /**
  18110. * Define the current rotation the camera is rotating to
  18111. */
  18112. cameraRotation: Vector2;
  18113. /**
  18114. * When set, the up vector of the camera will be updated by the rotation of the camera
  18115. */
  18116. updateUpVectorFromRotation: boolean;
  18117. private _tmpQuaternion;
  18118. /**
  18119. * Define the current rotation of the camera
  18120. */
  18121. rotation: Vector3;
  18122. /**
  18123. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18124. */
  18125. rotationQuaternion: Quaternion;
  18126. /**
  18127. * Define the current speed of the camera
  18128. */
  18129. speed: number;
  18130. /**
  18131. * Add constraint to the camera to prevent it to move freely in all directions and
  18132. * around all axis.
  18133. */
  18134. noRotationConstraint: boolean;
  18135. /**
  18136. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18137. * panning
  18138. */
  18139. invertRotation: boolean;
  18140. /**
  18141. * Speed multiplier for inverse camera panning
  18142. */
  18143. inverseRotationSpeed: number;
  18144. /**
  18145. * Define the current target of the camera as an object or a position.
  18146. */
  18147. lockedTarget: any;
  18148. /** @hidden */
  18149. _currentTarget: Vector3;
  18150. /** @hidden */
  18151. _initialFocalDistance: number;
  18152. /** @hidden */
  18153. _viewMatrix: Matrix;
  18154. /** @hidden */
  18155. _camMatrix: Matrix;
  18156. /** @hidden */
  18157. _cameraTransformMatrix: Matrix;
  18158. /** @hidden */
  18159. _cameraRotationMatrix: Matrix;
  18160. /** @hidden */
  18161. _referencePoint: Vector3;
  18162. /** @hidden */
  18163. _transformedReferencePoint: Vector3;
  18164. protected _globalCurrentTarget: Vector3;
  18165. protected _globalCurrentUpVector: Vector3;
  18166. /** @hidden */
  18167. _reset: () => void;
  18168. private _defaultUp;
  18169. /**
  18170. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  18171. * This is the base of the follow, arc rotate cameras and Free camera
  18172. * @see http://doc.babylonjs.com/features/cameras
  18173. * @param name Defines the name of the camera in the scene
  18174. * @param position Defines the start position of the camera in the scene
  18175. * @param scene Defines the scene the camera belongs to
  18176. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18177. */
  18178. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18179. /**
  18180. * Gets the position in front of the camera at a given distance.
  18181. * @param distance The distance from the camera we want the position to be
  18182. * @returns the position
  18183. */
  18184. getFrontPosition(distance: number): Vector3;
  18185. /** @hidden */
  18186. _getLockedTargetPosition(): Nullable<Vector3>;
  18187. private _storedPosition;
  18188. private _storedRotation;
  18189. private _storedRotationQuaternion;
  18190. /**
  18191. * Store current camera state of the camera (fov, position, rotation, etc..)
  18192. * @returns the camera
  18193. */
  18194. storeState(): Camera;
  18195. /**
  18196. * Restored camera state. You must call storeState() first
  18197. * @returns whether it was successful or not
  18198. * @hidden
  18199. */
  18200. _restoreStateValues(): boolean;
  18201. /** @hidden */
  18202. _initCache(): void;
  18203. /** @hidden */
  18204. _updateCache(ignoreParentClass?: boolean): void;
  18205. /** @hidden */
  18206. _isSynchronizedViewMatrix(): boolean;
  18207. /** @hidden */
  18208. _computeLocalCameraSpeed(): number;
  18209. /**
  18210. * Defines the target the camera should look at.
  18211. * @param target Defines the new target as a Vector or a mesh
  18212. */
  18213. setTarget(target: Vector3): void;
  18214. /**
  18215. * Return the current target position of the camera. This value is expressed in local space.
  18216. * @returns the target position
  18217. */
  18218. getTarget(): Vector3;
  18219. /** @hidden */
  18220. _decideIfNeedsToMove(): boolean;
  18221. /** @hidden */
  18222. _updatePosition(): void;
  18223. /** @hidden */
  18224. _checkInputs(): void;
  18225. protected _updateCameraRotationMatrix(): void;
  18226. /**
  18227. * 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)
  18228. * @returns the current camera
  18229. */
  18230. private _rotateUpVectorWithCameraRotationMatrix;
  18231. private _cachedRotationZ;
  18232. private _cachedQuaternionRotationZ;
  18233. /** @hidden */
  18234. _getViewMatrix(): Matrix;
  18235. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  18236. /**
  18237. * @hidden
  18238. */
  18239. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  18240. /**
  18241. * @hidden
  18242. */
  18243. _updateRigCameras(): void;
  18244. private _getRigCamPositionAndTarget;
  18245. /**
  18246. * Gets the current object class name.
  18247. * @return the class name
  18248. */
  18249. getClassName(): string;
  18250. }
  18251. }
  18252. declare module BABYLON {
  18253. /**
  18254. * Gather the list of keyboard event types as constants.
  18255. */
  18256. export class KeyboardEventTypes {
  18257. /**
  18258. * The keydown event is fired when a key becomes active (pressed).
  18259. */
  18260. static readonly KEYDOWN: number;
  18261. /**
  18262. * The keyup event is fired when a key has been released.
  18263. */
  18264. static readonly KEYUP: number;
  18265. }
  18266. /**
  18267. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18268. */
  18269. export class KeyboardInfo {
  18270. /**
  18271. * Defines the type of event (KeyboardEventTypes)
  18272. */
  18273. type: number;
  18274. /**
  18275. * Defines the related dom event
  18276. */
  18277. event: KeyboardEvent;
  18278. /**
  18279. * Instantiates a new keyboard info.
  18280. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18281. * @param type Defines the type of event (KeyboardEventTypes)
  18282. * @param event Defines the related dom event
  18283. */
  18284. constructor(
  18285. /**
  18286. * Defines the type of event (KeyboardEventTypes)
  18287. */
  18288. type: number,
  18289. /**
  18290. * Defines the related dom event
  18291. */
  18292. event: KeyboardEvent);
  18293. }
  18294. /**
  18295. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18296. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  18297. */
  18298. export class KeyboardInfoPre extends KeyboardInfo {
  18299. /**
  18300. * Defines the type of event (KeyboardEventTypes)
  18301. */
  18302. type: number;
  18303. /**
  18304. * Defines the related dom event
  18305. */
  18306. event: KeyboardEvent;
  18307. /**
  18308. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  18309. */
  18310. skipOnPointerObservable: boolean;
  18311. /**
  18312. * Instantiates a new keyboard pre info.
  18313. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18314. * @param type Defines the type of event (KeyboardEventTypes)
  18315. * @param event Defines the related dom event
  18316. */
  18317. constructor(
  18318. /**
  18319. * Defines the type of event (KeyboardEventTypes)
  18320. */
  18321. type: number,
  18322. /**
  18323. * Defines the related dom event
  18324. */
  18325. event: KeyboardEvent);
  18326. }
  18327. }
  18328. declare module BABYLON {
  18329. /**
  18330. * Manage the keyboard inputs to control the movement of a free camera.
  18331. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18332. */
  18333. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  18334. /**
  18335. * Defines the camera the input is attached to.
  18336. */
  18337. camera: FreeCamera;
  18338. /**
  18339. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18340. */
  18341. keysUp: number[];
  18342. /**
  18343. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18344. */
  18345. keysUpward: number[];
  18346. /**
  18347. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18348. */
  18349. keysDown: number[];
  18350. /**
  18351. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18352. */
  18353. keysDownward: number[];
  18354. /**
  18355. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18356. */
  18357. keysLeft: number[];
  18358. /**
  18359. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18360. */
  18361. keysRight: number[];
  18362. private _keys;
  18363. private _onCanvasBlurObserver;
  18364. private _onKeyboardObserver;
  18365. private _engine;
  18366. private _scene;
  18367. /**
  18368. * Attach the input controls to a specific dom element to get the input from.
  18369. * @param element Defines the element the controls should be listened from
  18370. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18371. */
  18372. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18373. /**
  18374. * Detach the current controls from the specified dom element.
  18375. * @param element Defines the element to stop listening the inputs from
  18376. */
  18377. detachControl(element: Nullable<HTMLElement>): void;
  18378. /**
  18379. * Update the current camera state depending on the inputs that have been used this frame.
  18380. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18381. */
  18382. checkInputs(): void;
  18383. /**
  18384. * Gets the class name of the current intput.
  18385. * @returns the class name
  18386. */
  18387. getClassName(): string;
  18388. /** @hidden */
  18389. _onLostFocus(): void;
  18390. /**
  18391. * Get the friendly name associated with the input class.
  18392. * @returns the input friendly name
  18393. */
  18394. getSimpleName(): string;
  18395. }
  18396. }
  18397. declare module BABYLON {
  18398. /**
  18399. * Gather the list of pointer event types as constants.
  18400. */
  18401. export class PointerEventTypes {
  18402. /**
  18403. * 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.
  18404. */
  18405. static readonly POINTERDOWN: number;
  18406. /**
  18407. * The pointerup event is fired when a pointer is no longer active.
  18408. */
  18409. static readonly POINTERUP: number;
  18410. /**
  18411. * The pointermove event is fired when a pointer changes coordinates.
  18412. */
  18413. static readonly POINTERMOVE: number;
  18414. /**
  18415. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18416. */
  18417. static readonly POINTERWHEEL: number;
  18418. /**
  18419. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18420. */
  18421. static readonly POINTERPICK: number;
  18422. /**
  18423. * The pointertap event is fired when a the object has been touched and released without drag.
  18424. */
  18425. static readonly POINTERTAP: number;
  18426. /**
  18427. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18428. */
  18429. static readonly POINTERDOUBLETAP: number;
  18430. }
  18431. /**
  18432. * Base class of pointer info types.
  18433. */
  18434. export class PointerInfoBase {
  18435. /**
  18436. * Defines the type of event (PointerEventTypes)
  18437. */
  18438. type: number;
  18439. /**
  18440. * Defines the related dom event
  18441. */
  18442. event: PointerEvent | MouseWheelEvent;
  18443. /**
  18444. * Instantiates the base class of pointers info.
  18445. * @param type Defines the type of event (PointerEventTypes)
  18446. * @param event Defines the related dom event
  18447. */
  18448. constructor(
  18449. /**
  18450. * Defines the type of event (PointerEventTypes)
  18451. */
  18452. type: number,
  18453. /**
  18454. * Defines the related dom event
  18455. */
  18456. event: PointerEvent | MouseWheelEvent);
  18457. }
  18458. /**
  18459. * This class is used to store pointer related info for the onPrePointerObservable event.
  18460. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18461. */
  18462. export class PointerInfoPre extends PointerInfoBase {
  18463. /**
  18464. * Ray from a pointer if availible (eg. 6dof controller)
  18465. */
  18466. ray: Nullable<Ray>;
  18467. /**
  18468. * Defines the local position of the pointer on the canvas.
  18469. */
  18470. localPosition: Vector2;
  18471. /**
  18472. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18473. */
  18474. skipOnPointerObservable: boolean;
  18475. /**
  18476. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18477. * @param type Defines the type of event (PointerEventTypes)
  18478. * @param event Defines the related dom event
  18479. * @param localX Defines the local x coordinates of the pointer when the event occured
  18480. * @param localY Defines the local y coordinates of the pointer when the event occured
  18481. */
  18482. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18483. }
  18484. /**
  18485. * This type contains all the data related to a pointer event in Babylon.js.
  18486. * 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.
  18487. */
  18488. export class PointerInfo extends PointerInfoBase {
  18489. /**
  18490. * Defines the picking info associated to the info (if any)\
  18491. */
  18492. pickInfo: Nullable<PickingInfo>;
  18493. /**
  18494. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18495. * @param type Defines the type of event (PointerEventTypes)
  18496. * @param event Defines the related dom event
  18497. * @param pickInfo Defines the picking info associated to the info (if any)\
  18498. */
  18499. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18500. /**
  18501. * Defines the picking info associated to the info (if any)\
  18502. */
  18503. pickInfo: Nullable<PickingInfo>);
  18504. }
  18505. /**
  18506. * Data relating to a touch event on the screen.
  18507. */
  18508. export interface PointerTouch {
  18509. /**
  18510. * X coordinate of touch.
  18511. */
  18512. x: number;
  18513. /**
  18514. * Y coordinate of touch.
  18515. */
  18516. y: number;
  18517. /**
  18518. * Id of touch. Unique for each finger.
  18519. */
  18520. pointerId: number;
  18521. /**
  18522. * Event type passed from DOM.
  18523. */
  18524. type: any;
  18525. }
  18526. }
  18527. declare module BABYLON {
  18528. /**
  18529. * Manage the mouse inputs to control the movement of a free camera.
  18530. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18531. */
  18532. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18533. /**
  18534. * Define if touch is enabled in the mouse input
  18535. */
  18536. touchEnabled: boolean;
  18537. /**
  18538. * Defines the camera the input is attached to.
  18539. */
  18540. camera: FreeCamera;
  18541. /**
  18542. * Defines the buttons associated with the input to handle camera move.
  18543. */
  18544. buttons: number[];
  18545. /**
  18546. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18547. */
  18548. angularSensibility: number;
  18549. private _pointerInput;
  18550. private _onMouseMove;
  18551. private _observer;
  18552. private previousPosition;
  18553. /**
  18554. * Observable for when a pointer move event occurs containing the move offset
  18555. */
  18556. onPointerMovedObservable: Observable<{
  18557. offsetX: number;
  18558. offsetY: number;
  18559. }>;
  18560. /**
  18561. * @hidden
  18562. * If the camera should be rotated automatically based on pointer movement
  18563. */
  18564. _allowCameraRotation: boolean;
  18565. /**
  18566. * Manage the mouse inputs to control the movement of a free camera.
  18567. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18568. * @param touchEnabled Defines if touch is enabled or not
  18569. */
  18570. constructor(
  18571. /**
  18572. * Define if touch is enabled in the mouse input
  18573. */
  18574. touchEnabled?: boolean);
  18575. /**
  18576. * Attach the input controls to a specific dom element to get the input from.
  18577. * @param element Defines the element the controls should be listened from
  18578. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18579. */
  18580. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18581. /**
  18582. * Called on JS contextmenu event.
  18583. * Override this method to provide functionality.
  18584. */
  18585. protected onContextMenu(evt: PointerEvent): void;
  18586. /**
  18587. * Detach the current controls from the specified dom element.
  18588. * @param element Defines the element to stop listening the inputs from
  18589. */
  18590. detachControl(element: Nullable<HTMLElement>): void;
  18591. /**
  18592. * Gets the class name of the current intput.
  18593. * @returns the class name
  18594. */
  18595. getClassName(): string;
  18596. /**
  18597. * Get the friendly name associated with the input class.
  18598. * @returns the input friendly name
  18599. */
  18600. getSimpleName(): string;
  18601. }
  18602. }
  18603. declare module BABYLON {
  18604. /**
  18605. * Manage the touch inputs to control the movement of a free camera.
  18606. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18607. */
  18608. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18609. /**
  18610. * Defines the camera the input is attached to.
  18611. */
  18612. camera: FreeCamera;
  18613. /**
  18614. * Defines the touch sensibility for rotation.
  18615. * The higher the faster.
  18616. */
  18617. touchAngularSensibility: number;
  18618. /**
  18619. * Defines the touch sensibility for move.
  18620. * The higher the faster.
  18621. */
  18622. touchMoveSensibility: number;
  18623. private _offsetX;
  18624. private _offsetY;
  18625. private _pointerPressed;
  18626. private _pointerInput;
  18627. private _observer;
  18628. private _onLostFocus;
  18629. /**
  18630. * Attach the input controls to a specific dom element to get the input from.
  18631. * @param element Defines the element the controls should be listened from
  18632. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18633. */
  18634. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18635. /**
  18636. * Detach the current controls from the specified dom element.
  18637. * @param element Defines the element to stop listening the inputs from
  18638. */
  18639. detachControl(element: Nullable<HTMLElement>): void;
  18640. /**
  18641. * Update the current camera state depending on the inputs that have been used this frame.
  18642. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18643. */
  18644. checkInputs(): void;
  18645. /**
  18646. * Gets the class name of the current intput.
  18647. * @returns the class name
  18648. */
  18649. getClassName(): string;
  18650. /**
  18651. * Get the friendly name associated with the input class.
  18652. * @returns the input friendly name
  18653. */
  18654. getSimpleName(): string;
  18655. }
  18656. }
  18657. declare module BABYLON {
  18658. /**
  18659. * Default Inputs manager for the FreeCamera.
  18660. * It groups all the default supported inputs for ease of use.
  18661. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18662. */
  18663. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18664. /**
  18665. * @hidden
  18666. */
  18667. _mouseInput: Nullable<FreeCameraMouseInput>;
  18668. /**
  18669. * Instantiates a new FreeCameraInputsManager.
  18670. * @param camera Defines the camera the inputs belong to
  18671. */
  18672. constructor(camera: FreeCamera);
  18673. /**
  18674. * Add keyboard input support to the input manager.
  18675. * @returns the current input manager
  18676. */
  18677. addKeyboard(): FreeCameraInputsManager;
  18678. /**
  18679. * Add mouse input support to the input manager.
  18680. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18681. * @returns the current input manager
  18682. */
  18683. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18684. /**
  18685. * Removes the mouse input support from the manager
  18686. * @returns the current input manager
  18687. */
  18688. removeMouse(): FreeCameraInputsManager;
  18689. /**
  18690. * Add touch input support to the input manager.
  18691. * @returns the current input manager
  18692. */
  18693. addTouch(): FreeCameraInputsManager;
  18694. /**
  18695. * Remove all attached input methods from a camera
  18696. */
  18697. clear(): void;
  18698. }
  18699. }
  18700. declare module BABYLON {
  18701. /**
  18702. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18703. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18704. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18705. */
  18706. export class FreeCamera extends TargetCamera {
  18707. /**
  18708. * Define the collision ellipsoid of the camera.
  18709. * This is helpful to simulate a camera body like the player body around the camera
  18710. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18711. */
  18712. ellipsoid: Vector3;
  18713. /**
  18714. * Define an offset for the position of the ellipsoid around the camera.
  18715. * This can be helpful to determine the center of the body near the gravity center of the body
  18716. * instead of its head.
  18717. */
  18718. ellipsoidOffset: Vector3;
  18719. /**
  18720. * Enable or disable collisions of the camera with the rest of the scene objects.
  18721. */
  18722. checkCollisions: boolean;
  18723. /**
  18724. * Enable or disable gravity on the camera.
  18725. */
  18726. applyGravity: boolean;
  18727. /**
  18728. * Define the input manager associated to the camera.
  18729. */
  18730. inputs: FreeCameraInputsManager;
  18731. /**
  18732. * Gets the input sensibility for a mouse input. (default is 2000.0)
  18733. * Higher values reduce sensitivity.
  18734. */
  18735. get angularSensibility(): number;
  18736. /**
  18737. * Sets the input sensibility for a mouse input. (default is 2000.0)
  18738. * Higher values reduce sensitivity.
  18739. */
  18740. set angularSensibility(value: number);
  18741. /**
  18742. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18743. */
  18744. get keysUp(): number[];
  18745. set keysUp(value: number[]);
  18746. /**
  18747. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18748. */
  18749. get keysUpward(): number[];
  18750. set keysUpward(value: number[]);
  18751. /**
  18752. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18753. */
  18754. get keysDown(): number[];
  18755. set keysDown(value: number[]);
  18756. /**
  18757. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18758. */
  18759. get keysDownward(): number[];
  18760. set keysDownward(value: number[]);
  18761. /**
  18762. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18763. */
  18764. get keysLeft(): number[];
  18765. set keysLeft(value: number[]);
  18766. /**
  18767. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18768. */
  18769. get keysRight(): number[];
  18770. set keysRight(value: number[]);
  18771. /**
  18772. * Event raised when the camera collide with a mesh in the scene.
  18773. */
  18774. onCollide: (collidedMesh: AbstractMesh) => void;
  18775. private _collider;
  18776. private _needMoveForGravity;
  18777. private _oldPosition;
  18778. private _diffPosition;
  18779. private _newPosition;
  18780. /** @hidden */
  18781. _localDirection: Vector3;
  18782. /** @hidden */
  18783. _transformedDirection: Vector3;
  18784. /**
  18785. * Instantiates a Free Camera.
  18786. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18787. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  18788. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18789. * @param name Define the name of the camera in the scene
  18790. * @param position Define the start position of the camera in the scene
  18791. * @param scene Define the scene the camera belongs to
  18792. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18793. */
  18794. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18795. /**
  18796. * Attached controls to the current camera.
  18797. * @param element Defines the element the controls should be listened from
  18798. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18799. */
  18800. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18801. /**
  18802. * Detach the current controls from the camera.
  18803. * The camera will stop reacting to inputs.
  18804. * @param element Defines the element to stop listening the inputs from
  18805. */
  18806. detachControl(element: HTMLElement): void;
  18807. private _collisionMask;
  18808. /**
  18809. * Define a collision mask to limit the list of object the camera can collide with
  18810. */
  18811. get collisionMask(): number;
  18812. set collisionMask(mask: number);
  18813. /** @hidden */
  18814. _collideWithWorld(displacement: Vector3): void;
  18815. private _onCollisionPositionChange;
  18816. /** @hidden */
  18817. _checkInputs(): void;
  18818. /** @hidden */
  18819. _decideIfNeedsToMove(): boolean;
  18820. /** @hidden */
  18821. _updatePosition(): void;
  18822. /**
  18823. * Destroy the camera and release the current resources hold by it.
  18824. */
  18825. dispose(): void;
  18826. /**
  18827. * Gets the current object class name.
  18828. * @return the class name
  18829. */
  18830. getClassName(): string;
  18831. }
  18832. }
  18833. declare module BABYLON {
  18834. /**
  18835. * Represents a gamepad control stick position
  18836. */
  18837. export class StickValues {
  18838. /**
  18839. * The x component of the control stick
  18840. */
  18841. x: number;
  18842. /**
  18843. * The y component of the control stick
  18844. */
  18845. y: number;
  18846. /**
  18847. * Initializes the gamepad x and y control stick values
  18848. * @param x The x component of the gamepad control stick value
  18849. * @param y The y component of the gamepad control stick value
  18850. */
  18851. constructor(
  18852. /**
  18853. * The x component of the control stick
  18854. */
  18855. x: number,
  18856. /**
  18857. * The y component of the control stick
  18858. */
  18859. y: number);
  18860. }
  18861. /**
  18862. * An interface which manages callbacks for gamepad button changes
  18863. */
  18864. export interface GamepadButtonChanges {
  18865. /**
  18866. * Called when a gamepad has been changed
  18867. */
  18868. changed: boolean;
  18869. /**
  18870. * Called when a gamepad press event has been triggered
  18871. */
  18872. pressChanged: boolean;
  18873. /**
  18874. * Called when a touch event has been triggered
  18875. */
  18876. touchChanged: boolean;
  18877. /**
  18878. * Called when a value has changed
  18879. */
  18880. valueChanged: boolean;
  18881. }
  18882. /**
  18883. * Represents a gamepad
  18884. */
  18885. export class Gamepad {
  18886. /**
  18887. * The id of the gamepad
  18888. */
  18889. id: string;
  18890. /**
  18891. * The index of the gamepad
  18892. */
  18893. index: number;
  18894. /**
  18895. * The browser gamepad
  18896. */
  18897. browserGamepad: any;
  18898. /**
  18899. * Specifies what type of gamepad this represents
  18900. */
  18901. type: number;
  18902. private _leftStick;
  18903. private _rightStick;
  18904. /** @hidden */
  18905. _isConnected: boolean;
  18906. private _leftStickAxisX;
  18907. private _leftStickAxisY;
  18908. private _rightStickAxisX;
  18909. private _rightStickAxisY;
  18910. /**
  18911. * Triggered when the left control stick has been changed
  18912. */
  18913. private _onleftstickchanged;
  18914. /**
  18915. * Triggered when the right control stick has been changed
  18916. */
  18917. private _onrightstickchanged;
  18918. /**
  18919. * Represents a gamepad controller
  18920. */
  18921. static GAMEPAD: number;
  18922. /**
  18923. * Represents a generic controller
  18924. */
  18925. static GENERIC: number;
  18926. /**
  18927. * Represents an XBox controller
  18928. */
  18929. static XBOX: number;
  18930. /**
  18931. * Represents a pose-enabled controller
  18932. */
  18933. static POSE_ENABLED: number;
  18934. /**
  18935. * Represents an Dual Shock controller
  18936. */
  18937. static DUALSHOCK: number;
  18938. /**
  18939. * Specifies whether the left control stick should be Y-inverted
  18940. */
  18941. protected _invertLeftStickY: boolean;
  18942. /**
  18943. * Specifies if the gamepad has been connected
  18944. */
  18945. get isConnected(): boolean;
  18946. /**
  18947. * Initializes the gamepad
  18948. * @param id The id of the gamepad
  18949. * @param index The index of the gamepad
  18950. * @param browserGamepad The browser gamepad
  18951. * @param leftStickX The x component of the left joystick
  18952. * @param leftStickY The y component of the left joystick
  18953. * @param rightStickX The x component of the right joystick
  18954. * @param rightStickY The y component of the right joystick
  18955. */
  18956. constructor(
  18957. /**
  18958. * The id of the gamepad
  18959. */
  18960. id: string,
  18961. /**
  18962. * The index of the gamepad
  18963. */
  18964. index: number,
  18965. /**
  18966. * The browser gamepad
  18967. */
  18968. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  18969. /**
  18970. * Callback triggered when the left joystick has changed
  18971. * @param callback
  18972. */
  18973. onleftstickchanged(callback: (values: StickValues) => void): void;
  18974. /**
  18975. * Callback triggered when the right joystick has changed
  18976. * @param callback
  18977. */
  18978. onrightstickchanged(callback: (values: StickValues) => void): void;
  18979. /**
  18980. * Gets the left joystick
  18981. */
  18982. get leftStick(): StickValues;
  18983. /**
  18984. * Sets the left joystick values
  18985. */
  18986. set leftStick(newValues: StickValues);
  18987. /**
  18988. * Gets the right joystick
  18989. */
  18990. get rightStick(): StickValues;
  18991. /**
  18992. * Sets the right joystick value
  18993. */
  18994. set rightStick(newValues: StickValues);
  18995. /**
  18996. * Updates the gamepad joystick positions
  18997. */
  18998. update(): void;
  18999. /**
  19000. * Disposes the gamepad
  19001. */
  19002. dispose(): void;
  19003. }
  19004. /**
  19005. * Represents a generic gamepad
  19006. */
  19007. export class GenericPad extends Gamepad {
  19008. private _buttons;
  19009. private _onbuttondown;
  19010. private _onbuttonup;
  19011. /**
  19012. * Observable triggered when a button has been pressed
  19013. */
  19014. onButtonDownObservable: Observable<number>;
  19015. /**
  19016. * Observable triggered when a button has been released
  19017. */
  19018. onButtonUpObservable: Observable<number>;
  19019. /**
  19020. * Callback triggered when a button has been pressed
  19021. * @param callback Called when a button has been pressed
  19022. */
  19023. onbuttondown(callback: (buttonPressed: number) => void): void;
  19024. /**
  19025. * Callback triggered when a button has been released
  19026. * @param callback Called when a button has been released
  19027. */
  19028. onbuttonup(callback: (buttonReleased: number) => void): void;
  19029. /**
  19030. * Initializes the generic gamepad
  19031. * @param id The id of the generic gamepad
  19032. * @param index The index of the generic gamepad
  19033. * @param browserGamepad The browser gamepad
  19034. */
  19035. constructor(id: string, index: number, browserGamepad: any);
  19036. private _setButtonValue;
  19037. /**
  19038. * Updates the generic gamepad
  19039. */
  19040. update(): void;
  19041. /**
  19042. * Disposes the generic gamepad
  19043. */
  19044. dispose(): void;
  19045. }
  19046. }
  19047. declare module BABYLON {
  19048. /**
  19049. * Defines the types of pose enabled controllers that are supported
  19050. */
  19051. export enum PoseEnabledControllerType {
  19052. /**
  19053. * HTC Vive
  19054. */
  19055. VIVE = 0,
  19056. /**
  19057. * Oculus Rift
  19058. */
  19059. OCULUS = 1,
  19060. /**
  19061. * Windows mixed reality
  19062. */
  19063. WINDOWS = 2,
  19064. /**
  19065. * Samsung gear VR
  19066. */
  19067. GEAR_VR = 3,
  19068. /**
  19069. * Google Daydream
  19070. */
  19071. DAYDREAM = 4,
  19072. /**
  19073. * Generic
  19074. */
  19075. GENERIC = 5
  19076. }
  19077. /**
  19078. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19079. */
  19080. export interface MutableGamepadButton {
  19081. /**
  19082. * Value of the button/trigger
  19083. */
  19084. value: number;
  19085. /**
  19086. * If the button/trigger is currently touched
  19087. */
  19088. touched: boolean;
  19089. /**
  19090. * If the button/trigger is currently pressed
  19091. */
  19092. pressed: boolean;
  19093. }
  19094. /**
  19095. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19096. * @hidden
  19097. */
  19098. export interface ExtendedGamepadButton extends GamepadButton {
  19099. /**
  19100. * If the button/trigger is currently pressed
  19101. */
  19102. readonly pressed: boolean;
  19103. /**
  19104. * If the button/trigger is currently touched
  19105. */
  19106. readonly touched: boolean;
  19107. /**
  19108. * Value of the button/trigger
  19109. */
  19110. readonly value: number;
  19111. }
  19112. /** @hidden */
  19113. export interface _GamePadFactory {
  19114. /**
  19115. * Returns whether or not the current gamepad can be created for this type of controller.
  19116. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19117. * @returns true if it can be created, otherwise false
  19118. */
  19119. canCreate(gamepadInfo: any): boolean;
  19120. /**
  19121. * Creates a new instance of the Gamepad.
  19122. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19123. * @returns the new gamepad instance
  19124. */
  19125. create(gamepadInfo: any): Gamepad;
  19126. }
  19127. /**
  19128. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19129. */
  19130. export class PoseEnabledControllerHelper {
  19131. /** @hidden */
  19132. static _ControllerFactories: _GamePadFactory[];
  19133. /** @hidden */
  19134. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19135. /**
  19136. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19137. * @param vrGamepad the gamepad to initialized
  19138. * @returns a vr controller of the type the gamepad identified as
  19139. */
  19140. static InitiateController(vrGamepad: any): Gamepad;
  19141. }
  19142. /**
  19143. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19144. */
  19145. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19146. /**
  19147. * If the controller is used in a webXR session
  19148. */
  19149. isXR: boolean;
  19150. private _deviceRoomPosition;
  19151. private _deviceRoomRotationQuaternion;
  19152. /**
  19153. * The device position in babylon space
  19154. */
  19155. devicePosition: Vector3;
  19156. /**
  19157. * The device rotation in babylon space
  19158. */
  19159. deviceRotationQuaternion: Quaternion;
  19160. /**
  19161. * The scale factor of the device in babylon space
  19162. */
  19163. deviceScaleFactor: number;
  19164. /**
  19165. * (Likely devicePosition should be used instead) The device position in its room space
  19166. */
  19167. position: Vector3;
  19168. /**
  19169. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19170. */
  19171. rotationQuaternion: Quaternion;
  19172. /**
  19173. * The type of controller (Eg. Windows mixed reality)
  19174. */
  19175. controllerType: PoseEnabledControllerType;
  19176. protected _calculatedPosition: Vector3;
  19177. private _calculatedRotation;
  19178. /**
  19179. * The raw pose from the device
  19180. */
  19181. rawPose: DevicePose;
  19182. private _trackPosition;
  19183. private _maxRotationDistFromHeadset;
  19184. private _draggedRoomRotation;
  19185. /**
  19186. * @hidden
  19187. */
  19188. _disableTrackPosition(fixedPosition: Vector3): void;
  19189. /**
  19190. * Internal, the mesh attached to the controller
  19191. * @hidden
  19192. */
  19193. _mesh: Nullable<AbstractMesh>;
  19194. private _poseControlledCamera;
  19195. private _leftHandSystemQuaternion;
  19196. /**
  19197. * Internal, matrix used to convert room space to babylon space
  19198. * @hidden
  19199. */
  19200. _deviceToWorld: Matrix;
  19201. /**
  19202. * Node to be used when casting a ray from the controller
  19203. * @hidden
  19204. */
  19205. _pointingPoseNode: Nullable<TransformNode>;
  19206. /**
  19207. * Name of the child mesh that can be used to cast a ray from the controller
  19208. */
  19209. static readonly POINTING_POSE: string;
  19210. /**
  19211. * Creates a new PoseEnabledController from a gamepad
  19212. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19213. */
  19214. constructor(browserGamepad: any);
  19215. private _workingMatrix;
  19216. /**
  19217. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19218. */
  19219. update(): void;
  19220. /**
  19221. * Updates only the pose device and mesh without doing any button event checking
  19222. */
  19223. protected _updatePoseAndMesh(): void;
  19224. /**
  19225. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19226. * @param poseData raw pose fromthe device
  19227. */
  19228. updateFromDevice(poseData: DevicePose): void;
  19229. /**
  19230. * @hidden
  19231. */
  19232. _meshAttachedObservable: Observable<AbstractMesh>;
  19233. /**
  19234. * Attaches a mesh to the controller
  19235. * @param mesh the mesh to be attached
  19236. */
  19237. attachToMesh(mesh: AbstractMesh): void;
  19238. /**
  19239. * Attaches the controllers mesh to a camera
  19240. * @param camera the camera the mesh should be attached to
  19241. */
  19242. attachToPoseControlledCamera(camera: TargetCamera): void;
  19243. /**
  19244. * Disposes of the controller
  19245. */
  19246. dispose(): void;
  19247. /**
  19248. * The mesh that is attached to the controller
  19249. */
  19250. get mesh(): Nullable<AbstractMesh>;
  19251. /**
  19252. * Gets the ray of the controller in the direction the controller is pointing
  19253. * @param length the length the resulting ray should be
  19254. * @returns a ray in the direction the controller is pointing
  19255. */
  19256. getForwardRay(length?: number): Ray;
  19257. }
  19258. }
  19259. declare module BABYLON {
  19260. /**
  19261. * Defines the WebVRController object that represents controllers tracked in 3D space
  19262. */
  19263. export abstract class WebVRController extends PoseEnabledController {
  19264. /**
  19265. * Internal, the default controller model for the controller
  19266. */
  19267. protected _defaultModel: Nullable<AbstractMesh>;
  19268. /**
  19269. * Fired when the trigger state has changed
  19270. */
  19271. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19272. /**
  19273. * Fired when the main button state has changed
  19274. */
  19275. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19276. /**
  19277. * Fired when the secondary button state has changed
  19278. */
  19279. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19280. /**
  19281. * Fired when the pad state has changed
  19282. */
  19283. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19284. /**
  19285. * Fired when controllers stick values have changed
  19286. */
  19287. onPadValuesChangedObservable: Observable<StickValues>;
  19288. /**
  19289. * Array of button availible on the controller
  19290. */
  19291. protected _buttons: Array<MutableGamepadButton>;
  19292. private _onButtonStateChange;
  19293. /**
  19294. * Fired when a controller button's state has changed
  19295. * @param callback the callback containing the button that was modified
  19296. */
  19297. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19298. /**
  19299. * X and Y axis corresponding to the controllers joystick
  19300. */
  19301. pad: StickValues;
  19302. /**
  19303. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19304. */
  19305. hand: string;
  19306. /**
  19307. * The default controller model for the controller
  19308. */
  19309. get defaultModel(): Nullable<AbstractMesh>;
  19310. /**
  19311. * Creates a new WebVRController from a gamepad
  19312. * @param vrGamepad the gamepad that the WebVRController should be created from
  19313. */
  19314. constructor(vrGamepad: any);
  19315. /**
  19316. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19317. */
  19318. update(): void;
  19319. /**
  19320. * Function to be called when a button is modified
  19321. */
  19322. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19323. /**
  19324. * Loads a mesh and attaches it to the controller
  19325. * @param scene the scene the mesh should be added to
  19326. * @param meshLoaded callback for when the mesh has been loaded
  19327. */
  19328. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19329. private _setButtonValue;
  19330. private _changes;
  19331. private _checkChanges;
  19332. /**
  19333. * Disposes of th webVRCOntroller
  19334. */
  19335. dispose(): void;
  19336. }
  19337. }
  19338. declare module BABYLON {
  19339. /**
  19340. * The HemisphericLight simulates the ambient environment light,
  19341. * so the passed direction is the light reflection direction, not the incoming direction.
  19342. */
  19343. export class HemisphericLight extends Light {
  19344. /**
  19345. * The groundColor is the light in the opposite direction to the one specified during creation.
  19346. * 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.
  19347. */
  19348. groundColor: Color3;
  19349. /**
  19350. * The light reflection direction, not the incoming direction.
  19351. */
  19352. direction: Vector3;
  19353. /**
  19354. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19355. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19356. * The HemisphericLight can't cast shadows.
  19357. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19358. * @param name The friendly name of the light
  19359. * @param direction The direction of the light reflection
  19360. * @param scene The scene the light belongs to
  19361. */
  19362. constructor(name: string, direction: Vector3, scene: Scene);
  19363. protected _buildUniformLayout(): void;
  19364. /**
  19365. * Returns the string "HemisphericLight".
  19366. * @return The class name
  19367. */
  19368. getClassName(): string;
  19369. /**
  19370. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19371. * Returns the updated direction.
  19372. * @param target The target the direction should point to
  19373. * @return The computed direction
  19374. */
  19375. setDirectionToTarget(target: Vector3): Vector3;
  19376. /**
  19377. * Returns the shadow generator associated to the light.
  19378. * @returns Always null for hemispheric lights because it does not support shadows.
  19379. */
  19380. getShadowGenerator(): Nullable<IShadowGenerator>;
  19381. /**
  19382. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19383. * @param effect The effect to update
  19384. * @param lightIndex The index of the light in the effect to update
  19385. * @returns The hemispheric light
  19386. */
  19387. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19388. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19389. /**
  19390. * Computes the world matrix of the node
  19391. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19392. * @param useWasUpdatedFlag defines a reserved property
  19393. * @returns the world matrix
  19394. */
  19395. computeWorldMatrix(): Matrix;
  19396. /**
  19397. * Returns the integer 3.
  19398. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19399. */
  19400. getTypeID(): number;
  19401. /**
  19402. * Prepares the list of defines specific to the light type.
  19403. * @param defines the list of defines
  19404. * @param lightIndex defines the index of the light for the effect
  19405. */
  19406. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19407. }
  19408. }
  19409. declare module BABYLON {
  19410. /** @hidden */
  19411. export var vrMultiviewToSingleviewPixelShader: {
  19412. name: string;
  19413. shader: string;
  19414. };
  19415. }
  19416. declare module BABYLON {
  19417. /**
  19418. * Renders to multiple views with a single draw call
  19419. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19420. */
  19421. export class MultiviewRenderTarget extends RenderTargetTexture {
  19422. /**
  19423. * Creates a multiview render target
  19424. * @param scene scene used with the render target
  19425. * @param size the size of the render target (used for each view)
  19426. */
  19427. constructor(scene: Scene, size?: number | {
  19428. width: number;
  19429. height: number;
  19430. } | {
  19431. ratio: number;
  19432. });
  19433. /**
  19434. * @hidden
  19435. * @param faceIndex the face index, if its a cube texture
  19436. */
  19437. _bindFrameBuffer(faceIndex?: number): void;
  19438. /**
  19439. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19440. * @returns the view count
  19441. */
  19442. getViewCount(): number;
  19443. }
  19444. }
  19445. declare module BABYLON {
  19446. interface Engine {
  19447. /**
  19448. * Creates a new multiview render target
  19449. * @param width defines the width of the texture
  19450. * @param height defines the height of the texture
  19451. * @returns the created multiview texture
  19452. */
  19453. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19454. /**
  19455. * Binds a multiview framebuffer to be drawn to
  19456. * @param multiviewTexture texture to bind
  19457. */
  19458. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19459. }
  19460. interface Camera {
  19461. /**
  19462. * @hidden
  19463. * 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)
  19464. */
  19465. _useMultiviewToSingleView: boolean;
  19466. /**
  19467. * @hidden
  19468. * 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)
  19469. */
  19470. _multiviewTexture: Nullable<RenderTargetTexture>;
  19471. /**
  19472. * @hidden
  19473. * ensures the multiview texture of the camera exists and has the specified width/height
  19474. * @param width height to set on the multiview texture
  19475. * @param height width to set on the multiview texture
  19476. */
  19477. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19478. }
  19479. interface Scene {
  19480. /** @hidden */
  19481. _transformMatrixR: Matrix;
  19482. /** @hidden */
  19483. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19484. /** @hidden */
  19485. _createMultiviewUbo(): void;
  19486. /** @hidden */
  19487. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19488. /** @hidden */
  19489. _renderMultiviewToSingleView(camera: Camera): void;
  19490. }
  19491. }
  19492. declare module BABYLON {
  19493. /**
  19494. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19495. * This will not be used for webXR as it supports displaying texture arrays directly
  19496. */
  19497. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19498. /**
  19499. * Initializes a VRMultiviewToSingleview
  19500. * @param name name of the post process
  19501. * @param camera camera to be applied to
  19502. * @param scaleFactor scaling factor to the size of the output texture
  19503. */
  19504. constructor(name: string, camera: Camera, scaleFactor: number);
  19505. }
  19506. }
  19507. declare module BABYLON {
  19508. /**
  19509. * Interface used to define additional presentation attributes
  19510. */
  19511. export interface IVRPresentationAttributes {
  19512. /**
  19513. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19514. */
  19515. highRefreshRate: boolean;
  19516. /**
  19517. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19518. */
  19519. foveationLevel: number;
  19520. }
  19521. interface Engine {
  19522. /** @hidden */
  19523. _vrDisplay: any;
  19524. /** @hidden */
  19525. _vrSupported: boolean;
  19526. /** @hidden */
  19527. _oldSize: Size;
  19528. /** @hidden */
  19529. _oldHardwareScaleFactor: number;
  19530. /** @hidden */
  19531. _vrExclusivePointerMode: boolean;
  19532. /** @hidden */
  19533. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19534. /** @hidden */
  19535. _onVRDisplayPointerRestricted: () => void;
  19536. /** @hidden */
  19537. _onVRDisplayPointerUnrestricted: () => void;
  19538. /** @hidden */
  19539. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19540. /** @hidden */
  19541. _onVrDisplayDisconnect: Nullable<() => void>;
  19542. /** @hidden */
  19543. _onVrDisplayPresentChange: Nullable<() => void>;
  19544. /**
  19545. * Observable signaled when VR display mode changes
  19546. */
  19547. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19548. /**
  19549. * Observable signaled when VR request present is complete
  19550. */
  19551. onVRRequestPresentComplete: Observable<boolean>;
  19552. /**
  19553. * Observable signaled when VR request present starts
  19554. */
  19555. onVRRequestPresentStart: Observable<Engine>;
  19556. /**
  19557. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19558. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19559. */
  19560. isInVRExclusivePointerMode: boolean;
  19561. /**
  19562. * Gets a boolean indicating if a webVR device was detected
  19563. * @returns true if a webVR device was detected
  19564. */
  19565. isVRDevicePresent(): boolean;
  19566. /**
  19567. * Gets the current webVR device
  19568. * @returns the current webVR device (or null)
  19569. */
  19570. getVRDevice(): any;
  19571. /**
  19572. * Initializes a webVR display and starts listening to display change events
  19573. * The onVRDisplayChangedObservable will be notified upon these changes
  19574. * @returns A promise containing a VRDisplay and if vr is supported
  19575. */
  19576. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19577. /** @hidden */
  19578. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19579. /**
  19580. * Gets or sets the presentation attributes used to configure VR rendering
  19581. */
  19582. vrPresentationAttributes?: IVRPresentationAttributes;
  19583. /**
  19584. * Call this function to switch to webVR mode
  19585. * Will do nothing if webVR is not supported or if there is no webVR device
  19586. * @param options the webvr options provided to the camera. mainly used for multiview
  19587. * @see http://doc.babylonjs.com/how_to/webvr_camera
  19588. */
  19589. enableVR(options: WebVROptions): void;
  19590. /** @hidden */
  19591. _onVRFullScreenTriggered(): void;
  19592. }
  19593. }
  19594. declare module BABYLON {
  19595. /**
  19596. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19597. * IMPORTANT!! The data is right-hand data.
  19598. * @export
  19599. * @interface DevicePose
  19600. */
  19601. export interface DevicePose {
  19602. /**
  19603. * The position of the device, values in array are [x,y,z].
  19604. */
  19605. readonly position: Nullable<Float32Array>;
  19606. /**
  19607. * The linearVelocity of the device, values in array are [x,y,z].
  19608. */
  19609. readonly linearVelocity: Nullable<Float32Array>;
  19610. /**
  19611. * The linearAcceleration of the device, values in array are [x,y,z].
  19612. */
  19613. readonly linearAcceleration: Nullable<Float32Array>;
  19614. /**
  19615. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19616. */
  19617. readonly orientation: Nullable<Float32Array>;
  19618. /**
  19619. * The angularVelocity of the device, values in array are [x,y,z].
  19620. */
  19621. readonly angularVelocity: Nullable<Float32Array>;
  19622. /**
  19623. * The angularAcceleration of the device, values in array are [x,y,z].
  19624. */
  19625. readonly angularAcceleration: Nullable<Float32Array>;
  19626. }
  19627. /**
  19628. * Interface representing a pose controlled object in Babylon.
  19629. * A pose controlled object has both regular pose values as well as pose values
  19630. * from an external device such as a VR head mounted display
  19631. */
  19632. export interface PoseControlled {
  19633. /**
  19634. * The position of the object in babylon space.
  19635. */
  19636. position: Vector3;
  19637. /**
  19638. * The rotation quaternion of the object in babylon space.
  19639. */
  19640. rotationQuaternion: Quaternion;
  19641. /**
  19642. * The position of the device in babylon space.
  19643. */
  19644. devicePosition?: Vector3;
  19645. /**
  19646. * The rotation quaternion of the device in babylon space.
  19647. */
  19648. deviceRotationQuaternion: Quaternion;
  19649. /**
  19650. * The raw pose coming from the device.
  19651. */
  19652. rawPose: Nullable<DevicePose>;
  19653. /**
  19654. * The scale of the device to be used when translating from device space to babylon space.
  19655. */
  19656. deviceScaleFactor: number;
  19657. /**
  19658. * Updates the poseControlled values based on the input device pose.
  19659. * @param poseData the pose data to update the object with
  19660. */
  19661. updateFromDevice(poseData: DevicePose): void;
  19662. }
  19663. /**
  19664. * Set of options to customize the webVRCamera
  19665. */
  19666. export interface WebVROptions {
  19667. /**
  19668. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19669. */
  19670. trackPosition?: boolean;
  19671. /**
  19672. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19673. */
  19674. positionScale?: number;
  19675. /**
  19676. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19677. */
  19678. displayName?: string;
  19679. /**
  19680. * Should the native controller meshes be initialized. (default: true)
  19681. */
  19682. controllerMeshes?: boolean;
  19683. /**
  19684. * Creating a default HemiLight only on controllers. (default: true)
  19685. */
  19686. defaultLightingOnControllers?: boolean;
  19687. /**
  19688. * If you don't want to use the default VR button of the helper. (default: false)
  19689. */
  19690. useCustomVRButton?: boolean;
  19691. /**
  19692. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19693. */
  19694. customVRButton?: HTMLButtonElement;
  19695. /**
  19696. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19697. */
  19698. rayLength?: number;
  19699. /**
  19700. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19701. */
  19702. defaultHeight?: number;
  19703. /**
  19704. * If multiview should be used if availible (default: false)
  19705. */
  19706. useMultiview?: boolean;
  19707. }
  19708. /**
  19709. * This represents a WebVR camera.
  19710. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  19711. * @example http://doc.babylonjs.com/how_to/webvr_camera
  19712. */
  19713. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  19714. private webVROptions;
  19715. /**
  19716. * @hidden
  19717. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  19718. */
  19719. _vrDevice: any;
  19720. /**
  19721. * The rawPose of the vrDevice.
  19722. */
  19723. rawPose: Nullable<DevicePose>;
  19724. private _onVREnabled;
  19725. private _specsVersion;
  19726. private _attached;
  19727. private _frameData;
  19728. protected _descendants: Array<Node>;
  19729. private _deviceRoomPosition;
  19730. /** @hidden */
  19731. _deviceRoomRotationQuaternion: Quaternion;
  19732. private _standingMatrix;
  19733. /**
  19734. * Represents device position in babylon space.
  19735. */
  19736. devicePosition: Vector3;
  19737. /**
  19738. * Represents device rotation in babylon space.
  19739. */
  19740. deviceRotationQuaternion: Quaternion;
  19741. /**
  19742. * The scale of the device to be used when translating from device space to babylon space.
  19743. */
  19744. deviceScaleFactor: number;
  19745. private _deviceToWorld;
  19746. private _worldToDevice;
  19747. /**
  19748. * References to the webVR controllers for the vrDevice.
  19749. */
  19750. controllers: Array<WebVRController>;
  19751. /**
  19752. * Emits an event when a controller is attached.
  19753. */
  19754. onControllersAttachedObservable: Observable<WebVRController[]>;
  19755. /**
  19756. * Emits an event when a controller's mesh has been loaded;
  19757. */
  19758. onControllerMeshLoadedObservable: Observable<WebVRController>;
  19759. /**
  19760. * Emits an event when the HMD's pose has been updated.
  19761. */
  19762. onPoseUpdatedFromDeviceObservable: Observable<any>;
  19763. private _poseSet;
  19764. /**
  19765. * If the rig cameras be used as parent instead of this camera.
  19766. */
  19767. rigParenting: boolean;
  19768. private _lightOnControllers;
  19769. private _defaultHeight?;
  19770. /**
  19771. * Instantiates a WebVRFreeCamera.
  19772. * @param name The name of the WebVRFreeCamera
  19773. * @param position The starting anchor position for the camera
  19774. * @param scene The scene the camera belongs to
  19775. * @param webVROptions a set of customizable options for the webVRCamera
  19776. */
  19777. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  19778. /**
  19779. * Gets the device distance from the ground in meters.
  19780. * @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.
  19781. */
  19782. deviceDistanceToRoomGround(): number;
  19783. /**
  19784. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19785. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  19786. */
  19787. useStandingMatrix(callback?: (bool: boolean) => void): void;
  19788. /**
  19789. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19790. * @returns A promise with a boolean set to if the standing matrix is supported.
  19791. */
  19792. useStandingMatrixAsync(): Promise<boolean>;
  19793. /**
  19794. * Disposes the camera
  19795. */
  19796. dispose(): void;
  19797. /**
  19798. * Gets a vrController by name.
  19799. * @param name The name of the controller to retreive
  19800. * @returns the controller matching the name specified or null if not found
  19801. */
  19802. getControllerByName(name: string): Nullable<WebVRController>;
  19803. private _leftController;
  19804. /**
  19805. * The controller corresponding to the users left hand.
  19806. */
  19807. get leftController(): Nullable<WebVRController>;
  19808. private _rightController;
  19809. /**
  19810. * The controller corresponding to the users right hand.
  19811. */
  19812. get rightController(): Nullable<WebVRController>;
  19813. /**
  19814. * Casts a ray forward from the vrCamera's gaze.
  19815. * @param length Length of the ray (default: 100)
  19816. * @returns the ray corresponding to the gaze
  19817. */
  19818. getForwardRay(length?: number): Ray;
  19819. /**
  19820. * @hidden
  19821. * Updates the camera based on device's frame data
  19822. */
  19823. _checkInputs(): void;
  19824. /**
  19825. * Updates the poseControlled values based on the input device pose.
  19826. * @param poseData Pose coming from the device
  19827. */
  19828. updateFromDevice(poseData: DevicePose): void;
  19829. private _htmlElementAttached;
  19830. private _detachIfAttached;
  19831. /**
  19832. * WebVR's attach control will start broadcasting frames to the device.
  19833. * Note that in certain browsers (chrome for example) this function must be called
  19834. * within a user-interaction callback. Example:
  19835. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  19836. *
  19837. * @param element html element to attach the vrDevice to
  19838. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  19839. */
  19840. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19841. /**
  19842. * Detaches the camera from the html element and disables VR
  19843. *
  19844. * @param element html element to detach from
  19845. */
  19846. detachControl(element: HTMLElement): void;
  19847. /**
  19848. * @returns the name of this class
  19849. */
  19850. getClassName(): string;
  19851. /**
  19852. * Calls resetPose on the vrDisplay
  19853. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  19854. */
  19855. resetToCurrentRotation(): void;
  19856. /**
  19857. * @hidden
  19858. * Updates the rig cameras (left and right eye)
  19859. */
  19860. _updateRigCameras(): void;
  19861. private _workingVector;
  19862. private _oneVector;
  19863. private _workingMatrix;
  19864. private updateCacheCalled;
  19865. private _correctPositionIfNotTrackPosition;
  19866. /**
  19867. * @hidden
  19868. * Updates the cached values of the camera
  19869. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  19870. */
  19871. _updateCache(ignoreParentClass?: boolean): void;
  19872. /**
  19873. * @hidden
  19874. * Get current device position in babylon world
  19875. */
  19876. _computeDevicePosition(): void;
  19877. /**
  19878. * Updates the current device position and rotation in the babylon world
  19879. */
  19880. update(): void;
  19881. /**
  19882. * @hidden
  19883. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  19884. * @returns an identity matrix
  19885. */
  19886. _getViewMatrix(): Matrix;
  19887. private _tmpMatrix;
  19888. /**
  19889. * This function is called by the two RIG cameras.
  19890. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  19891. * @hidden
  19892. */
  19893. _getWebVRViewMatrix(): Matrix;
  19894. /** @hidden */
  19895. _getWebVRProjectionMatrix(): Matrix;
  19896. private _onGamepadConnectedObserver;
  19897. private _onGamepadDisconnectedObserver;
  19898. private _updateCacheWhenTrackingDisabledObserver;
  19899. /**
  19900. * Initializes the controllers and their meshes
  19901. */
  19902. initControllers(): void;
  19903. }
  19904. }
  19905. declare module BABYLON {
  19906. /**
  19907. * "Static Class" containing the most commonly used helper while dealing with material for
  19908. * rendering purpose.
  19909. *
  19910. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  19911. *
  19912. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  19913. */
  19914. export class MaterialHelper {
  19915. /**
  19916. * Bind the current view position to an effect.
  19917. * @param effect The effect to be bound
  19918. * @param scene The scene the eyes position is used from
  19919. * @param variableName name of the shader variable that will hold the eye position
  19920. */
  19921. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  19922. /**
  19923. * Helps preparing the defines values about the UVs in used in the effect.
  19924. * UVs are shared as much as we can accross channels in the shaders.
  19925. * @param texture The texture we are preparing the UVs for
  19926. * @param defines The defines to update
  19927. * @param key The channel key "diffuse", "specular"... used in the shader
  19928. */
  19929. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  19930. /**
  19931. * Binds a texture matrix value to its corrsponding uniform
  19932. * @param texture The texture to bind the matrix for
  19933. * @param uniformBuffer The uniform buffer receivin the data
  19934. * @param key The channel key "diffuse", "specular"... used in the shader
  19935. */
  19936. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  19937. /**
  19938. * Gets the current status of the fog (should it be enabled?)
  19939. * @param mesh defines the mesh to evaluate for fog support
  19940. * @param scene defines the hosting scene
  19941. * @returns true if fog must be enabled
  19942. */
  19943. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  19944. /**
  19945. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  19946. * @param mesh defines the current mesh
  19947. * @param scene defines the current scene
  19948. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  19949. * @param pointsCloud defines if point cloud rendering has to be turned on
  19950. * @param fogEnabled defines if fog has to be turned on
  19951. * @param alphaTest defines if alpha testing has to be turned on
  19952. * @param defines defines the current list of defines
  19953. */
  19954. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  19955. /**
  19956. * Helper used to prepare the list of defines associated with frame values for shader compilation
  19957. * @param scene defines the current scene
  19958. * @param engine defines the current engine
  19959. * @param defines specifies the list of active defines
  19960. * @param useInstances defines if instances have to be turned on
  19961. * @param useClipPlane defines if clip plane have to be turned on
  19962. */
  19963. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  19964. /**
  19965. * Prepares the defines for bones
  19966. * @param mesh The mesh containing the geometry data we will draw
  19967. * @param defines The defines to update
  19968. */
  19969. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  19970. /**
  19971. * Prepares the defines for morph targets
  19972. * @param mesh The mesh containing the geometry data we will draw
  19973. * @param defines The defines to update
  19974. */
  19975. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  19976. /**
  19977. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  19978. * @param mesh The mesh containing the geometry data we will draw
  19979. * @param defines The defines to update
  19980. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  19981. * @param useBones Precise whether bones should be used or not (override mesh info)
  19982. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  19983. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  19984. * @returns false if defines are considered not dirty and have not been checked
  19985. */
  19986. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  19987. /**
  19988. * Prepares the defines related to multiview
  19989. * @param scene The scene we are intending to draw
  19990. * @param defines The defines to update
  19991. */
  19992. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  19993. /**
  19994. * Prepares the defines related to the light information passed in parameter
  19995. * @param scene The scene we are intending to draw
  19996. * @param mesh The mesh the effect is compiling for
  19997. * @param light The light the effect is compiling for
  19998. * @param lightIndex The index of the light
  19999. * @param defines The defines to update
  20000. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20001. * @param state Defines the current state regarding what is needed (normals, etc...)
  20002. */
  20003. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20004. needNormals: boolean;
  20005. needRebuild: boolean;
  20006. shadowEnabled: boolean;
  20007. specularEnabled: boolean;
  20008. lightmapMode: boolean;
  20009. }): void;
  20010. /**
  20011. * Prepares the defines related to the light information passed in parameter
  20012. * @param scene The scene we are intending to draw
  20013. * @param mesh The mesh the effect is compiling for
  20014. * @param defines The defines to update
  20015. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20016. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  20017. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  20018. * @returns true if normals will be required for the rest of the effect
  20019. */
  20020. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  20021. /**
  20022. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20023. * @param lightIndex defines the light index
  20024. * @param uniformsList The uniform list
  20025. * @param samplersList The sampler list
  20026. * @param projectedLightTexture defines if projected texture must be used
  20027. * @param uniformBuffersList defines an optional list of uniform buffers
  20028. */
  20029. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20030. /**
  20031. * Prepares the uniforms and samplers list to be used in the effect
  20032. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20033. * @param samplersList The sampler list
  20034. * @param defines The defines helping in the list generation
  20035. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20036. */
  20037. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20038. /**
  20039. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20040. * @param defines The defines to update while falling back
  20041. * @param fallbacks The authorized effect fallbacks
  20042. * @param maxSimultaneousLights The maximum number of lights allowed
  20043. * @param rank the current rank of the Effect
  20044. * @returns The newly affected rank
  20045. */
  20046. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  20047. private static _TmpMorphInfluencers;
  20048. /**
  20049. * Prepares the list of attributes required for morph targets according to the effect defines.
  20050. * @param attribs The current list of supported attribs
  20051. * @param mesh The mesh to prepare the morph targets attributes for
  20052. * @param influencers The number of influencers
  20053. */
  20054. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  20055. /**
  20056. * Prepares the list of attributes required for morph targets according to the effect defines.
  20057. * @param attribs The current list of supported attribs
  20058. * @param mesh The mesh to prepare the morph targets attributes for
  20059. * @param defines The current Defines of the effect
  20060. */
  20061. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  20062. /**
  20063. * Prepares the list of attributes required for bones according to the effect defines.
  20064. * @param attribs The current list of supported attribs
  20065. * @param mesh The mesh to prepare the bones attributes for
  20066. * @param defines The current Defines of the effect
  20067. * @param fallbacks The current efffect fallback strategy
  20068. */
  20069. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  20070. /**
  20071. * Check and prepare the list of attributes required for instances according to the effect defines.
  20072. * @param attribs The current list of supported attribs
  20073. * @param defines The current MaterialDefines of the effect
  20074. */
  20075. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  20076. /**
  20077. * Add the list of attributes required for instances to the attribs array.
  20078. * @param attribs The current list of supported attribs
  20079. */
  20080. static PushAttributesForInstances(attribs: string[]): void;
  20081. /**
  20082. * Binds the light information to the effect.
  20083. * @param light The light containing the generator
  20084. * @param effect The effect we are binding the data to
  20085. * @param lightIndex The light index in the effect used to render
  20086. */
  20087. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  20088. /**
  20089. * Binds the lights information from the scene to the effect for the given mesh.
  20090. * @param light Light to bind
  20091. * @param lightIndex Light index
  20092. * @param scene The scene where the light belongs to
  20093. * @param effect The effect we are binding the data to
  20094. * @param useSpecular Defines if specular is supported
  20095. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20096. */
  20097. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  20098. /**
  20099. * Binds the lights information from the scene to the effect for the given mesh.
  20100. * @param scene The scene the lights belongs to
  20101. * @param mesh The mesh we are binding the information to render
  20102. * @param effect The effect we are binding the data to
  20103. * @param defines The generated defines for the effect
  20104. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  20105. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20106. */
  20107. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  20108. private static _tempFogColor;
  20109. /**
  20110. * Binds the fog information from the scene to the effect for the given mesh.
  20111. * @param scene The scene the lights belongs to
  20112. * @param mesh The mesh we are binding the information to render
  20113. * @param effect The effect we are binding the data to
  20114. * @param linearSpace Defines if the fog effect is applied in linear space
  20115. */
  20116. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  20117. /**
  20118. * Binds the bones information from the mesh to the effect.
  20119. * @param mesh The mesh we are binding the information to render
  20120. * @param effect The effect we are binding the data to
  20121. */
  20122. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  20123. /**
  20124. * Binds the morph targets information from the mesh to the effect.
  20125. * @param abstractMesh The mesh we are binding the information to render
  20126. * @param effect The effect we are binding the data to
  20127. */
  20128. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  20129. /**
  20130. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  20131. * @param defines The generated defines used in the effect
  20132. * @param effect The effect we are binding the data to
  20133. * @param scene The scene we are willing to render with logarithmic scale for
  20134. */
  20135. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  20136. /**
  20137. * Binds the clip plane information from the scene to the effect.
  20138. * @param scene The scene the clip plane information are extracted from
  20139. * @param effect The effect we are binding the data to
  20140. */
  20141. static BindClipPlane(effect: Effect, scene: Scene): void;
  20142. }
  20143. }
  20144. declare module BABYLON {
  20145. /**
  20146. * Block used to expose an input value
  20147. */
  20148. export class InputBlock extends NodeMaterialBlock {
  20149. private _mode;
  20150. private _associatedVariableName;
  20151. private _storedValue;
  20152. private _valueCallback;
  20153. private _type;
  20154. private _animationType;
  20155. /** Gets or set a value used to limit the range of float values */
  20156. min: number;
  20157. /** Gets or set a value used to limit the range of float values */
  20158. max: number;
  20159. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  20160. isBoolean: boolean;
  20161. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  20162. matrixMode: number;
  20163. /** @hidden */
  20164. _systemValue: Nullable<NodeMaterialSystemValues>;
  20165. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  20166. visibleInInspector: boolean;
  20167. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  20168. isConstant: boolean;
  20169. /** Gets or sets the group to use to display this block in the Inspector */
  20170. groupInInspector: string;
  20171. /** Gets an observable raised when the value is changed */
  20172. onValueChangedObservable: Observable<InputBlock>;
  20173. /**
  20174. * Gets or sets the connection point type (default is float)
  20175. */
  20176. get type(): NodeMaterialBlockConnectionPointTypes;
  20177. /**
  20178. * Creates a new InputBlock
  20179. * @param name defines the block name
  20180. * @param target defines the target of that block (Vertex by default)
  20181. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  20182. */
  20183. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  20184. /**
  20185. * Gets the output component
  20186. */
  20187. get output(): NodeMaterialConnectionPoint;
  20188. /**
  20189. * Set the source of this connection point to a vertex attribute
  20190. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  20191. * @returns the current connection point
  20192. */
  20193. setAsAttribute(attributeName?: string): InputBlock;
  20194. /**
  20195. * Set the source of this connection point to a system value
  20196. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  20197. * @returns the current connection point
  20198. */
  20199. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  20200. /**
  20201. * Gets or sets the value of that point.
  20202. * Please note that this value will be ignored if valueCallback is defined
  20203. */
  20204. get value(): any;
  20205. set value(value: any);
  20206. /**
  20207. * Gets or sets a callback used to get the value of that point.
  20208. * Please note that setting this value will force the connection point to ignore the value property
  20209. */
  20210. get valueCallback(): () => any;
  20211. set valueCallback(value: () => any);
  20212. /**
  20213. * Gets or sets the associated variable name in the shader
  20214. */
  20215. get associatedVariableName(): string;
  20216. set associatedVariableName(value: string);
  20217. /** Gets or sets the type of animation applied to the input */
  20218. get animationType(): AnimatedInputBlockTypes;
  20219. set animationType(value: AnimatedInputBlockTypes);
  20220. /**
  20221. * Gets a boolean indicating that this connection point not defined yet
  20222. */
  20223. get isUndefined(): boolean;
  20224. /**
  20225. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  20226. * In this case the connection point name must be the name of the uniform to use.
  20227. * Can only be set on inputs
  20228. */
  20229. get isUniform(): boolean;
  20230. set isUniform(value: boolean);
  20231. /**
  20232. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  20233. * In this case the connection point name must be the name of the attribute to use
  20234. * Can only be set on inputs
  20235. */
  20236. get isAttribute(): boolean;
  20237. set isAttribute(value: boolean);
  20238. /**
  20239. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  20240. * Can only be set on exit points
  20241. */
  20242. get isVarying(): boolean;
  20243. set isVarying(value: boolean);
  20244. /**
  20245. * Gets a boolean indicating that the current connection point is a system value
  20246. */
  20247. get isSystemValue(): boolean;
  20248. /**
  20249. * Gets or sets the current well known value or null if not defined as a system value
  20250. */
  20251. get systemValue(): Nullable<NodeMaterialSystemValues>;
  20252. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  20253. /**
  20254. * Gets the current class name
  20255. * @returns the class name
  20256. */
  20257. getClassName(): string;
  20258. /**
  20259. * Animate the input if animationType !== None
  20260. * @param scene defines the rendering scene
  20261. */
  20262. animate(scene: Scene): void;
  20263. private _emitDefine;
  20264. initialize(state: NodeMaterialBuildState): void;
  20265. /**
  20266. * Set the input block to its default value (based on its type)
  20267. */
  20268. setDefaultValue(): void;
  20269. private _emitConstant;
  20270. /** @hidden */
  20271. get _noContextSwitch(): boolean;
  20272. private _emit;
  20273. /** @hidden */
  20274. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  20275. /** @hidden */
  20276. _transmit(effect: Effect, scene: Scene): void;
  20277. protected _buildBlock(state: NodeMaterialBuildState): void;
  20278. protected _dumpPropertiesCode(): string;
  20279. dispose(): void;
  20280. serialize(): any;
  20281. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20282. }
  20283. }
  20284. declare module BABYLON {
  20285. /**
  20286. * Enum used to define the compatibility state between two connection points
  20287. */
  20288. export enum NodeMaterialConnectionPointCompatibilityStates {
  20289. /** Points are compatibles */
  20290. Compatible = 0,
  20291. /** Points are incompatible because of their types */
  20292. TypeIncompatible = 1,
  20293. /** Points are incompatible because of their targets (vertex vs fragment) */
  20294. TargetIncompatible = 2
  20295. }
  20296. /**
  20297. * Defines the direction of a connection point
  20298. */
  20299. export enum NodeMaterialConnectionPointDirection {
  20300. /** Input */
  20301. Input = 0,
  20302. /** Output */
  20303. Output = 1
  20304. }
  20305. /**
  20306. * Defines a connection point for a block
  20307. */
  20308. export class NodeMaterialConnectionPoint {
  20309. /** @hidden */
  20310. _ownerBlock: NodeMaterialBlock;
  20311. /** @hidden */
  20312. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  20313. private _endpoints;
  20314. private _associatedVariableName;
  20315. private _direction;
  20316. /** @hidden */
  20317. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20318. /** @hidden */
  20319. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20320. private _type;
  20321. /** @hidden */
  20322. _enforceAssociatedVariableName: boolean;
  20323. /** Gets the direction of the point */
  20324. get direction(): NodeMaterialConnectionPointDirection;
  20325. /** Indicates that this connection point needs dual validation before being connected to another point */
  20326. needDualDirectionValidation: boolean;
  20327. /**
  20328. * Gets or sets the additional types supported by this connection point
  20329. */
  20330. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20331. /**
  20332. * Gets or sets the additional types excluded by this connection point
  20333. */
  20334. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20335. /**
  20336. * Observable triggered when this point is connected
  20337. */
  20338. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  20339. /**
  20340. * Gets or sets the associated variable name in the shader
  20341. */
  20342. get associatedVariableName(): string;
  20343. set associatedVariableName(value: string);
  20344. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  20345. get innerType(): NodeMaterialBlockConnectionPointTypes;
  20346. /**
  20347. * Gets or sets the connection point type (default is float)
  20348. */
  20349. get type(): NodeMaterialBlockConnectionPointTypes;
  20350. set type(value: NodeMaterialBlockConnectionPointTypes);
  20351. /**
  20352. * Gets or sets the connection point name
  20353. */
  20354. name: string;
  20355. /**
  20356. * Gets or sets the connection point name
  20357. */
  20358. displayName: string;
  20359. /**
  20360. * Gets or sets a boolean indicating that this connection point can be omitted
  20361. */
  20362. isOptional: boolean;
  20363. /**
  20364. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  20365. */
  20366. define: string;
  20367. /** @hidden */
  20368. _prioritizeVertex: boolean;
  20369. private _target;
  20370. /** Gets or sets the target of that connection point */
  20371. get target(): NodeMaterialBlockTargets;
  20372. set target(value: NodeMaterialBlockTargets);
  20373. /**
  20374. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  20375. */
  20376. get isConnected(): boolean;
  20377. /**
  20378. * Gets a boolean indicating that the current point is connected to an input block
  20379. */
  20380. get isConnectedToInputBlock(): boolean;
  20381. /**
  20382. * Gets a the connected input block (if any)
  20383. */
  20384. get connectInputBlock(): Nullable<InputBlock>;
  20385. /** Get the other side of the connection (if any) */
  20386. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  20387. /** Get the block that owns this connection point */
  20388. get ownerBlock(): NodeMaterialBlock;
  20389. /** Get the block connected on the other side of this connection (if any) */
  20390. get sourceBlock(): Nullable<NodeMaterialBlock>;
  20391. /** Get the block connected on the endpoints of this connection (if any) */
  20392. get connectedBlocks(): Array<NodeMaterialBlock>;
  20393. /** Gets the list of connected endpoints */
  20394. get endpoints(): NodeMaterialConnectionPoint[];
  20395. /** Gets a boolean indicating if that output point is connected to at least one input */
  20396. get hasEndpoints(): boolean;
  20397. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  20398. get isConnectedInVertexShader(): boolean;
  20399. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  20400. get isConnectedInFragmentShader(): boolean;
  20401. /**
  20402. * Creates a block suitable to be used as an input for this input point.
  20403. * If null is returned, a block based on the point type will be created.
  20404. * @returns The returned string parameter is the name of the output point of NodeMaterialBlock (first parameter of the returned array) that can be connected to the input
  20405. */
  20406. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  20407. /**
  20408. * Creates a new connection point
  20409. * @param name defines the connection point name
  20410. * @param ownerBlock defines the block hosting this connection point
  20411. * @param direction defines the direction of the connection point
  20412. */
  20413. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  20414. /**
  20415. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  20416. * @returns the class name
  20417. */
  20418. getClassName(): string;
  20419. /**
  20420. * Gets a boolean indicating if the current point can be connected to another point
  20421. * @param connectionPoint defines the other connection point
  20422. * @returns a boolean
  20423. */
  20424. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  20425. /**
  20426. * Gets a number indicating if the current point can be connected to another point
  20427. * @param connectionPoint defines the other connection point
  20428. * @returns a number defining the compatibility state
  20429. */
  20430. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20431. /**
  20432. * Connect this point to another connection point
  20433. * @param connectionPoint defines the other connection point
  20434. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  20435. * @returns the current connection point
  20436. */
  20437. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  20438. /**
  20439. * Disconnect this point from one of his endpoint
  20440. * @param endpoint defines the other connection point
  20441. * @returns the current connection point
  20442. */
  20443. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  20444. /**
  20445. * Serializes this point in a JSON representation
  20446. * @param isInput defines if the connection point is an input (default is true)
  20447. * @returns the serialized point object
  20448. */
  20449. serialize(isInput?: boolean): any;
  20450. /**
  20451. * Release resources
  20452. */
  20453. dispose(): void;
  20454. }
  20455. }
  20456. declare module BABYLON {
  20457. /**
  20458. * Enum used to define the material modes
  20459. */
  20460. export enum NodeMaterialModes {
  20461. /** Regular material */
  20462. Material = 0,
  20463. /** For post process */
  20464. PostProcess = 1,
  20465. /** For particle system */
  20466. Particle = 2
  20467. }
  20468. }
  20469. declare module BABYLON {
  20470. /**
  20471. * Block used to read a texture from a sampler
  20472. */
  20473. export class TextureBlock extends NodeMaterialBlock {
  20474. private _defineName;
  20475. private _linearDefineName;
  20476. private _gammaDefineName;
  20477. private _tempTextureRead;
  20478. private _samplerName;
  20479. private _transformedUVName;
  20480. private _textureTransformName;
  20481. private _textureInfoName;
  20482. private _mainUVName;
  20483. private _mainUVDefineName;
  20484. private _fragmentOnly;
  20485. /**
  20486. * Gets or sets the texture associated with the node
  20487. */
  20488. texture: Nullable<Texture>;
  20489. /**
  20490. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20491. */
  20492. convertToGammaSpace: boolean;
  20493. /**
  20494. * Gets or sets a boolean indicating if content needs to be converted to linear space
  20495. */
  20496. convertToLinearSpace: boolean;
  20497. /**
  20498. * Create a new TextureBlock
  20499. * @param name defines the block name
  20500. */
  20501. constructor(name: string, fragmentOnly?: boolean);
  20502. /**
  20503. * Gets the current class name
  20504. * @returns the class name
  20505. */
  20506. getClassName(): string;
  20507. /**
  20508. * Gets the uv input component
  20509. */
  20510. get uv(): NodeMaterialConnectionPoint;
  20511. /**
  20512. * Gets the rgba output component
  20513. */
  20514. get rgba(): NodeMaterialConnectionPoint;
  20515. /**
  20516. * Gets the rgb output component
  20517. */
  20518. get rgb(): NodeMaterialConnectionPoint;
  20519. /**
  20520. * Gets the r output component
  20521. */
  20522. get r(): NodeMaterialConnectionPoint;
  20523. /**
  20524. * Gets the g output component
  20525. */
  20526. get g(): NodeMaterialConnectionPoint;
  20527. /**
  20528. * Gets the b output component
  20529. */
  20530. get b(): NodeMaterialConnectionPoint;
  20531. /**
  20532. * Gets the a output component
  20533. */
  20534. get a(): NodeMaterialConnectionPoint;
  20535. get target(): NodeMaterialBlockTargets;
  20536. autoConfigure(material: NodeMaterial): void;
  20537. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  20538. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20539. isReady(): boolean;
  20540. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20541. private get _isMixed();
  20542. private _injectVertexCode;
  20543. private _writeTextureRead;
  20544. private _writeOutput;
  20545. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  20546. protected _dumpPropertiesCode(): string;
  20547. serialize(): any;
  20548. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20549. }
  20550. }
  20551. declare module BABYLON {
  20552. /** @hidden */
  20553. export var reflectionFunction: {
  20554. name: string;
  20555. shader: string;
  20556. };
  20557. }
  20558. declare module BABYLON {
  20559. /**
  20560. * Base block used to read a reflection texture from a sampler
  20561. */
  20562. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  20563. /** @hidden */
  20564. _define3DName: string;
  20565. /** @hidden */
  20566. _defineCubicName: string;
  20567. /** @hidden */
  20568. _defineExplicitName: string;
  20569. /** @hidden */
  20570. _defineProjectionName: string;
  20571. /** @hidden */
  20572. _defineLocalCubicName: string;
  20573. /** @hidden */
  20574. _defineSphericalName: string;
  20575. /** @hidden */
  20576. _definePlanarName: string;
  20577. /** @hidden */
  20578. _defineEquirectangularName: string;
  20579. /** @hidden */
  20580. _defineMirroredEquirectangularFixedName: string;
  20581. /** @hidden */
  20582. _defineEquirectangularFixedName: string;
  20583. /** @hidden */
  20584. _defineSkyboxName: string;
  20585. /** @hidden */
  20586. _defineOppositeZ: string;
  20587. /** @hidden */
  20588. _cubeSamplerName: string;
  20589. /** @hidden */
  20590. _2DSamplerName: string;
  20591. protected _positionUVWName: string;
  20592. protected _directionWName: string;
  20593. protected _reflectionVectorName: string;
  20594. /** @hidden */
  20595. _reflectionCoordsName: string;
  20596. /** @hidden */
  20597. _reflectionMatrixName: string;
  20598. protected _reflectionColorName: string;
  20599. /**
  20600. * Gets or sets the texture associated with the node
  20601. */
  20602. texture: Nullable<BaseTexture>;
  20603. /**
  20604. * Create a new ReflectionTextureBaseBlock
  20605. * @param name defines the block name
  20606. */
  20607. constructor(name: string);
  20608. /**
  20609. * Gets the current class name
  20610. * @returns the class name
  20611. */
  20612. getClassName(): string;
  20613. /**
  20614. * Gets the world position input component
  20615. */
  20616. abstract get position(): NodeMaterialConnectionPoint;
  20617. /**
  20618. * Gets the world position input component
  20619. */
  20620. abstract get worldPosition(): NodeMaterialConnectionPoint;
  20621. /**
  20622. * Gets the world normal input component
  20623. */
  20624. abstract get worldNormal(): NodeMaterialConnectionPoint;
  20625. /**
  20626. * Gets the world input component
  20627. */
  20628. abstract get world(): NodeMaterialConnectionPoint;
  20629. /**
  20630. * Gets the camera (or eye) position component
  20631. */
  20632. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  20633. /**
  20634. * Gets the view input component
  20635. */
  20636. abstract get view(): NodeMaterialConnectionPoint;
  20637. protected _getTexture(): Nullable<BaseTexture>;
  20638. autoConfigure(material: NodeMaterial): void;
  20639. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20640. isReady(): boolean;
  20641. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20642. /**
  20643. * Gets the code to inject in the vertex shader
  20644. * @param state current state of the node material building
  20645. * @returns the shader code
  20646. */
  20647. handleVertexSide(state: NodeMaterialBuildState): string;
  20648. /**
  20649. * Handles the inits for the fragment code path
  20650. * @param state node material build state
  20651. */
  20652. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  20653. /**
  20654. * Generates the reflection coords code for the fragment code path
  20655. * @param worldNormalVarName name of the world normal variable
  20656. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  20657. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  20658. * @returns the shader code
  20659. */
  20660. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  20661. /**
  20662. * Generates the reflection color code for the fragment code path
  20663. * @param lodVarName name of the lod variable
  20664. * @param swizzleLookupTexture swizzle to use for the final color variable
  20665. * @returns the shader code
  20666. */
  20667. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  20668. /**
  20669. * Generates the code corresponding to the connected output points
  20670. * @param state node material build state
  20671. * @param varName name of the variable to output
  20672. * @returns the shader code
  20673. */
  20674. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  20675. protected _buildBlock(state: NodeMaterialBuildState): this;
  20676. protected _dumpPropertiesCode(): string;
  20677. serialize(): any;
  20678. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20679. }
  20680. }
  20681. declare module BABYLON {
  20682. /**
  20683. * Defines a connection point to be used for points with a custom object type
  20684. */
  20685. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  20686. private _blockType;
  20687. private _blockName;
  20688. private _nameForCheking?;
  20689. /**
  20690. * Creates a new connection point
  20691. * @param name defines the connection point name
  20692. * @param ownerBlock defines the block hosting this connection point
  20693. * @param direction defines the direction of the connection point
  20694. */
  20695. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  20696. /**
  20697. * Gets a number indicating if the current point can be connected to another point
  20698. * @param connectionPoint defines the other connection point
  20699. * @returns a number defining the compatibility state
  20700. */
  20701. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20702. /**
  20703. * Creates a block suitable to be used as an input for this input point.
  20704. * If null is returned, a block based on the point type will be created.
  20705. * @returns The returned string parameter is the name of the output point of NodeMaterialBlock (first parameter of the returned array) that can be connected to the input
  20706. */
  20707. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  20708. }
  20709. }
  20710. declare module BABYLON {
  20711. /**
  20712. * Enum defining the type of properties that can be edited in the property pages in the NME
  20713. */
  20714. export enum PropertyTypeForEdition {
  20715. /** property is a boolean */
  20716. Boolean = 0,
  20717. /** property is a float */
  20718. Float = 1,
  20719. /** property is a Vector2 */
  20720. Vector2 = 2,
  20721. /** property is a list of values */
  20722. List = 3
  20723. }
  20724. /**
  20725. * Interface that defines an option in a variable of type list
  20726. */
  20727. export interface IEditablePropertyListOption {
  20728. /** label of the option */
  20729. "label": string;
  20730. /** value of the option */
  20731. "value": number;
  20732. }
  20733. /**
  20734. * Interface that defines the options available for an editable property
  20735. */
  20736. export interface IEditablePropertyOption {
  20737. /** min value */
  20738. "min"?: number;
  20739. /** max value */
  20740. "max"?: number;
  20741. /** notifiers: indicates which actions to take when the property is changed */
  20742. "notifiers"?: {
  20743. /** the material should be rebuilt */
  20744. "rebuild"?: boolean;
  20745. /** the preview should be updated */
  20746. "update"?: boolean;
  20747. };
  20748. /** list of the options for a variable of type list */
  20749. "options"?: IEditablePropertyListOption[];
  20750. }
  20751. /**
  20752. * Interface that describes an editable property
  20753. */
  20754. export interface IPropertyDescriptionForEdition {
  20755. /** name of the property */
  20756. "propertyName": string;
  20757. /** display name of the property */
  20758. "displayName": string;
  20759. /** type of the property */
  20760. "type": PropertyTypeForEdition;
  20761. /** group of the property - all properties with the same group value will be displayed in a specific section */
  20762. "groupName": string;
  20763. /** options for the property */
  20764. "options": IEditablePropertyOption;
  20765. }
  20766. /**
  20767. * Decorator that flags a property in a node material block as being editable
  20768. */
  20769. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  20770. }
  20771. declare module BABYLON {
  20772. /**
  20773. * Block used to implement the refraction part of the sub surface module of the PBR material
  20774. */
  20775. export class RefractionBlock extends NodeMaterialBlock {
  20776. /** @hidden */
  20777. _define3DName: string;
  20778. /** @hidden */
  20779. _refractionMatrixName: string;
  20780. /** @hidden */
  20781. _defineLODRefractionAlpha: string;
  20782. /** @hidden */
  20783. _defineLinearSpecularRefraction: string;
  20784. /** @hidden */
  20785. _defineOppositeZ: string;
  20786. /** @hidden */
  20787. _cubeSamplerName: string;
  20788. /** @hidden */
  20789. _2DSamplerName: string;
  20790. /** @hidden */
  20791. _vRefractionMicrosurfaceInfosName: string;
  20792. /** @hidden */
  20793. _vRefractionInfosName: string;
  20794. private _scene;
  20795. /**
  20796. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  20797. * Materials half opaque for instance using refraction could benefit from this control.
  20798. */
  20799. linkRefractionWithTransparency: boolean;
  20800. /**
  20801. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  20802. */
  20803. invertRefractionY: boolean;
  20804. /**
  20805. * Gets or sets the texture associated with the node
  20806. */
  20807. texture: Nullable<BaseTexture>;
  20808. /**
  20809. * Create a new RefractionBlock
  20810. * @param name defines the block name
  20811. */
  20812. constructor(name: string);
  20813. /**
  20814. * Gets the current class name
  20815. * @returns the class name
  20816. */
  20817. getClassName(): string;
  20818. /**
  20819. * Gets the intensity input component
  20820. */
  20821. get intensity(): NodeMaterialConnectionPoint;
  20822. /**
  20823. * Gets the index of refraction input component
  20824. */
  20825. get indexOfRefraction(): NodeMaterialConnectionPoint;
  20826. /**
  20827. * Gets the tint at distance input component
  20828. */
  20829. get tintAtDistance(): NodeMaterialConnectionPoint;
  20830. /**
  20831. * Gets the view input component
  20832. */
  20833. get view(): NodeMaterialConnectionPoint;
  20834. /**
  20835. * Gets the refraction object output component
  20836. */
  20837. get refraction(): NodeMaterialConnectionPoint;
  20838. /**
  20839. * Returns true if the block has a texture
  20840. */
  20841. get hasTexture(): boolean;
  20842. protected _getTexture(): Nullable<BaseTexture>;
  20843. autoConfigure(material: NodeMaterial): void;
  20844. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20845. isReady(): boolean;
  20846. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  20847. /**
  20848. * Gets the main code of the block (fragment side)
  20849. * @param state current state of the node material building
  20850. * @returns the shader code
  20851. */
  20852. getCode(state: NodeMaterialBuildState): string;
  20853. protected _buildBlock(state: NodeMaterialBuildState): this;
  20854. protected _dumpPropertiesCode(): string;
  20855. serialize(): any;
  20856. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20857. }
  20858. }
  20859. declare module BABYLON {
  20860. /**
  20861. * Base block used as input for post process
  20862. */
  20863. export class CurrentScreenBlock extends NodeMaterialBlock {
  20864. private _samplerName;
  20865. private _linearDefineName;
  20866. private _gammaDefineName;
  20867. private _mainUVName;
  20868. private _tempTextureRead;
  20869. /**
  20870. * Gets or sets the texture associated with the node
  20871. */
  20872. texture: Nullable<BaseTexture>;
  20873. /**
  20874. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20875. */
  20876. convertToGammaSpace: boolean;
  20877. /**
  20878. * Gets or sets a boolean indicating if content needs to be converted to linear space
  20879. */
  20880. convertToLinearSpace: boolean;
  20881. /**
  20882. * Create a new CurrentScreenBlock
  20883. * @param name defines the block name
  20884. */
  20885. constructor(name: string);
  20886. /**
  20887. * Gets the current class name
  20888. * @returns the class name
  20889. */
  20890. getClassName(): string;
  20891. /**
  20892. * Gets the uv input component
  20893. */
  20894. get uv(): NodeMaterialConnectionPoint;
  20895. /**
  20896. * Gets the rgba output component
  20897. */
  20898. get rgba(): NodeMaterialConnectionPoint;
  20899. /**
  20900. * Gets the rgb output component
  20901. */
  20902. get rgb(): NodeMaterialConnectionPoint;
  20903. /**
  20904. * Gets the r output component
  20905. */
  20906. get r(): NodeMaterialConnectionPoint;
  20907. /**
  20908. * Gets the g output component
  20909. */
  20910. get g(): NodeMaterialConnectionPoint;
  20911. /**
  20912. * Gets the b output component
  20913. */
  20914. get b(): NodeMaterialConnectionPoint;
  20915. /**
  20916. * Gets the a output component
  20917. */
  20918. get a(): NodeMaterialConnectionPoint;
  20919. /**
  20920. * Initialize the block and prepare the context for build
  20921. * @param state defines the state that will be used for the build
  20922. */
  20923. initialize(state: NodeMaterialBuildState): void;
  20924. get target(): NodeMaterialBlockTargets;
  20925. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20926. isReady(): boolean;
  20927. private _injectVertexCode;
  20928. private _writeTextureRead;
  20929. private _writeOutput;
  20930. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  20931. serialize(): any;
  20932. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20933. }
  20934. }
  20935. declare module BABYLON {
  20936. /**
  20937. * Base block used for the particle texture
  20938. */
  20939. export class ParticleTextureBlock extends NodeMaterialBlock {
  20940. private _samplerName;
  20941. private _linearDefineName;
  20942. private _gammaDefineName;
  20943. private _tempTextureRead;
  20944. /**
  20945. * Gets or sets the texture associated with the node
  20946. */
  20947. texture: Nullable<BaseTexture>;
  20948. /**
  20949. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20950. */
  20951. convertToGammaSpace: boolean;
  20952. /**
  20953. * Gets or sets a boolean indicating if content needs to be converted to linear space
  20954. */
  20955. convertToLinearSpace: boolean;
  20956. /**
  20957. * Create a new ParticleTextureBlock
  20958. * @param name defines the block name
  20959. */
  20960. constructor(name: string);
  20961. /**
  20962. * Gets the current class name
  20963. * @returns the class name
  20964. */
  20965. getClassName(): string;
  20966. /**
  20967. * Gets the uv input component
  20968. */
  20969. get uv(): NodeMaterialConnectionPoint;
  20970. /**
  20971. * Gets the rgba output component
  20972. */
  20973. get rgba(): NodeMaterialConnectionPoint;
  20974. /**
  20975. * Gets the rgb output component
  20976. */
  20977. get rgb(): NodeMaterialConnectionPoint;
  20978. /**
  20979. * Gets the r output component
  20980. */
  20981. get r(): NodeMaterialConnectionPoint;
  20982. /**
  20983. * Gets the g output component
  20984. */
  20985. get g(): NodeMaterialConnectionPoint;
  20986. /**
  20987. * Gets the b output component
  20988. */
  20989. get b(): NodeMaterialConnectionPoint;
  20990. /**
  20991. * Gets the a output component
  20992. */
  20993. get a(): NodeMaterialConnectionPoint;
  20994. /**
  20995. * Initialize the block and prepare the context for build
  20996. * @param state defines the state that will be used for the build
  20997. */
  20998. initialize(state: NodeMaterialBuildState): void;
  20999. autoConfigure(material: NodeMaterial): void;
  21000. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21001. isReady(): boolean;
  21002. private _writeOutput;
  21003. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21004. serialize(): any;
  21005. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21006. }
  21007. }
  21008. declare module BABYLON {
  21009. /**
  21010. * Class used to store shared data between 2 NodeMaterialBuildState
  21011. */
  21012. export class NodeMaterialBuildStateSharedData {
  21013. /**
  21014. * Gets the list of emitted varyings
  21015. */
  21016. temps: string[];
  21017. /**
  21018. * Gets the list of emitted varyings
  21019. */
  21020. varyings: string[];
  21021. /**
  21022. * Gets the varying declaration string
  21023. */
  21024. varyingDeclaration: string;
  21025. /**
  21026. * Input blocks
  21027. */
  21028. inputBlocks: InputBlock[];
  21029. /**
  21030. * Input blocks
  21031. */
  21032. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  21033. /**
  21034. * Bindable blocks (Blocks that need to set data to the effect)
  21035. */
  21036. bindableBlocks: NodeMaterialBlock[];
  21037. /**
  21038. * List of blocks that can provide a compilation fallback
  21039. */
  21040. blocksWithFallbacks: NodeMaterialBlock[];
  21041. /**
  21042. * List of blocks that can provide a define update
  21043. */
  21044. blocksWithDefines: NodeMaterialBlock[];
  21045. /**
  21046. * List of blocks that can provide a repeatable content
  21047. */
  21048. repeatableContentBlocks: NodeMaterialBlock[];
  21049. /**
  21050. * List of blocks that can provide a dynamic list of uniforms
  21051. */
  21052. dynamicUniformBlocks: NodeMaterialBlock[];
  21053. /**
  21054. * List of blocks that can block the isReady function for the material
  21055. */
  21056. blockingBlocks: NodeMaterialBlock[];
  21057. /**
  21058. * Gets the list of animated inputs
  21059. */
  21060. animatedInputs: InputBlock[];
  21061. /**
  21062. * Build Id used to avoid multiple recompilations
  21063. */
  21064. buildId: number;
  21065. /** List of emitted variables */
  21066. variableNames: {
  21067. [key: string]: number;
  21068. };
  21069. /** List of emitted defines */
  21070. defineNames: {
  21071. [key: string]: number;
  21072. };
  21073. /** Should emit comments? */
  21074. emitComments: boolean;
  21075. /** Emit build activity */
  21076. verbose: boolean;
  21077. /** Gets or sets the hosting scene */
  21078. scene: Scene;
  21079. /**
  21080. * Gets the compilation hints emitted at compilation time
  21081. */
  21082. hints: {
  21083. needWorldViewMatrix: boolean;
  21084. needWorldViewProjectionMatrix: boolean;
  21085. needAlphaBlending: boolean;
  21086. needAlphaTesting: boolean;
  21087. };
  21088. /**
  21089. * List of compilation checks
  21090. */
  21091. checks: {
  21092. emitVertex: boolean;
  21093. emitFragment: boolean;
  21094. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  21095. };
  21096. /**
  21097. * Is vertex program allowed to be empty?
  21098. */
  21099. allowEmptyVertexProgram: boolean;
  21100. /** Creates a new shared data */
  21101. constructor();
  21102. /**
  21103. * Emits console errors and exceptions if there is a failing check
  21104. */
  21105. emitErrors(): void;
  21106. }
  21107. }
  21108. declare module BABYLON {
  21109. /**
  21110. * Class used to store node based material build state
  21111. */
  21112. export class NodeMaterialBuildState {
  21113. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  21114. supportUniformBuffers: boolean;
  21115. /**
  21116. * Gets the list of emitted attributes
  21117. */
  21118. attributes: string[];
  21119. /**
  21120. * Gets the list of emitted uniforms
  21121. */
  21122. uniforms: string[];
  21123. /**
  21124. * Gets the list of emitted constants
  21125. */
  21126. constants: string[];
  21127. /**
  21128. * Gets the list of emitted samplers
  21129. */
  21130. samplers: string[];
  21131. /**
  21132. * Gets the list of emitted functions
  21133. */
  21134. functions: {
  21135. [key: string]: string;
  21136. };
  21137. /**
  21138. * Gets the list of emitted extensions
  21139. */
  21140. extensions: {
  21141. [key: string]: string;
  21142. };
  21143. /**
  21144. * Gets the target of the compilation state
  21145. */
  21146. target: NodeMaterialBlockTargets;
  21147. /**
  21148. * Gets the list of emitted counters
  21149. */
  21150. counters: {
  21151. [key: string]: number;
  21152. };
  21153. /**
  21154. * Shared data between multiple NodeMaterialBuildState instances
  21155. */
  21156. sharedData: NodeMaterialBuildStateSharedData;
  21157. /** @hidden */
  21158. _vertexState: NodeMaterialBuildState;
  21159. /** @hidden */
  21160. _attributeDeclaration: string;
  21161. /** @hidden */
  21162. _uniformDeclaration: string;
  21163. /** @hidden */
  21164. _constantDeclaration: string;
  21165. /** @hidden */
  21166. _samplerDeclaration: string;
  21167. /** @hidden */
  21168. _varyingTransfer: string;
  21169. /** @hidden */
  21170. _injectAtEnd: string;
  21171. private _repeatableContentAnchorIndex;
  21172. /** @hidden */
  21173. _builtCompilationString: string;
  21174. /**
  21175. * Gets the emitted compilation strings
  21176. */
  21177. compilationString: string;
  21178. /**
  21179. * Finalize the compilation strings
  21180. * @param state defines the current compilation state
  21181. */
  21182. finalize(state: NodeMaterialBuildState): void;
  21183. /** @hidden */
  21184. get _repeatableContentAnchor(): string;
  21185. /** @hidden */
  21186. _getFreeVariableName(prefix: string): string;
  21187. /** @hidden */
  21188. _getFreeDefineName(prefix: string): string;
  21189. /** @hidden */
  21190. _excludeVariableName(name: string): void;
  21191. /** @hidden */
  21192. _emit2DSampler(name: string): void;
  21193. /** @hidden */
  21194. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  21195. /** @hidden */
  21196. _emitExtension(name: string, extension: string, define?: string): void;
  21197. /** @hidden */
  21198. _emitFunction(name: string, code: string, comments: string): void;
  21199. /** @hidden */
  21200. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  21201. replaceStrings?: {
  21202. search: RegExp;
  21203. replace: string;
  21204. }[];
  21205. repeatKey?: string;
  21206. }): string;
  21207. /** @hidden */
  21208. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  21209. repeatKey?: string;
  21210. removeAttributes?: boolean;
  21211. removeUniforms?: boolean;
  21212. removeVaryings?: boolean;
  21213. removeIfDef?: boolean;
  21214. replaceStrings?: {
  21215. search: RegExp;
  21216. replace: string;
  21217. }[];
  21218. }, storeKey?: string): void;
  21219. /** @hidden */
  21220. _registerTempVariable(name: string): boolean;
  21221. /** @hidden */
  21222. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  21223. /** @hidden */
  21224. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  21225. /** @hidden */
  21226. _emitFloat(value: number): string;
  21227. }
  21228. }
  21229. declare module BABYLON {
  21230. /**
  21231. * Helper class used to generate session unique ID
  21232. */
  21233. export class UniqueIdGenerator {
  21234. private static _UniqueIdCounter;
  21235. /**
  21236. * Gets an unique (relatively to the current scene) Id
  21237. */
  21238. static get UniqueId(): number;
  21239. }
  21240. }
  21241. declare module BABYLON {
  21242. /**
  21243. * Defines a block that can be used inside a node based material
  21244. */
  21245. export class NodeMaterialBlock {
  21246. private _buildId;
  21247. private _buildTarget;
  21248. private _target;
  21249. private _isFinalMerger;
  21250. private _isInput;
  21251. protected _isUnique: boolean;
  21252. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  21253. inputsAreExclusive: boolean;
  21254. /** @hidden */
  21255. _codeVariableName: string;
  21256. /** @hidden */
  21257. _inputs: NodeMaterialConnectionPoint[];
  21258. /** @hidden */
  21259. _outputs: NodeMaterialConnectionPoint[];
  21260. /** @hidden */
  21261. _preparationId: number;
  21262. /**
  21263. * Gets or sets the name of the block
  21264. */
  21265. name: string;
  21266. /**
  21267. * Gets or sets the unique id of the node
  21268. */
  21269. uniqueId: number;
  21270. /**
  21271. * Gets or sets the comments associated with this block
  21272. */
  21273. comments: string;
  21274. /**
  21275. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  21276. */
  21277. get isUnique(): boolean;
  21278. /**
  21279. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  21280. */
  21281. get isFinalMerger(): boolean;
  21282. /**
  21283. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  21284. */
  21285. get isInput(): boolean;
  21286. /**
  21287. * Gets or sets the build Id
  21288. */
  21289. get buildId(): number;
  21290. set buildId(value: number);
  21291. /**
  21292. * Gets or sets the target of the block
  21293. */
  21294. get target(): NodeMaterialBlockTargets;
  21295. set target(value: NodeMaterialBlockTargets);
  21296. /**
  21297. * Gets the list of input points
  21298. */
  21299. get inputs(): NodeMaterialConnectionPoint[];
  21300. /** Gets the list of output points */
  21301. get outputs(): NodeMaterialConnectionPoint[];
  21302. /**
  21303. * Find an input by its name
  21304. * @param name defines the name of the input to look for
  21305. * @returns the input or null if not found
  21306. */
  21307. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21308. /**
  21309. * Find an output by its name
  21310. * @param name defines the name of the outputto look for
  21311. * @returns the output or null if not found
  21312. */
  21313. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21314. /**
  21315. * Creates a new NodeMaterialBlock
  21316. * @param name defines the block name
  21317. * @param target defines the target of that block (Vertex by default)
  21318. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  21319. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  21320. */
  21321. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  21322. /**
  21323. * Initialize the block and prepare the context for build
  21324. * @param state defines the state that will be used for the build
  21325. */
  21326. initialize(state: NodeMaterialBuildState): void;
  21327. /**
  21328. * Bind data to effect. Will only be called for blocks with isBindable === true
  21329. * @param effect defines the effect to bind data to
  21330. * @param nodeMaterial defines the hosting NodeMaterial
  21331. * @param mesh defines the mesh that will be rendered
  21332. * @param subMesh defines the submesh that will be rendered
  21333. */
  21334. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21335. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  21336. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  21337. protected _writeFloat(value: number): string;
  21338. /**
  21339. * Gets the current class name e.g. "NodeMaterialBlock"
  21340. * @returns the class name
  21341. */
  21342. getClassName(): string;
  21343. /**
  21344. * Register a new input. Must be called inside a block constructor
  21345. * @param name defines the connection point name
  21346. * @param type defines the connection point type
  21347. * @param isOptional defines a boolean indicating that this input can be omitted
  21348. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21349. * @param point an already created connection point. If not provided, create a new one
  21350. * @returns the current block
  21351. */
  21352. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21353. /**
  21354. * Register a new output. Must be called inside a block constructor
  21355. * @param name defines the connection point name
  21356. * @param type defines the connection point type
  21357. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21358. * @param point an already created connection point. If not provided, create a new one
  21359. * @returns the current block
  21360. */
  21361. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21362. /**
  21363. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  21364. * @param forOutput defines an optional connection point to check compatibility with
  21365. * @returns the first available input or null
  21366. */
  21367. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  21368. /**
  21369. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  21370. * @param forBlock defines an optional block to check compatibility with
  21371. * @returns the first available input or null
  21372. */
  21373. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  21374. /**
  21375. * Gets the sibling of the given output
  21376. * @param current defines the current output
  21377. * @returns the next output in the list or null
  21378. */
  21379. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  21380. /**
  21381. * Connect current block with another block
  21382. * @param other defines the block to connect with
  21383. * @param options define the various options to help pick the right connections
  21384. * @returns the current block
  21385. */
  21386. connectTo(other: NodeMaterialBlock, options?: {
  21387. input?: string;
  21388. output?: string;
  21389. outputSwizzle?: string;
  21390. }): this | undefined;
  21391. protected _buildBlock(state: NodeMaterialBuildState): void;
  21392. /**
  21393. * Add uniforms, samplers and uniform buffers at compilation time
  21394. * @param state defines the state to update
  21395. * @param nodeMaterial defines the node material requesting the update
  21396. * @param defines defines the material defines to update
  21397. * @param uniformBuffers defines the list of uniform buffer names
  21398. */
  21399. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  21400. /**
  21401. * Add potential fallbacks if shader compilation fails
  21402. * @param mesh defines the mesh to be rendered
  21403. * @param fallbacks defines the current prioritized list of fallbacks
  21404. */
  21405. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  21406. /**
  21407. * Initialize defines for shader compilation
  21408. * @param mesh defines the mesh to be rendered
  21409. * @param nodeMaterial defines the node material requesting the update
  21410. * @param defines defines the material defines to update
  21411. * @param useInstances specifies that instances should be used
  21412. */
  21413. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21414. /**
  21415. * Update defines for shader compilation
  21416. * @param mesh defines the mesh to be rendered
  21417. * @param nodeMaterial defines the node material requesting the update
  21418. * @param defines defines the material defines to update
  21419. * @param useInstances specifies that instances should be used
  21420. */
  21421. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21422. /**
  21423. * Lets the block try to connect some inputs automatically
  21424. * @param material defines the hosting NodeMaterial
  21425. */
  21426. autoConfigure(material: NodeMaterial): void;
  21427. /**
  21428. * Function called when a block is declared as repeatable content generator
  21429. * @param vertexShaderState defines the current compilation state for the vertex shader
  21430. * @param fragmentShaderState defines the current compilation state for the fragment shader
  21431. * @param mesh defines the mesh to be rendered
  21432. * @param defines defines the material defines to update
  21433. */
  21434. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  21435. /**
  21436. * Checks if the block is ready
  21437. * @param mesh defines the mesh to be rendered
  21438. * @param nodeMaterial defines the node material requesting the update
  21439. * @param defines defines the material defines to update
  21440. * @param useInstances specifies that instances should be used
  21441. * @returns true if the block is ready
  21442. */
  21443. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  21444. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  21445. private _processBuild;
  21446. /**
  21447. * Compile the current node and generate the shader code
  21448. * @param state defines the current compilation state (uniforms, samplers, current string)
  21449. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  21450. * @returns true if already built
  21451. */
  21452. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  21453. protected _inputRename(name: string): string;
  21454. protected _outputRename(name: string): string;
  21455. protected _dumpPropertiesCode(): string;
  21456. /** @hidden */
  21457. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  21458. /** @hidden */
  21459. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  21460. /**
  21461. * Clone the current block to a new identical block
  21462. * @param scene defines the hosting scene
  21463. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  21464. * @returns a copy of the current block
  21465. */
  21466. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  21467. /**
  21468. * Serializes this block in a JSON representation
  21469. * @returns the serialized block object
  21470. */
  21471. serialize(): any;
  21472. /** @hidden */
  21473. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21474. private _deserializePortDisplayNames;
  21475. /**
  21476. * Release resources
  21477. */
  21478. dispose(): void;
  21479. }
  21480. }
  21481. declare module BABYLON {
  21482. /**
  21483. * Base class of materials working in push mode in babylon JS
  21484. * @hidden
  21485. */
  21486. export class PushMaterial extends Material {
  21487. protected _activeEffect: Effect;
  21488. protected _normalMatrix: Matrix;
  21489. /**
  21490. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  21491. * This means that the material can keep using a previous shader while a new one is being compiled.
  21492. * This is mostly used when shader parallel compilation is supported (true by default)
  21493. */
  21494. allowShaderHotSwapping: boolean;
  21495. constructor(name: string, scene: Scene);
  21496. getEffect(): Effect;
  21497. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21498. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  21499. /**
  21500. * Binds the given world matrix to the active effect
  21501. *
  21502. * @param world the matrix to bind
  21503. */
  21504. bindOnlyWorldMatrix(world: Matrix): void;
  21505. /**
  21506. * Binds the given normal matrix to the active effect
  21507. *
  21508. * @param normalMatrix the matrix to bind
  21509. */
  21510. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  21511. bind(world: Matrix, mesh?: Mesh): void;
  21512. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  21513. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  21514. }
  21515. }
  21516. declare module BABYLON {
  21517. /**
  21518. * Root class for all node material optimizers
  21519. */
  21520. export class NodeMaterialOptimizer {
  21521. /**
  21522. * Function used to optimize a NodeMaterial graph
  21523. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  21524. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  21525. */
  21526. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  21527. }
  21528. }
  21529. declare module BABYLON {
  21530. /**
  21531. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  21532. */
  21533. export class TransformBlock extends NodeMaterialBlock {
  21534. /**
  21535. * Defines the value to use to complement W value to transform it to a Vector4
  21536. */
  21537. complementW: number;
  21538. /**
  21539. * Defines the value to use to complement z value to transform it to a Vector4
  21540. */
  21541. complementZ: number;
  21542. /**
  21543. * Creates a new TransformBlock
  21544. * @param name defines the block name
  21545. */
  21546. constructor(name: string);
  21547. /**
  21548. * Gets the current class name
  21549. * @returns the class name
  21550. */
  21551. getClassName(): string;
  21552. /**
  21553. * Gets the vector input
  21554. */
  21555. get vector(): NodeMaterialConnectionPoint;
  21556. /**
  21557. * Gets the output component
  21558. */
  21559. get output(): NodeMaterialConnectionPoint;
  21560. /**
  21561. * Gets the xyz output component
  21562. */
  21563. get xyz(): NodeMaterialConnectionPoint;
  21564. /**
  21565. * Gets the matrix transform input
  21566. */
  21567. get transform(): NodeMaterialConnectionPoint;
  21568. protected _buildBlock(state: NodeMaterialBuildState): this;
  21569. serialize(): any;
  21570. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21571. protected _dumpPropertiesCode(): string;
  21572. }
  21573. }
  21574. declare module BABYLON {
  21575. /**
  21576. * Block used to output the vertex position
  21577. */
  21578. export class VertexOutputBlock extends NodeMaterialBlock {
  21579. /**
  21580. * Creates a new VertexOutputBlock
  21581. * @param name defines the block name
  21582. */
  21583. constructor(name: string);
  21584. /**
  21585. * Gets the current class name
  21586. * @returns the class name
  21587. */
  21588. getClassName(): string;
  21589. /**
  21590. * Gets the vector input component
  21591. */
  21592. get vector(): NodeMaterialConnectionPoint;
  21593. protected _buildBlock(state: NodeMaterialBuildState): this;
  21594. }
  21595. }
  21596. declare module BABYLON {
  21597. /**
  21598. * Block used to output the final color
  21599. */
  21600. export class FragmentOutputBlock extends NodeMaterialBlock {
  21601. /**
  21602. * Create a new FragmentOutputBlock
  21603. * @param name defines the block name
  21604. */
  21605. constructor(name: string);
  21606. /**
  21607. * Gets the current class name
  21608. * @returns the class name
  21609. */
  21610. getClassName(): string;
  21611. /**
  21612. * Gets the rgba input component
  21613. */
  21614. get rgba(): NodeMaterialConnectionPoint;
  21615. /**
  21616. * Gets the rgb input component
  21617. */
  21618. get rgb(): NodeMaterialConnectionPoint;
  21619. /**
  21620. * Gets the a input component
  21621. */
  21622. get a(): NodeMaterialConnectionPoint;
  21623. protected _buildBlock(state: NodeMaterialBuildState): this;
  21624. }
  21625. }
  21626. declare module BABYLON {
  21627. /**
  21628. * Block used for the particle ramp gradient section
  21629. */
  21630. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  21631. /**
  21632. * Create a new ParticleRampGradientBlock
  21633. * @param name defines the block name
  21634. */
  21635. constructor(name: string);
  21636. /**
  21637. * Gets the current class name
  21638. * @returns the class name
  21639. */
  21640. getClassName(): string;
  21641. /**
  21642. * Gets the color input component
  21643. */
  21644. get color(): NodeMaterialConnectionPoint;
  21645. /**
  21646. * Gets the rampColor output component
  21647. */
  21648. get rampColor(): NodeMaterialConnectionPoint;
  21649. /**
  21650. * Initialize the block and prepare the context for build
  21651. * @param state defines the state that will be used for the build
  21652. */
  21653. initialize(state: NodeMaterialBuildState): void;
  21654. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21655. }
  21656. }
  21657. declare module BABYLON {
  21658. /**
  21659. * Block used for the particle blend multiply section
  21660. */
  21661. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  21662. /**
  21663. * Create a new ParticleBlendMultiplyBlock
  21664. * @param name defines the block name
  21665. */
  21666. constructor(name: string);
  21667. /**
  21668. * Gets the current class name
  21669. * @returns the class name
  21670. */
  21671. getClassName(): string;
  21672. /**
  21673. * Gets the color input component
  21674. */
  21675. get color(): NodeMaterialConnectionPoint;
  21676. /**
  21677. * Gets the alphaTexture input component
  21678. */
  21679. get alphaTexture(): NodeMaterialConnectionPoint;
  21680. /**
  21681. * Gets the alphaColor input component
  21682. */
  21683. get alphaColor(): NodeMaterialConnectionPoint;
  21684. /**
  21685. * Gets the blendColor output component
  21686. */
  21687. get blendColor(): NodeMaterialConnectionPoint;
  21688. /**
  21689. * Initialize the block and prepare the context for build
  21690. * @param state defines the state that will be used for the build
  21691. */
  21692. initialize(state: NodeMaterialBuildState): void;
  21693. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21694. }
  21695. }
  21696. declare module BABYLON {
  21697. /**
  21698. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  21699. */
  21700. export class VectorMergerBlock extends NodeMaterialBlock {
  21701. /**
  21702. * Create a new VectorMergerBlock
  21703. * @param name defines the block name
  21704. */
  21705. constructor(name: string);
  21706. /**
  21707. * Gets the current class name
  21708. * @returns the class name
  21709. */
  21710. getClassName(): string;
  21711. /**
  21712. * Gets the xyz component (input)
  21713. */
  21714. get xyzIn(): NodeMaterialConnectionPoint;
  21715. /**
  21716. * Gets the xy component (input)
  21717. */
  21718. get xyIn(): NodeMaterialConnectionPoint;
  21719. /**
  21720. * Gets the x component (input)
  21721. */
  21722. get x(): NodeMaterialConnectionPoint;
  21723. /**
  21724. * Gets the y component (input)
  21725. */
  21726. get y(): NodeMaterialConnectionPoint;
  21727. /**
  21728. * Gets the z component (input)
  21729. */
  21730. get z(): NodeMaterialConnectionPoint;
  21731. /**
  21732. * Gets the w component (input)
  21733. */
  21734. get w(): NodeMaterialConnectionPoint;
  21735. /**
  21736. * Gets the xyzw component (output)
  21737. */
  21738. get xyzw(): NodeMaterialConnectionPoint;
  21739. /**
  21740. * Gets the xyz component (output)
  21741. */
  21742. get xyzOut(): NodeMaterialConnectionPoint;
  21743. /**
  21744. * Gets the xy component (output)
  21745. */
  21746. get xyOut(): NodeMaterialConnectionPoint;
  21747. /**
  21748. * Gets the xy component (output)
  21749. * @deprecated Please use xyOut instead.
  21750. */
  21751. get xy(): NodeMaterialConnectionPoint;
  21752. /**
  21753. * Gets the xyz component (output)
  21754. * @deprecated Please use xyzOut instead.
  21755. */
  21756. get xyz(): NodeMaterialConnectionPoint;
  21757. protected _buildBlock(state: NodeMaterialBuildState): this;
  21758. }
  21759. }
  21760. declare module BABYLON {
  21761. /**
  21762. * Block used to remap a float from a range to a new one
  21763. */
  21764. export class RemapBlock extends NodeMaterialBlock {
  21765. /**
  21766. * Gets or sets the source range
  21767. */
  21768. sourceRange: Vector2;
  21769. /**
  21770. * Gets or sets the target range
  21771. */
  21772. targetRange: Vector2;
  21773. /**
  21774. * Creates a new RemapBlock
  21775. * @param name defines the block name
  21776. */
  21777. constructor(name: string);
  21778. /**
  21779. * Gets the current class name
  21780. * @returns the class name
  21781. */
  21782. getClassName(): string;
  21783. /**
  21784. * Gets the input component
  21785. */
  21786. get input(): NodeMaterialConnectionPoint;
  21787. /**
  21788. * Gets the source min input component
  21789. */
  21790. get sourceMin(): NodeMaterialConnectionPoint;
  21791. /**
  21792. * Gets the source max input component
  21793. */
  21794. get sourceMax(): NodeMaterialConnectionPoint;
  21795. /**
  21796. * Gets the target min input component
  21797. */
  21798. get targetMin(): NodeMaterialConnectionPoint;
  21799. /**
  21800. * Gets the target max input component
  21801. */
  21802. get targetMax(): NodeMaterialConnectionPoint;
  21803. /**
  21804. * Gets the output component
  21805. */
  21806. get output(): NodeMaterialConnectionPoint;
  21807. protected _buildBlock(state: NodeMaterialBuildState): this;
  21808. protected _dumpPropertiesCode(): string;
  21809. serialize(): any;
  21810. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21811. }
  21812. }
  21813. declare module BABYLON {
  21814. /**
  21815. * Block used to multiply 2 values
  21816. */
  21817. export class MultiplyBlock extends NodeMaterialBlock {
  21818. /**
  21819. * Creates a new MultiplyBlock
  21820. * @param name defines the block name
  21821. */
  21822. constructor(name: string);
  21823. /**
  21824. * Gets the current class name
  21825. * @returns the class name
  21826. */
  21827. getClassName(): string;
  21828. /**
  21829. * Gets the left operand input component
  21830. */
  21831. get left(): NodeMaterialConnectionPoint;
  21832. /**
  21833. * Gets the right operand input component
  21834. */
  21835. get right(): NodeMaterialConnectionPoint;
  21836. /**
  21837. * Gets the output component
  21838. */
  21839. get output(): NodeMaterialConnectionPoint;
  21840. protected _buildBlock(state: NodeMaterialBuildState): this;
  21841. }
  21842. }
  21843. declare module BABYLON {
  21844. /**
  21845. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  21846. */
  21847. export class ColorSplitterBlock extends NodeMaterialBlock {
  21848. /**
  21849. * Create a new ColorSplitterBlock
  21850. * @param name defines the block name
  21851. */
  21852. constructor(name: string);
  21853. /**
  21854. * Gets the current class name
  21855. * @returns the class name
  21856. */
  21857. getClassName(): string;
  21858. /**
  21859. * Gets the rgba component (input)
  21860. */
  21861. get rgba(): NodeMaterialConnectionPoint;
  21862. /**
  21863. * Gets the rgb component (input)
  21864. */
  21865. get rgbIn(): NodeMaterialConnectionPoint;
  21866. /**
  21867. * Gets the rgb component (output)
  21868. */
  21869. get rgbOut(): NodeMaterialConnectionPoint;
  21870. /**
  21871. * Gets the r component (output)
  21872. */
  21873. get r(): NodeMaterialConnectionPoint;
  21874. /**
  21875. * Gets the g component (output)
  21876. */
  21877. get g(): NodeMaterialConnectionPoint;
  21878. /**
  21879. * Gets the b component (output)
  21880. */
  21881. get b(): NodeMaterialConnectionPoint;
  21882. /**
  21883. * Gets the a component (output)
  21884. */
  21885. get a(): NodeMaterialConnectionPoint;
  21886. protected _inputRename(name: string): string;
  21887. protected _outputRename(name: string): string;
  21888. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21889. }
  21890. }
  21891. declare module BABYLON {
  21892. /**
  21893. * Interface used to configure the node material editor
  21894. */
  21895. export interface INodeMaterialEditorOptions {
  21896. /** Define the URl to load node editor script */
  21897. editorURL?: string;
  21898. }
  21899. /** @hidden */
  21900. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  21901. NORMAL: boolean;
  21902. TANGENT: boolean;
  21903. UV1: boolean;
  21904. /** BONES */
  21905. NUM_BONE_INFLUENCERS: number;
  21906. BonesPerMesh: number;
  21907. BONETEXTURE: boolean;
  21908. /** MORPH TARGETS */
  21909. MORPHTARGETS: boolean;
  21910. MORPHTARGETS_NORMAL: boolean;
  21911. MORPHTARGETS_TANGENT: boolean;
  21912. MORPHTARGETS_UV: boolean;
  21913. NUM_MORPH_INFLUENCERS: number;
  21914. /** IMAGE PROCESSING */
  21915. IMAGEPROCESSING: boolean;
  21916. VIGNETTE: boolean;
  21917. VIGNETTEBLENDMODEMULTIPLY: boolean;
  21918. VIGNETTEBLENDMODEOPAQUE: boolean;
  21919. TONEMAPPING: boolean;
  21920. TONEMAPPING_ACES: boolean;
  21921. CONTRAST: boolean;
  21922. EXPOSURE: boolean;
  21923. COLORCURVES: boolean;
  21924. COLORGRADING: boolean;
  21925. COLORGRADING3D: boolean;
  21926. SAMPLER3DGREENDEPTH: boolean;
  21927. SAMPLER3DBGRMAP: boolean;
  21928. IMAGEPROCESSINGPOSTPROCESS: boolean;
  21929. /** MISC. */
  21930. BUMPDIRECTUV: number;
  21931. constructor();
  21932. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  21933. }
  21934. /**
  21935. * Class used to configure NodeMaterial
  21936. */
  21937. export interface INodeMaterialOptions {
  21938. /**
  21939. * Defines if blocks should emit comments
  21940. */
  21941. emitComments: boolean;
  21942. }
  21943. /**
  21944. * Class used to create a node based material built by assembling shader blocks
  21945. */
  21946. export class NodeMaterial extends PushMaterial {
  21947. private static _BuildIdGenerator;
  21948. private _options;
  21949. private _vertexCompilationState;
  21950. private _fragmentCompilationState;
  21951. private _sharedData;
  21952. private _buildId;
  21953. private _buildWasSuccessful;
  21954. private _cachedWorldViewMatrix;
  21955. private _cachedWorldViewProjectionMatrix;
  21956. private _optimizers;
  21957. private _animationFrame;
  21958. /** Define the Url to load node editor script */
  21959. static EditorURL: string;
  21960. /** Define the Url to load snippets */
  21961. static SnippetUrl: string;
  21962. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  21963. static IgnoreTexturesAtLoadTime: boolean;
  21964. private BJSNODEMATERIALEDITOR;
  21965. /** Get the inspector from bundle or global */
  21966. private _getGlobalNodeMaterialEditor;
  21967. /**
  21968. * Snippet ID if the material was created from the snippet server
  21969. */
  21970. snippetId: string;
  21971. /**
  21972. * Gets or sets data used by visual editor
  21973. * @see https://nme.babylonjs.com
  21974. */
  21975. editorData: any;
  21976. /**
  21977. * 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)
  21978. */
  21979. ignoreAlpha: boolean;
  21980. /**
  21981. * Defines the maximum number of lights that can be used in the material
  21982. */
  21983. maxSimultaneousLights: number;
  21984. /**
  21985. * Observable raised when the material is built
  21986. */
  21987. onBuildObservable: Observable<NodeMaterial>;
  21988. /**
  21989. * Gets or sets the root nodes of the material vertex shader
  21990. */
  21991. _vertexOutputNodes: NodeMaterialBlock[];
  21992. /**
  21993. * Gets or sets the root nodes of the material fragment (pixel) shader
  21994. */
  21995. _fragmentOutputNodes: NodeMaterialBlock[];
  21996. /** Gets or sets options to control the node material overall behavior */
  21997. get options(): INodeMaterialOptions;
  21998. set options(options: INodeMaterialOptions);
  21999. /**
  22000. * Default configuration related to image processing available in the standard Material.
  22001. */
  22002. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22003. /**
  22004. * Gets the image processing configuration used either in this material.
  22005. */
  22006. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22007. /**
  22008. * Sets the Default image processing configuration used either in the this material.
  22009. *
  22010. * If sets to null, the scene one is in use.
  22011. */
  22012. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22013. /**
  22014. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  22015. */
  22016. attachedBlocks: NodeMaterialBlock[];
  22017. /**
  22018. * Specifies the mode of the node material
  22019. * @hidden
  22020. */
  22021. _mode: NodeMaterialModes;
  22022. /**
  22023. * Gets the mode property
  22024. */
  22025. get mode(): NodeMaterialModes;
  22026. /**
  22027. * Create a new node based material
  22028. * @param name defines the material name
  22029. * @param scene defines the hosting scene
  22030. * @param options defines creation option
  22031. */
  22032. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  22033. /**
  22034. * Gets the current class name of the material e.g. "NodeMaterial"
  22035. * @returns the class name
  22036. */
  22037. getClassName(): string;
  22038. /**
  22039. * Keep track of the image processing observer to allow dispose and replace.
  22040. */
  22041. private _imageProcessingObserver;
  22042. /**
  22043. * Attaches a new image processing configuration to the Standard Material.
  22044. * @param configuration
  22045. */
  22046. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22047. /**
  22048. * Get a block by its name
  22049. * @param name defines the name of the block to retrieve
  22050. * @returns the required block or null if not found
  22051. */
  22052. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  22053. /**
  22054. * Get a block by its name
  22055. * @param predicate defines the predicate used to find the good candidate
  22056. * @returns the required block or null if not found
  22057. */
  22058. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  22059. /**
  22060. * Get an input block by its name
  22061. * @param predicate defines the predicate used to find the good candidate
  22062. * @returns the required input block or null if not found
  22063. */
  22064. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  22065. /**
  22066. * Gets the list of input blocks attached to this material
  22067. * @returns an array of InputBlocks
  22068. */
  22069. getInputBlocks(): InputBlock[];
  22070. /**
  22071. * Adds a new optimizer to the list of optimizers
  22072. * @param optimizer defines the optimizers to add
  22073. * @returns the current material
  22074. */
  22075. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22076. /**
  22077. * Remove an optimizer from the list of optimizers
  22078. * @param optimizer defines the optimizers to remove
  22079. * @returns the current material
  22080. */
  22081. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22082. /**
  22083. * Add a new block to the list of output nodes
  22084. * @param node defines the node to add
  22085. * @returns the current material
  22086. */
  22087. addOutputNode(node: NodeMaterialBlock): this;
  22088. /**
  22089. * Remove a block from the list of root nodes
  22090. * @param node defines the node to remove
  22091. * @returns the current material
  22092. */
  22093. removeOutputNode(node: NodeMaterialBlock): this;
  22094. private _addVertexOutputNode;
  22095. private _removeVertexOutputNode;
  22096. private _addFragmentOutputNode;
  22097. private _removeFragmentOutputNode;
  22098. /**
  22099. * Specifies if the material will require alpha blending
  22100. * @returns a boolean specifying if alpha blending is needed
  22101. */
  22102. needAlphaBlending(): boolean;
  22103. /**
  22104. * Specifies if this material should be rendered in alpha test mode
  22105. * @returns a boolean specifying if an alpha test is needed.
  22106. */
  22107. needAlphaTesting(): boolean;
  22108. private _initializeBlock;
  22109. private _resetDualBlocks;
  22110. /**
  22111. * Remove a block from the current node material
  22112. * @param block defines the block to remove
  22113. */
  22114. removeBlock(block: NodeMaterialBlock): void;
  22115. /**
  22116. * Build the material and generates the inner effect
  22117. * @param verbose defines if the build should log activity
  22118. */
  22119. build(verbose?: boolean): void;
  22120. /**
  22121. * Runs an otpimization phase to try to improve the shader code
  22122. */
  22123. optimize(): void;
  22124. private _prepareDefinesForAttributes;
  22125. /**
  22126. * Create a post process from the material
  22127. * @param camera The camera to apply the render pass to.
  22128. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22129. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22130. * @param engine The engine which the post process will be applied. (default: current engine)
  22131. * @param reusable If the post process can be reused on the same frame. (default: false)
  22132. * @param textureType Type of textures used when performing the post process. (default: 0)
  22133. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22134. * @returns the post process created
  22135. */
  22136. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  22137. private _createEffectForParticles;
  22138. /**
  22139. * Create the effect to be used as the custom effect for a particle system
  22140. * @param particleSystem Particle system to create the effect for
  22141. * @param onCompiled defines a function to call when the effect creation is successful
  22142. * @param onError defines a function to call when the effect creation has failed
  22143. */
  22144. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22145. private _processDefines;
  22146. /**
  22147. * Get if the submesh is ready to be used and all its information available.
  22148. * Child classes can use it to update shaders
  22149. * @param mesh defines the mesh to check
  22150. * @param subMesh defines which submesh to check
  22151. * @param useInstances specifies that instances should be used
  22152. * @returns a boolean indicating that the submesh is ready or not
  22153. */
  22154. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22155. /**
  22156. * Get a string representing the shaders built by the current node graph
  22157. */
  22158. get compiledShaders(): string;
  22159. /**
  22160. * Binds the world matrix to the material
  22161. * @param world defines the world transformation matrix
  22162. */
  22163. bindOnlyWorldMatrix(world: Matrix): void;
  22164. /**
  22165. * Binds the submesh to this material by preparing the effect and shader to draw
  22166. * @param world defines the world transformation matrix
  22167. * @param mesh defines the mesh containing the submesh
  22168. * @param subMesh defines the submesh to bind the material to
  22169. */
  22170. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22171. /**
  22172. * Gets the active textures from the material
  22173. * @returns an array of textures
  22174. */
  22175. getActiveTextures(): BaseTexture[];
  22176. /**
  22177. * Gets the list of texture blocks
  22178. * @returns an array of texture blocks
  22179. */
  22180. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22181. /**
  22182. * Specifies if the material uses a texture
  22183. * @param texture defines the texture to check against the material
  22184. * @returns a boolean specifying if the material uses the texture
  22185. */
  22186. hasTexture(texture: BaseTexture): boolean;
  22187. /**
  22188. * Disposes the material
  22189. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22190. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22191. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22192. */
  22193. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22194. /** Creates the node editor window. */
  22195. private _createNodeEditor;
  22196. /**
  22197. * Launch the node material editor
  22198. * @param config Define the configuration of the editor
  22199. * @return a promise fulfilled when the node editor is visible
  22200. */
  22201. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  22202. /**
  22203. * Clear the current material
  22204. */
  22205. clear(): void;
  22206. /**
  22207. * Clear the current material and set it to a default state
  22208. */
  22209. setToDefault(): void;
  22210. /**
  22211. * Clear the current material and set it to a default state for post process
  22212. */
  22213. setToDefaultPostProcess(): void;
  22214. /**
  22215. * Clear the current material and set it to a default state for particle
  22216. */
  22217. setToDefaultParticle(): void;
  22218. /**
  22219. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  22220. * @param url defines the url to load from
  22221. * @returns a promise that will fullfil when the material is fully loaded
  22222. */
  22223. loadAsync(url: string): Promise<void>;
  22224. private _gatherBlocks;
  22225. /**
  22226. * Generate a string containing the code declaration required to create an equivalent of this material
  22227. * @returns a string
  22228. */
  22229. generateCode(): string;
  22230. /**
  22231. * Serializes this material in a JSON representation
  22232. * @returns the serialized material object
  22233. */
  22234. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  22235. private _restoreConnections;
  22236. /**
  22237. * Clear the current graph and load a new one from a serialization object
  22238. * @param source defines the JSON representation of the material
  22239. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22240. */
  22241. loadFromSerialization(source: any, rootUrl?: string): void;
  22242. /**
  22243. * Makes a duplicate of the current material.
  22244. * @param name - name to use for the new material.
  22245. */
  22246. clone(name: string): NodeMaterial;
  22247. /**
  22248. * Creates a node material from parsed material data
  22249. * @param source defines the JSON representation of the material
  22250. * @param scene defines the hosting scene
  22251. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22252. * @returns a new node material
  22253. */
  22254. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  22255. /**
  22256. * Creates a node material from a snippet saved in a remote file
  22257. * @param name defines the name of the material to create
  22258. * @param url defines the url to load from
  22259. * @param scene defines the hosting scene
  22260. * @returns a promise that will resolve to the new node material
  22261. */
  22262. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  22263. /**
  22264. * Creates a node material from a snippet saved by the node material editor
  22265. * @param snippetId defines the snippet to load
  22266. * @param scene defines the hosting scene
  22267. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22268. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  22269. * @returns a promise that will resolve to the new node material
  22270. */
  22271. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  22272. /**
  22273. * Creates a new node material set to default basic configuration
  22274. * @param name defines the name of the material
  22275. * @param scene defines the hosting scene
  22276. * @returns a new NodeMaterial
  22277. */
  22278. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  22279. }
  22280. }
  22281. declare module BABYLON {
  22282. /**
  22283. * Size options for a post process
  22284. */
  22285. export type PostProcessOptions = {
  22286. width: number;
  22287. height: number;
  22288. };
  22289. /**
  22290. * PostProcess can be used to apply a shader to a texture after it has been rendered
  22291. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  22292. */
  22293. export class PostProcess {
  22294. /** Name of the PostProcess. */
  22295. name: string;
  22296. /**
  22297. * Gets or sets the unique id of the post process
  22298. */
  22299. uniqueId: number;
  22300. /**
  22301. * Width of the texture to apply the post process on
  22302. */
  22303. width: number;
  22304. /**
  22305. * Height of the texture to apply the post process on
  22306. */
  22307. height: number;
  22308. /**
  22309. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  22310. */
  22311. nodeMaterialSource: Nullable<NodeMaterial>;
  22312. /**
  22313. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  22314. * @hidden
  22315. */
  22316. _outputTexture: Nullable<InternalTexture>;
  22317. /**
  22318. * Sampling mode used by the shader
  22319. * See https://doc.babylonjs.com/classes/3.1/texture
  22320. */
  22321. renderTargetSamplingMode: number;
  22322. /**
  22323. * Clear color to use when screen clearing
  22324. */
  22325. clearColor: Color4;
  22326. /**
  22327. * If the buffer needs to be cleared before applying the post process. (default: true)
  22328. * Should be set to false if shader will overwrite all previous pixels.
  22329. */
  22330. autoClear: boolean;
  22331. /**
  22332. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  22333. */
  22334. alphaMode: number;
  22335. /**
  22336. * Sets the setAlphaBlendConstants of the babylon engine
  22337. */
  22338. alphaConstants: Color4;
  22339. /**
  22340. * Animations to be used for the post processing
  22341. */
  22342. animations: Animation[];
  22343. /**
  22344. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  22345. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  22346. */
  22347. enablePixelPerfectMode: boolean;
  22348. /**
  22349. * Force the postprocess to be applied without taking in account viewport
  22350. */
  22351. forceFullscreenViewport: boolean;
  22352. /**
  22353. * List of inspectable custom properties (used by the Inspector)
  22354. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22355. */
  22356. inspectableCustomProperties: IInspectable[];
  22357. /**
  22358. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  22359. *
  22360. * | Value | Type | Description |
  22361. * | ----- | ----------------------------------- | ----------- |
  22362. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  22363. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  22364. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  22365. *
  22366. */
  22367. scaleMode: number;
  22368. /**
  22369. * Force textures to be a power of two (default: false)
  22370. */
  22371. alwaysForcePOT: boolean;
  22372. private _samples;
  22373. /**
  22374. * Number of sample textures (default: 1)
  22375. */
  22376. get samples(): number;
  22377. set samples(n: number);
  22378. /**
  22379. * Modify the scale of the post process to be the same as the viewport (default: false)
  22380. */
  22381. adaptScaleToCurrentViewport: boolean;
  22382. private _camera;
  22383. private _scene;
  22384. private _engine;
  22385. private _options;
  22386. private _reusable;
  22387. private _textureType;
  22388. private _textureFormat;
  22389. /**
  22390. * Smart array of input and output textures for the post process.
  22391. * @hidden
  22392. */
  22393. _textures: SmartArray<InternalTexture>;
  22394. /**
  22395. * The index in _textures that corresponds to the output texture.
  22396. * @hidden
  22397. */
  22398. _currentRenderTextureInd: number;
  22399. private _effect;
  22400. private _samplers;
  22401. private _fragmentUrl;
  22402. private _vertexUrl;
  22403. private _parameters;
  22404. private _scaleRatio;
  22405. protected _indexParameters: any;
  22406. private _shareOutputWithPostProcess;
  22407. private _texelSize;
  22408. private _forcedOutputTexture;
  22409. /**
  22410. * Returns the fragment url or shader name used in the post process.
  22411. * @returns the fragment url or name in the shader store.
  22412. */
  22413. getEffectName(): string;
  22414. /**
  22415. * An event triggered when the postprocess is activated.
  22416. */
  22417. onActivateObservable: Observable<Camera>;
  22418. private _onActivateObserver;
  22419. /**
  22420. * A function that is added to the onActivateObservable
  22421. */
  22422. set onActivate(callback: Nullable<(camera: Camera) => void>);
  22423. /**
  22424. * An event triggered when the postprocess changes its size.
  22425. */
  22426. onSizeChangedObservable: Observable<PostProcess>;
  22427. private _onSizeChangedObserver;
  22428. /**
  22429. * A function that is added to the onSizeChangedObservable
  22430. */
  22431. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  22432. /**
  22433. * An event triggered when the postprocess applies its effect.
  22434. */
  22435. onApplyObservable: Observable<Effect>;
  22436. private _onApplyObserver;
  22437. /**
  22438. * A function that is added to the onApplyObservable
  22439. */
  22440. set onApply(callback: (effect: Effect) => void);
  22441. /**
  22442. * An event triggered before rendering the postprocess
  22443. */
  22444. onBeforeRenderObservable: Observable<Effect>;
  22445. private _onBeforeRenderObserver;
  22446. /**
  22447. * A function that is added to the onBeforeRenderObservable
  22448. */
  22449. set onBeforeRender(callback: (effect: Effect) => void);
  22450. /**
  22451. * An event triggered after rendering the postprocess
  22452. */
  22453. onAfterRenderObservable: Observable<Effect>;
  22454. private _onAfterRenderObserver;
  22455. /**
  22456. * A function that is added to the onAfterRenderObservable
  22457. */
  22458. set onAfterRender(callback: (efect: Effect) => void);
  22459. /**
  22460. * 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
  22461. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  22462. */
  22463. get inputTexture(): InternalTexture;
  22464. set inputTexture(value: InternalTexture);
  22465. /**
  22466. * Gets the camera which post process is applied to.
  22467. * @returns The camera the post process is applied to.
  22468. */
  22469. getCamera(): Camera;
  22470. /**
  22471. * Gets the texel size of the postprocess.
  22472. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  22473. */
  22474. get texelSize(): Vector2;
  22475. /**
  22476. * Creates a new instance PostProcess
  22477. * @param name The name of the PostProcess.
  22478. * @param fragmentUrl The url of the fragment shader to be used.
  22479. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  22480. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  22481. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22482. * @param camera The camera to apply the render pass to.
  22483. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22484. * @param engine The engine which the post process will be applied. (default: current engine)
  22485. * @param reusable If the post process can be reused on the same frame. (default: false)
  22486. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  22487. * @param textureType Type of textures used when performing the post process. (default: 0)
  22488. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  22489. * @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
  22490. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  22491. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22492. */
  22493. constructor(
  22494. /** Name of the PostProcess. */
  22495. 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, textureFormat?: number);
  22496. /**
  22497. * Gets a string idenfifying the name of the class
  22498. * @returns "PostProcess" string
  22499. */
  22500. getClassName(): string;
  22501. /**
  22502. * Gets the engine which this post process belongs to.
  22503. * @returns The engine the post process was enabled with.
  22504. */
  22505. getEngine(): Engine;
  22506. /**
  22507. * The effect that is created when initializing the post process.
  22508. * @returns The created effect corresponding the the postprocess.
  22509. */
  22510. getEffect(): Effect;
  22511. /**
  22512. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  22513. * @param postProcess The post process to share the output with.
  22514. * @returns This post process.
  22515. */
  22516. shareOutputWith(postProcess: PostProcess): PostProcess;
  22517. /**
  22518. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  22519. * This should be called if the post process that shares output with this post process is disabled/disposed.
  22520. */
  22521. useOwnOutput(): void;
  22522. /**
  22523. * Updates the effect with the current post process compile time values and recompiles the shader.
  22524. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22525. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22526. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22527. * @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
  22528. * @param onCompiled Called when the shader has been compiled.
  22529. * @param onError Called if there is an error when compiling a shader.
  22530. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  22531. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  22532. */
  22533. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, vertexUrl?: string, fragmentUrl?: string): void;
  22534. /**
  22535. * The post process is reusable if it can be used multiple times within one frame.
  22536. * @returns If the post process is reusable
  22537. */
  22538. isReusable(): boolean;
  22539. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  22540. markTextureDirty(): void;
  22541. /**
  22542. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  22543. * 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.
  22544. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  22545. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  22546. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  22547. * @returns The target texture that was bound to be written to.
  22548. */
  22549. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  22550. /**
  22551. * If the post process is supported.
  22552. */
  22553. get isSupported(): boolean;
  22554. /**
  22555. * The aspect ratio of the output texture.
  22556. */
  22557. get aspectRatio(): number;
  22558. /**
  22559. * Get a value indicating if the post-process is ready to be used
  22560. * @returns true if the post-process is ready (shader is compiled)
  22561. */
  22562. isReady(): boolean;
  22563. /**
  22564. * Binds all textures and uniforms to the shader, this will be run on every pass.
  22565. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  22566. */
  22567. apply(): Nullable<Effect>;
  22568. private _disposeTextures;
  22569. /**
  22570. * Disposes the post process.
  22571. * @param camera The camera to dispose the post process on.
  22572. */
  22573. dispose(camera?: Camera): void;
  22574. }
  22575. }
  22576. declare module BABYLON {
  22577. /** @hidden */
  22578. export var kernelBlurVaryingDeclaration: {
  22579. name: string;
  22580. shader: string;
  22581. };
  22582. }
  22583. declare module BABYLON {
  22584. /** @hidden */
  22585. export var kernelBlurFragment: {
  22586. name: string;
  22587. shader: string;
  22588. };
  22589. }
  22590. declare module BABYLON {
  22591. /** @hidden */
  22592. export var kernelBlurFragment2: {
  22593. name: string;
  22594. shader: string;
  22595. };
  22596. }
  22597. declare module BABYLON {
  22598. /** @hidden */
  22599. export var kernelBlurPixelShader: {
  22600. name: string;
  22601. shader: string;
  22602. };
  22603. }
  22604. declare module BABYLON {
  22605. /** @hidden */
  22606. export var kernelBlurVertex: {
  22607. name: string;
  22608. shader: string;
  22609. };
  22610. }
  22611. declare module BABYLON {
  22612. /** @hidden */
  22613. export var kernelBlurVertexShader: {
  22614. name: string;
  22615. shader: string;
  22616. };
  22617. }
  22618. declare module BABYLON {
  22619. /**
  22620. * The Blur Post Process which blurs an image based on a kernel and direction.
  22621. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  22622. */
  22623. export class BlurPostProcess extends PostProcess {
  22624. /** The direction in which to blur the image. */
  22625. direction: Vector2;
  22626. private blockCompilation;
  22627. protected _kernel: number;
  22628. protected _idealKernel: number;
  22629. protected _packedFloat: boolean;
  22630. private _staticDefines;
  22631. /**
  22632. * Sets the length in pixels of the blur sample region
  22633. */
  22634. set kernel(v: number);
  22635. /**
  22636. * Gets the length in pixels of the blur sample region
  22637. */
  22638. get kernel(): number;
  22639. /**
  22640. * Sets wether or not the blur needs to unpack/repack floats
  22641. */
  22642. set packedFloat(v: boolean);
  22643. /**
  22644. * Gets wether or not the blur is unpacking/repacking floats
  22645. */
  22646. get packedFloat(): boolean;
  22647. /**
  22648. * Creates a new instance BlurPostProcess
  22649. * @param name The name of the effect.
  22650. * @param direction The direction in which to blur the image.
  22651. * @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.
  22652. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22653. * @param camera The camera to apply the render pass to.
  22654. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22655. * @param engine The engine which the post process will be applied. (default: current engine)
  22656. * @param reusable If the post process can be reused on the same frame. (default: false)
  22657. * @param textureType Type of textures used when performing the post process. (default: 0)
  22658. * @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)
  22659. */
  22660. constructor(name: string,
  22661. /** The direction in which to blur the image. */
  22662. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  22663. /**
  22664. * Updates the effect with the current post process compile time values and recompiles the shader.
  22665. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22666. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22667. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22668. * @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
  22669. * @param onCompiled Called when the shader has been compiled.
  22670. * @param onError Called if there is an error when compiling a shader.
  22671. */
  22672. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22673. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22674. /**
  22675. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  22676. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  22677. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  22678. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  22679. * The gaps between physical kernels are compensated for in the weighting of the samples
  22680. * @param idealKernel Ideal blur kernel.
  22681. * @return Nearest best kernel.
  22682. */
  22683. protected _nearestBestKernel(idealKernel: number): number;
  22684. /**
  22685. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  22686. * @param x The point on the Gaussian distribution to sample.
  22687. * @return the value of the Gaussian function at x.
  22688. */
  22689. protected _gaussianWeight(x: number): number;
  22690. /**
  22691. * Generates a string that can be used as a floating point number in GLSL.
  22692. * @param x Value to print.
  22693. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  22694. * @return GLSL float string.
  22695. */
  22696. protected _glslFloat(x: number, decimalFigures?: number): string;
  22697. }
  22698. }
  22699. declare module BABYLON {
  22700. /**
  22701. * Mirror texture can be used to simulate the view from a mirror in a scene.
  22702. * It will dynamically be rendered every frame to adapt to the camera point of view.
  22703. * You can then easily use it as a reflectionTexture on a flat surface.
  22704. * In case the surface is not a plane, please consider relying on reflection probes.
  22705. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22706. */
  22707. export class MirrorTexture extends RenderTargetTexture {
  22708. private scene;
  22709. /**
  22710. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  22711. * 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.
  22712. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22713. */
  22714. mirrorPlane: Plane;
  22715. /**
  22716. * Define the blur ratio used to blur the reflection if needed.
  22717. */
  22718. set blurRatio(value: number);
  22719. get blurRatio(): number;
  22720. /**
  22721. * Define the adaptive blur kernel used to blur the reflection if needed.
  22722. * This will autocompute the closest best match for the `blurKernel`
  22723. */
  22724. set adaptiveBlurKernel(value: number);
  22725. /**
  22726. * Define the blur kernel used to blur the reflection if needed.
  22727. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22728. */
  22729. set blurKernel(value: number);
  22730. /**
  22731. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  22732. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22733. */
  22734. set blurKernelX(value: number);
  22735. get blurKernelX(): number;
  22736. /**
  22737. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  22738. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22739. */
  22740. set blurKernelY(value: number);
  22741. get blurKernelY(): number;
  22742. private _autoComputeBlurKernel;
  22743. protected _onRatioRescale(): void;
  22744. private _updateGammaSpace;
  22745. private _imageProcessingConfigChangeObserver;
  22746. private _transformMatrix;
  22747. private _mirrorMatrix;
  22748. private _savedViewMatrix;
  22749. private _blurX;
  22750. private _blurY;
  22751. private _adaptiveBlurKernel;
  22752. private _blurKernelX;
  22753. private _blurKernelY;
  22754. private _blurRatio;
  22755. /**
  22756. * Instantiates a Mirror Texture.
  22757. * Mirror texture can be used to simulate the view from a mirror in a scene.
  22758. * It will dynamically be rendered every frame to adapt to the camera point of view.
  22759. * You can then easily use it as a reflectionTexture on a flat surface.
  22760. * In case the surface is not a plane, please consider relying on reflection probes.
  22761. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22762. * @param name
  22763. * @param size
  22764. * @param scene
  22765. * @param generateMipMaps
  22766. * @param type
  22767. * @param samplingMode
  22768. * @param generateDepthBuffer
  22769. */
  22770. constructor(name: string, size: number | {
  22771. width: number;
  22772. height: number;
  22773. } | {
  22774. ratio: number;
  22775. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  22776. private _preparePostProcesses;
  22777. /**
  22778. * Clone the mirror texture.
  22779. * @returns the cloned texture
  22780. */
  22781. clone(): MirrorTexture;
  22782. /**
  22783. * Serialize the texture to a JSON representation you could use in Parse later on
  22784. * @returns the serialized JSON representation
  22785. */
  22786. serialize(): any;
  22787. /**
  22788. * Dispose the texture and release its associated resources.
  22789. */
  22790. dispose(): void;
  22791. }
  22792. }
  22793. declare module BABYLON {
  22794. /**
  22795. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  22796. * @see http://doc.babylonjs.com/babylon101/materials#texture
  22797. */
  22798. export class Texture extends BaseTexture {
  22799. /**
  22800. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  22801. */
  22802. static SerializeBuffers: boolean;
  22803. /** @hidden */
  22804. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  22805. /** @hidden */
  22806. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  22807. /** @hidden */
  22808. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  22809. /** nearest is mag = nearest and min = nearest and mip = linear */
  22810. static readonly NEAREST_SAMPLINGMODE: number;
  22811. /** nearest is mag = nearest and min = nearest and mip = linear */
  22812. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  22813. /** Bilinear is mag = linear and min = linear and mip = nearest */
  22814. static readonly BILINEAR_SAMPLINGMODE: number;
  22815. /** Bilinear is mag = linear and min = linear and mip = nearest */
  22816. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  22817. /** Trilinear is mag = linear and min = linear and mip = linear */
  22818. static readonly TRILINEAR_SAMPLINGMODE: number;
  22819. /** Trilinear is mag = linear and min = linear and mip = linear */
  22820. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  22821. /** mag = nearest and min = nearest and mip = nearest */
  22822. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  22823. /** mag = nearest and min = linear and mip = nearest */
  22824. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  22825. /** mag = nearest and min = linear and mip = linear */
  22826. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  22827. /** mag = nearest and min = linear and mip = none */
  22828. static readonly NEAREST_LINEAR: number;
  22829. /** mag = nearest and min = nearest and mip = none */
  22830. static readonly NEAREST_NEAREST: number;
  22831. /** mag = linear and min = nearest and mip = nearest */
  22832. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  22833. /** mag = linear and min = nearest and mip = linear */
  22834. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  22835. /** mag = linear and min = linear and mip = none */
  22836. static readonly LINEAR_LINEAR: number;
  22837. /** mag = linear and min = nearest and mip = none */
  22838. static readonly LINEAR_NEAREST: number;
  22839. /** Explicit coordinates mode */
  22840. static readonly EXPLICIT_MODE: number;
  22841. /** Spherical coordinates mode */
  22842. static readonly SPHERICAL_MODE: number;
  22843. /** Planar coordinates mode */
  22844. static readonly PLANAR_MODE: number;
  22845. /** Cubic coordinates mode */
  22846. static readonly CUBIC_MODE: number;
  22847. /** Projection coordinates mode */
  22848. static readonly PROJECTION_MODE: number;
  22849. /** Inverse Cubic coordinates mode */
  22850. static readonly SKYBOX_MODE: number;
  22851. /** Inverse Cubic coordinates mode */
  22852. static readonly INVCUBIC_MODE: number;
  22853. /** Equirectangular coordinates mode */
  22854. static readonly EQUIRECTANGULAR_MODE: number;
  22855. /** Equirectangular Fixed coordinates mode */
  22856. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  22857. /** Equirectangular Fixed Mirrored coordinates mode */
  22858. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  22859. /** Texture is not repeating outside of 0..1 UVs */
  22860. static readonly CLAMP_ADDRESSMODE: number;
  22861. /** Texture is repeating outside of 0..1 UVs */
  22862. static readonly WRAP_ADDRESSMODE: number;
  22863. /** Texture is repeating and mirrored */
  22864. static readonly MIRROR_ADDRESSMODE: number;
  22865. /**
  22866. * 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
  22867. */
  22868. static UseSerializedUrlIfAny: boolean;
  22869. /**
  22870. * Define the url of the texture.
  22871. */
  22872. url: Nullable<string>;
  22873. /**
  22874. * Define an offset on the texture to offset the u coordinates of the UVs
  22875. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  22876. */
  22877. uOffset: number;
  22878. /**
  22879. * Define an offset on the texture to offset the v coordinates of the UVs
  22880. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  22881. */
  22882. vOffset: number;
  22883. /**
  22884. * Define an offset on the texture to scale the u coordinates of the UVs
  22885. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  22886. */
  22887. uScale: number;
  22888. /**
  22889. * Define an offset on the texture to scale the v coordinates of the UVs
  22890. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  22891. */
  22892. vScale: number;
  22893. /**
  22894. * Define an offset on the texture to rotate around the u coordinates of the UVs
  22895. * @see http://doc.babylonjs.com/how_to/more_materials
  22896. */
  22897. uAng: number;
  22898. /**
  22899. * Define an offset on the texture to rotate around the v coordinates of the UVs
  22900. * @see http://doc.babylonjs.com/how_to/more_materials
  22901. */
  22902. vAng: number;
  22903. /**
  22904. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  22905. * @see http://doc.babylonjs.com/how_to/more_materials
  22906. */
  22907. wAng: number;
  22908. /**
  22909. * Defines the center of rotation (U)
  22910. */
  22911. uRotationCenter: number;
  22912. /**
  22913. * Defines the center of rotation (V)
  22914. */
  22915. vRotationCenter: number;
  22916. /**
  22917. * Defines the center of rotation (W)
  22918. */
  22919. wRotationCenter: number;
  22920. /**
  22921. * Are mip maps generated for this texture or not.
  22922. */
  22923. get noMipmap(): boolean;
  22924. /**
  22925. * List of inspectable custom properties (used by the Inspector)
  22926. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22927. */
  22928. inspectableCustomProperties: Nullable<IInspectable[]>;
  22929. private _noMipmap;
  22930. /** @hidden */
  22931. _invertY: boolean;
  22932. private _rowGenerationMatrix;
  22933. private _cachedTextureMatrix;
  22934. private _projectionModeMatrix;
  22935. private _t0;
  22936. private _t1;
  22937. private _t2;
  22938. private _cachedUOffset;
  22939. private _cachedVOffset;
  22940. private _cachedUScale;
  22941. private _cachedVScale;
  22942. private _cachedUAng;
  22943. private _cachedVAng;
  22944. private _cachedWAng;
  22945. private _cachedProjectionMatrixId;
  22946. private _cachedCoordinatesMode;
  22947. /** @hidden */
  22948. protected _initialSamplingMode: number;
  22949. /** @hidden */
  22950. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  22951. private _deleteBuffer;
  22952. protected _format: Nullable<number>;
  22953. private _delayedOnLoad;
  22954. private _delayedOnError;
  22955. private _mimeType?;
  22956. /**
  22957. * Observable triggered once the texture has been loaded.
  22958. */
  22959. onLoadObservable: Observable<Texture>;
  22960. protected _isBlocking: boolean;
  22961. /**
  22962. * Is the texture preventing material to render while loading.
  22963. * If false, a default texture will be used instead of the loading one during the preparation step.
  22964. */
  22965. set isBlocking(value: boolean);
  22966. get isBlocking(): boolean;
  22967. /**
  22968. * Get the current sampling mode associated with the texture.
  22969. */
  22970. get samplingMode(): number;
  22971. /**
  22972. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  22973. */
  22974. get invertY(): boolean;
  22975. /**
  22976. * Instantiates a new texture.
  22977. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  22978. * @see http://doc.babylonjs.com/babylon101/materials#texture
  22979. * @param url defines the url of the picture to load as a texture
  22980. * @param sceneOrEngine defines the scene or engine the texture will belong to
  22981. * @param noMipmap defines if the texture will require mip maps or not
  22982. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  22983. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  22984. * @param onLoad defines a callback triggered when the texture has been loaded
  22985. * @param onError defines a callback triggered when an error occurred during the loading session
  22986. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  22987. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  22988. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  22989. * @param mimeType defines an optional mime type information
  22990. */
  22991. 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);
  22992. /**
  22993. * Update the url (and optional buffer) of this texture if url was null during construction.
  22994. * @param url the url of the texture
  22995. * @param buffer the buffer of the texture (defaults to null)
  22996. * @param onLoad callback called when the texture is loaded (defaults to null)
  22997. */
  22998. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  22999. /**
  23000. * Finish the loading sequence of a texture flagged as delayed load.
  23001. * @hidden
  23002. */
  23003. delayLoad(): void;
  23004. private _prepareRowForTextureGeneration;
  23005. /**
  23006. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23007. * @returns the transform matrix of the texture.
  23008. */
  23009. getTextureMatrix(uBase?: number): Matrix;
  23010. /**
  23011. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23012. * @returns The reflection texture transform
  23013. */
  23014. getReflectionTextureMatrix(): Matrix;
  23015. /**
  23016. * Clones the texture.
  23017. * @returns the cloned texture
  23018. */
  23019. clone(): Texture;
  23020. /**
  23021. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23022. * @returns The JSON representation of the texture
  23023. */
  23024. serialize(): any;
  23025. /**
  23026. * Get the current class name of the texture useful for serialization or dynamic coding.
  23027. * @returns "Texture"
  23028. */
  23029. getClassName(): string;
  23030. /**
  23031. * Dispose the texture and release its associated resources.
  23032. */
  23033. dispose(): void;
  23034. /**
  23035. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  23036. * @param parsedTexture Define the JSON representation of the texture
  23037. * @param scene Define the scene the parsed texture should be instantiated in
  23038. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  23039. * @returns The parsed texture if successful
  23040. */
  23041. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  23042. /**
  23043. * Creates a texture from its base 64 representation.
  23044. * @param data Define the base64 payload without the data: prefix
  23045. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23046. * @param scene Define the scene the texture should belong to
  23047. * @param noMipmap Forces the texture to not create mip map information if true
  23048. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23049. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23050. * @param onLoad define a callback triggered when the texture has been loaded
  23051. * @param onError define a callback triggered when an error occurred during the loading session
  23052. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23053. * @returns the created texture
  23054. */
  23055. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  23056. /**
  23057. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  23058. * @param data Define the base64 payload without the data: prefix
  23059. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23060. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  23061. * @param scene Define the scene the texture should belong to
  23062. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  23063. * @param noMipmap Forces the texture to not create mip map information if true
  23064. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23065. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23066. * @param onLoad define a callback triggered when the texture has been loaded
  23067. * @param onError define a callback triggered when an error occurred during the loading session
  23068. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23069. * @returns the created texture
  23070. */
  23071. 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;
  23072. }
  23073. }
  23074. declare module BABYLON {
  23075. /**
  23076. * PostProcessManager is used to manage one or more post processes or post process pipelines
  23077. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23078. */
  23079. export class PostProcessManager {
  23080. private _scene;
  23081. private _indexBuffer;
  23082. private _vertexBuffers;
  23083. /**
  23084. * Creates a new instance PostProcess
  23085. * @param scene The scene that the post process is associated with.
  23086. */
  23087. constructor(scene: Scene);
  23088. private _prepareBuffers;
  23089. private _buildIndexBuffer;
  23090. /**
  23091. * Rebuilds the vertex buffers of the manager.
  23092. * @hidden
  23093. */
  23094. _rebuild(): void;
  23095. /**
  23096. * Prepares a frame to be run through a post process.
  23097. * @param sourceTexture The input texture to the post procesess. (default: null)
  23098. * @param postProcesses An array of post processes to be run. (default: null)
  23099. * @returns True if the post processes were able to be run.
  23100. * @hidden
  23101. */
  23102. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  23103. /**
  23104. * Manually render a set of post processes to a texture.
  23105. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  23106. * @param postProcesses An array of post processes to be run.
  23107. * @param targetTexture The target texture to render to.
  23108. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  23109. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  23110. * @param lodLevel defines which lod of the texture to render to
  23111. */
  23112. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  23113. /**
  23114. * Finalize the result of the output of the postprocesses.
  23115. * @param doNotPresent If true the result will not be displayed to the screen.
  23116. * @param targetTexture The target texture to render to.
  23117. * @param faceIndex The index of the face to bind the target texture to.
  23118. * @param postProcesses The array of post processes to render.
  23119. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  23120. * @hidden
  23121. */
  23122. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  23123. /**
  23124. * Disposes of the post process manager.
  23125. */
  23126. dispose(): void;
  23127. }
  23128. }
  23129. declare module BABYLON {
  23130. /**
  23131. * This Helps creating a texture that will be created from a camera in your scene.
  23132. * It is basically a dynamic texture that could be used to create special effects for instance.
  23133. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  23134. */
  23135. export class RenderTargetTexture extends Texture {
  23136. isCube: boolean;
  23137. /**
  23138. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  23139. */
  23140. static readonly REFRESHRATE_RENDER_ONCE: number;
  23141. /**
  23142. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  23143. */
  23144. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  23145. /**
  23146. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  23147. * the central point of your effect and can save a lot of performances.
  23148. */
  23149. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  23150. /**
  23151. * Use this predicate to dynamically define the list of mesh you want to render.
  23152. * If set, the renderList property will be overwritten.
  23153. */
  23154. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  23155. private _renderList;
  23156. /**
  23157. * Use this list to define the list of mesh you want to render.
  23158. */
  23159. get renderList(): Nullable<Array<AbstractMesh>>;
  23160. set renderList(value: Nullable<Array<AbstractMesh>>);
  23161. /**
  23162. * Use this function to overload the renderList array at rendering time.
  23163. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  23164. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  23165. * the cube (if the RTT is a cube, else layerOrFace=0).
  23166. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  23167. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  23168. * hold dummy elements!
  23169. */
  23170. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  23171. private _hookArray;
  23172. /**
  23173. * Define if particles should be rendered in your texture.
  23174. */
  23175. renderParticles: boolean;
  23176. /**
  23177. * Define if sprites should be rendered in your texture.
  23178. */
  23179. renderSprites: boolean;
  23180. /**
  23181. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  23182. */
  23183. coordinatesMode: number;
  23184. /**
  23185. * Define the camera used to render the texture.
  23186. */
  23187. activeCamera: Nullable<Camera>;
  23188. /**
  23189. * Override the mesh isReady function with your own one.
  23190. */
  23191. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  23192. /**
  23193. * Override the render function of the texture with your own one.
  23194. */
  23195. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  23196. /**
  23197. * Define if camera post processes should be use while rendering the texture.
  23198. */
  23199. useCameraPostProcesses: boolean;
  23200. /**
  23201. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  23202. */
  23203. ignoreCameraViewport: boolean;
  23204. private _postProcessManager;
  23205. private _postProcesses;
  23206. private _resizeObserver;
  23207. /**
  23208. * An event triggered when the texture is unbind.
  23209. */
  23210. onBeforeBindObservable: Observable<RenderTargetTexture>;
  23211. /**
  23212. * An event triggered when the texture is unbind.
  23213. */
  23214. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  23215. private _onAfterUnbindObserver;
  23216. /**
  23217. * Set a after unbind callback in the texture.
  23218. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  23219. */
  23220. set onAfterUnbind(callback: () => void);
  23221. /**
  23222. * An event triggered before rendering the texture
  23223. */
  23224. onBeforeRenderObservable: Observable<number>;
  23225. private _onBeforeRenderObserver;
  23226. /**
  23227. * Set a before render callback in the texture.
  23228. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  23229. */
  23230. set onBeforeRender(callback: (faceIndex: number) => void);
  23231. /**
  23232. * An event triggered after rendering the texture
  23233. */
  23234. onAfterRenderObservable: Observable<number>;
  23235. private _onAfterRenderObserver;
  23236. /**
  23237. * Set a after render callback in the texture.
  23238. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  23239. */
  23240. set onAfterRender(callback: (faceIndex: number) => void);
  23241. /**
  23242. * An event triggered after the texture clear
  23243. */
  23244. onClearObservable: Observable<Engine>;
  23245. private _onClearObserver;
  23246. /**
  23247. * Set a clear callback in the texture.
  23248. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  23249. */
  23250. set onClear(callback: (Engine: Engine) => void);
  23251. /**
  23252. * An event triggered when the texture is resized.
  23253. */
  23254. onResizeObservable: Observable<RenderTargetTexture>;
  23255. /**
  23256. * Define the clear color of the Render Target if it should be different from the scene.
  23257. */
  23258. clearColor: Color4;
  23259. protected _size: number | {
  23260. width: number;
  23261. height: number;
  23262. layers?: number;
  23263. };
  23264. protected _initialSizeParameter: number | {
  23265. width: number;
  23266. height: number;
  23267. } | {
  23268. ratio: number;
  23269. };
  23270. protected _sizeRatio: Nullable<number>;
  23271. /** @hidden */
  23272. _generateMipMaps: boolean;
  23273. protected _renderingManager: RenderingManager;
  23274. /** @hidden */
  23275. _waitingRenderList: string[];
  23276. protected _doNotChangeAspectRatio: boolean;
  23277. protected _currentRefreshId: number;
  23278. protected _refreshRate: number;
  23279. protected _textureMatrix: Matrix;
  23280. protected _samples: number;
  23281. protected _renderTargetOptions: RenderTargetCreationOptions;
  23282. /**
  23283. * Gets render target creation options that were used.
  23284. */
  23285. get renderTargetOptions(): RenderTargetCreationOptions;
  23286. protected _onRatioRescale(): void;
  23287. /**
  23288. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  23289. * It must define where the camera used to render the texture is set
  23290. */
  23291. boundingBoxPosition: Vector3;
  23292. private _boundingBoxSize;
  23293. /**
  23294. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  23295. * When defined, the cubemap will switch to local mode
  23296. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  23297. * @example https://www.babylonjs-playground.com/#RNASML
  23298. */
  23299. set boundingBoxSize(value: Vector3);
  23300. get boundingBoxSize(): Vector3;
  23301. /**
  23302. * In case the RTT has been created with a depth texture, get the associated
  23303. * depth texture.
  23304. * Otherwise, return null.
  23305. */
  23306. get depthStencilTexture(): Nullable<InternalTexture>;
  23307. /**
  23308. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  23309. * or used a shadow, depth texture...
  23310. * @param name The friendly name of the texture
  23311. * @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)
  23312. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  23313. * @param generateMipMaps True if mip maps need to be generated after render.
  23314. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  23315. * @param type The type of the buffer in the RTT (int, half float, float...)
  23316. * @param isCube True if a cube texture needs to be created
  23317. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  23318. * @param generateDepthBuffer True to generate a depth buffer
  23319. * @param generateStencilBuffer True to generate a stencil buffer
  23320. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  23321. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  23322. * @param delayAllocation if the texture allocation should be delayed (default: false)
  23323. */
  23324. constructor(name: string, size: number | {
  23325. width: number;
  23326. height: number;
  23327. layers?: number;
  23328. } | {
  23329. ratio: number;
  23330. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  23331. /**
  23332. * Creates a depth stencil texture.
  23333. * This is only available in WebGL 2 or with the depth texture extension available.
  23334. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  23335. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  23336. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  23337. */
  23338. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  23339. private _processSizeParameter;
  23340. /**
  23341. * Define the number of samples to use in case of MSAA.
  23342. * It defaults to one meaning no MSAA has been enabled.
  23343. */
  23344. get samples(): number;
  23345. set samples(value: number);
  23346. /**
  23347. * Resets the refresh counter of the texture and start bak from scratch.
  23348. * Could be useful to regenerate the texture if it is setup to render only once.
  23349. */
  23350. resetRefreshCounter(): void;
  23351. /**
  23352. * Define the refresh rate of the texture or the rendering frequency.
  23353. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  23354. */
  23355. get refreshRate(): number;
  23356. set refreshRate(value: number);
  23357. /**
  23358. * Adds a post process to the render target rendering passes.
  23359. * @param postProcess define the post process to add
  23360. */
  23361. addPostProcess(postProcess: PostProcess): void;
  23362. /**
  23363. * Clear all the post processes attached to the render target
  23364. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  23365. */
  23366. clearPostProcesses(dispose?: boolean): void;
  23367. /**
  23368. * Remove one of the post process from the list of attached post processes to the texture
  23369. * @param postProcess define the post process to remove from the list
  23370. */
  23371. removePostProcess(postProcess: PostProcess): void;
  23372. /** @hidden */
  23373. _shouldRender(): boolean;
  23374. /**
  23375. * Gets the actual render size of the texture.
  23376. * @returns the width of the render size
  23377. */
  23378. getRenderSize(): number;
  23379. /**
  23380. * Gets the actual render width of the texture.
  23381. * @returns the width of the render size
  23382. */
  23383. getRenderWidth(): number;
  23384. /**
  23385. * Gets the actual render height of the texture.
  23386. * @returns the height of the render size
  23387. */
  23388. getRenderHeight(): number;
  23389. /**
  23390. * Gets the actual number of layers of the texture.
  23391. * @returns the number of layers
  23392. */
  23393. getRenderLayers(): number;
  23394. /**
  23395. * Get if the texture can be rescaled or not.
  23396. */
  23397. get canRescale(): boolean;
  23398. /**
  23399. * Resize the texture using a ratio.
  23400. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  23401. */
  23402. scale(ratio: number): void;
  23403. /**
  23404. * Get the texture reflection matrix used to rotate/transform the reflection.
  23405. * @returns the reflection matrix
  23406. */
  23407. getReflectionTextureMatrix(): Matrix;
  23408. /**
  23409. * Resize the texture to a new desired size.
  23410. * Be carrefull as it will recreate all the data in the new texture.
  23411. * @param size Define the new size. It can be:
  23412. * - a number for squared texture,
  23413. * - an object containing { width: number, height: number }
  23414. * - or an object containing a ratio { ratio: number }
  23415. */
  23416. resize(size: number | {
  23417. width: number;
  23418. height: number;
  23419. } | {
  23420. ratio: number;
  23421. }): void;
  23422. private _defaultRenderListPrepared;
  23423. /**
  23424. * Renders all the objects from the render list into the texture.
  23425. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  23426. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  23427. */
  23428. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  23429. private _bestReflectionRenderTargetDimension;
  23430. private _prepareRenderingManager;
  23431. /**
  23432. * @hidden
  23433. * @param faceIndex face index to bind to if this is a cubetexture
  23434. * @param layer defines the index of the texture to bind in the array
  23435. */
  23436. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  23437. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  23438. private renderToTarget;
  23439. /**
  23440. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  23441. * This allowed control for front to back rendering or reversly depending of the special needs.
  23442. *
  23443. * @param renderingGroupId The rendering group id corresponding to its index
  23444. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  23445. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  23446. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  23447. */
  23448. 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;
  23449. /**
  23450. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  23451. *
  23452. * @param renderingGroupId The rendering group id corresponding to its index
  23453. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  23454. */
  23455. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  23456. /**
  23457. * Clones the texture.
  23458. * @returns the cloned texture
  23459. */
  23460. clone(): RenderTargetTexture;
  23461. /**
  23462. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23463. * @returns The JSON representation of the texture
  23464. */
  23465. serialize(): any;
  23466. /**
  23467. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  23468. */
  23469. disposeFramebufferObjects(): void;
  23470. /**
  23471. * Dispose the texture and release its associated resources.
  23472. */
  23473. dispose(): void;
  23474. /** @hidden */
  23475. _rebuild(): void;
  23476. /**
  23477. * Clear the info related to rendering groups preventing retention point in material dispose.
  23478. */
  23479. freeRenderingGroups(): void;
  23480. /**
  23481. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  23482. * @returns the view count
  23483. */
  23484. getViewCount(): number;
  23485. }
  23486. }
  23487. declare module BABYLON {
  23488. /**
  23489. * Class used to manipulate GUIDs
  23490. */
  23491. export class GUID {
  23492. /**
  23493. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23494. * Be aware Math.random() could cause collisions, but:
  23495. * "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"
  23496. * @returns a pseudo random id
  23497. */
  23498. static RandomId(): string;
  23499. }
  23500. }
  23501. declare module BABYLON {
  23502. /**
  23503. * Options to be used when creating a shadow depth material
  23504. */
  23505. export interface IIOptionShadowDepthMaterial {
  23506. /** Variables in the vertex shader code that need to have their names remapped.
  23507. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  23508. * "var_name" should be either: worldPos or vNormalW
  23509. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  23510. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  23511. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  23512. */
  23513. remappedVariables?: string[];
  23514. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  23515. standalone?: boolean;
  23516. }
  23517. /**
  23518. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  23519. */
  23520. export class ShadowDepthWrapper {
  23521. private _scene;
  23522. private _options?;
  23523. private _baseMaterial;
  23524. private _onEffectCreatedObserver;
  23525. private _subMeshToEffect;
  23526. private _subMeshToDepthEffect;
  23527. private _meshes;
  23528. /** @hidden */
  23529. _matriceNames: any;
  23530. /** Gets the standalone status of the wrapper */
  23531. get standalone(): boolean;
  23532. /** Gets the base material the wrapper is built upon */
  23533. get baseMaterial(): Material;
  23534. /**
  23535. * Instantiate a new shadow depth wrapper.
  23536. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  23537. * generate the shadow depth map. For more information, please refer to the documentation:
  23538. * https://doc.babylonjs.com/babylon101/shadows
  23539. * @param baseMaterial Material to wrap
  23540. * @param scene Define the scene the material belongs to
  23541. * @param options Options used to create the wrapper
  23542. */
  23543. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  23544. /**
  23545. * Gets the effect to use to generate the depth map
  23546. * @param subMesh subMesh to get the effect for
  23547. * @param shadowGenerator shadow generator to get the effect for
  23548. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  23549. */
  23550. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  23551. /**
  23552. * Specifies that the submesh is ready to be used for depth rendering
  23553. * @param subMesh submesh to check
  23554. * @param defines the list of defines to take into account when checking the effect
  23555. * @param shadowGenerator combined with subMesh, it defines the effect to check
  23556. * @param useInstances specifies that instances should be used
  23557. * @returns a boolean indicating that the submesh is ready or not
  23558. */
  23559. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  23560. /**
  23561. * Disposes the resources
  23562. */
  23563. dispose(): void;
  23564. private _makeEffect;
  23565. }
  23566. }
  23567. declare module BABYLON {
  23568. /**
  23569. * Options for compiling materials.
  23570. */
  23571. export interface IMaterialCompilationOptions {
  23572. /**
  23573. * Defines whether clip planes are enabled.
  23574. */
  23575. clipPlane: boolean;
  23576. /**
  23577. * Defines whether instances are enabled.
  23578. */
  23579. useInstances: boolean;
  23580. }
  23581. /**
  23582. * Base class for the main features of a material in Babylon.js
  23583. */
  23584. export class Material implements IAnimatable {
  23585. /**
  23586. * Returns the triangle fill mode
  23587. */
  23588. static readonly TriangleFillMode: number;
  23589. /**
  23590. * Returns the wireframe mode
  23591. */
  23592. static readonly WireFrameFillMode: number;
  23593. /**
  23594. * Returns the point fill mode
  23595. */
  23596. static readonly PointFillMode: number;
  23597. /**
  23598. * Returns the point list draw mode
  23599. */
  23600. static readonly PointListDrawMode: number;
  23601. /**
  23602. * Returns the line list draw mode
  23603. */
  23604. static readonly LineListDrawMode: number;
  23605. /**
  23606. * Returns the line loop draw mode
  23607. */
  23608. static readonly LineLoopDrawMode: number;
  23609. /**
  23610. * Returns the line strip draw mode
  23611. */
  23612. static readonly LineStripDrawMode: number;
  23613. /**
  23614. * Returns the triangle strip draw mode
  23615. */
  23616. static readonly TriangleStripDrawMode: number;
  23617. /**
  23618. * Returns the triangle fan draw mode
  23619. */
  23620. static readonly TriangleFanDrawMode: number;
  23621. /**
  23622. * Stores the clock-wise side orientation
  23623. */
  23624. static readonly ClockWiseSideOrientation: number;
  23625. /**
  23626. * Stores the counter clock-wise side orientation
  23627. */
  23628. static readonly CounterClockWiseSideOrientation: number;
  23629. /**
  23630. * The dirty texture flag value
  23631. */
  23632. static readonly TextureDirtyFlag: number;
  23633. /**
  23634. * The dirty light flag value
  23635. */
  23636. static readonly LightDirtyFlag: number;
  23637. /**
  23638. * The dirty fresnel flag value
  23639. */
  23640. static readonly FresnelDirtyFlag: number;
  23641. /**
  23642. * The dirty attribute flag value
  23643. */
  23644. static readonly AttributesDirtyFlag: number;
  23645. /**
  23646. * The dirty misc flag value
  23647. */
  23648. static readonly MiscDirtyFlag: number;
  23649. /**
  23650. * The all dirty flag value
  23651. */
  23652. static readonly AllDirtyFlag: number;
  23653. /**
  23654. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  23655. */
  23656. static readonly MATERIAL_OPAQUE: number;
  23657. /**
  23658. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  23659. */
  23660. static readonly MATERIAL_ALPHATEST: number;
  23661. /**
  23662. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  23663. */
  23664. static readonly MATERIAL_ALPHABLEND: number;
  23665. /**
  23666. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  23667. * They are also discarded below the alpha cutoff threshold to improve performances.
  23668. */
  23669. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  23670. /**
  23671. * Custom callback helping to override the default shader used in the material.
  23672. */
  23673. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[]) => string;
  23674. /**
  23675. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  23676. */
  23677. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  23678. /**
  23679. * The ID of the material
  23680. */
  23681. id: string;
  23682. /**
  23683. * Gets or sets the unique id of the material
  23684. */
  23685. uniqueId: number;
  23686. /**
  23687. * The name of the material
  23688. */
  23689. name: string;
  23690. /**
  23691. * Gets or sets user defined metadata
  23692. */
  23693. metadata: any;
  23694. /**
  23695. * For internal use only. Please do not use.
  23696. */
  23697. reservedDataStore: any;
  23698. /**
  23699. * Specifies if the ready state should be checked on each call
  23700. */
  23701. checkReadyOnEveryCall: boolean;
  23702. /**
  23703. * Specifies if the ready state should be checked once
  23704. */
  23705. checkReadyOnlyOnce: boolean;
  23706. /**
  23707. * The state of the material
  23708. */
  23709. state: string;
  23710. /**
  23711. * The alpha value of the material
  23712. */
  23713. protected _alpha: number;
  23714. /**
  23715. * List of inspectable custom properties (used by the Inspector)
  23716. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23717. */
  23718. inspectableCustomProperties: IInspectable[];
  23719. /**
  23720. * Sets the alpha value of the material
  23721. */
  23722. set alpha(value: number);
  23723. /**
  23724. * Gets the alpha value of the material
  23725. */
  23726. get alpha(): number;
  23727. /**
  23728. * Specifies if back face culling is enabled
  23729. */
  23730. protected _backFaceCulling: boolean;
  23731. /**
  23732. * Sets the back-face culling state
  23733. */
  23734. set backFaceCulling(value: boolean);
  23735. /**
  23736. * Gets the back-face culling state
  23737. */
  23738. get backFaceCulling(): boolean;
  23739. /**
  23740. * Stores the value for side orientation
  23741. */
  23742. sideOrientation: number;
  23743. /**
  23744. * Callback triggered when the material is compiled
  23745. */
  23746. onCompiled: Nullable<(effect: Effect) => void>;
  23747. /**
  23748. * Callback triggered when an error occurs
  23749. */
  23750. onError: Nullable<(effect: Effect, errors: string) => void>;
  23751. /**
  23752. * Callback triggered to get the render target textures
  23753. */
  23754. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  23755. /**
  23756. * Gets a boolean indicating that current material needs to register RTT
  23757. */
  23758. get hasRenderTargetTextures(): boolean;
  23759. /**
  23760. * Specifies if the material should be serialized
  23761. */
  23762. doNotSerialize: boolean;
  23763. /**
  23764. * @hidden
  23765. */
  23766. _storeEffectOnSubMeshes: boolean;
  23767. /**
  23768. * Stores the animations for the material
  23769. */
  23770. animations: Nullable<Array<Animation>>;
  23771. /**
  23772. * An event triggered when the material is disposed
  23773. */
  23774. onDisposeObservable: Observable<Material>;
  23775. /**
  23776. * An observer which watches for dispose events
  23777. */
  23778. private _onDisposeObserver;
  23779. private _onUnBindObservable;
  23780. /**
  23781. * Called during a dispose event
  23782. */
  23783. set onDispose(callback: () => void);
  23784. private _onBindObservable;
  23785. /**
  23786. * An event triggered when the material is bound
  23787. */
  23788. get onBindObservable(): Observable<AbstractMesh>;
  23789. /**
  23790. * An observer which watches for bind events
  23791. */
  23792. private _onBindObserver;
  23793. /**
  23794. * Called during a bind event
  23795. */
  23796. set onBind(callback: (Mesh: AbstractMesh) => void);
  23797. /**
  23798. * An event triggered when the material is unbound
  23799. */
  23800. get onUnBindObservable(): Observable<Material>;
  23801. protected _onEffectCreatedObservable: Nullable<Observable<{
  23802. effect: Effect;
  23803. subMesh: Nullable<SubMesh>;
  23804. }>>;
  23805. /**
  23806. * An event triggered when the effect is (re)created
  23807. */
  23808. get onEffectCreatedObservable(): Observable<{
  23809. effect: Effect;
  23810. subMesh: Nullable<SubMesh>;
  23811. }>;
  23812. /**
  23813. * Stores the value of the alpha mode
  23814. */
  23815. private _alphaMode;
  23816. /**
  23817. * Sets the value of the alpha mode.
  23818. *
  23819. * | Value | Type | Description |
  23820. * | --- | --- | --- |
  23821. * | 0 | ALPHA_DISABLE | |
  23822. * | 1 | ALPHA_ADD | |
  23823. * | 2 | ALPHA_COMBINE | |
  23824. * | 3 | ALPHA_SUBTRACT | |
  23825. * | 4 | ALPHA_MULTIPLY | |
  23826. * | 5 | ALPHA_MAXIMIZED | |
  23827. * | 6 | ALPHA_ONEONE | |
  23828. * | 7 | ALPHA_PREMULTIPLIED | |
  23829. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  23830. * | 9 | ALPHA_INTERPOLATE | |
  23831. * | 10 | ALPHA_SCREENMODE | |
  23832. *
  23833. */
  23834. set alphaMode(value: number);
  23835. /**
  23836. * Gets the value of the alpha mode
  23837. */
  23838. get alphaMode(): number;
  23839. /**
  23840. * Stores the state of the need depth pre-pass value
  23841. */
  23842. private _needDepthPrePass;
  23843. /**
  23844. * Sets the need depth pre-pass value
  23845. */
  23846. set needDepthPrePass(value: boolean);
  23847. /**
  23848. * Gets the depth pre-pass value
  23849. */
  23850. get needDepthPrePass(): boolean;
  23851. /**
  23852. * Specifies if depth writing should be disabled
  23853. */
  23854. disableDepthWrite: boolean;
  23855. /**
  23856. * Specifies if color writing should be disabled
  23857. */
  23858. disableColorWrite: boolean;
  23859. /**
  23860. * Specifies if depth writing should be forced
  23861. */
  23862. forceDepthWrite: boolean;
  23863. /**
  23864. * Specifies the depth function that should be used. 0 means the default engine function
  23865. */
  23866. depthFunction: number;
  23867. /**
  23868. * Specifies if there should be a separate pass for culling
  23869. */
  23870. separateCullingPass: boolean;
  23871. /**
  23872. * Stores the state specifing if fog should be enabled
  23873. */
  23874. private _fogEnabled;
  23875. /**
  23876. * Sets the state for enabling fog
  23877. */
  23878. set fogEnabled(value: boolean);
  23879. /**
  23880. * Gets the value of the fog enabled state
  23881. */
  23882. get fogEnabled(): boolean;
  23883. /**
  23884. * Stores the size of points
  23885. */
  23886. pointSize: number;
  23887. /**
  23888. * Stores the z offset value
  23889. */
  23890. zOffset: number;
  23891. get wireframe(): boolean;
  23892. /**
  23893. * Sets the state of wireframe mode
  23894. */
  23895. set wireframe(value: boolean);
  23896. /**
  23897. * Gets the value specifying if point clouds are enabled
  23898. */
  23899. get pointsCloud(): boolean;
  23900. /**
  23901. * Sets the state of point cloud mode
  23902. */
  23903. set pointsCloud(value: boolean);
  23904. /**
  23905. * Gets the material fill mode
  23906. */
  23907. get fillMode(): number;
  23908. /**
  23909. * Sets the material fill mode
  23910. */
  23911. set fillMode(value: number);
  23912. /**
  23913. * @hidden
  23914. * Stores the effects for the material
  23915. */
  23916. _effect: Nullable<Effect>;
  23917. /**
  23918. * Specifies if uniform buffers should be used
  23919. */
  23920. private _useUBO;
  23921. /**
  23922. * Stores a reference to the scene
  23923. */
  23924. private _scene;
  23925. /**
  23926. * Stores the fill mode state
  23927. */
  23928. private _fillMode;
  23929. /**
  23930. * Specifies if the depth write state should be cached
  23931. */
  23932. private _cachedDepthWriteState;
  23933. /**
  23934. * Specifies if the color write state should be cached
  23935. */
  23936. private _cachedColorWriteState;
  23937. /**
  23938. * Specifies if the depth function state should be cached
  23939. */
  23940. private _cachedDepthFunctionState;
  23941. /**
  23942. * Stores the uniform buffer
  23943. */
  23944. protected _uniformBuffer: UniformBuffer;
  23945. /** @hidden */
  23946. _indexInSceneMaterialArray: number;
  23947. /** @hidden */
  23948. meshMap: Nullable<{
  23949. [id: string]: AbstractMesh | undefined;
  23950. }>;
  23951. /**
  23952. * Creates a material instance
  23953. * @param name defines the name of the material
  23954. * @param scene defines the scene to reference
  23955. * @param doNotAdd specifies if the material should be added to the scene
  23956. */
  23957. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  23958. /**
  23959. * Returns a string representation of the current material
  23960. * @param fullDetails defines a boolean indicating which levels of logging is desired
  23961. * @returns a string with material information
  23962. */
  23963. toString(fullDetails?: boolean): string;
  23964. /**
  23965. * Gets the class name of the material
  23966. * @returns a string with the class name of the material
  23967. */
  23968. getClassName(): string;
  23969. /**
  23970. * Specifies if updates for the material been locked
  23971. */
  23972. get isFrozen(): boolean;
  23973. /**
  23974. * Locks updates for the material
  23975. */
  23976. freeze(): void;
  23977. /**
  23978. * Unlocks updates for the material
  23979. */
  23980. unfreeze(): void;
  23981. /**
  23982. * Specifies if the material is ready to be used
  23983. * @param mesh defines the mesh to check
  23984. * @param useInstances specifies if instances should be used
  23985. * @returns a boolean indicating if the material is ready to be used
  23986. */
  23987. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  23988. /**
  23989. * Specifies that the submesh is ready to be used
  23990. * @param mesh defines the mesh to check
  23991. * @param subMesh defines which submesh to check
  23992. * @param useInstances specifies that instances should be used
  23993. * @returns a boolean indicating that the submesh is ready or not
  23994. */
  23995. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  23996. /**
  23997. * Returns the material effect
  23998. * @returns the effect associated with the material
  23999. */
  24000. getEffect(): Nullable<Effect>;
  24001. /**
  24002. * Returns the current scene
  24003. * @returns a Scene
  24004. */
  24005. getScene(): Scene;
  24006. /**
  24007. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  24008. */
  24009. protected _forceAlphaTest: boolean;
  24010. /**
  24011. * The transparency mode of the material.
  24012. */
  24013. protected _transparencyMode: Nullable<number>;
  24014. /**
  24015. * Gets the current transparency mode.
  24016. */
  24017. get transparencyMode(): Nullable<number>;
  24018. /**
  24019. * Sets the transparency mode of the material.
  24020. *
  24021. * | Value | Type | Description |
  24022. * | ----- | ----------------------------------- | ----------- |
  24023. * | 0 | OPAQUE | |
  24024. * | 1 | ALPHATEST | |
  24025. * | 2 | ALPHABLEND | |
  24026. * | 3 | ALPHATESTANDBLEND | |
  24027. *
  24028. */
  24029. set transparencyMode(value: Nullable<number>);
  24030. /**
  24031. * Returns true if alpha blending should be disabled.
  24032. */
  24033. protected get _disableAlphaBlending(): boolean;
  24034. /**
  24035. * Specifies whether or not this material should be rendered in alpha blend mode.
  24036. * @returns a boolean specifying if alpha blending is needed
  24037. */
  24038. needAlphaBlending(): boolean;
  24039. /**
  24040. * Specifies if the mesh will require alpha blending
  24041. * @param mesh defines the mesh to check
  24042. * @returns a boolean specifying if alpha blending is needed for the mesh
  24043. */
  24044. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  24045. /**
  24046. * Specifies whether or not this material should be rendered in alpha test mode.
  24047. * @returns a boolean specifying if an alpha test is needed.
  24048. */
  24049. needAlphaTesting(): boolean;
  24050. /**
  24051. * Specifies if material alpha testing should be turned on for the mesh
  24052. * @param mesh defines the mesh to check
  24053. */
  24054. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  24055. /**
  24056. * Gets the texture used for the alpha test
  24057. * @returns the texture to use for alpha testing
  24058. */
  24059. getAlphaTestTexture(): Nullable<BaseTexture>;
  24060. /**
  24061. * Marks the material to indicate that it needs to be re-calculated
  24062. */
  24063. markDirty(): void;
  24064. /** @hidden */
  24065. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  24066. /**
  24067. * Binds the material to the mesh
  24068. * @param world defines the world transformation matrix
  24069. * @param mesh defines the mesh to bind the material to
  24070. */
  24071. bind(world: Matrix, mesh?: Mesh): void;
  24072. /**
  24073. * Binds the submesh to the material
  24074. * @param world defines the world transformation matrix
  24075. * @param mesh defines the mesh containing the submesh
  24076. * @param subMesh defines the submesh to bind the material to
  24077. */
  24078. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  24079. /**
  24080. * Binds the world matrix to the material
  24081. * @param world defines the world transformation matrix
  24082. */
  24083. bindOnlyWorldMatrix(world: Matrix): void;
  24084. /**
  24085. * Binds the scene's uniform buffer to the effect.
  24086. * @param effect defines the effect to bind to the scene uniform buffer
  24087. * @param sceneUbo defines the uniform buffer storing scene data
  24088. */
  24089. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  24090. /**
  24091. * Binds the view matrix to the effect
  24092. * @param effect defines the effect to bind the view matrix to
  24093. */
  24094. bindView(effect: Effect): void;
  24095. /**
  24096. * Binds the view projection matrix to the effect
  24097. * @param effect defines the effect to bind the view projection matrix to
  24098. */
  24099. bindViewProjection(effect: Effect): void;
  24100. /**
  24101. * Processes to execute after binding the material to a mesh
  24102. * @param mesh defines the rendered mesh
  24103. */
  24104. protected _afterBind(mesh?: Mesh): void;
  24105. /**
  24106. * Unbinds the material from the mesh
  24107. */
  24108. unbind(): void;
  24109. /**
  24110. * Gets the active textures from the material
  24111. * @returns an array of textures
  24112. */
  24113. getActiveTextures(): BaseTexture[];
  24114. /**
  24115. * Specifies if the material uses a texture
  24116. * @param texture defines the texture to check against the material
  24117. * @returns a boolean specifying if the material uses the texture
  24118. */
  24119. hasTexture(texture: BaseTexture): boolean;
  24120. /**
  24121. * Makes a duplicate of the material, and gives it a new name
  24122. * @param name defines the new name for the duplicated material
  24123. * @returns the cloned material
  24124. */
  24125. clone(name: string): Nullable<Material>;
  24126. /**
  24127. * Gets the meshes bound to the material
  24128. * @returns an array of meshes bound to the material
  24129. */
  24130. getBindedMeshes(): AbstractMesh[];
  24131. /**
  24132. * Force shader compilation
  24133. * @param mesh defines the mesh associated with this material
  24134. * @param onCompiled defines a function to execute once the material is compiled
  24135. * @param options defines the options to configure the compilation
  24136. * @param onError defines a function to execute if the material fails compiling
  24137. */
  24138. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  24139. /**
  24140. * Force shader compilation
  24141. * @param mesh defines the mesh that will use this material
  24142. * @param options defines additional options for compiling the shaders
  24143. * @returns a promise that resolves when the compilation completes
  24144. */
  24145. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  24146. private static readonly _AllDirtyCallBack;
  24147. private static readonly _ImageProcessingDirtyCallBack;
  24148. private static readonly _TextureDirtyCallBack;
  24149. private static readonly _FresnelDirtyCallBack;
  24150. private static readonly _MiscDirtyCallBack;
  24151. private static readonly _LightsDirtyCallBack;
  24152. private static readonly _AttributeDirtyCallBack;
  24153. private static _FresnelAndMiscDirtyCallBack;
  24154. private static _TextureAndMiscDirtyCallBack;
  24155. private static readonly _DirtyCallbackArray;
  24156. private static readonly _RunDirtyCallBacks;
  24157. /**
  24158. * Marks a define in the material to indicate that it needs to be re-computed
  24159. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  24160. */
  24161. markAsDirty(flag: number): void;
  24162. /**
  24163. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  24164. * @param func defines a function which checks material defines against the submeshes
  24165. */
  24166. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  24167. /**
  24168. * Indicates that we need to re-calculated for all submeshes
  24169. */
  24170. protected _markAllSubMeshesAsAllDirty(): void;
  24171. /**
  24172. * Indicates that image processing needs to be re-calculated for all submeshes
  24173. */
  24174. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  24175. /**
  24176. * Indicates that textures need to be re-calculated for all submeshes
  24177. */
  24178. protected _markAllSubMeshesAsTexturesDirty(): void;
  24179. /**
  24180. * Indicates that fresnel needs to be re-calculated for all submeshes
  24181. */
  24182. protected _markAllSubMeshesAsFresnelDirty(): void;
  24183. /**
  24184. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  24185. */
  24186. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  24187. /**
  24188. * Indicates that lights need to be re-calculated for all submeshes
  24189. */
  24190. protected _markAllSubMeshesAsLightsDirty(): void;
  24191. /**
  24192. * Indicates that attributes need to be re-calculated for all submeshes
  24193. */
  24194. protected _markAllSubMeshesAsAttributesDirty(): void;
  24195. /**
  24196. * Indicates that misc needs to be re-calculated for all submeshes
  24197. */
  24198. protected _markAllSubMeshesAsMiscDirty(): void;
  24199. /**
  24200. * Indicates that textures and misc need to be re-calculated for all submeshes
  24201. */
  24202. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  24203. /**
  24204. * Disposes the material
  24205. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  24206. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  24207. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  24208. */
  24209. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  24210. /** @hidden */
  24211. private releaseVertexArrayObject;
  24212. /**
  24213. * Serializes this material
  24214. * @returns the serialized material object
  24215. */
  24216. serialize(): any;
  24217. /**
  24218. * Creates a material from parsed material data
  24219. * @param parsedMaterial defines parsed material data
  24220. * @param scene defines the hosting scene
  24221. * @param rootUrl defines the root URL to use to load textures
  24222. * @returns a new material
  24223. */
  24224. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  24225. }
  24226. }
  24227. declare module BABYLON {
  24228. /**
  24229. * A multi-material is used to apply different materials to different parts of the same object without the need of
  24230. * separate meshes. This can be use to improve performances.
  24231. * @see http://doc.babylonjs.com/how_to/multi_materials
  24232. */
  24233. export class MultiMaterial extends Material {
  24234. private _subMaterials;
  24235. /**
  24236. * Gets or Sets the list of Materials used within the multi material.
  24237. * They need to be ordered according to the submeshes order in the associated mesh
  24238. */
  24239. get subMaterials(): Nullable<Material>[];
  24240. set subMaterials(value: Nullable<Material>[]);
  24241. /**
  24242. * Function used to align with Node.getChildren()
  24243. * @returns the list of Materials used within the multi material
  24244. */
  24245. getChildren(): Nullable<Material>[];
  24246. /**
  24247. * Instantiates a new Multi Material
  24248. * A multi-material is used to apply different materials to different parts of the same object without the need of
  24249. * separate meshes. This can be use to improve performances.
  24250. * @see http://doc.babylonjs.com/how_to/multi_materials
  24251. * @param name Define the name in the scene
  24252. * @param scene Define the scene the material belongs to
  24253. */
  24254. constructor(name: string, scene: Scene);
  24255. private _hookArray;
  24256. /**
  24257. * Get one of the submaterial by its index in the submaterials array
  24258. * @param index The index to look the sub material at
  24259. * @returns The Material if the index has been defined
  24260. */
  24261. getSubMaterial(index: number): Nullable<Material>;
  24262. /**
  24263. * Get the list of active textures for the whole sub materials list.
  24264. * @returns All the textures that will be used during the rendering
  24265. */
  24266. getActiveTextures(): BaseTexture[];
  24267. /**
  24268. * Gets the current class name of the material e.g. "MultiMaterial"
  24269. * Mainly use in serialization.
  24270. * @returns the class name
  24271. */
  24272. getClassName(): string;
  24273. /**
  24274. * Checks if the material is ready to render the requested sub mesh
  24275. * @param mesh Define the mesh the submesh belongs to
  24276. * @param subMesh Define the sub mesh to look readyness for
  24277. * @param useInstances Define whether or not the material is used with instances
  24278. * @returns true if ready, otherwise false
  24279. */
  24280. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  24281. /**
  24282. * Clones the current material and its related sub materials
  24283. * @param name Define the name of the newly cloned material
  24284. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  24285. * @returns the cloned material
  24286. */
  24287. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  24288. /**
  24289. * Serializes the materials into a JSON representation.
  24290. * @returns the JSON representation
  24291. */
  24292. serialize(): any;
  24293. /**
  24294. * Dispose the material and release its associated resources
  24295. * @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)
  24296. * @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)
  24297. * @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)
  24298. */
  24299. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  24300. /**
  24301. * Creates a MultiMaterial from parsed MultiMaterial data.
  24302. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  24303. * @param scene defines the hosting scene
  24304. * @returns a new MultiMaterial
  24305. */
  24306. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  24307. }
  24308. }
  24309. declare module BABYLON {
  24310. /**
  24311. * Base class for submeshes
  24312. */
  24313. export class BaseSubMesh {
  24314. /** @hidden */
  24315. _materialDefines: Nullable<MaterialDefines>;
  24316. /** @hidden */
  24317. _materialEffect: Nullable<Effect>;
  24318. /** @hidden */
  24319. _effectOverride: Nullable<Effect>;
  24320. /**
  24321. * Gets material defines used by the effect associated to the sub mesh
  24322. */
  24323. get materialDefines(): Nullable<MaterialDefines>;
  24324. /**
  24325. * Sets material defines used by the effect associated to the sub mesh
  24326. */
  24327. set materialDefines(defines: Nullable<MaterialDefines>);
  24328. /**
  24329. * Gets associated effect
  24330. */
  24331. get effect(): Nullable<Effect>;
  24332. /**
  24333. * Sets associated effect (effect used to render this submesh)
  24334. * @param effect defines the effect to associate with
  24335. * @param defines defines the set of defines used to compile this effect
  24336. */
  24337. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  24338. }
  24339. /**
  24340. * Defines a subdivision inside a mesh
  24341. */
  24342. export class SubMesh extends BaseSubMesh implements ICullable {
  24343. /** the material index to use */
  24344. materialIndex: number;
  24345. /** vertex index start */
  24346. verticesStart: number;
  24347. /** vertices count */
  24348. verticesCount: number;
  24349. /** index start */
  24350. indexStart: number;
  24351. /** indices count */
  24352. indexCount: number;
  24353. /** @hidden */
  24354. _linesIndexCount: number;
  24355. private _mesh;
  24356. private _renderingMesh;
  24357. private _boundingInfo;
  24358. private _linesIndexBuffer;
  24359. /** @hidden */
  24360. _lastColliderWorldVertices: Nullable<Vector3[]>;
  24361. /** @hidden */
  24362. _trianglePlanes: Plane[];
  24363. /** @hidden */
  24364. _lastColliderTransformMatrix: Nullable<Matrix>;
  24365. /** @hidden */
  24366. _renderId: number;
  24367. /** @hidden */
  24368. _alphaIndex: number;
  24369. /** @hidden */
  24370. _distanceToCamera: number;
  24371. /** @hidden */
  24372. _id: number;
  24373. private _currentMaterial;
  24374. /**
  24375. * Add a new submesh to a mesh
  24376. * @param materialIndex defines the material index to use
  24377. * @param verticesStart defines vertex index start
  24378. * @param verticesCount defines vertices count
  24379. * @param indexStart defines index start
  24380. * @param indexCount defines indices count
  24381. * @param mesh defines the parent mesh
  24382. * @param renderingMesh defines an optional rendering mesh
  24383. * @param createBoundingBox defines if bounding box should be created for this submesh
  24384. * @returns the new submesh
  24385. */
  24386. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  24387. /**
  24388. * Creates a new submesh
  24389. * @param materialIndex defines the material index to use
  24390. * @param verticesStart defines vertex index start
  24391. * @param verticesCount defines vertices count
  24392. * @param indexStart defines index start
  24393. * @param indexCount defines indices count
  24394. * @param mesh defines the parent mesh
  24395. * @param renderingMesh defines an optional rendering mesh
  24396. * @param createBoundingBox defines if bounding box should be created for this submesh
  24397. */
  24398. constructor(
  24399. /** the material index to use */
  24400. materialIndex: number,
  24401. /** vertex index start */
  24402. verticesStart: number,
  24403. /** vertices count */
  24404. verticesCount: number,
  24405. /** index start */
  24406. indexStart: number,
  24407. /** indices count */
  24408. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  24409. /**
  24410. * Returns true if this submesh covers the entire parent mesh
  24411. * @ignorenaming
  24412. */
  24413. get IsGlobal(): boolean;
  24414. /**
  24415. * Returns the submesh BoudingInfo object
  24416. * @returns current bounding info (or mesh's one if the submesh is global)
  24417. */
  24418. getBoundingInfo(): BoundingInfo;
  24419. /**
  24420. * Sets the submesh BoundingInfo
  24421. * @param boundingInfo defines the new bounding info to use
  24422. * @returns the SubMesh
  24423. */
  24424. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  24425. /**
  24426. * Returns the mesh of the current submesh
  24427. * @return the parent mesh
  24428. */
  24429. getMesh(): AbstractMesh;
  24430. /**
  24431. * Returns the rendering mesh of the submesh
  24432. * @returns the rendering mesh (could be different from parent mesh)
  24433. */
  24434. getRenderingMesh(): Mesh;
  24435. /**
  24436. * Returns the submesh material
  24437. * @returns null or the current material
  24438. */
  24439. getMaterial(): Nullable<Material>;
  24440. /**
  24441. * Sets a new updated BoundingInfo object to the submesh
  24442. * @param data defines an optional position array to use to determine the bounding info
  24443. * @returns the SubMesh
  24444. */
  24445. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  24446. /** @hidden */
  24447. _checkCollision(collider: Collider): boolean;
  24448. /**
  24449. * Updates the submesh BoundingInfo
  24450. * @param world defines the world matrix to use to update the bounding info
  24451. * @returns the submesh
  24452. */
  24453. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  24454. /**
  24455. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  24456. * @param frustumPlanes defines the frustum planes
  24457. * @returns true if the submesh is intersecting with the frustum
  24458. */
  24459. isInFrustum(frustumPlanes: Plane[]): boolean;
  24460. /**
  24461. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  24462. * @param frustumPlanes defines the frustum planes
  24463. * @returns true if the submesh is inside the frustum
  24464. */
  24465. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24466. /**
  24467. * Renders the submesh
  24468. * @param enableAlphaMode defines if alpha needs to be used
  24469. * @returns the submesh
  24470. */
  24471. render(enableAlphaMode: boolean): SubMesh;
  24472. /**
  24473. * @hidden
  24474. */
  24475. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  24476. /**
  24477. * Checks if the submesh intersects with a ray
  24478. * @param ray defines the ray to test
  24479. * @returns true is the passed ray intersects the submesh bounding box
  24480. */
  24481. canIntersects(ray: Ray): boolean;
  24482. /**
  24483. * Intersects current submesh with a ray
  24484. * @param ray defines the ray to test
  24485. * @param positions defines mesh's positions array
  24486. * @param indices defines mesh's indices array
  24487. * @param fastCheck defines if the first intersection will be used (and not the closest)
  24488. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  24489. * @returns intersection info or null if no intersection
  24490. */
  24491. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  24492. /** @hidden */
  24493. private _intersectLines;
  24494. /** @hidden */
  24495. private _intersectUnIndexedLines;
  24496. /** @hidden */
  24497. private _intersectTriangles;
  24498. /** @hidden */
  24499. private _intersectUnIndexedTriangles;
  24500. /** @hidden */
  24501. _rebuild(): void;
  24502. /**
  24503. * Creates a new submesh from the passed mesh
  24504. * @param newMesh defines the new hosting mesh
  24505. * @param newRenderingMesh defines an optional rendering mesh
  24506. * @returns the new submesh
  24507. */
  24508. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  24509. /**
  24510. * Release associated resources
  24511. */
  24512. dispose(): void;
  24513. /**
  24514. * Gets the class name
  24515. * @returns the string "SubMesh".
  24516. */
  24517. getClassName(): string;
  24518. /**
  24519. * Creates a new submesh from indices data
  24520. * @param materialIndex the index of the main mesh material
  24521. * @param startIndex the index where to start the copy in the mesh indices array
  24522. * @param indexCount the number of indices to copy then from the startIndex
  24523. * @param mesh the main mesh to create the submesh from
  24524. * @param renderingMesh the optional rendering mesh
  24525. * @returns a new submesh
  24526. */
  24527. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  24528. }
  24529. }
  24530. declare module BABYLON {
  24531. /**
  24532. * Class used to represent data loading progression
  24533. */
  24534. export class SceneLoaderFlags {
  24535. private static _ForceFullSceneLoadingForIncremental;
  24536. private static _ShowLoadingScreen;
  24537. private static _CleanBoneMatrixWeights;
  24538. private static _loggingLevel;
  24539. /**
  24540. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  24541. */
  24542. static get ForceFullSceneLoadingForIncremental(): boolean;
  24543. static set ForceFullSceneLoadingForIncremental(value: boolean);
  24544. /**
  24545. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  24546. */
  24547. static get ShowLoadingScreen(): boolean;
  24548. static set ShowLoadingScreen(value: boolean);
  24549. /**
  24550. * Defines the current logging level (while loading the scene)
  24551. * @ignorenaming
  24552. */
  24553. static get loggingLevel(): number;
  24554. static set loggingLevel(value: number);
  24555. /**
  24556. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  24557. */
  24558. static get CleanBoneMatrixWeights(): boolean;
  24559. static set CleanBoneMatrixWeights(value: boolean);
  24560. }
  24561. }
  24562. declare module BABYLON {
  24563. /**
  24564. * Class used to store geometry data (vertex buffers + index buffer)
  24565. */
  24566. export class Geometry implements IGetSetVerticesData {
  24567. /**
  24568. * Gets or sets the ID of the geometry
  24569. */
  24570. id: string;
  24571. /**
  24572. * Gets or sets the unique ID of the geometry
  24573. */
  24574. uniqueId: number;
  24575. /**
  24576. * Gets the delay loading state of the geometry (none by default which means not delayed)
  24577. */
  24578. delayLoadState: number;
  24579. /**
  24580. * Gets the file containing the data to load when running in delay load state
  24581. */
  24582. delayLoadingFile: Nullable<string>;
  24583. /**
  24584. * Callback called when the geometry is updated
  24585. */
  24586. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  24587. private _scene;
  24588. private _engine;
  24589. private _meshes;
  24590. private _totalVertices;
  24591. /** @hidden */
  24592. _indices: IndicesArray;
  24593. /** @hidden */
  24594. _vertexBuffers: {
  24595. [key: string]: VertexBuffer;
  24596. };
  24597. private _isDisposed;
  24598. private _extend;
  24599. private _boundingBias;
  24600. /** @hidden */
  24601. _delayInfo: Array<string>;
  24602. private _indexBuffer;
  24603. private _indexBufferIsUpdatable;
  24604. /** @hidden */
  24605. _boundingInfo: Nullable<BoundingInfo>;
  24606. /** @hidden */
  24607. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  24608. /** @hidden */
  24609. _softwareSkinningFrameId: number;
  24610. private _vertexArrayObjects;
  24611. private _updatable;
  24612. /** @hidden */
  24613. _positions: Nullable<Vector3[]>;
  24614. /**
  24615. * 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
  24616. */
  24617. get boundingBias(): Vector2;
  24618. /**
  24619. * 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
  24620. */
  24621. set boundingBias(value: Vector2);
  24622. /**
  24623. * Static function used to attach a new empty geometry to a mesh
  24624. * @param mesh defines the mesh to attach the geometry to
  24625. * @returns the new Geometry
  24626. */
  24627. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  24628. /** Get the list of meshes using this geometry */
  24629. get meshes(): Mesh[];
  24630. /**
  24631. * Creates a new geometry
  24632. * @param id defines the unique ID
  24633. * @param scene defines the hosting scene
  24634. * @param vertexData defines the VertexData used to get geometry data
  24635. * @param updatable defines if geometry must be updatable (false by default)
  24636. * @param mesh defines the mesh that will be associated with the geometry
  24637. */
  24638. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  24639. /**
  24640. * Gets the current extend of the geometry
  24641. */
  24642. get extend(): {
  24643. minimum: Vector3;
  24644. maximum: Vector3;
  24645. };
  24646. /**
  24647. * Gets the hosting scene
  24648. * @returns the hosting Scene
  24649. */
  24650. getScene(): Scene;
  24651. /**
  24652. * Gets the hosting engine
  24653. * @returns the hosting Engine
  24654. */
  24655. getEngine(): Engine;
  24656. /**
  24657. * Defines if the geometry is ready to use
  24658. * @returns true if the geometry is ready to be used
  24659. */
  24660. isReady(): boolean;
  24661. /**
  24662. * Gets a value indicating that the geometry should not be serialized
  24663. */
  24664. get doNotSerialize(): boolean;
  24665. /** @hidden */
  24666. _rebuild(): void;
  24667. /**
  24668. * Affects all geometry data in one call
  24669. * @param vertexData defines the geometry data
  24670. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  24671. */
  24672. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  24673. /**
  24674. * Set specific vertex data
  24675. * @param kind defines the data kind (Position, normal, etc...)
  24676. * @param data defines the vertex data to use
  24677. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  24678. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  24679. */
  24680. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  24681. /**
  24682. * Removes a specific vertex data
  24683. * @param kind defines the data kind (Position, normal, etc...)
  24684. */
  24685. removeVerticesData(kind: string): void;
  24686. /**
  24687. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  24688. * @param buffer defines the vertex buffer to use
  24689. * @param totalVertices defines the total number of vertices for position kind (could be null)
  24690. */
  24691. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  24692. /**
  24693. * Update a specific vertex buffer
  24694. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  24695. * It will do nothing if the buffer is not updatable
  24696. * @param kind defines the data kind (Position, normal, etc...)
  24697. * @param data defines the data to use
  24698. * @param offset defines the offset in the target buffer where to store the data
  24699. * @param useBytes set to true if the offset is in bytes
  24700. */
  24701. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  24702. /**
  24703. * Update a specific vertex buffer
  24704. * This function will create a new buffer if the current one is not updatable
  24705. * @param kind defines the data kind (Position, normal, etc...)
  24706. * @param data defines the data to use
  24707. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  24708. */
  24709. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  24710. private _updateBoundingInfo;
  24711. /** @hidden */
  24712. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  24713. /**
  24714. * Gets total number of vertices
  24715. * @returns the total number of vertices
  24716. */
  24717. getTotalVertices(): number;
  24718. /**
  24719. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  24720. * @param kind defines the data kind (Position, normal, etc...)
  24721. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  24722. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24723. * @returns a float array containing vertex data
  24724. */
  24725. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24726. /**
  24727. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  24728. * @param kind defines the data kind (Position, normal, etc...)
  24729. * @returns true if the vertex buffer with the specified kind is updatable
  24730. */
  24731. isVertexBufferUpdatable(kind: string): boolean;
  24732. /**
  24733. * Gets a specific vertex buffer
  24734. * @param kind defines the data kind (Position, normal, etc...)
  24735. * @returns a VertexBuffer
  24736. */
  24737. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24738. /**
  24739. * Returns all vertex buffers
  24740. * @return an object holding all vertex buffers indexed by kind
  24741. */
  24742. getVertexBuffers(): Nullable<{
  24743. [key: string]: VertexBuffer;
  24744. }>;
  24745. /**
  24746. * Gets a boolean indicating if specific vertex buffer is present
  24747. * @param kind defines the data kind (Position, normal, etc...)
  24748. * @returns true if data is present
  24749. */
  24750. isVerticesDataPresent(kind: string): boolean;
  24751. /**
  24752. * Gets a list of all attached data kinds (Position, normal, etc...)
  24753. * @returns a list of string containing all kinds
  24754. */
  24755. getVerticesDataKinds(): string[];
  24756. /**
  24757. * Update index buffer
  24758. * @param indices defines the indices to store in the index buffer
  24759. * @param offset defines the offset in the target buffer where to store the data
  24760. * @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)
  24761. */
  24762. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  24763. /**
  24764. * Creates a new index buffer
  24765. * @param indices defines the indices to store in the index buffer
  24766. * @param totalVertices defines the total number of vertices (could be null)
  24767. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  24768. */
  24769. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  24770. /**
  24771. * Return the total number of indices
  24772. * @returns the total number of indices
  24773. */
  24774. getTotalIndices(): number;
  24775. /**
  24776. * Gets the index buffer array
  24777. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  24778. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24779. * @returns the index buffer array
  24780. */
  24781. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24782. /**
  24783. * Gets the index buffer
  24784. * @return the index buffer
  24785. */
  24786. getIndexBuffer(): Nullable<DataBuffer>;
  24787. /** @hidden */
  24788. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  24789. /**
  24790. * Release the associated resources for a specific mesh
  24791. * @param mesh defines the source mesh
  24792. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  24793. */
  24794. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  24795. /**
  24796. * Apply current geometry to a given mesh
  24797. * @param mesh defines the mesh to apply geometry to
  24798. */
  24799. applyToMesh(mesh: Mesh): void;
  24800. private _updateExtend;
  24801. private _applyToMesh;
  24802. private notifyUpdate;
  24803. /**
  24804. * Load the geometry if it was flagged as delay loaded
  24805. * @param scene defines the hosting scene
  24806. * @param onLoaded defines a callback called when the geometry is loaded
  24807. */
  24808. load(scene: Scene, onLoaded?: () => void): void;
  24809. private _queueLoad;
  24810. /**
  24811. * Invert the geometry to move from a right handed system to a left handed one.
  24812. */
  24813. toLeftHanded(): void;
  24814. /** @hidden */
  24815. _resetPointsArrayCache(): void;
  24816. /** @hidden */
  24817. _generatePointsArray(): boolean;
  24818. /**
  24819. * Gets a value indicating if the geometry is disposed
  24820. * @returns true if the geometry was disposed
  24821. */
  24822. isDisposed(): boolean;
  24823. private _disposeVertexArrayObjects;
  24824. /**
  24825. * Free all associated resources
  24826. */
  24827. dispose(): void;
  24828. /**
  24829. * Clone the current geometry into a new geometry
  24830. * @param id defines the unique ID of the new geometry
  24831. * @returns a new geometry object
  24832. */
  24833. copy(id: string): Geometry;
  24834. /**
  24835. * Serialize the current geometry info (and not the vertices data) into a JSON object
  24836. * @return a JSON representation of the current geometry data (without the vertices data)
  24837. */
  24838. serialize(): any;
  24839. private toNumberArray;
  24840. /**
  24841. * Serialize all vertices data into a JSON oject
  24842. * @returns a JSON representation of the current geometry data
  24843. */
  24844. serializeVerticeData(): any;
  24845. /**
  24846. * Extracts a clone of a mesh geometry
  24847. * @param mesh defines the source mesh
  24848. * @param id defines the unique ID of the new geometry object
  24849. * @returns the new geometry object
  24850. */
  24851. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  24852. /**
  24853. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  24854. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  24855. * Be aware Math.random() could cause collisions, but:
  24856. * "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"
  24857. * @returns a string containing a new GUID
  24858. */
  24859. static RandomId(): string;
  24860. /** @hidden */
  24861. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  24862. private static _CleanMatricesWeights;
  24863. /**
  24864. * Create a new geometry from persisted data (Using .babylon file format)
  24865. * @param parsedVertexData defines the persisted data
  24866. * @param scene defines the hosting scene
  24867. * @param rootUrl defines the root url to use to load assets (like delayed data)
  24868. * @returns the new geometry object
  24869. */
  24870. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  24871. }
  24872. }
  24873. declare module BABYLON {
  24874. /**
  24875. * Define an interface for all classes that will get and set the data on vertices
  24876. */
  24877. export interface IGetSetVerticesData {
  24878. /**
  24879. * Gets a boolean indicating if specific vertex data is present
  24880. * @param kind defines the vertex data kind to use
  24881. * @returns true is data kind is present
  24882. */
  24883. isVerticesDataPresent(kind: string): boolean;
  24884. /**
  24885. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  24886. * @param kind defines the data kind (Position, normal, etc...)
  24887. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  24888. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24889. * @returns a float array containing vertex data
  24890. */
  24891. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24892. /**
  24893. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24894. * @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.
  24895. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24896. * @returns the indices array or an empty array if the mesh has no geometry
  24897. */
  24898. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24899. /**
  24900. * Set specific vertex data
  24901. * @param kind defines the data kind (Position, normal, etc...)
  24902. * @param data defines the vertex data to use
  24903. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  24904. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  24905. */
  24906. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  24907. /**
  24908. * Update a specific associated vertex buffer
  24909. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24910. * - VertexBuffer.PositionKind
  24911. * - VertexBuffer.UVKind
  24912. * - VertexBuffer.UV2Kind
  24913. * - VertexBuffer.UV3Kind
  24914. * - VertexBuffer.UV4Kind
  24915. * - VertexBuffer.UV5Kind
  24916. * - VertexBuffer.UV6Kind
  24917. * - VertexBuffer.ColorKind
  24918. * - VertexBuffer.MatricesIndicesKind
  24919. * - VertexBuffer.MatricesIndicesExtraKind
  24920. * - VertexBuffer.MatricesWeightsKind
  24921. * - VertexBuffer.MatricesWeightsExtraKind
  24922. * @param data defines the data source
  24923. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24924. * @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)
  24925. */
  24926. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  24927. /**
  24928. * Creates a new index buffer
  24929. * @param indices defines the indices to store in the index buffer
  24930. * @param totalVertices defines the total number of vertices (could be null)
  24931. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  24932. */
  24933. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  24934. }
  24935. /**
  24936. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  24937. */
  24938. export class VertexData {
  24939. /**
  24940. * Mesh side orientation : usually the external or front surface
  24941. */
  24942. static readonly FRONTSIDE: number;
  24943. /**
  24944. * Mesh side orientation : usually the internal or back surface
  24945. */
  24946. static readonly BACKSIDE: number;
  24947. /**
  24948. * Mesh side orientation : both internal and external or front and back surfaces
  24949. */
  24950. static readonly DOUBLESIDE: number;
  24951. /**
  24952. * Mesh side orientation : by default, `FRONTSIDE`
  24953. */
  24954. static readonly DEFAULTSIDE: number;
  24955. /**
  24956. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  24957. */
  24958. positions: Nullable<FloatArray>;
  24959. /**
  24960. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  24961. */
  24962. normals: Nullable<FloatArray>;
  24963. /**
  24964. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  24965. */
  24966. tangents: Nullable<FloatArray>;
  24967. /**
  24968. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  24969. */
  24970. uvs: Nullable<FloatArray>;
  24971. /**
  24972. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  24973. */
  24974. uvs2: Nullable<FloatArray>;
  24975. /**
  24976. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  24977. */
  24978. uvs3: Nullable<FloatArray>;
  24979. /**
  24980. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  24981. */
  24982. uvs4: Nullable<FloatArray>;
  24983. /**
  24984. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  24985. */
  24986. uvs5: Nullable<FloatArray>;
  24987. /**
  24988. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  24989. */
  24990. uvs6: Nullable<FloatArray>;
  24991. /**
  24992. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  24993. */
  24994. colors: Nullable<FloatArray>;
  24995. /**
  24996. * 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).
  24997. */
  24998. matricesIndices: Nullable<FloatArray>;
  24999. /**
  25000. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  25001. */
  25002. matricesWeights: Nullable<FloatArray>;
  25003. /**
  25004. * An array extending the number of possible indices
  25005. */
  25006. matricesIndicesExtra: Nullable<FloatArray>;
  25007. /**
  25008. * An array extending the number of possible weights when the number of indices is extended
  25009. */
  25010. matricesWeightsExtra: Nullable<FloatArray>;
  25011. /**
  25012. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  25013. */
  25014. indices: Nullable<IndicesArray>;
  25015. /**
  25016. * Uses the passed data array to set the set the values for the specified kind of data
  25017. * @param data a linear array of floating numbers
  25018. * @param kind the type of data that is being set, eg positions, colors etc
  25019. */
  25020. set(data: FloatArray, kind: string): void;
  25021. /**
  25022. * Associates the vertexData to the passed Mesh.
  25023. * Sets it as updatable or not (default `false`)
  25024. * @param mesh the mesh the vertexData is applied to
  25025. * @param updatable when used and having the value true allows new data to update the vertexData
  25026. * @returns the VertexData
  25027. */
  25028. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  25029. /**
  25030. * Associates the vertexData to the passed Geometry.
  25031. * Sets it as updatable or not (default `false`)
  25032. * @param geometry the geometry the vertexData is applied to
  25033. * @param updatable when used and having the value true allows new data to update the vertexData
  25034. * @returns VertexData
  25035. */
  25036. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  25037. /**
  25038. * Updates the associated mesh
  25039. * @param mesh the mesh to be updated
  25040. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  25041. * @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
  25042. * @returns VertexData
  25043. */
  25044. updateMesh(mesh: Mesh): VertexData;
  25045. /**
  25046. * Updates the associated geometry
  25047. * @param geometry the geometry to be updated
  25048. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  25049. * @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
  25050. * @returns VertexData.
  25051. */
  25052. updateGeometry(geometry: Geometry): VertexData;
  25053. private _applyTo;
  25054. private _update;
  25055. /**
  25056. * Transforms each position and each normal of the vertexData according to the passed Matrix
  25057. * @param matrix the transforming matrix
  25058. * @returns the VertexData
  25059. */
  25060. transform(matrix: Matrix): VertexData;
  25061. /**
  25062. * Merges the passed VertexData into the current one
  25063. * @param other the VertexData to be merged into the current one
  25064. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  25065. * @returns the modified VertexData
  25066. */
  25067. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  25068. private _mergeElement;
  25069. private _validate;
  25070. /**
  25071. * Serializes the VertexData
  25072. * @returns a serialized object
  25073. */
  25074. serialize(): any;
  25075. /**
  25076. * Extracts the vertexData from a mesh
  25077. * @param mesh the mesh from which to extract the VertexData
  25078. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  25079. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  25080. * @returns the object VertexData associated to the passed mesh
  25081. */
  25082. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  25083. /**
  25084. * Extracts the vertexData from the geometry
  25085. * @param geometry the geometry from which to extract the VertexData
  25086. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  25087. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  25088. * @returns the object VertexData associated to the passed mesh
  25089. */
  25090. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  25091. private static _ExtractFrom;
  25092. /**
  25093. * Creates the VertexData for a Ribbon
  25094. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  25095. * * pathArray array of paths, each of which an array of successive Vector3
  25096. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  25097. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  25098. * * 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
  25099. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25100. * * 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)
  25101. * * 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)
  25102. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  25103. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  25104. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  25105. * @returns the VertexData of the ribbon
  25106. */
  25107. static CreateRibbon(options: {
  25108. pathArray: Vector3[][];
  25109. closeArray?: boolean;
  25110. closePath?: boolean;
  25111. offset?: number;
  25112. sideOrientation?: number;
  25113. frontUVs?: Vector4;
  25114. backUVs?: Vector4;
  25115. invertUV?: boolean;
  25116. uvs?: Vector2[];
  25117. colors?: Color4[];
  25118. }): VertexData;
  25119. /**
  25120. * Creates the VertexData for a box
  25121. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25122. * * size sets the width, height and depth of the box to the value of size, optional default 1
  25123. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  25124. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  25125. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  25126. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  25127. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  25128. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25129. * * 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)
  25130. * * 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)
  25131. * @returns the VertexData of the box
  25132. */
  25133. static CreateBox(options: {
  25134. size?: number;
  25135. width?: number;
  25136. height?: number;
  25137. depth?: number;
  25138. faceUV?: Vector4[];
  25139. faceColors?: Color4[];
  25140. sideOrientation?: number;
  25141. frontUVs?: Vector4;
  25142. backUVs?: Vector4;
  25143. }): VertexData;
  25144. /**
  25145. * Creates the VertexData for a tiled box
  25146. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25147. * * faceTiles sets the pattern, tile size and number of tiles for a face
  25148. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  25149. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  25150. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25151. * @returns the VertexData of the box
  25152. */
  25153. static CreateTiledBox(options: {
  25154. pattern?: number;
  25155. width?: number;
  25156. height?: number;
  25157. depth?: number;
  25158. tileSize?: number;
  25159. tileWidth?: number;
  25160. tileHeight?: number;
  25161. alignHorizontal?: number;
  25162. alignVertical?: number;
  25163. faceUV?: Vector4[];
  25164. faceColors?: Color4[];
  25165. sideOrientation?: number;
  25166. }): VertexData;
  25167. /**
  25168. * Creates the VertexData for a tiled plane
  25169. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25170. * * pattern a limited pattern arrangement depending on the number
  25171. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  25172. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  25173. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  25174. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25175. * * 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)
  25176. * * 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)
  25177. * @returns the VertexData of the tiled plane
  25178. */
  25179. static CreateTiledPlane(options: {
  25180. pattern?: number;
  25181. tileSize?: number;
  25182. tileWidth?: number;
  25183. tileHeight?: number;
  25184. size?: number;
  25185. width?: number;
  25186. height?: number;
  25187. alignHorizontal?: number;
  25188. alignVertical?: number;
  25189. sideOrientation?: number;
  25190. frontUVs?: Vector4;
  25191. backUVs?: Vector4;
  25192. }): VertexData;
  25193. /**
  25194. * Creates the VertexData for an ellipsoid, defaults to a sphere
  25195. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25196. * * segments sets the number of horizontal strips optional, default 32
  25197. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  25198. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  25199. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  25200. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  25201. * * 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
  25202. * * 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
  25203. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25204. * * 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)
  25205. * * 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)
  25206. * @returns the VertexData of the ellipsoid
  25207. */
  25208. static CreateSphere(options: {
  25209. segments?: number;
  25210. diameter?: number;
  25211. diameterX?: number;
  25212. diameterY?: number;
  25213. diameterZ?: number;
  25214. arc?: number;
  25215. slice?: number;
  25216. sideOrientation?: number;
  25217. frontUVs?: Vector4;
  25218. backUVs?: Vector4;
  25219. }): VertexData;
  25220. /**
  25221. * Creates the VertexData for a cylinder, cone or prism
  25222. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25223. * * height sets the height (y direction) of the cylinder, optional, default 2
  25224. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  25225. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  25226. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  25227. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  25228. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  25229. * * 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
  25230. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  25231. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  25232. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  25233. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  25234. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25235. * * 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)
  25236. * * 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)
  25237. * @returns the VertexData of the cylinder, cone or prism
  25238. */
  25239. static CreateCylinder(options: {
  25240. height?: number;
  25241. diameterTop?: number;
  25242. diameterBottom?: number;
  25243. diameter?: number;
  25244. tessellation?: number;
  25245. subdivisions?: number;
  25246. arc?: number;
  25247. faceColors?: Color4[];
  25248. faceUV?: Vector4[];
  25249. hasRings?: boolean;
  25250. enclose?: boolean;
  25251. sideOrientation?: number;
  25252. frontUVs?: Vector4;
  25253. backUVs?: Vector4;
  25254. }): VertexData;
  25255. /**
  25256. * Creates the VertexData for a torus
  25257. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25258. * * diameter the diameter of the torus, optional default 1
  25259. * * thickness the diameter of the tube forming the torus, optional default 0.5
  25260. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  25261. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25262. * * 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)
  25263. * * 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)
  25264. * @returns the VertexData of the torus
  25265. */
  25266. static CreateTorus(options: {
  25267. diameter?: number;
  25268. thickness?: number;
  25269. tessellation?: number;
  25270. sideOrientation?: number;
  25271. frontUVs?: Vector4;
  25272. backUVs?: Vector4;
  25273. }): VertexData;
  25274. /**
  25275. * Creates the VertexData of the LineSystem
  25276. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  25277. * - lines an array of lines, each line being an array of successive Vector3
  25278. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  25279. * @returns the VertexData of the LineSystem
  25280. */
  25281. static CreateLineSystem(options: {
  25282. lines: Vector3[][];
  25283. colors?: Nullable<Color4[][]>;
  25284. }): VertexData;
  25285. /**
  25286. * Create the VertexData for a DashedLines
  25287. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  25288. * - points an array successive Vector3
  25289. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  25290. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  25291. * - dashNb the intended total number of dashes, optional, default 200
  25292. * @returns the VertexData for the DashedLines
  25293. */
  25294. static CreateDashedLines(options: {
  25295. points: Vector3[];
  25296. dashSize?: number;
  25297. gapSize?: number;
  25298. dashNb?: number;
  25299. }): VertexData;
  25300. /**
  25301. * Creates the VertexData for a Ground
  25302. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  25303. * - width the width (x direction) of the ground, optional, default 1
  25304. * - height the height (z direction) of the ground, optional, default 1
  25305. * - subdivisions the number of subdivisions per side, optional, default 1
  25306. * @returns the VertexData of the Ground
  25307. */
  25308. static CreateGround(options: {
  25309. width?: number;
  25310. height?: number;
  25311. subdivisions?: number;
  25312. subdivisionsX?: number;
  25313. subdivisionsY?: number;
  25314. }): VertexData;
  25315. /**
  25316. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  25317. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  25318. * * xmin the ground minimum X coordinate, optional, default -1
  25319. * * zmin the ground minimum Z coordinate, optional, default -1
  25320. * * xmax the ground maximum X coordinate, optional, default 1
  25321. * * zmax the ground maximum Z coordinate, optional, default 1
  25322. * * 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}
  25323. * * 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}
  25324. * @returns the VertexData of the TiledGround
  25325. */
  25326. static CreateTiledGround(options: {
  25327. xmin: number;
  25328. zmin: number;
  25329. xmax: number;
  25330. zmax: number;
  25331. subdivisions?: {
  25332. w: number;
  25333. h: number;
  25334. };
  25335. precision?: {
  25336. w: number;
  25337. h: number;
  25338. };
  25339. }): VertexData;
  25340. /**
  25341. * Creates the VertexData of the Ground designed from a heightmap
  25342. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  25343. * * width the width (x direction) of the ground
  25344. * * height the height (z direction) of the ground
  25345. * * subdivisions the number of subdivisions per side
  25346. * * minHeight the minimum altitude on the ground, optional, default 0
  25347. * * maxHeight the maximum altitude on the ground, optional default 1
  25348. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  25349. * * buffer the array holding the image color data
  25350. * * bufferWidth the width of image
  25351. * * bufferHeight the height of image
  25352. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  25353. * @returns the VertexData of the Ground designed from a heightmap
  25354. */
  25355. static CreateGroundFromHeightMap(options: {
  25356. width: number;
  25357. height: number;
  25358. subdivisions: number;
  25359. minHeight: number;
  25360. maxHeight: number;
  25361. colorFilter: Color3;
  25362. buffer: Uint8Array;
  25363. bufferWidth: number;
  25364. bufferHeight: number;
  25365. alphaFilter: number;
  25366. }): VertexData;
  25367. /**
  25368. * Creates the VertexData for a Plane
  25369. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  25370. * * size sets the width and height of the plane to the value of size, optional default 1
  25371. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  25372. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  25373. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25374. * * 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)
  25375. * * 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)
  25376. * @returns the VertexData of the box
  25377. */
  25378. static CreatePlane(options: {
  25379. size?: number;
  25380. width?: number;
  25381. height?: number;
  25382. sideOrientation?: number;
  25383. frontUVs?: Vector4;
  25384. backUVs?: Vector4;
  25385. }): VertexData;
  25386. /**
  25387. * Creates the VertexData of the Disc or regular Polygon
  25388. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  25389. * * radius the radius of the disc, optional default 0.5
  25390. * * tessellation the number of polygon sides, optional, default 64
  25391. * * 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
  25392. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25393. * * 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)
  25394. * * 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)
  25395. * @returns the VertexData of the box
  25396. */
  25397. static CreateDisc(options: {
  25398. radius?: number;
  25399. tessellation?: number;
  25400. arc?: number;
  25401. sideOrientation?: number;
  25402. frontUVs?: Vector4;
  25403. backUVs?: Vector4;
  25404. }): VertexData;
  25405. /**
  25406. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  25407. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  25408. * @param polygon a mesh built from polygonTriangulation.build()
  25409. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25410. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  25411. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  25412. * @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)
  25413. * @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)
  25414. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  25415. * @returns the VertexData of the Polygon
  25416. */
  25417. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  25418. /**
  25419. * Creates the VertexData of the IcoSphere
  25420. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  25421. * * radius the radius of the IcoSphere, optional default 1
  25422. * * radiusX allows stretching in the x direction, optional, default radius
  25423. * * radiusY allows stretching in the y direction, optional, default radius
  25424. * * radiusZ allows stretching in the z direction, optional, default radius
  25425. * * flat when true creates a flat shaded mesh, optional, default true
  25426. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  25427. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25428. * * 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)
  25429. * * 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)
  25430. * @returns the VertexData of the IcoSphere
  25431. */
  25432. static CreateIcoSphere(options: {
  25433. radius?: number;
  25434. radiusX?: number;
  25435. radiusY?: number;
  25436. radiusZ?: number;
  25437. flat?: boolean;
  25438. subdivisions?: number;
  25439. sideOrientation?: number;
  25440. frontUVs?: Vector4;
  25441. backUVs?: Vector4;
  25442. }): VertexData;
  25443. /**
  25444. * Creates the VertexData for a Polyhedron
  25445. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  25446. * * type provided types are:
  25447. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  25448. * * 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)
  25449. * * size the size of the IcoSphere, optional default 1
  25450. * * sizeX allows stretching in the x direction, optional, default size
  25451. * * sizeY allows stretching in the y direction, optional, default size
  25452. * * sizeZ allows stretching in the z direction, optional, default size
  25453. * * 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
  25454. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  25455. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  25456. * * flat when true creates a flat shaded mesh, optional, default true
  25457. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  25458. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25459. * * 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)
  25460. * * 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)
  25461. * @returns the VertexData of the Polyhedron
  25462. */
  25463. static CreatePolyhedron(options: {
  25464. type?: number;
  25465. size?: number;
  25466. sizeX?: number;
  25467. sizeY?: number;
  25468. sizeZ?: number;
  25469. custom?: any;
  25470. faceUV?: Vector4[];
  25471. faceColors?: Color4[];
  25472. flat?: boolean;
  25473. sideOrientation?: number;
  25474. frontUVs?: Vector4;
  25475. backUVs?: Vector4;
  25476. }): VertexData;
  25477. /**
  25478. * Creates the VertexData for a TorusKnot
  25479. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  25480. * * radius the radius of the torus knot, optional, default 2
  25481. * * tube the thickness of the tube, optional, default 0.5
  25482. * * radialSegments the number of sides on each tube segments, optional, default 32
  25483. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  25484. * * p the number of windings around the z axis, optional, default 2
  25485. * * q the number of windings around the x axis, optional, default 3
  25486. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25487. * * 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)
  25488. * * 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)
  25489. * @returns the VertexData of the Torus Knot
  25490. */
  25491. static CreateTorusKnot(options: {
  25492. radius?: number;
  25493. tube?: number;
  25494. radialSegments?: number;
  25495. tubularSegments?: number;
  25496. p?: number;
  25497. q?: number;
  25498. sideOrientation?: number;
  25499. frontUVs?: Vector4;
  25500. backUVs?: Vector4;
  25501. }): VertexData;
  25502. /**
  25503. * Compute normals for given positions and indices
  25504. * @param positions an array of vertex positions, [...., x, y, z, ......]
  25505. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  25506. * @param normals an array of vertex normals, [...., x, y, z, ......]
  25507. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  25508. * * facetNormals : optional array of facet normals (vector3)
  25509. * * facetPositions : optional array of facet positions (vector3)
  25510. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  25511. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  25512. * * bInfo : optional bounding info, required for facetPartitioning computation
  25513. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  25514. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  25515. * * useRightHandedSystem: optional boolean to for right handed system computation
  25516. * * depthSort : optional boolean to enable the facet depth sort computation
  25517. * * distanceTo : optional Vector3 to compute the facet depth from this location
  25518. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  25519. */
  25520. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  25521. facetNormals?: any;
  25522. facetPositions?: any;
  25523. facetPartitioning?: any;
  25524. ratio?: number;
  25525. bInfo?: any;
  25526. bbSize?: Vector3;
  25527. subDiv?: any;
  25528. useRightHandedSystem?: boolean;
  25529. depthSort?: boolean;
  25530. distanceTo?: Vector3;
  25531. depthSortedFacets?: any;
  25532. }): void;
  25533. /** @hidden */
  25534. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  25535. /**
  25536. * Applies VertexData created from the imported parameters to the geometry
  25537. * @param parsedVertexData the parsed data from an imported file
  25538. * @param geometry the geometry to apply the VertexData to
  25539. */
  25540. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  25541. }
  25542. }
  25543. declare module BABYLON {
  25544. /**
  25545. * Defines a target to use with MorphTargetManager
  25546. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  25547. */
  25548. export class MorphTarget implements IAnimatable {
  25549. /** defines the name of the target */
  25550. name: string;
  25551. /**
  25552. * Gets or sets the list of animations
  25553. */
  25554. animations: Animation[];
  25555. private _scene;
  25556. private _positions;
  25557. private _normals;
  25558. private _tangents;
  25559. private _uvs;
  25560. private _influence;
  25561. private _uniqueId;
  25562. /**
  25563. * Observable raised when the influence changes
  25564. */
  25565. onInfluenceChanged: Observable<boolean>;
  25566. /** @hidden */
  25567. _onDataLayoutChanged: Observable<void>;
  25568. /**
  25569. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  25570. */
  25571. get influence(): number;
  25572. set influence(influence: number);
  25573. /**
  25574. * Gets or sets the id of the morph Target
  25575. */
  25576. id: string;
  25577. private _animationPropertiesOverride;
  25578. /**
  25579. * Gets or sets the animation properties override
  25580. */
  25581. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  25582. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  25583. /**
  25584. * Creates a new MorphTarget
  25585. * @param name defines the name of the target
  25586. * @param influence defines the influence to use
  25587. * @param scene defines the scene the morphtarget belongs to
  25588. */
  25589. constructor(
  25590. /** defines the name of the target */
  25591. name: string, influence?: number, scene?: Nullable<Scene>);
  25592. /**
  25593. * Gets the unique ID of this manager
  25594. */
  25595. get uniqueId(): number;
  25596. /**
  25597. * Gets a boolean defining if the target contains position data
  25598. */
  25599. get hasPositions(): boolean;
  25600. /**
  25601. * Gets a boolean defining if the target contains normal data
  25602. */
  25603. get hasNormals(): boolean;
  25604. /**
  25605. * Gets a boolean defining if the target contains tangent data
  25606. */
  25607. get hasTangents(): boolean;
  25608. /**
  25609. * Gets a boolean defining if the target contains texture coordinates data
  25610. */
  25611. get hasUVs(): boolean;
  25612. /**
  25613. * Affects position data to this target
  25614. * @param data defines the position data to use
  25615. */
  25616. setPositions(data: Nullable<FloatArray>): void;
  25617. /**
  25618. * Gets the position data stored in this target
  25619. * @returns a FloatArray containing the position data (or null if not present)
  25620. */
  25621. getPositions(): Nullable<FloatArray>;
  25622. /**
  25623. * Affects normal data to this target
  25624. * @param data defines the normal data to use
  25625. */
  25626. setNormals(data: Nullable<FloatArray>): void;
  25627. /**
  25628. * Gets the normal data stored in this target
  25629. * @returns a FloatArray containing the normal data (or null if not present)
  25630. */
  25631. getNormals(): Nullable<FloatArray>;
  25632. /**
  25633. * Affects tangent data to this target
  25634. * @param data defines the tangent data to use
  25635. */
  25636. setTangents(data: Nullable<FloatArray>): void;
  25637. /**
  25638. * Gets the tangent data stored in this target
  25639. * @returns a FloatArray containing the tangent data (or null if not present)
  25640. */
  25641. getTangents(): Nullable<FloatArray>;
  25642. /**
  25643. * Affects texture coordinates data to this target
  25644. * @param data defines the texture coordinates data to use
  25645. */
  25646. setUVs(data: Nullable<FloatArray>): void;
  25647. /**
  25648. * Gets the texture coordinates data stored in this target
  25649. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  25650. */
  25651. getUVs(): Nullable<FloatArray>;
  25652. /**
  25653. * Clone the current target
  25654. * @returns a new MorphTarget
  25655. */
  25656. clone(): MorphTarget;
  25657. /**
  25658. * Serializes the current target into a Serialization object
  25659. * @returns the serialized object
  25660. */
  25661. serialize(): any;
  25662. /**
  25663. * Returns the string "MorphTarget"
  25664. * @returns "MorphTarget"
  25665. */
  25666. getClassName(): string;
  25667. /**
  25668. * Creates a new target from serialized data
  25669. * @param serializationObject defines the serialized data to use
  25670. * @returns a new MorphTarget
  25671. */
  25672. static Parse(serializationObject: any): MorphTarget;
  25673. /**
  25674. * Creates a MorphTarget from mesh data
  25675. * @param mesh defines the source mesh
  25676. * @param name defines the name to use for the new target
  25677. * @param influence defines the influence to attach to the target
  25678. * @returns a new MorphTarget
  25679. */
  25680. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  25681. }
  25682. }
  25683. declare module BABYLON {
  25684. /**
  25685. * This class is used to deform meshes using morphing between different targets
  25686. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  25687. */
  25688. export class MorphTargetManager {
  25689. private _targets;
  25690. private _targetInfluenceChangedObservers;
  25691. private _targetDataLayoutChangedObservers;
  25692. private _activeTargets;
  25693. private _scene;
  25694. private _influences;
  25695. private _supportsNormals;
  25696. private _supportsTangents;
  25697. private _supportsUVs;
  25698. private _vertexCount;
  25699. private _uniqueId;
  25700. private _tempInfluences;
  25701. /**
  25702. * Gets or sets a boolean indicating if normals must be morphed
  25703. */
  25704. enableNormalMorphing: boolean;
  25705. /**
  25706. * Gets or sets a boolean indicating if tangents must be morphed
  25707. */
  25708. enableTangentMorphing: boolean;
  25709. /**
  25710. * Gets or sets a boolean indicating if UV must be morphed
  25711. */
  25712. enableUVMorphing: boolean;
  25713. /**
  25714. * Creates a new MorphTargetManager
  25715. * @param scene defines the current scene
  25716. */
  25717. constructor(scene?: Nullable<Scene>);
  25718. /**
  25719. * Gets the unique ID of this manager
  25720. */
  25721. get uniqueId(): number;
  25722. /**
  25723. * Gets the number of vertices handled by this manager
  25724. */
  25725. get vertexCount(): number;
  25726. /**
  25727. * Gets a boolean indicating if this manager supports morphing of normals
  25728. */
  25729. get supportsNormals(): boolean;
  25730. /**
  25731. * Gets a boolean indicating if this manager supports morphing of tangents
  25732. */
  25733. get supportsTangents(): boolean;
  25734. /**
  25735. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  25736. */
  25737. get supportsUVs(): boolean;
  25738. /**
  25739. * Gets the number of targets stored in this manager
  25740. */
  25741. get numTargets(): number;
  25742. /**
  25743. * Gets the number of influencers (ie. the number of targets with influences > 0)
  25744. */
  25745. get numInfluencers(): number;
  25746. /**
  25747. * Gets the list of influences (one per target)
  25748. */
  25749. get influences(): Float32Array;
  25750. /**
  25751. * Gets the active target at specified index. An active target is a target with an influence > 0
  25752. * @param index defines the index to check
  25753. * @returns the requested target
  25754. */
  25755. getActiveTarget(index: number): MorphTarget;
  25756. /**
  25757. * Gets the target at specified index
  25758. * @param index defines the index to check
  25759. * @returns the requested target
  25760. */
  25761. getTarget(index: number): MorphTarget;
  25762. /**
  25763. * Add a new target to this manager
  25764. * @param target defines the target to add
  25765. */
  25766. addTarget(target: MorphTarget): void;
  25767. /**
  25768. * Removes a target from the manager
  25769. * @param target defines the target to remove
  25770. */
  25771. removeTarget(target: MorphTarget): void;
  25772. /**
  25773. * Clone the current manager
  25774. * @returns a new MorphTargetManager
  25775. */
  25776. clone(): MorphTargetManager;
  25777. /**
  25778. * Serializes the current manager into a Serialization object
  25779. * @returns the serialized object
  25780. */
  25781. serialize(): any;
  25782. private _syncActiveTargets;
  25783. /**
  25784. * Syncrhonize the targets with all the meshes using this morph target manager
  25785. */
  25786. synchronize(): void;
  25787. /**
  25788. * Creates a new MorphTargetManager from serialized data
  25789. * @param serializationObject defines the serialized data
  25790. * @param scene defines the hosting scene
  25791. * @returns the new MorphTargetManager
  25792. */
  25793. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  25794. }
  25795. }
  25796. declare module BABYLON {
  25797. /**
  25798. * Class used to represent a specific level of detail of a mesh
  25799. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  25800. */
  25801. export class MeshLODLevel {
  25802. /** Defines the distance where this level should start being displayed */
  25803. distance: number;
  25804. /** Defines the mesh to use to render this level */
  25805. mesh: Nullable<Mesh>;
  25806. /**
  25807. * Creates a new LOD level
  25808. * @param distance defines the distance where this level should star being displayed
  25809. * @param mesh defines the mesh to use to render this level
  25810. */
  25811. constructor(
  25812. /** Defines the distance where this level should start being displayed */
  25813. distance: number,
  25814. /** Defines the mesh to use to render this level */
  25815. mesh: Nullable<Mesh>);
  25816. }
  25817. }
  25818. declare module BABYLON {
  25819. /**
  25820. * Mesh representing the gorund
  25821. */
  25822. export class GroundMesh extends Mesh {
  25823. /** If octree should be generated */
  25824. generateOctree: boolean;
  25825. private _heightQuads;
  25826. /** @hidden */
  25827. _subdivisionsX: number;
  25828. /** @hidden */
  25829. _subdivisionsY: number;
  25830. /** @hidden */
  25831. _width: number;
  25832. /** @hidden */
  25833. _height: number;
  25834. /** @hidden */
  25835. _minX: number;
  25836. /** @hidden */
  25837. _maxX: number;
  25838. /** @hidden */
  25839. _minZ: number;
  25840. /** @hidden */
  25841. _maxZ: number;
  25842. constructor(name: string, scene: Scene);
  25843. /**
  25844. * "GroundMesh"
  25845. * @returns "GroundMesh"
  25846. */
  25847. getClassName(): string;
  25848. /**
  25849. * The minimum of x and y subdivisions
  25850. */
  25851. get subdivisions(): number;
  25852. /**
  25853. * X subdivisions
  25854. */
  25855. get subdivisionsX(): number;
  25856. /**
  25857. * Y subdivisions
  25858. */
  25859. get subdivisionsY(): number;
  25860. /**
  25861. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  25862. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  25863. * @param chunksCount the number of subdivisions for x and y
  25864. * @param octreeBlocksSize (Default: 32)
  25865. */
  25866. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  25867. /**
  25868. * Returns a height (y) value in the Worl system :
  25869. * the ground altitude at the coordinates (x, z) expressed in the World system.
  25870. * @param x x coordinate
  25871. * @param z z coordinate
  25872. * @returns the ground y position if (x, z) are outside the ground surface.
  25873. */
  25874. getHeightAtCoordinates(x: number, z: number): number;
  25875. /**
  25876. * Returns a normalized vector (Vector3) orthogonal to the ground
  25877. * at the ground coordinates (x, z) expressed in the World system.
  25878. * @param x x coordinate
  25879. * @param z z coordinate
  25880. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  25881. */
  25882. getNormalAtCoordinates(x: number, z: number): Vector3;
  25883. /**
  25884. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  25885. * at the ground coordinates (x, z) expressed in the World system.
  25886. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  25887. * @param x x coordinate
  25888. * @param z z coordinate
  25889. * @param ref vector to store the result
  25890. * @returns the GroundMesh.
  25891. */
  25892. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  25893. /**
  25894. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  25895. * if the ground has been updated.
  25896. * This can be used in the render loop.
  25897. * @returns the GroundMesh.
  25898. */
  25899. updateCoordinateHeights(): GroundMesh;
  25900. private _getFacetAt;
  25901. private _initHeightQuads;
  25902. private _computeHeightQuads;
  25903. /**
  25904. * Serializes this ground mesh
  25905. * @param serializationObject object to write serialization to
  25906. */
  25907. serialize(serializationObject: any): void;
  25908. /**
  25909. * Parses a serialized ground mesh
  25910. * @param parsedMesh the serialized mesh
  25911. * @param scene the scene to create the ground mesh in
  25912. * @returns the created ground mesh
  25913. */
  25914. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  25915. }
  25916. }
  25917. declare module BABYLON {
  25918. /**
  25919. * Interface for Physics-Joint data
  25920. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  25921. */
  25922. export interface PhysicsJointData {
  25923. /**
  25924. * The main pivot of the joint
  25925. */
  25926. mainPivot?: Vector3;
  25927. /**
  25928. * The connected pivot of the joint
  25929. */
  25930. connectedPivot?: Vector3;
  25931. /**
  25932. * The main axis of the joint
  25933. */
  25934. mainAxis?: Vector3;
  25935. /**
  25936. * The connected axis of the joint
  25937. */
  25938. connectedAxis?: Vector3;
  25939. /**
  25940. * The collision of the joint
  25941. */
  25942. collision?: boolean;
  25943. /**
  25944. * Native Oimo/Cannon/Energy data
  25945. */
  25946. nativeParams?: any;
  25947. }
  25948. /**
  25949. * This is a holder class for the physics joint created by the physics plugin
  25950. * It holds a set of functions to control the underlying joint
  25951. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  25952. */
  25953. export class PhysicsJoint {
  25954. /**
  25955. * The type of the physics joint
  25956. */
  25957. type: number;
  25958. /**
  25959. * The data for the physics joint
  25960. */
  25961. jointData: PhysicsJointData;
  25962. private _physicsJoint;
  25963. protected _physicsPlugin: IPhysicsEnginePlugin;
  25964. /**
  25965. * Initializes the physics joint
  25966. * @param type The type of the physics joint
  25967. * @param jointData The data for the physics joint
  25968. */
  25969. constructor(
  25970. /**
  25971. * The type of the physics joint
  25972. */
  25973. type: number,
  25974. /**
  25975. * The data for the physics joint
  25976. */
  25977. jointData: PhysicsJointData);
  25978. /**
  25979. * Gets the physics joint
  25980. */
  25981. get physicsJoint(): any;
  25982. /**
  25983. * Sets the physics joint
  25984. */
  25985. set physicsJoint(newJoint: any);
  25986. /**
  25987. * Sets the physics plugin
  25988. */
  25989. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  25990. /**
  25991. * Execute a function that is physics-plugin specific.
  25992. * @param {Function} func the function that will be executed.
  25993. * It accepts two parameters: the physics world and the physics joint
  25994. */
  25995. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  25996. /**
  25997. * Distance-Joint type
  25998. */
  25999. static DistanceJoint: number;
  26000. /**
  26001. * Hinge-Joint type
  26002. */
  26003. static HingeJoint: number;
  26004. /**
  26005. * Ball-and-Socket joint type
  26006. */
  26007. static BallAndSocketJoint: number;
  26008. /**
  26009. * Wheel-Joint type
  26010. */
  26011. static WheelJoint: number;
  26012. /**
  26013. * Slider-Joint type
  26014. */
  26015. static SliderJoint: number;
  26016. /**
  26017. * Prismatic-Joint type
  26018. */
  26019. static PrismaticJoint: number;
  26020. /**
  26021. * Universal-Joint type
  26022. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  26023. */
  26024. static UniversalJoint: number;
  26025. /**
  26026. * Hinge-Joint 2 type
  26027. */
  26028. static Hinge2Joint: number;
  26029. /**
  26030. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  26031. */
  26032. static PointToPointJoint: number;
  26033. /**
  26034. * Spring-Joint type
  26035. */
  26036. static SpringJoint: number;
  26037. /**
  26038. * Lock-Joint type
  26039. */
  26040. static LockJoint: number;
  26041. }
  26042. /**
  26043. * A class representing a physics distance joint
  26044. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26045. */
  26046. export class DistanceJoint extends PhysicsJoint {
  26047. /**
  26048. *
  26049. * @param jointData The data for the Distance-Joint
  26050. */
  26051. constructor(jointData: DistanceJointData);
  26052. /**
  26053. * Update the predefined distance.
  26054. * @param maxDistance The maximum preferred distance
  26055. * @param minDistance The minimum preferred distance
  26056. */
  26057. updateDistance(maxDistance: number, minDistance?: number): void;
  26058. }
  26059. /**
  26060. * Represents a Motor-Enabled Joint
  26061. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26062. */
  26063. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  26064. /**
  26065. * Initializes the Motor-Enabled Joint
  26066. * @param type The type of the joint
  26067. * @param jointData The physica joint data for the joint
  26068. */
  26069. constructor(type: number, jointData: PhysicsJointData);
  26070. /**
  26071. * Set the motor values.
  26072. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26073. * @param force the force to apply
  26074. * @param maxForce max force for this motor.
  26075. */
  26076. setMotor(force?: number, maxForce?: number): void;
  26077. /**
  26078. * Set the motor's limits.
  26079. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26080. * @param upperLimit The upper limit of the motor
  26081. * @param lowerLimit The lower limit of the motor
  26082. */
  26083. setLimit(upperLimit: number, lowerLimit?: number): void;
  26084. }
  26085. /**
  26086. * This class represents a single physics Hinge-Joint
  26087. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26088. */
  26089. export class HingeJoint extends MotorEnabledJoint {
  26090. /**
  26091. * Initializes the Hinge-Joint
  26092. * @param jointData The joint data for the Hinge-Joint
  26093. */
  26094. constructor(jointData: PhysicsJointData);
  26095. /**
  26096. * Set the motor values.
  26097. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26098. * @param {number} force the force to apply
  26099. * @param {number} maxForce max force for this motor.
  26100. */
  26101. setMotor(force?: number, maxForce?: number): void;
  26102. /**
  26103. * Set the motor's limits.
  26104. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26105. * @param upperLimit The upper limit of the motor
  26106. * @param lowerLimit The lower limit of the motor
  26107. */
  26108. setLimit(upperLimit: number, lowerLimit?: number): void;
  26109. }
  26110. /**
  26111. * This class represents a dual hinge physics joint (same as wheel joint)
  26112. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26113. */
  26114. export class Hinge2Joint extends MotorEnabledJoint {
  26115. /**
  26116. * Initializes the Hinge2-Joint
  26117. * @param jointData The joint data for the Hinge2-Joint
  26118. */
  26119. constructor(jointData: PhysicsJointData);
  26120. /**
  26121. * Set the motor values.
  26122. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26123. * @param {number} targetSpeed the speed the motor is to reach
  26124. * @param {number} maxForce max force for this motor.
  26125. * @param {motorIndex} the motor's index, 0 or 1.
  26126. */
  26127. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  26128. /**
  26129. * Set the motor limits.
  26130. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26131. * @param {number} upperLimit the upper limit
  26132. * @param {number} lowerLimit lower limit
  26133. * @param {motorIndex} the motor's index, 0 or 1.
  26134. */
  26135. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26136. }
  26137. /**
  26138. * Interface for a motor enabled joint
  26139. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26140. */
  26141. export interface IMotorEnabledJoint {
  26142. /**
  26143. * Physics joint
  26144. */
  26145. physicsJoint: any;
  26146. /**
  26147. * Sets the motor of the motor-enabled joint
  26148. * @param force The force of the motor
  26149. * @param maxForce The maximum force of the motor
  26150. * @param motorIndex The index of the motor
  26151. */
  26152. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  26153. /**
  26154. * Sets the limit of the motor
  26155. * @param upperLimit The upper limit of the motor
  26156. * @param lowerLimit The lower limit of the motor
  26157. * @param motorIndex The index of the motor
  26158. */
  26159. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26160. }
  26161. /**
  26162. * Joint data for a Distance-Joint
  26163. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26164. */
  26165. export interface DistanceJointData extends PhysicsJointData {
  26166. /**
  26167. * Max distance the 2 joint objects can be apart
  26168. */
  26169. maxDistance: number;
  26170. }
  26171. /**
  26172. * Joint data from a spring joint
  26173. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26174. */
  26175. export interface SpringJointData extends PhysicsJointData {
  26176. /**
  26177. * Length of the spring
  26178. */
  26179. length: number;
  26180. /**
  26181. * Stiffness of the spring
  26182. */
  26183. stiffness: number;
  26184. /**
  26185. * Damping of the spring
  26186. */
  26187. damping: number;
  26188. /** this callback will be called when applying the force to the impostors. */
  26189. forceApplicationCallback: () => void;
  26190. }
  26191. }
  26192. declare module BABYLON {
  26193. /**
  26194. * Holds the data for the raycast result
  26195. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26196. */
  26197. export class PhysicsRaycastResult {
  26198. private _hasHit;
  26199. private _hitDistance;
  26200. private _hitNormalWorld;
  26201. private _hitPointWorld;
  26202. private _rayFromWorld;
  26203. private _rayToWorld;
  26204. /**
  26205. * Gets if there was a hit
  26206. */
  26207. get hasHit(): boolean;
  26208. /**
  26209. * Gets the distance from the hit
  26210. */
  26211. get hitDistance(): number;
  26212. /**
  26213. * Gets the hit normal/direction in the world
  26214. */
  26215. get hitNormalWorld(): Vector3;
  26216. /**
  26217. * Gets the hit point in the world
  26218. */
  26219. get hitPointWorld(): Vector3;
  26220. /**
  26221. * Gets the ray "start point" of the ray in the world
  26222. */
  26223. get rayFromWorld(): Vector3;
  26224. /**
  26225. * Gets the ray "end point" of the ray in the world
  26226. */
  26227. get rayToWorld(): Vector3;
  26228. /**
  26229. * Sets the hit data (normal & point in world space)
  26230. * @param hitNormalWorld defines the normal in world space
  26231. * @param hitPointWorld defines the point in world space
  26232. */
  26233. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  26234. /**
  26235. * Sets the distance from the start point to the hit point
  26236. * @param distance
  26237. */
  26238. setHitDistance(distance: number): void;
  26239. /**
  26240. * Calculates the distance manually
  26241. */
  26242. calculateHitDistance(): void;
  26243. /**
  26244. * Resets all the values to default
  26245. * @param from The from point on world space
  26246. * @param to The to point on world space
  26247. */
  26248. reset(from?: Vector3, to?: Vector3): void;
  26249. }
  26250. /**
  26251. * Interface for the size containing width and height
  26252. */
  26253. interface IXYZ {
  26254. /**
  26255. * X
  26256. */
  26257. x: number;
  26258. /**
  26259. * Y
  26260. */
  26261. y: number;
  26262. /**
  26263. * Z
  26264. */
  26265. z: number;
  26266. }
  26267. }
  26268. declare module BABYLON {
  26269. /**
  26270. * Interface used to describe a physics joint
  26271. */
  26272. export interface PhysicsImpostorJoint {
  26273. /** Defines the main impostor to which the joint is linked */
  26274. mainImpostor: PhysicsImpostor;
  26275. /** Defines the impostor that is connected to the main impostor using this joint */
  26276. connectedImpostor: PhysicsImpostor;
  26277. /** Defines the joint itself */
  26278. joint: PhysicsJoint;
  26279. }
  26280. /** @hidden */
  26281. export interface IPhysicsEnginePlugin {
  26282. world: any;
  26283. name: string;
  26284. setGravity(gravity: Vector3): void;
  26285. setTimeStep(timeStep: number): void;
  26286. getTimeStep(): number;
  26287. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  26288. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  26289. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  26290. generatePhysicsBody(impostor: PhysicsImpostor): void;
  26291. removePhysicsBody(impostor: PhysicsImpostor): void;
  26292. generateJoint(joint: PhysicsImpostorJoint): void;
  26293. removeJoint(joint: PhysicsImpostorJoint): void;
  26294. isSupported(): boolean;
  26295. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  26296. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  26297. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  26298. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  26299. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  26300. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  26301. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  26302. getBodyMass(impostor: PhysicsImpostor): number;
  26303. getBodyFriction(impostor: PhysicsImpostor): number;
  26304. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  26305. getBodyRestitution(impostor: PhysicsImpostor): number;
  26306. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  26307. getBodyPressure?(impostor: PhysicsImpostor): number;
  26308. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  26309. getBodyStiffness?(impostor: PhysicsImpostor): number;
  26310. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  26311. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  26312. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  26313. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  26314. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  26315. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  26316. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  26317. sleepBody(impostor: PhysicsImpostor): void;
  26318. wakeUpBody(impostor: PhysicsImpostor): void;
  26319. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  26320. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  26321. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  26322. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26323. getRadius(impostor: PhysicsImpostor): number;
  26324. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  26325. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  26326. dispose(): void;
  26327. }
  26328. /**
  26329. * Interface used to define a physics engine
  26330. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  26331. */
  26332. export interface IPhysicsEngine {
  26333. /**
  26334. * Gets the gravity vector used by the simulation
  26335. */
  26336. gravity: Vector3;
  26337. /**
  26338. * Sets the gravity vector used by the simulation
  26339. * @param gravity defines the gravity vector to use
  26340. */
  26341. setGravity(gravity: Vector3): void;
  26342. /**
  26343. * Set the time step of the physics engine.
  26344. * Default is 1/60.
  26345. * To slow it down, enter 1/600 for example.
  26346. * To speed it up, 1/30
  26347. * @param newTimeStep the new timestep to apply to this world.
  26348. */
  26349. setTimeStep(newTimeStep: number): void;
  26350. /**
  26351. * Get the time step of the physics engine.
  26352. * @returns the current time step
  26353. */
  26354. getTimeStep(): number;
  26355. /**
  26356. * Set the sub time step of the physics engine.
  26357. * Default is 0 meaning there is no sub steps
  26358. * To increase physics resolution precision, set a small value (like 1 ms)
  26359. * @param subTimeStep defines the new sub timestep used for physics resolution.
  26360. */
  26361. setSubTimeStep(subTimeStep: number): void;
  26362. /**
  26363. * Get the sub time step of the physics engine.
  26364. * @returns the current sub time step
  26365. */
  26366. getSubTimeStep(): number;
  26367. /**
  26368. * Release all resources
  26369. */
  26370. dispose(): void;
  26371. /**
  26372. * Gets the name of the current physics plugin
  26373. * @returns the name of the plugin
  26374. */
  26375. getPhysicsPluginName(): string;
  26376. /**
  26377. * Adding a new impostor for the impostor tracking.
  26378. * This will be done by the impostor itself.
  26379. * @param impostor the impostor to add
  26380. */
  26381. addImpostor(impostor: PhysicsImpostor): void;
  26382. /**
  26383. * Remove an impostor from the engine.
  26384. * This impostor and its mesh will not longer be updated by the physics engine.
  26385. * @param impostor the impostor to remove
  26386. */
  26387. removeImpostor(impostor: PhysicsImpostor): void;
  26388. /**
  26389. * Add a joint to the physics engine
  26390. * @param mainImpostor defines the main impostor to which the joint is added.
  26391. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  26392. * @param joint defines the joint that will connect both impostors.
  26393. */
  26394. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  26395. /**
  26396. * Removes a joint from the simulation
  26397. * @param mainImpostor defines the impostor used with the joint
  26398. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  26399. * @param joint defines the joint to remove
  26400. */
  26401. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  26402. /**
  26403. * Gets the current plugin used to run the simulation
  26404. * @returns current plugin
  26405. */
  26406. getPhysicsPlugin(): IPhysicsEnginePlugin;
  26407. /**
  26408. * Gets the list of physic impostors
  26409. * @returns an array of PhysicsImpostor
  26410. */
  26411. getImpostors(): Array<PhysicsImpostor>;
  26412. /**
  26413. * Gets the impostor for a physics enabled object
  26414. * @param object defines the object impersonated by the impostor
  26415. * @returns the PhysicsImpostor or null if not found
  26416. */
  26417. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  26418. /**
  26419. * Gets the impostor for a physics body object
  26420. * @param body defines physics body used by the impostor
  26421. * @returns the PhysicsImpostor or null if not found
  26422. */
  26423. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  26424. /**
  26425. * Does a raycast in the physics world
  26426. * @param from when should the ray start?
  26427. * @param to when should the ray end?
  26428. * @returns PhysicsRaycastResult
  26429. */
  26430. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  26431. /**
  26432. * Called by the scene. No need to call it.
  26433. * @param delta defines the timespam between frames
  26434. */
  26435. _step(delta: number): void;
  26436. }
  26437. }
  26438. declare module BABYLON {
  26439. /**
  26440. * The interface for the physics imposter parameters
  26441. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26442. */
  26443. export interface PhysicsImpostorParameters {
  26444. /**
  26445. * The mass of the physics imposter
  26446. */
  26447. mass: number;
  26448. /**
  26449. * The friction of the physics imposter
  26450. */
  26451. friction?: number;
  26452. /**
  26453. * The coefficient of restitution of the physics imposter
  26454. */
  26455. restitution?: number;
  26456. /**
  26457. * The native options of the physics imposter
  26458. */
  26459. nativeOptions?: any;
  26460. /**
  26461. * Specifies if the parent should be ignored
  26462. */
  26463. ignoreParent?: boolean;
  26464. /**
  26465. * Specifies if bi-directional transformations should be disabled
  26466. */
  26467. disableBidirectionalTransformation?: boolean;
  26468. /**
  26469. * The pressure inside the physics imposter, soft object only
  26470. */
  26471. pressure?: number;
  26472. /**
  26473. * The stiffness the physics imposter, soft object only
  26474. */
  26475. stiffness?: number;
  26476. /**
  26477. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  26478. */
  26479. velocityIterations?: number;
  26480. /**
  26481. * The number of iterations used in maintaining consistent vertex positions, soft object only
  26482. */
  26483. positionIterations?: number;
  26484. /**
  26485. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  26486. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  26487. * Add to fix multiple points
  26488. */
  26489. fixedPoints?: number;
  26490. /**
  26491. * The collision margin around a soft object
  26492. */
  26493. margin?: number;
  26494. /**
  26495. * The collision margin around a soft object
  26496. */
  26497. damping?: number;
  26498. /**
  26499. * The path for a rope based on an extrusion
  26500. */
  26501. path?: any;
  26502. /**
  26503. * The shape of an extrusion used for a rope based on an extrusion
  26504. */
  26505. shape?: any;
  26506. }
  26507. /**
  26508. * Interface for a physics-enabled object
  26509. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26510. */
  26511. export interface IPhysicsEnabledObject {
  26512. /**
  26513. * The position of the physics-enabled object
  26514. */
  26515. position: Vector3;
  26516. /**
  26517. * The rotation of the physics-enabled object
  26518. */
  26519. rotationQuaternion: Nullable<Quaternion>;
  26520. /**
  26521. * The scale of the physics-enabled object
  26522. */
  26523. scaling: Vector3;
  26524. /**
  26525. * The rotation of the physics-enabled object
  26526. */
  26527. rotation?: Vector3;
  26528. /**
  26529. * The parent of the physics-enabled object
  26530. */
  26531. parent?: any;
  26532. /**
  26533. * The bounding info of the physics-enabled object
  26534. * @returns The bounding info of the physics-enabled object
  26535. */
  26536. getBoundingInfo(): BoundingInfo;
  26537. /**
  26538. * Computes the world matrix
  26539. * @param force Specifies if the world matrix should be computed by force
  26540. * @returns A world matrix
  26541. */
  26542. computeWorldMatrix(force: boolean): Matrix;
  26543. /**
  26544. * Gets the world matrix
  26545. * @returns A world matrix
  26546. */
  26547. getWorldMatrix?(): Matrix;
  26548. /**
  26549. * Gets the child meshes
  26550. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  26551. * @returns An array of abstract meshes
  26552. */
  26553. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  26554. /**
  26555. * Gets the vertex data
  26556. * @param kind The type of vertex data
  26557. * @returns A nullable array of numbers, or a float32 array
  26558. */
  26559. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  26560. /**
  26561. * Gets the indices from the mesh
  26562. * @returns A nullable array of index arrays
  26563. */
  26564. getIndices?(): Nullable<IndicesArray>;
  26565. /**
  26566. * Gets the scene from the mesh
  26567. * @returns the indices array or null
  26568. */
  26569. getScene?(): Scene;
  26570. /**
  26571. * Gets the absolute position from the mesh
  26572. * @returns the absolute position
  26573. */
  26574. getAbsolutePosition(): Vector3;
  26575. /**
  26576. * Gets the absolute pivot point from the mesh
  26577. * @returns the absolute pivot point
  26578. */
  26579. getAbsolutePivotPoint(): Vector3;
  26580. /**
  26581. * Rotates the mesh
  26582. * @param axis The axis of rotation
  26583. * @param amount The amount of rotation
  26584. * @param space The space of the rotation
  26585. * @returns The rotation transform node
  26586. */
  26587. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  26588. /**
  26589. * Translates the mesh
  26590. * @param axis The axis of translation
  26591. * @param distance The distance of translation
  26592. * @param space The space of the translation
  26593. * @returns The transform node
  26594. */
  26595. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  26596. /**
  26597. * Sets the absolute position of the mesh
  26598. * @param absolutePosition The absolute position of the mesh
  26599. * @returns The transform node
  26600. */
  26601. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  26602. /**
  26603. * Gets the class name of the mesh
  26604. * @returns The class name
  26605. */
  26606. getClassName(): string;
  26607. }
  26608. /**
  26609. * Represents a physics imposter
  26610. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26611. */
  26612. export class PhysicsImpostor {
  26613. /**
  26614. * The physics-enabled object used as the physics imposter
  26615. */
  26616. object: IPhysicsEnabledObject;
  26617. /**
  26618. * The type of the physics imposter
  26619. */
  26620. type: number;
  26621. private _options;
  26622. private _scene?;
  26623. /**
  26624. * The default object size of the imposter
  26625. */
  26626. static DEFAULT_OBJECT_SIZE: Vector3;
  26627. /**
  26628. * The identity quaternion of the imposter
  26629. */
  26630. static IDENTITY_QUATERNION: Quaternion;
  26631. /** @hidden */
  26632. _pluginData: any;
  26633. private _physicsEngine;
  26634. private _physicsBody;
  26635. private _bodyUpdateRequired;
  26636. private _onBeforePhysicsStepCallbacks;
  26637. private _onAfterPhysicsStepCallbacks;
  26638. /** @hidden */
  26639. _onPhysicsCollideCallbacks: Array<{
  26640. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  26641. otherImpostors: Array<PhysicsImpostor>;
  26642. }>;
  26643. private _deltaPosition;
  26644. private _deltaRotation;
  26645. private _deltaRotationConjugated;
  26646. /** @hidden */
  26647. _isFromLine: boolean;
  26648. private _parent;
  26649. private _isDisposed;
  26650. private static _tmpVecs;
  26651. private static _tmpQuat;
  26652. /**
  26653. * Specifies if the physics imposter is disposed
  26654. */
  26655. get isDisposed(): boolean;
  26656. /**
  26657. * Gets the mass of the physics imposter
  26658. */
  26659. get mass(): number;
  26660. set mass(value: number);
  26661. /**
  26662. * Gets the coefficient of friction
  26663. */
  26664. get friction(): number;
  26665. /**
  26666. * Sets the coefficient of friction
  26667. */
  26668. set friction(value: number);
  26669. /**
  26670. * Gets the coefficient of restitution
  26671. */
  26672. get restitution(): number;
  26673. /**
  26674. * Sets the coefficient of restitution
  26675. */
  26676. set restitution(value: number);
  26677. /**
  26678. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  26679. */
  26680. get pressure(): number;
  26681. /**
  26682. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  26683. */
  26684. set pressure(value: number);
  26685. /**
  26686. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  26687. */
  26688. get stiffness(): number;
  26689. /**
  26690. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  26691. */
  26692. set stiffness(value: number);
  26693. /**
  26694. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  26695. */
  26696. get velocityIterations(): number;
  26697. /**
  26698. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  26699. */
  26700. set velocityIterations(value: number);
  26701. /**
  26702. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  26703. */
  26704. get positionIterations(): number;
  26705. /**
  26706. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  26707. */
  26708. set positionIterations(value: number);
  26709. /**
  26710. * The unique id of the physics imposter
  26711. * set by the physics engine when adding this impostor to the array
  26712. */
  26713. uniqueId: number;
  26714. /**
  26715. * @hidden
  26716. */
  26717. soft: boolean;
  26718. /**
  26719. * @hidden
  26720. */
  26721. segments: number;
  26722. private _joints;
  26723. /**
  26724. * Initializes the physics imposter
  26725. * @param object The physics-enabled object used as the physics imposter
  26726. * @param type The type of the physics imposter
  26727. * @param _options The options for the physics imposter
  26728. * @param _scene The Babylon scene
  26729. */
  26730. constructor(
  26731. /**
  26732. * The physics-enabled object used as the physics imposter
  26733. */
  26734. object: IPhysicsEnabledObject,
  26735. /**
  26736. * The type of the physics imposter
  26737. */
  26738. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  26739. /**
  26740. * This function will completly initialize this impostor.
  26741. * It will create a new body - but only if this mesh has no parent.
  26742. * If it has, this impostor will not be used other than to define the impostor
  26743. * of the child mesh.
  26744. * @hidden
  26745. */
  26746. _init(): void;
  26747. private _getPhysicsParent;
  26748. /**
  26749. * Should a new body be generated.
  26750. * @returns boolean specifying if body initialization is required
  26751. */
  26752. isBodyInitRequired(): boolean;
  26753. /**
  26754. * Sets the updated scaling
  26755. * @param updated Specifies if the scaling is updated
  26756. */
  26757. setScalingUpdated(): void;
  26758. /**
  26759. * Force a regeneration of this or the parent's impostor's body.
  26760. * Use under cautious - This will remove all joints already implemented.
  26761. */
  26762. forceUpdate(): void;
  26763. /**
  26764. * Gets the body that holds this impostor. Either its own, or its parent.
  26765. */
  26766. get physicsBody(): any;
  26767. /**
  26768. * Get the parent of the physics imposter
  26769. * @returns Physics imposter or null
  26770. */
  26771. get parent(): Nullable<PhysicsImpostor>;
  26772. /**
  26773. * Sets the parent of the physics imposter
  26774. */
  26775. set parent(value: Nullable<PhysicsImpostor>);
  26776. /**
  26777. * Set the physics body. Used mainly by the physics engine/plugin
  26778. */
  26779. set physicsBody(physicsBody: any);
  26780. /**
  26781. * Resets the update flags
  26782. */
  26783. resetUpdateFlags(): void;
  26784. /**
  26785. * Gets the object extend size
  26786. * @returns the object extend size
  26787. */
  26788. getObjectExtendSize(): Vector3;
  26789. /**
  26790. * Gets the object center
  26791. * @returns The object center
  26792. */
  26793. getObjectCenter(): Vector3;
  26794. /**
  26795. * Get a specific parameter from the options parameters
  26796. * @param paramName The object parameter name
  26797. * @returns The object parameter
  26798. */
  26799. getParam(paramName: string): any;
  26800. /**
  26801. * Sets a specific parameter in the options given to the physics plugin
  26802. * @param paramName The parameter name
  26803. * @param value The value of the parameter
  26804. */
  26805. setParam(paramName: string, value: number): void;
  26806. /**
  26807. * Specifically change the body's mass option. Won't recreate the physics body object
  26808. * @param mass The mass of the physics imposter
  26809. */
  26810. setMass(mass: number): void;
  26811. /**
  26812. * Gets the linear velocity
  26813. * @returns linear velocity or null
  26814. */
  26815. getLinearVelocity(): Nullable<Vector3>;
  26816. /**
  26817. * Sets the linear velocity
  26818. * @param velocity linear velocity or null
  26819. */
  26820. setLinearVelocity(velocity: Nullable<Vector3>): void;
  26821. /**
  26822. * Gets the angular velocity
  26823. * @returns angular velocity or null
  26824. */
  26825. getAngularVelocity(): Nullable<Vector3>;
  26826. /**
  26827. * Sets the angular velocity
  26828. * @param velocity The velocity or null
  26829. */
  26830. setAngularVelocity(velocity: Nullable<Vector3>): void;
  26831. /**
  26832. * Execute a function with the physics plugin native code
  26833. * Provide a function the will have two variables - the world object and the physics body object
  26834. * @param func The function to execute with the physics plugin native code
  26835. */
  26836. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  26837. /**
  26838. * Register a function that will be executed before the physics world is stepping forward
  26839. * @param func The function to execute before the physics world is stepped forward
  26840. */
  26841. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26842. /**
  26843. * Unregister a function that will be executed before the physics world is stepping forward
  26844. * @param func The function to execute before the physics world is stepped forward
  26845. */
  26846. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26847. /**
  26848. * Register a function that will be executed after the physics step
  26849. * @param func The function to execute after physics step
  26850. */
  26851. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26852. /**
  26853. * Unregisters a function that will be executed after the physics step
  26854. * @param func The function to execute after physics step
  26855. */
  26856. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26857. /**
  26858. * register a function that will be executed when this impostor collides against a different body
  26859. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  26860. * @param func Callback that is executed on collision
  26861. */
  26862. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  26863. /**
  26864. * Unregisters the physics imposter on contact
  26865. * @param collideAgainst The physics object to collide against
  26866. * @param func Callback to execute on collision
  26867. */
  26868. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  26869. private _tmpQuat;
  26870. private _tmpQuat2;
  26871. /**
  26872. * Get the parent rotation
  26873. * @returns The parent rotation
  26874. */
  26875. getParentsRotation(): Quaternion;
  26876. /**
  26877. * this function is executed by the physics engine.
  26878. */
  26879. beforeStep: () => void;
  26880. /**
  26881. * this function is executed by the physics engine
  26882. */
  26883. afterStep: () => void;
  26884. /**
  26885. * Legacy collision detection event support
  26886. */
  26887. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  26888. /**
  26889. * event and body object due to cannon's event-based architecture.
  26890. */
  26891. onCollide: (e: {
  26892. body: any;
  26893. }) => void;
  26894. /**
  26895. * Apply a force
  26896. * @param force The force to apply
  26897. * @param contactPoint The contact point for the force
  26898. * @returns The physics imposter
  26899. */
  26900. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  26901. /**
  26902. * Apply an impulse
  26903. * @param force The impulse force
  26904. * @param contactPoint The contact point for the impulse force
  26905. * @returns The physics imposter
  26906. */
  26907. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  26908. /**
  26909. * A help function to create a joint
  26910. * @param otherImpostor A physics imposter used to create a joint
  26911. * @param jointType The type of joint
  26912. * @param jointData The data for the joint
  26913. * @returns The physics imposter
  26914. */
  26915. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  26916. /**
  26917. * Add a joint to this impostor with a different impostor
  26918. * @param otherImpostor A physics imposter used to add a joint
  26919. * @param joint The joint to add
  26920. * @returns The physics imposter
  26921. */
  26922. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  26923. /**
  26924. * Add an anchor to a cloth impostor
  26925. * @param otherImpostor rigid impostor to anchor to
  26926. * @param width ratio across width from 0 to 1
  26927. * @param height ratio up height from 0 to 1
  26928. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  26929. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  26930. * @returns impostor the soft imposter
  26931. */
  26932. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  26933. /**
  26934. * Add a hook to a rope impostor
  26935. * @param otherImpostor rigid impostor to anchor to
  26936. * @param length ratio across rope from 0 to 1
  26937. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  26938. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  26939. * @returns impostor the rope imposter
  26940. */
  26941. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  26942. /**
  26943. * Will keep this body still, in a sleep mode.
  26944. * @returns the physics imposter
  26945. */
  26946. sleep(): PhysicsImpostor;
  26947. /**
  26948. * Wake the body up.
  26949. * @returns The physics imposter
  26950. */
  26951. wakeUp(): PhysicsImpostor;
  26952. /**
  26953. * Clones the physics imposter
  26954. * @param newObject The physics imposter clones to this physics-enabled object
  26955. * @returns A nullable physics imposter
  26956. */
  26957. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  26958. /**
  26959. * Disposes the physics imposter
  26960. */
  26961. dispose(): void;
  26962. /**
  26963. * Sets the delta position
  26964. * @param position The delta position amount
  26965. */
  26966. setDeltaPosition(position: Vector3): void;
  26967. /**
  26968. * Sets the delta rotation
  26969. * @param rotation The delta rotation amount
  26970. */
  26971. setDeltaRotation(rotation: Quaternion): void;
  26972. /**
  26973. * Gets the box size of the physics imposter and stores the result in the input parameter
  26974. * @param result Stores the box size
  26975. * @returns The physics imposter
  26976. */
  26977. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  26978. /**
  26979. * Gets the radius of the physics imposter
  26980. * @returns Radius of the physics imposter
  26981. */
  26982. getRadius(): number;
  26983. /**
  26984. * Sync a bone with this impostor
  26985. * @param bone The bone to sync to the impostor.
  26986. * @param boneMesh The mesh that the bone is influencing.
  26987. * @param jointPivot The pivot of the joint / bone in local space.
  26988. * @param distToJoint Optional distance from the impostor to the joint.
  26989. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  26990. */
  26991. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  26992. /**
  26993. * Sync impostor to a bone
  26994. * @param bone The bone that the impostor will be synced to.
  26995. * @param boneMesh The mesh that the bone is influencing.
  26996. * @param jointPivot The pivot of the joint / bone in local space.
  26997. * @param distToJoint Optional distance from the impostor to the joint.
  26998. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  26999. * @param boneAxis Optional vector3 axis the bone is aligned with
  27000. */
  27001. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  27002. /**
  27003. * No-Imposter type
  27004. */
  27005. static NoImpostor: number;
  27006. /**
  27007. * Sphere-Imposter type
  27008. */
  27009. static SphereImpostor: number;
  27010. /**
  27011. * Box-Imposter type
  27012. */
  27013. static BoxImpostor: number;
  27014. /**
  27015. * Plane-Imposter type
  27016. */
  27017. static PlaneImpostor: number;
  27018. /**
  27019. * Mesh-imposter type
  27020. */
  27021. static MeshImpostor: number;
  27022. /**
  27023. * Capsule-Impostor type (Ammo.js plugin only)
  27024. */
  27025. static CapsuleImpostor: number;
  27026. /**
  27027. * Cylinder-Imposter type
  27028. */
  27029. static CylinderImpostor: number;
  27030. /**
  27031. * Particle-Imposter type
  27032. */
  27033. static ParticleImpostor: number;
  27034. /**
  27035. * Heightmap-Imposter type
  27036. */
  27037. static HeightmapImpostor: number;
  27038. /**
  27039. * ConvexHull-Impostor type (Ammo.js plugin only)
  27040. */
  27041. static ConvexHullImpostor: number;
  27042. /**
  27043. * Custom-Imposter type (Ammo.js plugin only)
  27044. */
  27045. static CustomImpostor: number;
  27046. /**
  27047. * Rope-Imposter type
  27048. */
  27049. static RopeImpostor: number;
  27050. /**
  27051. * Cloth-Imposter type
  27052. */
  27053. static ClothImpostor: number;
  27054. /**
  27055. * Softbody-Imposter type
  27056. */
  27057. static SoftbodyImpostor: number;
  27058. }
  27059. }
  27060. declare module BABYLON {
  27061. /**
  27062. * @hidden
  27063. **/
  27064. export class _CreationDataStorage {
  27065. closePath?: boolean;
  27066. closeArray?: boolean;
  27067. idx: number[];
  27068. dashSize: number;
  27069. gapSize: number;
  27070. path3D: Path3D;
  27071. pathArray: Vector3[][];
  27072. arc: number;
  27073. radius: number;
  27074. cap: number;
  27075. tessellation: number;
  27076. }
  27077. /**
  27078. * @hidden
  27079. **/
  27080. class _InstanceDataStorage {
  27081. visibleInstances: any;
  27082. batchCache: _InstancesBatch;
  27083. instancesBufferSize: number;
  27084. instancesBuffer: Nullable<Buffer>;
  27085. instancesData: Float32Array;
  27086. overridenInstanceCount: number;
  27087. isFrozen: boolean;
  27088. previousBatch: Nullable<_InstancesBatch>;
  27089. hardwareInstancedRendering: boolean;
  27090. sideOrientation: number;
  27091. manualUpdate: boolean;
  27092. }
  27093. /**
  27094. * @hidden
  27095. **/
  27096. export class _InstancesBatch {
  27097. mustReturn: boolean;
  27098. visibleInstances: Nullable<InstancedMesh[]>[];
  27099. renderSelf: boolean[];
  27100. hardwareInstancedRendering: boolean[];
  27101. }
  27102. /**
  27103. * Class used to represent renderable models
  27104. */
  27105. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  27106. /**
  27107. * Mesh side orientation : usually the external or front surface
  27108. */
  27109. static readonly FRONTSIDE: number;
  27110. /**
  27111. * Mesh side orientation : usually the internal or back surface
  27112. */
  27113. static readonly BACKSIDE: number;
  27114. /**
  27115. * Mesh side orientation : both internal and external or front and back surfaces
  27116. */
  27117. static readonly DOUBLESIDE: number;
  27118. /**
  27119. * Mesh side orientation : by default, `FRONTSIDE`
  27120. */
  27121. static readonly DEFAULTSIDE: number;
  27122. /**
  27123. * Mesh cap setting : no cap
  27124. */
  27125. static readonly NO_CAP: number;
  27126. /**
  27127. * Mesh cap setting : one cap at the beginning of the mesh
  27128. */
  27129. static readonly CAP_START: number;
  27130. /**
  27131. * Mesh cap setting : one cap at the end of the mesh
  27132. */
  27133. static readonly CAP_END: number;
  27134. /**
  27135. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  27136. */
  27137. static readonly CAP_ALL: number;
  27138. /**
  27139. * Mesh pattern setting : no flip or rotate
  27140. */
  27141. static readonly NO_FLIP: number;
  27142. /**
  27143. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  27144. */
  27145. static readonly FLIP_TILE: number;
  27146. /**
  27147. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  27148. */
  27149. static readonly ROTATE_TILE: number;
  27150. /**
  27151. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  27152. */
  27153. static readonly FLIP_ROW: number;
  27154. /**
  27155. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  27156. */
  27157. static readonly ROTATE_ROW: number;
  27158. /**
  27159. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  27160. */
  27161. static readonly FLIP_N_ROTATE_TILE: number;
  27162. /**
  27163. * Mesh pattern setting : rotate pattern and rotate
  27164. */
  27165. static readonly FLIP_N_ROTATE_ROW: number;
  27166. /**
  27167. * Mesh tile positioning : part tiles same on left/right or top/bottom
  27168. */
  27169. static readonly CENTER: number;
  27170. /**
  27171. * Mesh tile positioning : part tiles on left
  27172. */
  27173. static readonly LEFT: number;
  27174. /**
  27175. * Mesh tile positioning : part tiles on right
  27176. */
  27177. static readonly RIGHT: number;
  27178. /**
  27179. * Mesh tile positioning : part tiles on top
  27180. */
  27181. static readonly TOP: number;
  27182. /**
  27183. * Mesh tile positioning : part tiles on bottom
  27184. */
  27185. static readonly BOTTOM: number;
  27186. /**
  27187. * Gets the default side orientation.
  27188. * @param orientation the orientation to value to attempt to get
  27189. * @returns the default orientation
  27190. * @hidden
  27191. */
  27192. static _GetDefaultSideOrientation(orientation?: number): number;
  27193. private _internalMeshDataInfo;
  27194. /**
  27195. * An event triggered before rendering the mesh
  27196. */
  27197. get onBeforeRenderObservable(): Observable<Mesh>;
  27198. /**
  27199. * An event triggered before binding the mesh
  27200. */
  27201. get onBeforeBindObservable(): Observable<Mesh>;
  27202. /**
  27203. * An event triggered after rendering the mesh
  27204. */
  27205. get onAfterRenderObservable(): Observable<Mesh>;
  27206. /**
  27207. * An event triggered before drawing the mesh
  27208. */
  27209. get onBeforeDrawObservable(): Observable<Mesh>;
  27210. private _onBeforeDrawObserver;
  27211. /**
  27212. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  27213. */
  27214. set onBeforeDraw(callback: () => void);
  27215. get hasInstances(): boolean;
  27216. /**
  27217. * Gets the delay loading state of the mesh (when delay loading is turned on)
  27218. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  27219. */
  27220. delayLoadState: number;
  27221. /**
  27222. * Gets the list of instances created from this mesh
  27223. * it is not supposed to be modified manually.
  27224. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  27225. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  27226. */
  27227. instances: InstancedMesh[];
  27228. /**
  27229. * Gets the file containing delay loading data for this mesh
  27230. */
  27231. delayLoadingFile: string;
  27232. /** @hidden */
  27233. _binaryInfo: any;
  27234. /**
  27235. * User defined function used to change how LOD level selection is done
  27236. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  27237. */
  27238. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  27239. /**
  27240. * Gets or sets the morph target manager
  27241. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  27242. */
  27243. get morphTargetManager(): Nullable<MorphTargetManager>;
  27244. set morphTargetManager(value: Nullable<MorphTargetManager>);
  27245. /** @hidden */
  27246. _creationDataStorage: Nullable<_CreationDataStorage>;
  27247. /** @hidden */
  27248. _geometry: Nullable<Geometry>;
  27249. /** @hidden */
  27250. _delayInfo: Array<string>;
  27251. /** @hidden */
  27252. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  27253. /** @hidden */
  27254. _instanceDataStorage: _InstanceDataStorage;
  27255. private _effectiveMaterial;
  27256. /** @hidden */
  27257. _shouldGenerateFlatShading: boolean;
  27258. /** @hidden */
  27259. _originalBuilderSideOrientation: number;
  27260. /**
  27261. * Use this property to change the original side orientation defined at construction time
  27262. */
  27263. overrideMaterialSideOrientation: Nullable<number>;
  27264. /**
  27265. * Gets the source mesh (the one used to clone this one from)
  27266. */
  27267. get source(): Nullable<Mesh>;
  27268. /**
  27269. * Gets or sets a boolean indicating that this mesh does not use index buffer
  27270. */
  27271. get isUnIndexed(): boolean;
  27272. set isUnIndexed(value: boolean);
  27273. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  27274. get worldMatrixInstancedBuffer(): Float32Array;
  27275. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  27276. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  27277. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  27278. /**
  27279. * @constructor
  27280. * @param name The value used by scene.getMeshByName() to do a lookup.
  27281. * @param scene The scene to add this mesh to.
  27282. * @param parent The parent of this mesh, if it has one
  27283. * @param source An optional Mesh from which geometry is shared, cloned.
  27284. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  27285. * When false, achieved by calling a clone(), also passing False.
  27286. * This will make creation of children, recursive.
  27287. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  27288. */
  27289. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  27290. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  27291. doNotInstantiate: boolean;
  27292. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  27293. /**
  27294. * Gets the class name
  27295. * @returns the string "Mesh".
  27296. */
  27297. getClassName(): string;
  27298. /** @hidden */
  27299. get _isMesh(): boolean;
  27300. /**
  27301. * Returns a description of this mesh
  27302. * @param fullDetails define if full details about this mesh must be used
  27303. * @returns a descriptive string representing this mesh
  27304. */
  27305. toString(fullDetails?: boolean): string;
  27306. /** @hidden */
  27307. _unBindEffect(): void;
  27308. /**
  27309. * Gets a boolean indicating if this mesh has LOD
  27310. */
  27311. get hasLODLevels(): boolean;
  27312. /**
  27313. * Gets the list of MeshLODLevel associated with the current mesh
  27314. * @returns an array of MeshLODLevel
  27315. */
  27316. getLODLevels(): MeshLODLevel[];
  27317. private _sortLODLevels;
  27318. /**
  27319. * Add a mesh as LOD level triggered at the given distance.
  27320. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27321. * @param distance The distance from the center of the object to show this level
  27322. * @param mesh The mesh to be added as LOD level (can be null)
  27323. * @return This mesh (for chaining)
  27324. */
  27325. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  27326. /**
  27327. * Returns the LOD level mesh at the passed distance or null if not found.
  27328. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27329. * @param distance The distance from the center of the object to show this level
  27330. * @returns a Mesh or `null`
  27331. */
  27332. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  27333. /**
  27334. * Remove a mesh from the LOD array
  27335. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27336. * @param mesh defines the mesh to be removed
  27337. * @return This mesh (for chaining)
  27338. */
  27339. removeLODLevel(mesh: Mesh): Mesh;
  27340. /**
  27341. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  27342. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27343. * @param camera defines the camera to use to compute distance
  27344. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  27345. * @return This mesh (for chaining)
  27346. */
  27347. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  27348. /**
  27349. * Gets the mesh internal Geometry object
  27350. */
  27351. get geometry(): Nullable<Geometry>;
  27352. /**
  27353. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  27354. * @returns the total number of vertices
  27355. */
  27356. getTotalVertices(): number;
  27357. /**
  27358. * Returns the content of an associated vertex buffer
  27359. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  27360. * - VertexBuffer.PositionKind
  27361. * - VertexBuffer.UVKind
  27362. * - VertexBuffer.UV2Kind
  27363. * - VertexBuffer.UV3Kind
  27364. * - VertexBuffer.UV4Kind
  27365. * - VertexBuffer.UV5Kind
  27366. * - VertexBuffer.UV6Kind
  27367. * - VertexBuffer.ColorKind
  27368. * - VertexBuffer.MatricesIndicesKind
  27369. * - VertexBuffer.MatricesIndicesExtraKind
  27370. * - VertexBuffer.MatricesWeightsKind
  27371. * - VertexBuffer.MatricesWeightsExtraKind
  27372. * @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
  27373. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  27374. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  27375. */
  27376. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  27377. /**
  27378. * Returns the mesh VertexBuffer object from the requested `kind`
  27379. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  27380. * - VertexBuffer.PositionKind
  27381. * - VertexBuffer.NormalKind
  27382. * - VertexBuffer.UVKind
  27383. * - VertexBuffer.UV2Kind
  27384. * - VertexBuffer.UV3Kind
  27385. * - VertexBuffer.UV4Kind
  27386. * - VertexBuffer.UV5Kind
  27387. * - VertexBuffer.UV6Kind
  27388. * - VertexBuffer.ColorKind
  27389. * - VertexBuffer.MatricesIndicesKind
  27390. * - VertexBuffer.MatricesIndicesExtraKind
  27391. * - VertexBuffer.MatricesWeightsKind
  27392. * - VertexBuffer.MatricesWeightsExtraKind
  27393. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  27394. */
  27395. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  27396. /**
  27397. * Tests if a specific vertex buffer is associated with this mesh
  27398. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  27399. * - VertexBuffer.PositionKind
  27400. * - VertexBuffer.NormalKind
  27401. * - VertexBuffer.UVKind
  27402. * - VertexBuffer.UV2Kind
  27403. * - VertexBuffer.UV3Kind
  27404. * - VertexBuffer.UV4Kind
  27405. * - VertexBuffer.UV5Kind
  27406. * - VertexBuffer.UV6Kind
  27407. * - VertexBuffer.ColorKind
  27408. * - VertexBuffer.MatricesIndicesKind
  27409. * - VertexBuffer.MatricesIndicesExtraKind
  27410. * - VertexBuffer.MatricesWeightsKind
  27411. * - VertexBuffer.MatricesWeightsExtraKind
  27412. * @returns a boolean
  27413. */
  27414. isVerticesDataPresent(kind: string): boolean;
  27415. /**
  27416. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  27417. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  27418. * - VertexBuffer.PositionKind
  27419. * - VertexBuffer.UVKind
  27420. * - VertexBuffer.UV2Kind
  27421. * - VertexBuffer.UV3Kind
  27422. * - VertexBuffer.UV4Kind
  27423. * - VertexBuffer.UV5Kind
  27424. * - VertexBuffer.UV6Kind
  27425. * - VertexBuffer.ColorKind
  27426. * - VertexBuffer.MatricesIndicesKind
  27427. * - VertexBuffer.MatricesIndicesExtraKind
  27428. * - VertexBuffer.MatricesWeightsKind
  27429. * - VertexBuffer.MatricesWeightsExtraKind
  27430. * @returns a boolean
  27431. */
  27432. isVertexBufferUpdatable(kind: string): boolean;
  27433. /**
  27434. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  27435. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  27436. * - VertexBuffer.PositionKind
  27437. * - VertexBuffer.NormalKind
  27438. * - VertexBuffer.UVKind
  27439. * - VertexBuffer.UV2Kind
  27440. * - VertexBuffer.UV3Kind
  27441. * - VertexBuffer.UV4Kind
  27442. * - VertexBuffer.UV5Kind
  27443. * - VertexBuffer.UV6Kind
  27444. * - VertexBuffer.ColorKind
  27445. * - VertexBuffer.MatricesIndicesKind
  27446. * - VertexBuffer.MatricesIndicesExtraKind
  27447. * - VertexBuffer.MatricesWeightsKind
  27448. * - VertexBuffer.MatricesWeightsExtraKind
  27449. * @returns an array of strings
  27450. */
  27451. getVerticesDataKinds(): string[];
  27452. /**
  27453. * Returns a positive integer : the total number of indices in this mesh geometry.
  27454. * @returns the numner of indices or zero if the mesh has no geometry.
  27455. */
  27456. getTotalIndices(): number;
  27457. /**
  27458. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  27459. * @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.
  27460. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  27461. * @returns the indices array or an empty array if the mesh has no geometry
  27462. */
  27463. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  27464. get isBlocked(): boolean;
  27465. /**
  27466. * Determine if the current mesh is ready to be rendered
  27467. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27468. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  27469. * @returns true if all associated assets are ready (material, textures, shaders)
  27470. */
  27471. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  27472. /**
  27473. * 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.
  27474. */
  27475. get areNormalsFrozen(): boolean;
  27476. /**
  27477. * 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.
  27478. * @returns the current mesh
  27479. */
  27480. freezeNormals(): Mesh;
  27481. /**
  27482. * 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
  27483. * @returns the current mesh
  27484. */
  27485. unfreezeNormals(): Mesh;
  27486. /**
  27487. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  27488. */
  27489. set overridenInstanceCount(count: number);
  27490. /** @hidden */
  27491. _preActivate(): Mesh;
  27492. /** @hidden */
  27493. _preActivateForIntermediateRendering(renderId: number): Mesh;
  27494. /** @hidden */
  27495. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  27496. /**
  27497. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  27498. * This means the mesh underlying bounding box and sphere are recomputed.
  27499. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  27500. * @returns the current mesh
  27501. */
  27502. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  27503. /** @hidden */
  27504. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  27505. /**
  27506. * This function will subdivide the mesh into multiple submeshes
  27507. * @param count defines the expected number of submeshes
  27508. */
  27509. subdivide(count: number): void;
  27510. /**
  27511. * Copy a FloatArray into a specific associated vertex buffer
  27512. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  27513. * - VertexBuffer.PositionKind
  27514. * - VertexBuffer.UVKind
  27515. * - VertexBuffer.UV2Kind
  27516. * - VertexBuffer.UV3Kind
  27517. * - VertexBuffer.UV4Kind
  27518. * - VertexBuffer.UV5Kind
  27519. * - VertexBuffer.UV6Kind
  27520. * - VertexBuffer.ColorKind
  27521. * - VertexBuffer.MatricesIndicesKind
  27522. * - VertexBuffer.MatricesIndicesExtraKind
  27523. * - VertexBuffer.MatricesWeightsKind
  27524. * - VertexBuffer.MatricesWeightsExtraKind
  27525. * @param data defines the data source
  27526. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  27527. * @param stride defines the data stride size (can be null)
  27528. * @returns the current mesh
  27529. */
  27530. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  27531. /**
  27532. * Delete a vertex buffer associated with this mesh
  27533. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  27534. * - VertexBuffer.PositionKind
  27535. * - VertexBuffer.UVKind
  27536. * - VertexBuffer.UV2Kind
  27537. * - VertexBuffer.UV3Kind
  27538. * - VertexBuffer.UV4Kind
  27539. * - VertexBuffer.UV5Kind
  27540. * - VertexBuffer.UV6Kind
  27541. * - VertexBuffer.ColorKind
  27542. * - VertexBuffer.MatricesIndicesKind
  27543. * - VertexBuffer.MatricesIndicesExtraKind
  27544. * - VertexBuffer.MatricesWeightsKind
  27545. * - VertexBuffer.MatricesWeightsExtraKind
  27546. */
  27547. removeVerticesData(kind: string): void;
  27548. /**
  27549. * Flags an associated vertex buffer as updatable
  27550. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  27551. * - VertexBuffer.PositionKind
  27552. * - VertexBuffer.UVKind
  27553. * - VertexBuffer.UV2Kind
  27554. * - VertexBuffer.UV3Kind
  27555. * - VertexBuffer.UV4Kind
  27556. * - VertexBuffer.UV5Kind
  27557. * - VertexBuffer.UV6Kind
  27558. * - VertexBuffer.ColorKind
  27559. * - VertexBuffer.MatricesIndicesKind
  27560. * - VertexBuffer.MatricesIndicesExtraKind
  27561. * - VertexBuffer.MatricesWeightsKind
  27562. * - VertexBuffer.MatricesWeightsExtraKind
  27563. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  27564. */
  27565. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  27566. /**
  27567. * Sets the mesh global Vertex Buffer
  27568. * @param buffer defines the buffer to use
  27569. * @returns the current mesh
  27570. */
  27571. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  27572. /**
  27573. * Update a specific associated vertex buffer
  27574. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  27575. * - VertexBuffer.PositionKind
  27576. * - VertexBuffer.UVKind
  27577. * - VertexBuffer.UV2Kind
  27578. * - VertexBuffer.UV3Kind
  27579. * - VertexBuffer.UV4Kind
  27580. * - VertexBuffer.UV5Kind
  27581. * - VertexBuffer.UV6Kind
  27582. * - VertexBuffer.ColorKind
  27583. * - VertexBuffer.MatricesIndicesKind
  27584. * - VertexBuffer.MatricesIndicesExtraKind
  27585. * - VertexBuffer.MatricesWeightsKind
  27586. * - VertexBuffer.MatricesWeightsExtraKind
  27587. * @param data defines the data source
  27588. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  27589. * @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)
  27590. * @returns the current mesh
  27591. */
  27592. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  27593. /**
  27594. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  27595. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  27596. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  27597. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  27598. * @returns the current mesh
  27599. */
  27600. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  27601. /**
  27602. * Creates a un-shared specific occurence of the geometry for the mesh.
  27603. * @returns the current mesh
  27604. */
  27605. makeGeometryUnique(): Mesh;
  27606. /**
  27607. * Set the index buffer of this mesh
  27608. * @param indices defines the source data
  27609. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  27610. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  27611. * @returns the current mesh
  27612. */
  27613. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  27614. /**
  27615. * Update the current index buffer
  27616. * @param indices defines the source data
  27617. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27618. * @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)
  27619. * @returns the current mesh
  27620. */
  27621. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27622. /**
  27623. * Invert the geometry to move from a right handed system to a left handed one.
  27624. * @returns the current mesh
  27625. */
  27626. toLeftHanded(): Mesh;
  27627. /** @hidden */
  27628. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  27629. /** @hidden */
  27630. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  27631. /**
  27632. * Registers for this mesh a javascript function called just before the rendering process
  27633. * @param func defines the function to call before rendering this mesh
  27634. * @returns the current mesh
  27635. */
  27636. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  27637. /**
  27638. * Disposes a previously registered javascript function called before the rendering
  27639. * @param func defines the function to remove
  27640. * @returns the current mesh
  27641. */
  27642. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  27643. /**
  27644. * Registers for this mesh a javascript function called just after the rendering is complete
  27645. * @param func defines the function to call after rendering this mesh
  27646. * @returns the current mesh
  27647. */
  27648. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  27649. /**
  27650. * Disposes a previously registered javascript function called after the rendering.
  27651. * @param func defines the function to remove
  27652. * @returns the current mesh
  27653. */
  27654. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  27655. /** @hidden */
  27656. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  27657. /** @hidden */
  27658. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  27659. /** @hidden */
  27660. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  27661. /** @hidden */
  27662. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  27663. /** @hidden */
  27664. _rebuild(): void;
  27665. /** @hidden */
  27666. _freeze(): void;
  27667. /** @hidden */
  27668. _unFreeze(): void;
  27669. /**
  27670. * 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
  27671. * @param subMesh defines the subMesh to render
  27672. * @param enableAlphaMode defines if alpha mode can be changed
  27673. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  27674. * @returns the current mesh
  27675. */
  27676. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  27677. private _onBeforeDraw;
  27678. /**
  27679. * Renormalize the mesh and patch it up if there are no weights
  27680. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  27681. * However in the case of zero weights then we set just a single influence to 1.
  27682. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  27683. */
  27684. cleanMatrixWeights(): void;
  27685. private normalizeSkinFourWeights;
  27686. private normalizeSkinWeightsAndExtra;
  27687. /**
  27688. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  27689. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  27690. * the user know there was an issue with importing the mesh
  27691. * @returns a validation object with skinned, valid and report string
  27692. */
  27693. validateSkinning(): {
  27694. skinned: boolean;
  27695. valid: boolean;
  27696. report: string;
  27697. };
  27698. /** @hidden */
  27699. _checkDelayState(): Mesh;
  27700. private _queueLoad;
  27701. /**
  27702. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  27703. * A mesh is in the frustum if its bounding box intersects the frustum
  27704. * @param frustumPlanes defines the frustum to test
  27705. * @returns true if the mesh is in the frustum planes
  27706. */
  27707. isInFrustum(frustumPlanes: Plane[]): boolean;
  27708. /**
  27709. * Sets the mesh material by the material or multiMaterial `id` property
  27710. * @param id is a string identifying the material or the multiMaterial
  27711. * @returns the current mesh
  27712. */
  27713. setMaterialByID(id: string): Mesh;
  27714. /**
  27715. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  27716. * @returns an array of IAnimatable
  27717. */
  27718. getAnimatables(): IAnimatable[];
  27719. /**
  27720. * Modifies the mesh geometry according to the passed transformation matrix.
  27721. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  27722. * The mesh normals are modified using the same transformation.
  27723. * Note that, under the hood, this method sets a new VertexBuffer each call.
  27724. * @param transform defines the transform matrix to use
  27725. * @see http://doc.babylonjs.com/resources/baking_transformations
  27726. * @returns the current mesh
  27727. */
  27728. bakeTransformIntoVertices(transform: Matrix): Mesh;
  27729. /**
  27730. * Modifies the mesh geometry according to its own current World Matrix.
  27731. * The mesh World Matrix is then reset.
  27732. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  27733. * Note that, under the hood, this method sets a new VertexBuffer each call.
  27734. * @see http://doc.babylonjs.com/resources/baking_transformations
  27735. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  27736. * @returns the current mesh
  27737. */
  27738. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  27739. /** @hidden */
  27740. get _positions(): Nullable<Vector3[]>;
  27741. /** @hidden */
  27742. _resetPointsArrayCache(): Mesh;
  27743. /** @hidden */
  27744. _generatePointsArray(): boolean;
  27745. /**
  27746. * Returns a new Mesh object generated from the current mesh properties.
  27747. * This method must not get confused with createInstance()
  27748. * @param name is a string, the name given to the new mesh
  27749. * @param newParent can be any Node object (default `null`)
  27750. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  27751. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  27752. * @returns a new mesh
  27753. */
  27754. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  27755. /**
  27756. * Releases resources associated with this mesh.
  27757. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27758. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27759. */
  27760. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27761. /** @hidden */
  27762. _disposeInstanceSpecificData(): void;
  27763. /**
  27764. * Modifies the mesh geometry according to a displacement map.
  27765. * 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.
  27766. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  27767. * @param url is a string, the URL from the image file is to be downloaded.
  27768. * @param minHeight is the lower limit of the displacement.
  27769. * @param maxHeight is the upper limit of the displacement.
  27770. * @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.
  27771. * @param uvOffset is an optional vector2 used to offset UV.
  27772. * @param uvScale is an optional vector2 used to scale UV.
  27773. * @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.
  27774. * @returns the Mesh.
  27775. */
  27776. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  27777. /**
  27778. * Modifies the mesh geometry according to a displacementMap buffer.
  27779. * 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.
  27780. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  27781. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  27782. * @param heightMapWidth is the width of the buffer image.
  27783. * @param heightMapHeight is the height of the buffer image.
  27784. * @param minHeight is the lower limit of the displacement.
  27785. * @param maxHeight is the upper limit of the displacement.
  27786. * @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.
  27787. * @param uvOffset is an optional vector2 used to offset UV.
  27788. * @param uvScale is an optional vector2 used to scale UV.
  27789. * @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.
  27790. * @returns the Mesh.
  27791. */
  27792. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  27793. /**
  27794. * Modify the mesh to get a flat shading rendering.
  27795. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  27796. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  27797. * @returns current mesh
  27798. */
  27799. convertToFlatShadedMesh(): Mesh;
  27800. /**
  27801. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  27802. * In other words, more vertices, no more indices and a single bigger VBO.
  27803. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  27804. * @returns current mesh
  27805. */
  27806. convertToUnIndexedMesh(): Mesh;
  27807. /**
  27808. * Inverses facet orientations.
  27809. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  27810. * @param flipNormals will also inverts the normals
  27811. * @returns current mesh
  27812. */
  27813. flipFaces(flipNormals?: boolean): Mesh;
  27814. /**
  27815. * Increase the number of facets and hence vertices in a mesh
  27816. * Vertex normals are interpolated from existing vertex normals
  27817. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  27818. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  27819. */
  27820. increaseVertices(numberPerEdge: number): void;
  27821. /**
  27822. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  27823. * This will undo any application of covertToFlatShadedMesh
  27824. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  27825. */
  27826. forceSharedVertices(): void;
  27827. /** @hidden */
  27828. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  27829. /** @hidden */
  27830. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  27831. /**
  27832. * Creates a new InstancedMesh object from the mesh model.
  27833. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  27834. * @param name defines the name of the new instance
  27835. * @returns a new InstancedMesh
  27836. */
  27837. createInstance(name: string): InstancedMesh;
  27838. /**
  27839. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  27840. * After this call, all the mesh instances have the same submeshes than the current mesh.
  27841. * @returns the current mesh
  27842. */
  27843. synchronizeInstances(): Mesh;
  27844. /**
  27845. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  27846. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  27847. * This should be used together with the simplification to avoid disappearing triangles.
  27848. * @param successCallback an optional success callback to be called after the optimization finished.
  27849. * @returns the current mesh
  27850. */
  27851. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  27852. /**
  27853. * Serialize current mesh
  27854. * @param serializationObject defines the object which will receive the serialization data
  27855. */
  27856. serialize(serializationObject: any): void;
  27857. /** @hidden */
  27858. _syncGeometryWithMorphTargetManager(): void;
  27859. /** @hidden */
  27860. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  27861. /**
  27862. * Returns a new Mesh object parsed from the source provided.
  27863. * @param parsedMesh is the source
  27864. * @param scene defines the hosting scene
  27865. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  27866. * @returns a new Mesh
  27867. */
  27868. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  27869. /**
  27870. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  27871. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  27872. * @param name defines the name of the mesh to create
  27873. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  27874. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  27875. * @param closePath creates a seam between the first and the last points of each path of the path array
  27876. * @param offset is taken in account only if the `pathArray` is containing a single path
  27877. * @param scene defines the hosting scene
  27878. * @param updatable defines if the mesh must be flagged as updatable
  27879. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27880. * @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)
  27881. * @returns a new Mesh
  27882. */
  27883. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  27884. /**
  27885. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  27886. * @param name defines the name of the mesh to create
  27887. * @param radius sets the radius size (float) of the polygon (default 0.5)
  27888. * @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
  27889. * @param scene defines the hosting scene
  27890. * @param updatable defines if the mesh must be flagged as updatable
  27891. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27892. * @returns a new Mesh
  27893. */
  27894. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  27895. /**
  27896. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  27897. * @param name defines the name of the mesh to create
  27898. * @param size sets the size (float) of each box side (default 1)
  27899. * @param scene defines the hosting scene
  27900. * @param updatable defines if the mesh must be flagged as updatable
  27901. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27902. * @returns a new Mesh
  27903. */
  27904. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  27905. /**
  27906. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  27907. * @param name defines the name of the mesh to create
  27908. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  27909. * @param diameter sets the diameter size (float) of the sphere (default 1)
  27910. * @param scene defines the hosting scene
  27911. * @param updatable defines if the mesh must be flagged as updatable
  27912. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27913. * @returns a new Mesh
  27914. */
  27915. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27916. /**
  27917. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  27918. * @param name defines the name of the mesh to create
  27919. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  27920. * @param diameter sets the diameter size (float) of the sphere (default 1)
  27921. * @param scene defines the hosting scene
  27922. * @returns a new Mesh
  27923. */
  27924. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  27925. /**
  27926. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  27927. * @param name defines the name of the mesh to create
  27928. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  27929. * @param diameterTop set the top cap diameter (floats, default 1)
  27930. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  27931. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  27932. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  27933. * @param scene defines the hosting scene
  27934. * @param updatable defines if the mesh must be flagged as updatable
  27935. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27936. * @returns a new Mesh
  27937. */
  27938. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  27939. /**
  27940. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  27941. * @param name defines the name of the mesh to create
  27942. * @param diameter sets the diameter size (float) of the torus (default 1)
  27943. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  27944. * @param tessellation sets the number of torus sides (postive integer, default 16)
  27945. * @param scene defines the hosting scene
  27946. * @param updatable defines if the mesh must be flagged as updatable
  27947. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27948. * @returns a new Mesh
  27949. */
  27950. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27951. /**
  27952. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  27953. * @param name defines the name of the mesh to create
  27954. * @param radius sets the global radius size (float) of the torus knot (default 2)
  27955. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  27956. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  27957. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  27958. * @param p the number of windings on X axis (positive integers, default 2)
  27959. * @param q the number of windings on Y axis (positive integers, default 3)
  27960. * @param scene defines the hosting scene
  27961. * @param updatable defines if the mesh must be flagged as updatable
  27962. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27963. * @returns a new Mesh
  27964. */
  27965. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27966. /**
  27967. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  27968. * @param name defines the name of the mesh to create
  27969. * @param points is an array successive Vector3
  27970. * @param scene defines the hosting scene
  27971. * @param updatable defines if the mesh must be flagged as updatable
  27972. * @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).
  27973. * @returns a new Mesh
  27974. */
  27975. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  27976. /**
  27977. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  27978. * @param name defines the name of the mesh to create
  27979. * @param points is an array successive Vector3
  27980. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  27981. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  27982. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  27983. * @param scene defines the hosting scene
  27984. * @param updatable defines if the mesh must be flagged as updatable
  27985. * @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)
  27986. * @returns a new Mesh
  27987. */
  27988. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  27989. /**
  27990. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  27991. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  27992. * 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.
  27993. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27994. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  27995. * Remember you can only change the shape positions, not their number when updating a polygon.
  27996. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  27997. * @param name defines the name of the mesh to create
  27998. * @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
  27999. * @param scene defines the hosting scene
  28000. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  28001. * @param updatable defines if the mesh must be flagged as updatable
  28002. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28003. * @param earcutInjection can be used to inject your own earcut reference
  28004. * @returns a new Mesh
  28005. */
  28006. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  28007. /**
  28008. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  28009. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  28010. * @param name defines the name of the mesh to create
  28011. * @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
  28012. * @param depth defines the height of extrusion
  28013. * @param scene defines the hosting scene
  28014. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  28015. * @param updatable defines if the mesh must be flagged as updatable
  28016. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28017. * @param earcutInjection can be used to inject your own earcut reference
  28018. * @returns a new Mesh
  28019. */
  28020. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  28021. /**
  28022. * Creates an extruded shape mesh.
  28023. * 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
  28024. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  28025. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28026. * @param name defines the name of the mesh to create
  28027. * @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
  28028. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  28029. * @param scale is the value to scale the shape
  28030. * @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
  28031. * @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
  28032. * @param scene defines the hosting scene
  28033. * @param updatable defines if the mesh must be flagged as updatable
  28034. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28035. * @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)
  28036. * @returns a new Mesh
  28037. */
  28038. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28039. /**
  28040. * Creates an custom extruded shape mesh.
  28041. * The custom extrusion is a parametric shape.
  28042. * It has no predefined shape. Its final shape will depend on the input parameters.
  28043. * Please consider using the same method from the MeshBuilder class instead
  28044. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28045. * @param name defines the name of the mesh to create
  28046. * @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
  28047. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  28048. * @param scaleFunction is a custom Javascript function called on each path point
  28049. * @param rotationFunction is a custom Javascript function called on each path point
  28050. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  28051. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  28052. * @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
  28053. * @param scene defines the hosting scene
  28054. * @param updatable defines if the mesh must be flagged as updatable
  28055. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28056. * @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)
  28057. * @returns a new Mesh
  28058. */
  28059. 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;
  28060. /**
  28061. * Creates lathe mesh.
  28062. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  28063. * Please consider using the same method from the MeshBuilder class instead
  28064. * @param name defines the name of the mesh to create
  28065. * @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
  28066. * @param radius is the radius value of the lathe
  28067. * @param tessellation is the side number of the lathe.
  28068. * @param scene defines the hosting scene
  28069. * @param updatable defines if the mesh must be flagged as updatable
  28070. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28071. * @returns a new Mesh
  28072. */
  28073. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28074. /**
  28075. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  28076. * @param name defines the name of the mesh to create
  28077. * @param size sets the size (float) of both sides of the plane at once (default 1)
  28078. * @param scene defines the hosting scene
  28079. * @param updatable defines if the mesh must be flagged as updatable
  28080. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28081. * @returns a new Mesh
  28082. */
  28083. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28084. /**
  28085. * Creates a ground mesh.
  28086. * Please consider using the same method from the MeshBuilder class instead
  28087. * @param name defines the name of the mesh to create
  28088. * @param width set the width of the ground
  28089. * @param height set the height of the ground
  28090. * @param subdivisions sets the number of subdivisions per side
  28091. * @param scene defines the hosting scene
  28092. * @param updatable defines if the mesh must be flagged as updatable
  28093. * @returns a new Mesh
  28094. */
  28095. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  28096. /**
  28097. * Creates a tiled ground mesh.
  28098. * Please consider using the same method from the MeshBuilder class instead
  28099. * @param name defines the name of the mesh to create
  28100. * @param xmin set the ground minimum X coordinate
  28101. * @param zmin set the ground minimum Y coordinate
  28102. * @param xmax set the ground maximum X coordinate
  28103. * @param zmax set the ground maximum Z coordinate
  28104. * @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
  28105. * @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
  28106. * @param scene defines the hosting scene
  28107. * @param updatable defines if the mesh must be flagged as updatable
  28108. * @returns a new Mesh
  28109. */
  28110. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  28111. w: number;
  28112. h: number;
  28113. }, precision: {
  28114. w: number;
  28115. h: number;
  28116. }, scene: Scene, updatable?: boolean): Mesh;
  28117. /**
  28118. * Creates a ground mesh from a height map.
  28119. * Please consider using the same method from the MeshBuilder class instead
  28120. * @see http://doc.babylonjs.com/babylon101/height_map
  28121. * @param name defines the name of the mesh to create
  28122. * @param url sets the URL of the height map image resource
  28123. * @param width set the ground width size
  28124. * @param height set the ground height size
  28125. * @param subdivisions sets the number of subdivision per side
  28126. * @param minHeight is the minimum altitude on the ground
  28127. * @param maxHeight is the maximum altitude on the ground
  28128. * @param scene defines the hosting scene
  28129. * @param updatable defines if the mesh must be flagged as updatable
  28130. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  28131. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  28132. * @returns a new Mesh
  28133. */
  28134. 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;
  28135. /**
  28136. * Creates a tube mesh.
  28137. * The tube is a parametric shape.
  28138. * It has no predefined shape. Its final shape will depend on the input parameters.
  28139. * Please consider using the same method from the MeshBuilder class instead
  28140. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  28141. * @param name defines the name of the mesh to create
  28142. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  28143. * @param radius sets the tube radius size
  28144. * @param tessellation is the number of sides on the tubular surface
  28145. * @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
  28146. * @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
  28147. * @param scene defines the hosting scene
  28148. * @param updatable defines if the mesh must be flagged as updatable
  28149. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28150. * @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)
  28151. * @returns a new Mesh
  28152. */
  28153. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  28154. (i: number, distance: number): number;
  28155. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28156. /**
  28157. * Creates a polyhedron mesh.
  28158. * Please consider using the same method from the MeshBuilder class instead.
  28159. * * 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
  28160. * * The parameter `size` (positive float, default 1) sets the polygon size
  28161. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  28162. * * 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`
  28163. * * 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
  28164. * * 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)`)
  28165. * * 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
  28166. * * 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
  28167. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  28168. * * 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
  28169. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28170. * @param name defines the name of the mesh to create
  28171. * @param options defines the options used to create the mesh
  28172. * @param scene defines the hosting scene
  28173. * @returns a new Mesh
  28174. */
  28175. static CreatePolyhedron(name: string, options: {
  28176. type?: number;
  28177. size?: number;
  28178. sizeX?: number;
  28179. sizeY?: number;
  28180. sizeZ?: number;
  28181. custom?: any;
  28182. faceUV?: Vector4[];
  28183. faceColors?: Color4[];
  28184. updatable?: boolean;
  28185. sideOrientation?: number;
  28186. }, scene: Scene): Mesh;
  28187. /**
  28188. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  28189. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  28190. * * 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`)
  28191. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  28192. * * 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
  28193. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  28194. * * 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
  28195. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28196. * @param name defines the name of the mesh
  28197. * @param options defines the options used to create the mesh
  28198. * @param scene defines the hosting scene
  28199. * @returns a new Mesh
  28200. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  28201. */
  28202. static CreateIcoSphere(name: string, options: {
  28203. radius?: number;
  28204. flat?: boolean;
  28205. subdivisions?: number;
  28206. sideOrientation?: number;
  28207. updatable?: boolean;
  28208. }, scene: Scene): Mesh;
  28209. /**
  28210. * Creates a decal mesh.
  28211. * Please consider using the same method from the MeshBuilder class instead.
  28212. * A decal is a mesh usually applied as a model onto the surface of another mesh
  28213. * @param name defines the name of the mesh
  28214. * @param sourceMesh defines the mesh receiving the decal
  28215. * @param position sets the position of the decal in world coordinates
  28216. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  28217. * @param size sets the decal scaling
  28218. * @param angle sets the angle to rotate the decal
  28219. * @returns a new Mesh
  28220. */
  28221. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  28222. /**
  28223. * Prepare internal position array for software CPU skinning
  28224. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  28225. */
  28226. setPositionsForCPUSkinning(): Float32Array;
  28227. /**
  28228. * Prepare internal normal array for software CPU skinning
  28229. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  28230. */
  28231. setNormalsForCPUSkinning(): Float32Array;
  28232. /**
  28233. * Updates the vertex buffer by applying transformation from the bones
  28234. * @param skeleton defines the skeleton to apply to current mesh
  28235. * @returns the current mesh
  28236. */
  28237. applySkeleton(skeleton: Skeleton): Mesh;
  28238. /**
  28239. * 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
  28240. * @param meshes defines the list of meshes to scan
  28241. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  28242. */
  28243. static MinMax(meshes: AbstractMesh[]): {
  28244. min: Vector3;
  28245. max: Vector3;
  28246. };
  28247. /**
  28248. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  28249. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  28250. * @returns a vector3
  28251. */
  28252. static Center(meshesOrMinMaxVector: {
  28253. min: Vector3;
  28254. max: Vector3;
  28255. } | AbstractMesh[]): Vector3;
  28256. /**
  28257. * Merge the array of meshes into a single mesh for performance reasons.
  28258. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  28259. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  28260. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  28261. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  28262. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  28263. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  28264. * @returns a new mesh
  28265. */
  28266. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  28267. /** @hidden */
  28268. addInstance(instance: InstancedMesh): void;
  28269. /** @hidden */
  28270. removeInstance(instance: InstancedMesh): void;
  28271. }
  28272. }
  28273. declare module BABYLON {
  28274. /**
  28275. * This is the base class of all the camera used in the application.
  28276. * @see http://doc.babylonjs.com/features/cameras
  28277. */
  28278. export class Camera extends Node {
  28279. /** @hidden */
  28280. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  28281. /**
  28282. * This is the default projection mode used by the cameras.
  28283. * It helps recreating a feeling of perspective and better appreciate depth.
  28284. * This is the best way to simulate real life cameras.
  28285. */
  28286. static readonly PERSPECTIVE_CAMERA: number;
  28287. /**
  28288. * This helps creating camera with an orthographic mode.
  28289. * 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.
  28290. */
  28291. static readonly ORTHOGRAPHIC_CAMERA: number;
  28292. /**
  28293. * This is the default FOV mode for perspective cameras.
  28294. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  28295. */
  28296. static readonly FOVMODE_VERTICAL_FIXED: number;
  28297. /**
  28298. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  28299. */
  28300. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  28301. /**
  28302. * This specifies ther is no need for a camera rig.
  28303. * Basically only one eye is rendered corresponding to the camera.
  28304. */
  28305. static readonly RIG_MODE_NONE: number;
  28306. /**
  28307. * Simulates a camera Rig with one blue eye and one red eye.
  28308. * This can be use with 3d blue and red glasses.
  28309. */
  28310. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  28311. /**
  28312. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  28313. */
  28314. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  28315. /**
  28316. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  28317. */
  28318. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  28319. /**
  28320. * Defines that both eyes of the camera will be rendered over under each other.
  28321. */
  28322. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  28323. /**
  28324. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  28325. */
  28326. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  28327. /**
  28328. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  28329. */
  28330. static readonly RIG_MODE_VR: number;
  28331. /**
  28332. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  28333. */
  28334. static readonly RIG_MODE_WEBVR: number;
  28335. /**
  28336. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  28337. */
  28338. static readonly RIG_MODE_CUSTOM: number;
  28339. /**
  28340. * Defines if by default attaching controls should prevent the default javascript event to continue.
  28341. */
  28342. static ForceAttachControlToAlwaysPreventDefault: boolean;
  28343. /**
  28344. * Define the input manager associated with the camera.
  28345. */
  28346. inputs: CameraInputsManager<Camera>;
  28347. /** @hidden */
  28348. _position: Vector3;
  28349. /**
  28350. * Define the current local position of the camera in the scene
  28351. */
  28352. get position(): Vector3;
  28353. set position(newPosition: Vector3);
  28354. /**
  28355. * The vector the camera should consider as up.
  28356. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  28357. */
  28358. upVector: Vector3;
  28359. /**
  28360. * Define the current limit on the left side for an orthographic camera
  28361. * In scene unit
  28362. */
  28363. orthoLeft: Nullable<number>;
  28364. /**
  28365. * Define the current limit on the right side for an orthographic camera
  28366. * In scene unit
  28367. */
  28368. orthoRight: Nullable<number>;
  28369. /**
  28370. * Define the current limit on the bottom side for an orthographic camera
  28371. * In scene unit
  28372. */
  28373. orthoBottom: Nullable<number>;
  28374. /**
  28375. * Define the current limit on the top side for an orthographic camera
  28376. * In scene unit
  28377. */
  28378. orthoTop: Nullable<number>;
  28379. /**
  28380. * Field Of View is set in Radians. (default is 0.8)
  28381. */
  28382. fov: number;
  28383. /**
  28384. * Define the minimum distance the camera can see from.
  28385. * This is important to note that the depth buffer are not infinite and the closer it starts
  28386. * the more your scene might encounter depth fighting issue.
  28387. */
  28388. minZ: number;
  28389. /**
  28390. * Define the maximum distance the camera can see to.
  28391. * This is important to note that the depth buffer are not infinite and the further it end
  28392. * the more your scene might encounter depth fighting issue.
  28393. */
  28394. maxZ: number;
  28395. /**
  28396. * Define the default inertia of the camera.
  28397. * This helps giving a smooth feeling to the camera movement.
  28398. */
  28399. inertia: number;
  28400. /**
  28401. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  28402. */
  28403. mode: number;
  28404. /**
  28405. * Define whether the camera is intermediate.
  28406. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  28407. */
  28408. isIntermediate: boolean;
  28409. /**
  28410. * Define the viewport of the camera.
  28411. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  28412. */
  28413. viewport: Viewport;
  28414. /**
  28415. * Restricts the camera to viewing objects with the same layerMask.
  28416. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  28417. */
  28418. layerMask: number;
  28419. /**
  28420. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  28421. */
  28422. fovMode: number;
  28423. /**
  28424. * Rig mode of the camera.
  28425. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  28426. * This is normally controlled byt the camera themselves as internal use.
  28427. */
  28428. cameraRigMode: number;
  28429. /**
  28430. * Defines the distance between both "eyes" in case of a RIG
  28431. */
  28432. interaxialDistance: number;
  28433. /**
  28434. * Defines if stereoscopic rendering is done side by side or over under.
  28435. */
  28436. isStereoscopicSideBySide: boolean;
  28437. /**
  28438. * 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
  28439. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  28440. * else in the scene. (Eg. security camera)
  28441. *
  28442. * 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)
  28443. */
  28444. customRenderTargets: RenderTargetTexture[];
  28445. /**
  28446. * When set, the camera will render to this render target instead of the default canvas
  28447. *
  28448. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  28449. */
  28450. outputRenderTarget: Nullable<RenderTargetTexture>;
  28451. /**
  28452. * Observable triggered when the camera view matrix has changed.
  28453. */
  28454. onViewMatrixChangedObservable: Observable<Camera>;
  28455. /**
  28456. * Observable triggered when the camera Projection matrix has changed.
  28457. */
  28458. onProjectionMatrixChangedObservable: Observable<Camera>;
  28459. /**
  28460. * Observable triggered when the inputs have been processed.
  28461. */
  28462. onAfterCheckInputsObservable: Observable<Camera>;
  28463. /**
  28464. * Observable triggered when reset has been called and applied to the camera.
  28465. */
  28466. onRestoreStateObservable: Observable<Camera>;
  28467. /**
  28468. * Is this camera a part of a rig system?
  28469. */
  28470. isRigCamera: boolean;
  28471. /**
  28472. * If isRigCamera set to true this will be set with the parent camera.
  28473. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  28474. */
  28475. rigParent?: Camera;
  28476. /** @hidden */
  28477. _cameraRigParams: any;
  28478. /** @hidden */
  28479. _rigCameras: Camera[];
  28480. /** @hidden */
  28481. _rigPostProcess: Nullable<PostProcess>;
  28482. protected _webvrViewMatrix: Matrix;
  28483. /** @hidden */
  28484. _skipRendering: boolean;
  28485. /** @hidden */
  28486. _projectionMatrix: Matrix;
  28487. /** @hidden */
  28488. _postProcesses: Nullable<PostProcess>[];
  28489. /** @hidden */
  28490. _activeMeshes: SmartArray<AbstractMesh>;
  28491. protected _globalPosition: Vector3;
  28492. /** @hidden */
  28493. _computedViewMatrix: Matrix;
  28494. private _doNotComputeProjectionMatrix;
  28495. private _transformMatrix;
  28496. private _frustumPlanes;
  28497. private _refreshFrustumPlanes;
  28498. private _storedFov;
  28499. private _stateStored;
  28500. /**
  28501. * Instantiates a new camera object.
  28502. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  28503. * @see http://doc.babylonjs.com/features/cameras
  28504. * @param name Defines the name of the camera in the scene
  28505. * @param position Defines the position of the camera
  28506. * @param scene Defines the scene the camera belongs too
  28507. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  28508. */
  28509. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  28510. /**
  28511. * Store current camera state (fov, position, etc..)
  28512. * @returns the camera
  28513. */
  28514. storeState(): Camera;
  28515. /**
  28516. * Restores the camera state values if it has been stored. You must call storeState() first
  28517. */
  28518. protected _restoreStateValues(): boolean;
  28519. /**
  28520. * Restored camera state. You must call storeState() first.
  28521. * @returns true if restored and false otherwise
  28522. */
  28523. restoreState(): boolean;
  28524. /**
  28525. * Gets the class name of the camera.
  28526. * @returns the class name
  28527. */
  28528. getClassName(): string;
  28529. /** @hidden */
  28530. readonly _isCamera: boolean;
  28531. /**
  28532. * Gets a string representation of the camera useful for debug purpose.
  28533. * @param fullDetails Defines that a more verboe level of logging is required
  28534. * @returns the string representation
  28535. */
  28536. toString(fullDetails?: boolean): string;
  28537. /**
  28538. * Gets the current world space position of the camera.
  28539. */
  28540. get globalPosition(): Vector3;
  28541. /**
  28542. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  28543. * @returns the active meshe list
  28544. */
  28545. getActiveMeshes(): SmartArray<AbstractMesh>;
  28546. /**
  28547. * Check whether a mesh is part of the current active mesh list of the camera
  28548. * @param mesh Defines the mesh to check
  28549. * @returns true if active, false otherwise
  28550. */
  28551. isActiveMesh(mesh: Mesh): boolean;
  28552. /**
  28553. * Is this camera ready to be used/rendered
  28554. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  28555. * @return true if the camera is ready
  28556. */
  28557. isReady(completeCheck?: boolean): boolean;
  28558. /** @hidden */
  28559. _initCache(): void;
  28560. /** @hidden */
  28561. _updateCache(ignoreParentClass?: boolean): void;
  28562. /** @hidden */
  28563. _isSynchronized(): boolean;
  28564. /** @hidden */
  28565. _isSynchronizedViewMatrix(): boolean;
  28566. /** @hidden */
  28567. _isSynchronizedProjectionMatrix(): boolean;
  28568. /**
  28569. * Attach the input controls to a specific dom element to get the input from.
  28570. * @param element Defines the element the controls should be listened from
  28571. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  28572. */
  28573. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  28574. /**
  28575. * Detach the current controls from the specified dom element.
  28576. * @param element Defines the element to stop listening the inputs from
  28577. */
  28578. detachControl(element: HTMLElement): void;
  28579. /**
  28580. * Update the camera state according to the different inputs gathered during the frame.
  28581. */
  28582. update(): void;
  28583. /** @hidden */
  28584. _checkInputs(): void;
  28585. /** @hidden */
  28586. get rigCameras(): Camera[];
  28587. /**
  28588. * Gets the post process used by the rig cameras
  28589. */
  28590. get rigPostProcess(): Nullable<PostProcess>;
  28591. /**
  28592. * Internal, gets the first post proces.
  28593. * @returns the first post process to be run on this camera.
  28594. */
  28595. _getFirstPostProcess(): Nullable<PostProcess>;
  28596. private _cascadePostProcessesToRigCams;
  28597. /**
  28598. * Attach a post process to the camera.
  28599. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  28600. * @param postProcess The post process to attach to the camera
  28601. * @param insertAt The position of the post process in case several of them are in use in the scene
  28602. * @returns the position the post process has been inserted at
  28603. */
  28604. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  28605. /**
  28606. * Detach a post process to the camera.
  28607. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  28608. * @param postProcess The post process to detach from the camera
  28609. */
  28610. detachPostProcess(postProcess: PostProcess): void;
  28611. /**
  28612. * Gets the current world matrix of the camera
  28613. */
  28614. getWorldMatrix(): Matrix;
  28615. /** @hidden */
  28616. _getViewMatrix(): Matrix;
  28617. /**
  28618. * Gets the current view matrix of the camera.
  28619. * @param force forces the camera to recompute the matrix without looking at the cached state
  28620. * @returns the view matrix
  28621. */
  28622. getViewMatrix(force?: boolean): Matrix;
  28623. /**
  28624. * Freeze the projection matrix.
  28625. * It will prevent the cache check of the camera projection compute and can speed up perf
  28626. * if no parameter of the camera are meant to change
  28627. * @param projection Defines manually a projection if necessary
  28628. */
  28629. freezeProjectionMatrix(projection?: Matrix): void;
  28630. /**
  28631. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  28632. */
  28633. unfreezeProjectionMatrix(): void;
  28634. /**
  28635. * Gets the current projection matrix of the camera.
  28636. * @param force forces the camera to recompute the matrix without looking at the cached state
  28637. * @returns the projection matrix
  28638. */
  28639. getProjectionMatrix(force?: boolean): Matrix;
  28640. /**
  28641. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  28642. * @returns a Matrix
  28643. */
  28644. getTransformationMatrix(): Matrix;
  28645. private _updateFrustumPlanes;
  28646. /**
  28647. * Checks if a cullable object (mesh...) is in the camera frustum
  28648. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  28649. * @param target The object to check
  28650. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  28651. * @returns true if the object is in frustum otherwise false
  28652. */
  28653. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  28654. /**
  28655. * Checks if a cullable object (mesh...) is in the camera frustum
  28656. * Unlike isInFrustum this cheks the full bounding box
  28657. * @param target The object to check
  28658. * @returns true if the object is in frustum otherwise false
  28659. */
  28660. isCompletelyInFrustum(target: ICullable): boolean;
  28661. /**
  28662. * Gets a ray in the forward direction from the camera.
  28663. * @param length Defines the length of the ray to create
  28664. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  28665. * @param origin Defines the start point of the ray which defaults to the camera position
  28666. * @returns the forward ray
  28667. */
  28668. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  28669. /**
  28670. * Releases resources associated with this node.
  28671. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28672. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28673. */
  28674. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28675. /** @hidden */
  28676. _isLeftCamera: boolean;
  28677. /**
  28678. * Gets the left camera of a rig setup in case of Rigged Camera
  28679. */
  28680. get isLeftCamera(): boolean;
  28681. /** @hidden */
  28682. _isRightCamera: boolean;
  28683. /**
  28684. * Gets the right camera of a rig setup in case of Rigged Camera
  28685. */
  28686. get isRightCamera(): boolean;
  28687. /**
  28688. * Gets the left camera of a rig setup in case of Rigged Camera
  28689. */
  28690. get leftCamera(): Nullable<FreeCamera>;
  28691. /**
  28692. * Gets the right camera of a rig setup in case of Rigged Camera
  28693. */
  28694. get rightCamera(): Nullable<FreeCamera>;
  28695. /**
  28696. * Gets the left camera target of a rig setup in case of Rigged Camera
  28697. * @returns the target position
  28698. */
  28699. getLeftTarget(): Nullable<Vector3>;
  28700. /**
  28701. * Gets the right camera target of a rig setup in case of Rigged Camera
  28702. * @returns the target position
  28703. */
  28704. getRightTarget(): Nullable<Vector3>;
  28705. /**
  28706. * @hidden
  28707. */
  28708. setCameraRigMode(mode: number, rigParams: any): void;
  28709. /** @hidden */
  28710. static _setStereoscopicRigMode(camera: Camera): void;
  28711. /** @hidden */
  28712. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  28713. /** @hidden */
  28714. static _setVRRigMode(camera: Camera, rigParams: any): void;
  28715. /** @hidden */
  28716. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  28717. /** @hidden */
  28718. _getVRProjectionMatrix(): Matrix;
  28719. protected _updateCameraRotationMatrix(): void;
  28720. protected _updateWebVRCameraRotationMatrix(): void;
  28721. /**
  28722. * This function MUST be overwritten by the different WebVR cameras available.
  28723. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  28724. * @hidden
  28725. */
  28726. _getWebVRProjectionMatrix(): Matrix;
  28727. /**
  28728. * This function MUST be overwritten by the different WebVR cameras available.
  28729. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  28730. * @hidden
  28731. */
  28732. _getWebVRViewMatrix(): Matrix;
  28733. /** @hidden */
  28734. setCameraRigParameter(name: string, value: any): void;
  28735. /**
  28736. * needs to be overridden by children so sub has required properties to be copied
  28737. * @hidden
  28738. */
  28739. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  28740. /**
  28741. * May need to be overridden by children
  28742. * @hidden
  28743. */
  28744. _updateRigCameras(): void;
  28745. /** @hidden */
  28746. _setupInputs(): void;
  28747. /**
  28748. * Serialiaze the camera setup to a json represention
  28749. * @returns the JSON representation
  28750. */
  28751. serialize(): any;
  28752. /**
  28753. * Clones the current camera.
  28754. * @param name The cloned camera name
  28755. * @returns the cloned camera
  28756. */
  28757. clone(name: string): Camera;
  28758. /**
  28759. * Gets the direction of the camera relative to a given local axis.
  28760. * @param localAxis Defines the reference axis to provide a relative direction.
  28761. * @return the direction
  28762. */
  28763. getDirection(localAxis: Vector3): Vector3;
  28764. /**
  28765. * Returns the current camera absolute rotation
  28766. */
  28767. get absoluteRotation(): Quaternion;
  28768. /**
  28769. * Gets the direction of the camera relative to a given local axis into a passed vector.
  28770. * @param localAxis Defines the reference axis to provide a relative direction.
  28771. * @param result Defines the vector to store the result in
  28772. */
  28773. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  28774. /**
  28775. * Gets a camera constructor for a given camera type
  28776. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  28777. * @param name The name of the camera the result will be able to instantiate
  28778. * @param scene The scene the result will construct the camera in
  28779. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  28780. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  28781. * @returns a factory method to construc the camera
  28782. */
  28783. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  28784. /**
  28785. * Compute the world matrix of the camera.
  28786. * @returns the camera world matrix
  28787. */
  28788. computeWorldMatrix(): Matrix;
  28789. /**
  28790. * Parse a JSON and creates the camera from the parsed information
  28791. * @param parsedCamera The JSON to parse
  28792. * @param scene The scene to instantiate the camera in
  28793. * @returns the newly constructed camera
  28794. */
  28795. static Parse(parsedCamera: any, scene: Scene): Camera;
  28796. }
  28797. }
  28798. declare module BABYLON {
  28799. /**
  28800. * Class containing static functions to help procedurally build meshes
  28801. */
  28802. export class DiscBuilder {
  28803. /**
  28804. * Creates a plane polygonal mesh. By default, this is a disc
  28805. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  28806. * * 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
  28807. * * 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
  28808. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28809. * * 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
  28810. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28811. * @param name defines the name of the mesh
  28812. * @param options defines the options used to create the mesh
  28813. * @param scene defines the hosting scene
  28814. * @returns the plane polygonal mesh
  28815. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  28816. */
  28817. static CreateDisc(name: string, options: {
  28818. radius?: number;
  28819. tessellation?: number;
  28820. arc?: number;
  28821. updatable?: boolean;
  28822. sideOrientation?: number;
  28823. frontUVs?: Vector4;
  28824. backUVs?: Vector4;
  28825. }, scene?: Nullable<Scene>): Mesh;
  28826. }
  28827. }
  28828. declare module BABYLON {
  28829. /**
  28830. * Options to be used when creating a FresnelParameters.
  28831. */
  28832. export type IFresnelParametersCreationOptions = {
  28833. /**
  28834. * Define the color used on edges (grazing angle)
  28835. */
  28836. leftColor?: Color3;
  28837. /**
  28838. * Define the color used on center
  28839. */
  28840. rightColor?: Color3;
  28841. /**
  28842. * Define bias applied to computed fresnel term
  28843. */
  28844. bias?: number;
  28845. /**
  28846. * Defined the power exponent applied to fresnel term
  28847. */
  28848. power?: number;
  28849. /**
  28850. * Define if the fresnel effect is enable or not.
  28851. */
  28852. isEnabled?: boolean;
  28853. };
  28854. /**
  28855. * Serialized format for FresnelParameters.
  28856. */
  28857. export type IFresnelParametersSerialized = {
  28858. /**
  28859. * Define the color used on edges (grazing angle) [as an array]
  28860. */
  28861. leftColor: number[];
  28862. /**
  28863. * Define the color used on center [as an array]
  28864. */
  28865. rightColor: number[];
  28866. /**
  28867. * Define bias applied to computed fresnel term
  28868. */
  28869. bias: number;
  28870. /**
  28871. * Defined the power exponent applied to fresnel term
  28872. */
  28873. power?: number;
  28874. /**
  28875. * Define if the fresnel effect is enable or not.
  28876. */
  28877. isEnabled: boolean;
  28878. };
  28879. /**
  28880. * This represents all the required information to add a fresnel effect on a material:
  28881. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28882. */
  28883. export class FresnelParameters {
  28884. private _isEnabled;
  28885. /**
  28886. * Define if the fresnel effect is enable or not.
  28887. */
  28888. get isEnabled(): boolean;
  28889. set isEnabled(value: boolean);
  28890. /**
  28891. * Define the color used on edges (grazing angle)
  28892. */
  28893. leftColor: Color3;
  28894. /**
  28895. * Define the color used on center
  28896. */
  28897. rightColor: Color3;
  28898. /**
  28899. * Define bias applied to computed fresnel term
  28900. */
  28901. bias: number;
  28902. /**
  28903. * Defined the power exponent applied to fresnel term
  28904. */
  28905. power: number;
  28906. /**
  28907. * Creates a new FresnelParameters object.
  28908. *
  28909. * @param options provide your own settings to optionally to override defaults
  28910. */
  28911. constructor(options?: IFresnelParametersCreationOptions);
  28912. /**
  28913. * Clones the current fresnel and its valuues
  28914. * @returns a clone fresnel configuration
  28915. */
  28916. clone(): FresnelParameters;
  28917. /**
  28918. * Determines equality between FresnelParameters objects
  28919. * @param otherFresnelParameters defines the second operand
  28920. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  28921. */
  28922. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  28923. /**
  28924. * Serializes the current fresnel parameters to a JSON representation.
  28925. * @return the JSON serialization
  28926. */
  28927. serialize(): IFresnelParametersSerialized;
  28928. /**
  28929. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  28930. * @param parsedFresnelParameters Define the JSON representation
  28931. * @returns the parsed parameters
  28932. */
  28933. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  28934. }
  28935. }
  28936. declare module BABYLON {
  28937. /**
  28938. * This groups all the flags used to control the materials channel.
  28939. */
  28940. export class MaterialFlags {
  28941. private static _DiffuseTextureEnabled;
  28942. /**
  28943. * Are diffuse textures enabled in the application.
  28944. */
  28945. static get DiffuseTextureEnabled(): boolean;
  28946. static set DiffuseTextureEnabled(value: boolean);
  28947. private static _AmbientTextureEnabled;
  28948. /**
  28949. * Are ambient textures enabled in the application.
  28950. */
  28951. static get AmbientTextureEnabled(): boolean;
  28952. static set AmbientTextureEnabled(value: boolean);
  28953. private static _OpacityTextureEnabled;
  28954. /**
  28955. * Are opacity textures enabled in the application.
  28956. */
  28957. static get OpacityTextureEnabled(): boolean;
  28958. static set OpacityTextureEnabled(value: boolean);
  28959. private static _ReflectionTextureEnabled;
  28960. /**
  28961. * Are reflection textures enabled in the application.
  28962. */
  28963. static get ReflectionTextureEnabled(): boolean;
  28964. static set ReflectionTextureEnabled(value: boolean);
  28965. private static _EmissiveTextureEnabled;
  28966. /**
  28967. * Are emissive textures enabled in the application.
  28968. */
  28969. static get EmissiveTextureEnabled(): boolean;
  28970. static set EmissiveTextureEnabled(value: boolean);
  28971. private static _SpecularTextureEnabled;
  28972. /**
  28973. * Are specular textures enabled in the application.
  28974. */
  28975. static get SpecularTextureEnabled(): boolean;
  28976. static set SpecularTextureEnabled(value: boolean);
  28977. private static _BumpTextureEnabled;
  28978. /**
  28979. * Are bump textures enabled in the application.
  28980. */
  28981. static get BumpTextureEnabled(): boolean;
  28982. static set BumpTextureEnabled(value: boolean);
  28983. private static _LightmapTextureEnabled;
  28984. /**
  28985. * Are lightmap textures enabled in the application.
  28986. */
  28987. static get LightmapTextureEnabled(): boolean;
  28988. static set LightmapTextureEnabled(value: boolean);
  28989. private static _RefractionTextureEnabled;
  28990. /**
  28991. * Are refraction textures enabled in the application.
  28992. */
  28993. static get RefractionTextureEnabled(): boolean;
  28994. static set RefractionTextureEnabled(value: boolean);
  28995. private static _ColorGradingTextureEnabled;
  28996. /**
  28997. * Are color grading textures enabled in the application.
  28998. */
  28999. static get ColorGradingTextureEnabled(): boolean;
  29000. static set ColorGradingTextureEnabled(value: boolean);
  29001. private static _FresnelEnabled;
  29002. /**
  29003. * Are fresnels enabled in the application.
  29004. */
  29005. static get FresnelEnabled(): boolean;
  29006. static set FresnelEnabled(value: boolean);
  29007. private static _ClearCoatTextureEnabled;
  29008. /**
  29009. * Are clear coat textures enabled in the application.
  29010. */
  29011. static get ClearCoatTextureEnabled(): boolean;
  29012. static set ClearCoatTextureEnabled(value: boolean);
  29013. private static _ClearCoatBumpTextureEnabled;
  29014. /**
  29015. * Are clear coat bump textures enabled in the application.
  29016. */
  29017. static get ClearCoatBumpTextureEnabled(): boolean;
  29018. static set ClearCoatBumpTextureEnabled(value: boolean);
  29019. private static _ClearCoatTintTextureEnabled;
  29020. /**
  29021. * Are clear coat tint textures enabled in the application.
  29022. */
  29023. static get ClearCoatTintTextureEnabled(): boolean;
  29024. static set ClearCoatTintTextureEnabled(value: boolean);
  29025. private static _SheenTextureEnabled;
  29026. /**
  29027. * Are sheen textures enabled in the application.
  29028. */
  29029. static get SheenTextureEnabled(): boolean;
  29030. static set SheenTextureEnabled(value: boolean);
  29031. private static _AnisotropicTextureEnabled;
  29032. /**
  29033. * Are anisotropic textures enabled in the application.
  29034. */
  29035. static get AnisotropicTextureEnabled(): boolean;
  29036. static set AnisotropicTextureEnabled(value: boolean);
  29037. private static _ThicknessTextureEnabled;
  29038. /**
  29039. * Are thickness textures enabled in the application.
  29040. */
  29041. static get ThicknessTextureEnabled(): boolean;
  29042. static set ThicknessTextureEnabled(value: boolean);
  29043. }
  29044. }
  29045. declare module BABYLON {
  29046. /** @hidden */
  29047. export var defaultFragmentDeclaration: {
  29048. name: string;
  29049. shader: string;
  29050. };
  29051. }
  29052. declare module BABYLON {
  29053. /** @hidden */
  29054. export var defaultUboDeclaration: {
  29055. name: string;
  29056. shader: string;
  29057. };
  29058. }
  29059. declare module BABYLON {
  29060. /** @hidden */
  29061. export var lightFragmentDeclaration: {
  29062. name: string;
  29063. shader: string;
  29064. };
  29065. }
  29066. declare module BABYLON {
  29067. /** @hidden */
  29068. export var lightUboDeclaration: {
  29069. name: string;
  29070. shader: string;
  29071. };
  29072. }
  29073. declare module BABYLON {
  29074. /** @hidden */
  29075. export var lightsFragmentFunctions: {
  29076. name: string;
  29077. shader: string;
  29078. };
  29079. }
  29080. declare module BABYLON {
  29081. /** @hidden */
  29082. export var shadowsFragmentFunctions: {
  29083. name: string;
  29084. shader: string;
  29085. };
  29086. }
  29087. declare module BABYLON {
  29088. /** @hidden */
  29089. export var fresnelFunction: {
  29090. name: string;
  29091. shader: string;
  29092. };
  29093. }
  29094. declare module BABYLON {
  29095. /** @hidden */
  29096. export var bumpFragmentMainFunctions: {
  29097. name: string;
  29098. shader: string;
  29099. };
  29100. }
  29101. declare module BABYLON {
  29102. /** @hidden */
  29103. export var bumpFragmentFunctions: {
  29104. name: string;
  29105. shader: string;
  29106. };
  29107. }
  29108. declare module BABYLON {
  29109. /** @hidden */
  29110. export var logDepthDeclaration: {
  29111. name: string;
  29112. shader: string;
  29113. };
  29114. }
  29115. declare module BABYLON {
  29116. /** @hidden */
  29117. export var bumpFragment: {
  29118. name: string;
  29119. shader: string;
  29120. };
  29121. }
  29122. declare module BABYLON {
  29123. /** @hidden */
  29124. export var depthPrePass: {
  29125. name: string;
  29126. shader: string;
  29127. };
  29128. }
  29129. declare module BABYLON {
  29130. /** @hidden */
  29131. export var lightFragment: {
  29132. name: string;
  29133. shader: string;
  29134. };
  29135. }
  29136. declare module BABYLON {
  29137. /** @hidden */
  29138. export var logDepthFragment: {
  29139. name: string;
  29140. shader: string;
  29141. };
  29142. }
  29143. declare module BABYLON {
  29144. /** @hidden */
  29145. export var defaultPixelShader: {
  29146. name: string;
  29147. shader: string;
  29148. };
  29149. }
  29150. declare module BABYLON {
  29151. /** @hidden */
  29152. export var defaultVertexDeclaration: {
  29153. name: string;
  29154. shader: string;
  29155. };
  29156. }
  29157. declare module BABYLON {
  29158. /** @hidden */
  29159. export var bumpVertexDeclaration: {
  29160. name: string;
  29161. shader: string;
  29162. };
  29163. }
  29164. declare module BABYLON {
  29165. /** @hidden */
  29166. export var bumpVertex: {
  29167. name: string;
  29168. shader: string;
  29169. };
  29170. }
  29171. declare module BABYLON {
  29172. /** @hidden */
  29173. export var fogVertex: {
  29174. name: string;
  29175. shader: string;
  29176. };
  29177. }
  29178. declare module BABYLON {
  29179. /** @hidden */
  29180. export var shadowsVertex: {
  29181. name: string;
  29182. shader: string;
  29183. };
  29184. }
  29185. declare module BABYLON {
  29186. /** @hidden */
  29187. export var pointCloudVertex: {
  29188. name: string;
  29189. shader: string;
  29190. };
  29191. }
  29192. declare module BABYLON {
  29193. /** @hidden */
  29194. export var logDepthVertex: {
  29195. name: string;
  29196. shader: string;
  29197. };
  29198. }
  29199. declare module BABYLON {
  29200. /** @hidden */
  29201. export var defaultVertexShader: {
  29202. name: string;
  29203. shader: string;
  29204. };
  29205. }
  29206. declare module BABYLON {
  29207. /** @hidden */
  29208. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  29209. MAINUV1: boolean;
  29210. MAINUV2: boolean;
  29211. DIFFUSE: boolean;
  29212. DIFFUSEDIRECTUV: number;
  29213. AMBIENT: boolean;
  29214. AMBIENTDIRECTUV: number;
  29215. OPACITY: boolean;
  29216. OPACITYDIRECTUV: number;
  29217. OPACITYRGB: boolean;
  29218. REFLECTION: boolean;
  29219. EMISSIVE: boolean;
  29220. EMISSIVEDIRECTUV: number;
  29221. SPECULAR: boolean;
  29222. SPECULARDIRECTUV: number;
  29223. BUMP: boolean;
  29224. BUMPDIRECTUV: number;
  29225. PARALLAX: boolean;
  29226. PARALLAXOCCLUSION: boolean;
  29227. SPECULAROVERALPHA: boolean;
  29228. CLIPPLANE: boolean;
  29229. CLIPPLANE2: boolean;
  29230. CLIPPLANE3: boolean;
  29231. CLIPPLANE4: boolean;
  29232. CLIPPLANE5: boolean;
  29233. CLIPPLANE6: boolean;
  29234. ALPHATEST: boolean;
  29235. DEPTHPREPASS: boolean;
  29236. ALPHAFROMDIFFUSE: boolean;
  29237. POINTSIZE: boolean;
  29238. FOG: boolean;
  29239. SPECULARTERM: boolean;
  29240. DIFFUSEFRESNEL: boolean;
  29241. OPACITYFRESNEL: boolean;
  29242. REFLECTIONFRESNEL: boolean;
  29243. REFRACTIONFRESNEL: boolean;
  29244. EMISSIVEFRESNEL: boolean;
  29245. FRESNEL: boolean;
  29246. NORMAL: boolean;
  29247. UV1: boolean;
  29248. UV2: boolean;
  29249. VERTEXCOLOR: boolean;
  29250. VERTEXALPHA: boolean;
  29251. NUM_BONE_INFLUENCERS: number;
  29252. BonesPerMesh: number;
  29253. BONETEXTURE: boolean;
  29254. INSTANCES: boolean;
  29255. GLOSSINESS: boolean;
  29256. ROUGHNESS: boolean;
  29257. EMISSIVEASILLUMINATION: boolean;
  29258. LINKEMISSIVEWITHDIFFUSE: boolean;
  29259. REFLECTIONFRESNELFROMSPECULAR: boolean;
  29260. LIGHTMAP: boolean;
  29261. LIGHTMAPDIRECTUV: number;
  29262. OBJECTSPACE_NORMALMAP: boolean;
  29263. USELIGHTMAPASSHADOWMAP: boolean;
  29264. REFLECTIONMAP_3D: boolean;
  29265. REFLECTIONMAP_SPHERICAL: boolean;
  29266. REFLECTIONMAP_PLANAR: boolean;
  29267. REFLECTIONMAP_CUBIC: boolean;
  29268. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  29269. REFLECTIONMAP_PROJECTION: boolean;
  29270. REFLECTIONMAP_SKYBOX: boolean;
  29271. REFLECTIONMAP_EXPLICIT: boolean;
  29272. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  29273. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  29274. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  29275. INVERTCUBICMAP: boolean;
  29276. LOGARITHMICDEPTH: boolean;
  29277. REFRACTION: boolean;
  29278. REFRACTIONMAP_3D: boolean;
  29279. REFLECTIONOVERALPHA: boolean;
  29280. TWOSIDEDLIGHTING: boolean;
  29281. SHADOWFLOAT: boolean;
  29282. MORPHTARGETS: boolean;
  29283. MORPHTARGETS_NORMAL: boolean;
  29284. MORPHTARGETS_TANGENT: boolean;
  29285. MORPHTARGETS_UV: boolean;
  29286. NUM_MORPH_INFLUENCERS: number;
  29287. NONUNIFORMSCALING: boolean;
  29288. PREMULTIPLYALPHA: boolean;
  29289. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  29290. ALPHABLEND: boolean;
  29291. RGBDLIGHTMAP: boolean;
  29292. RGBDREFLECTION: boolean;
  29293. RGBDREFRACTION: boolean;
  29294. IMAGEPROCESSING: boolean;
  29295. VIGNETTE: boolean;
  29296. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29297. VIGNETTEBLENDMODEOPAQUE: boolean;
  29298. TONEMAPPING: boolean;
  29299. TONEMAPPING_ACES: boolean;
  29300. CONTRAST: boolean;
  29301. COLORCURVES: boolean;
  29302. COLORGRADING: boolean;
  29303. COLORGRADING3D: boolean;
  29304. SAMPLER3DGREENDEPTH: boolean;
  29305. SAMPLER3DBGRMAP: boolean;
  29306. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29307. MULTIVIEW: boolean;
  29308. /**
  29309. * If the reflection texture on this material is in linear color space
  29310. * @hidden
  29311. */
  29312. IS_REFLECTION_LINEAR: boolean;
  29313. /**
  29314. * If the refraction texture on this material is in linear color space
  29315. * @hidden
  29316. */
  29317. IS_REFRACTION_LINEAR: boolean;
  29318. EXPOSURE: boolean;
  29319. constructor();
  29320. setReflectionMode(modeToEnable: string): void;
  29321. }
  29322. /**
  29323. * This is the default material used in Babylon. It is the best trade off between quality
  29324. * and performances.
  29325. * @see http://doc.babylonjs.com/babylon101/materials
  29326. */
  29327. export class StandardMaterial extends PushMaterial {
  29328. private _diffuseTexture;
  29329. /**
  29330. * The basic texture of the material as viewed under a light.
  29331. */
  29332. diffuseTexture: Nullable<BaseTexture>;
  29333. private _ambientTexture;
  29334. /**
  29335. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  29336. */
  29337. ambientTexture: Nullable<BaseTexture>;
  29338. private _opacityTexture;
  29339. /**
  29340. * Define the transparency of the material from a texture.
  29341. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  29342. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  29343. */
  29344. opacityTexture: Nullable<BaseTexture>;
  29345. private _reflectionTexture;
  29346. /**
  29347. * Define the texture used to display the reflection.
  29348. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29349. */
  29350. reflectionTexture: Nullable<BaseTexture>;
  29351. private _emissiveTexture;
  29352. /**
  29353. * Define texture of the material as if self lit.
  29354. * This will be mixed in the final result even in the absence of light.
  29355. */
  29356. emissiveTexture: Nullable<BaseTexture>;
  29357. private _specularTexture;
  29358. /**
  29359. * Define how the color and intensity of the highlight given by the light in the material.
  29360. */
  29361. specularTexture: Nullable<BaseTexture>;
  29362. private _bumpTexture;
  29363. /**
  29364. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  29365. * 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.
  29366. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  29367. */
  29368. bumpTexture: Nullable<BaseTexture>;
  29369. private _lightmapTexture;
  29370. /**
  29371. * Complex lighting can be computationally expensive to compute at runtime.
  29372. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  29373. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  29374. */
  29375. lightmapTexture: Nullable<BaseTexture>;
  29376. private _refractionTexture;
  29377. /**
  29378. * Define the texture used to display the refraction.
  29379. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29380. */
  29381. refractionTexture: Nullable<BaseTexture>;
  29382. /**
  29383. * The color of the material lit by the environmental background lighting.
  29384. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  29385. */
  29386. ambientColor: Color3;
  29387. /**
  29388. * The basic color of the material as viewed under a light.
  29389. */
  29390. diffuseColor: Color3;
  29391. /**
  29392. * Define how the color and intensity of the highlight given by the light in the material.
  29393. */
  29394. specularColor: Color3;
  29395. /**
  29396. * Define the color of the material as if self lit.
  29397. * This will be mixed in the final result even in the absence of light.
  29398. */
  29399. emissiveColor: Color3;
  29400. /**
  29401. * Defines how sharp are the highlights in the material.
  29402. * The bigger the value the sharper giving a more glossy feeling to the result.
  29403. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  29404. */
  29405. specularPower: number;
  29406. private _useAlphaFromDiffuseTexture;
  29407. /**
  29408. * Does the transparency come from the diffuse texture alpha channel.
  29409. */
  29410. useAlphaFromDiffuseTexture: boolean;
  29411. private _useEmissiveAsIllumination;
  29412. /**
  29413. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  29414. */
  29415. useEmissiveAsIllumination: boolean;
  29416. private _linkEmissiveWithDiffuse;
  29417. /**
  29418. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  29419. * the emissive level when the final color is close to one.
  29420. */
  29421. linkEmissiveWithDiffuse: boolean;
  29422. private _useSpecularOverAlpha;
  29423. /**
  29424. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  29425. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  29426. */
  29427. useSpecularOverAlpha: boolean;
  29428. private _useReflectionOverAlpha;
  29429. /**
  29430. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  29431. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  29432. */
  29433. useReflectionOverAlpha: boolean;
  29434. private _disableLighting;
  29435. /**
  29436. * Does lights from the scene impacts this material.
  29437. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  29438. */
  29439. disableLighting: boolean;
  29440. private _useObjectSpaceNormalMap;
  29441. /**
  29442. * Allows using an object space normal map (instead of tangent space).
  29443. */
  29444. useObjectSpaceNormalMap: boolean;
  29445. private _useParallax;
  29446. /**
  29447. * Is parallax enabled or not.
  29448. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  29449. */
  29450. useParallax: boolean;
  29451. private _useParallaxOcclusion;
  29452. /**
  29453. * Is parallax occlusion enabled or not.
  29454. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  29455. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  29456. */
  29457. useParallaxOcclusion: boolean;
  29458. /**
  29459. * 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.
  29460. */
  29461. parallaxScaleBias: number;
  29462. private _roughness;
  29463. /**
  29464. * Helps to define how blurry the reflections should appears in the material.
  29465. */
  29466. roughness: number;
  29467. /**
  29468. * In case of refraction, define the value of the index of refraction.
  29469. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29470. */
  29471. indexOfRefraction: number;
  29472. /**
  29473. * Invert the refraction texture alongside the y axis.
  29474. * It can be useful with procedural textures or probe for instance.
  29475. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29476. */
  29477. invertRefractionY: boolean;
  29478. /**
  29479. * Defines the alpha limits in alpha test mode.
  29480. */
  29481. alphaCutOff: number;
  29482. private _useLightmapAsShadowmap;
  29483. /**
  29484. * In case of light mapping, define whether the map contains light or shadow informations.
  29485. */
  29486. useLightmapAsShadowmap: boolean;
  29487. private _diffuseFresnelParameters;
  29488. /**
  29489. * Define the diffuse fresnel parameters of the material.
  29490. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29491. */
  29492. diffuseFresnelParameters: FresnelParameters;
  29493. private _opacityFresnelParameters;
  29494. /**
  29495. * Define the opacity fresnel parameters of the material.
  29496. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29497. */
  29498. opacityFresnelParameters: FresnelParameters;
  29499. private _reflectionFresnelParameters;
  29500. /**
  29501. * Define the reflection fresnel parameters of the material.
  29502. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29503. */
  29504. reflectionFresnelParameters: FresnelParameters;
  29505. private _refractionFresnelParameters;
  29506. /**
  29507. * Define the refraction fresnel parameters of the material.
  29508. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29509. */
  29510. refractionFresnelParameters: FresnelParameters;
  29511. private _emissiveFresnelParameters;
  29512. /**
  29513. * Define the emissive fresnel parameters of the material.
  29514. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29515. */
  29516. emissiveFresnelParameters: FresnelParameters;
  29517. private _useReflectionFresnelFromSpecular;
  29518. /**
  29519. * If true automatically deducts the fresnels values from the material specularity.
  29520. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29521. */
  29522. useReflectionFresnelFromSpecular: boolean;
  29523. private _useGlossinessFromSpecularMapAlpha;
  29524. /**
  29525. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  29526. */
  29527. useGlossinessFromSpecularMapAlpha: boolean;
  29528. private _maxSimultaneousLights;
  29529. /**
  29530. * Defines the maximum number of lights that can be used in the material
  29531. */
  29532. maxSimultaneousLights: number;
  29533. private _invertNormalMapX;
  29534. /**
  29535. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  29536. */
  29537. invertNormalMapX: boolean;
  29538. private _invertNormalMapY;
  29539. /**
  29540. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  29541. */
  29542. invertNormalMapY: boolean;
  29543. private _twoSidedLighting;
  29544. /**
  29545. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  29546. */
  29547. twoSidedLighting: boolean;
  29548. /**
  29549. * Default configuration related to image processing available in the standard Material.
  29550. */
  29551. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  29552. /**
  29553. * Gets the image processing configuration used either in this material.
  29554. */
  29555. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  29556. /**
  29557. * Sets the Default image processing configuration used either in the this material.
  29558. *
  29559. * If sets to null, the scene one is in use.
  29560. */
  29561. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  29562. /**
  29563. * Keep track of the image processing observer to allow dispose and replace.
  29564. */
  29565. private _imageProcessingObserver;
  29566. /**
  29567. * Attaches a new image processing configuration to the Standard Material.
  29568. * @param configuration
  29569. */
  29570. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  29571. /**
  29572. * Gets wether the color curves effect is enabled.
  29573. */
  29574. get cameraColorCurvesEnabled(): boolean;
  29575. /**
  29576. * Sets wether the color curves effect is enabled.
  29577. */
  29578. set cameraColorCurvesEnabled(value: boolean);
  29579. /**
  29580. * Gets wether the color grading effect is enabled.
  29581. */
  29582. get cameraColorGradingEnabled(): boolean;
  29583. /**
  29584. * Gets wether the color grading effect is enabled.
  29585. */
  29586. set cameraColorGradingEnabled(value: boolean);
  29587. /**
  29588. * Gets wether tonemapping is enabled or not.
  29589. */
  29590. get cameraToneMappingEnabled(): boolean;
  29591. /**
  29592. * Sets wether tonemapping is enabled or not
  29593. */
  29594. set cameraToneMappingEnabled(value: boolean);
  29595. /**
  29596. * The camera exposure used on this material.
  29597. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  29598. * This corresponds to a photographic exposure.
  29599. */
  29600. get cameraExposure(): number;
  29601. /**
  29602. * The camera exposure used on this material.
  29603. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  29604. * This corresponds to a photographic exposure.
  29605. */
  29606. set cameraExposure(value: number);
  29607. /**
  29608. * Gets The camera contrast used on this material.
  29609. */
  29610. get cameraContrast(): number;
  29611. /**
  29612. * Sets The camera contrast used on this material.
  29613. */
  29614. set cameraContrast(value: number);
  29615. /**
  29616. * Gets the Color Grading 2D Lookup Texture.
  29617. */
  29618. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  29619. /**
  29620. * Sets the Color Grading 2D Lookup Texture.
  29621. */
  29622. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  29623. /**
  29624. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29625. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29626. * 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;
  29627. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29628. */
  29629. get cameraColorCurves(): Nullable<ColorCurves>;
  29630. /**
  29631. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29632. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29633. * 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;
  29634. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29635. */
  29636. set cameraColorCurves(value: Nullable<ColorCurves>);
  29637. protected _renderTargets: SmartArray<RenderTargetTexture>;
  29638. protected _worldViewProjectionMatrix: Matrix;
  29639. protected _globalAmbientColor: Color3;
  29640. protected _useLogarithmicDepth: boolean;
  29641. protected _rebuildInParallel: boolean;
  29642. /**
  29643. * Instantiates a new standard material.
  29644. * This is the default material used in Babylon. It is the best trade off between quality
  29645. * and performances.
  29646. * @see http://doc.babylonjs.com/babylon101/materials
  29647. * @param name Define the name of the material in the scene
  29648. * @param scene Define the scene the material belong to
  29649. */
  29650. constructor(name: string, scene: Scene);
  29651. /**
  29652. * Gets a boolean indicating that current material needs to register RTT
  29653. */
  29654. get hasRenderTargetTextures(): boolean;
  29655. /**
  29656. * Gets the current class name of the material e.g. "StandardMaterial"
  29657. * Mainly use in serialization.
  29658. * @returns the class name
  29659. */
  29660. getClassName(): string;
  29661. /**
  29662. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  29663. * You can try switching to logarithmic depth.
  29664. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  29665. */
  29666. get useLogarithmicDepth(): boolean;
  29667. set useLogarithmicDepth(value: boolean);
  29668. /**
  29669. * Specifies if the material will require alpha blending
  29670. * @returns a boolean specifying if alpha blending is needed
  29671. */
  29672. needAlphaBlending(): boolean;
  29673. /**
  29674. * Specifies if this material should be rendered in alpha test mode
  29675. * @returns a boolean specifying if an alpha test is needed.
  29676. */
  29677. needAlphaTesting(): boolean;
  29678. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  29679. /**
  29680. * Get the texture used for alpha test purpose.
  29681. * @returns the diffuse texture in case of the standard material.
  29682. */
  29683. getAlphaTestTexture(): Nullable<BaseTexture>;
  29684. /**
  29685. * Get if the submesh is ready to be used and all its information available.
  29686. * Child classes can use it to update shaders
  29687. * @param mesh defines the mesh to check
  29688. * @param subMesh defines which submesh to check
  29689. * @param useInstances specifies that instances should be used
  29690. * @returns a boolean indicating that the submesh is ready or not
  29691. */
  29692. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  29693. /**
  29694. * Builds the material UBO layouts.
  29695. * Used internally during the effect preparation.
  29696. */
  29697. buildUniformLayout(): void;
  29698. /**
  29699. * Unbinds the material from the mesh
  29700. */
  29701. unbind(): void;
  29702. /**
  29703. * Binds the submesh to this material by preparing the effect and shader to draw
  29704. * @param world defines the world transformation matrix
  29705. * @param mesh defines the mesh containing the submesh
  29706. * @param subMesh defines the submesh to bind the material to
  29707. */
  29708. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  29709. /**
  29710. * Get the list of animatables in the material.
  29711. * @returns the list of animatables object used in the material
  29712. */
  29713. getAnimatables(): IAnimatable[];
  29714. /**
  29715. * Gets the active textures from the material
  29716. * @returns an array of textures
  29717. */
  29718. getActiveTextures(): BaseTexture[];
  29719. /**
  29720. * Specifies if the material uses a texture
  29721. * @param texture defines the texture to check against the material
  29722. * @returns a boolean specifying if the material uses the texture
  29723. */
  29724. hasTexture(texture: BaseTexture): boolean;
  29725. /**
  29726. * Disposes the material
  29727. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  29728. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  29729. */
  29730. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  29731. /**
  29732. * Makes a duplicate of the material, and gives it a new name
  29733. * @param name defines the new name for the duplicated material
  29734. * @returns the cloned material
  29735. */
  29736. clone(name: string): StandardMaterial;
  29737. /**
  29738. * Serializes this material in a JSON representation
  29739. * @returns the serialized material object
  29740. */
  29741. serialize(): any;
  29742. /**
  29743. * Creates a standard material from parsed material data
  29744. * @param source defines the JSON representation of the material
  29745. * @param scene defines the hosting scene
  29746. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  29747. * @returns a new standard material
  29748. */
  29749. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  29750. /**
  29751. * Are diffuse textures enabled in the application.
  29752. */
  29753. static get DiffuseTextureEnabled(): boolean;
  29754. static set DiffuseTextureEnabled(value: boolean);
  29755. /**
  29756. * Are ambient textures enabled in the application.
  29757. */
  29758. static get AmbientTextureEnabled(): boolean;
  29759. static set AmbientTextureEnabled(value: boolean);
  29760. /**
  29761. * Are opacity textures enabled in the application.
  29762. */
  29763. static get OpacityTextureEnabled(): boolean;
  29764. static set OpacityTextureEnabled(value: boolean);
  29765. /**
  29766. * Are reflection textures enabled in the application.
  29767. */
  29768. static get ReflectionTextureEnabled(): boolean;
  29769. static set ReflectionTextureEnabled(value: boolean);
  29770. /**
  29771. * Are emissive textures enabled in the application.
  29772. */
  29773. static get EmissiveTextureEnabled(): boolean;
  29774. static set EmissiveTextureEnabled(value: boolean);
  29775. /**
  29776. * Are specular textures enabled in the application.
  29777. */
  29778. static get SpecularTextureEnabled(): boolean;
  29779. static set SpecularTextureEnabled(value: boolean);
  29780. /**
  29781. * Are bump textures enabled in the application.
  29782. */
  29783. static get BumpTextureEnabled(): boolean;
  29784. static set BumpTextureEnabled(value: boolean);
  29785. /**
  29786. * Are lightmap textures enabled in the application.
  29787. */
  29788. static get LightmapTextureEnabled(): boolean;
  29789. static set LightmapTextureEnabled(value: boolean);
  29790. /**
  29791. * Are refraction textures enabled in the application.
  29792. */
  29793. static get RefractionTextureEnabled(): boolean;
  29794. static set RefractionTextureEnabled(value: boolean);
  29795. /**
  29796. * Are color grading textures enabled in the application.
  29797. */
  29798. static get ColorGradingTextureEnabled(): boolean;
  29799. static set ColorGradingTextureEnabled(value: boolean);
  29800. /**
  29801. * Are fresnels enabled in the application.
  29802. */
  29803. static get FresnelEnabled(): boolean;
  29804. static set FresnelEnabled(value: boolean);
  29805. }
  29806. }
  29807. declare module BABYLON {
  29808. /**
  29809. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  29810. *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.
  29811. * The SPS is also a particle system. It provides some methods to manage the particles.
  29812. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  29813. *
  29814. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  29815. */
  29816. export class SolidParticleSystem implements IDisposable {
  29817. /**
  29818. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  29819. * Example : var p = SPS.particles[i];
  29820. */
  29821. particles: SolidParticle[];
  29822. /**
  29823. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  29824. */
  29825. nbParticles: number;
  29826. /**
  29827. * If the particles must ever face the camera (default false). Useful for planar particles.
  29828. */
  29829. billboard: boolean;
  29830. /**
  29831. * Recompute normals when adding a shape
  29832. */
  29833. recomputeNormals: boolean;
  29834. /**
  29835. * This a counter ofr your own usage. It's not set by any SPS functions.
  29836. */
  29837. counter: number;
  29838. /**
  29839. * The SPS name. This name is also given to the underlying mesh.
  29840. */
  29841. name: string;
  29842. /**
  29843. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  29844. */
  29845. mesh: Mesh;
  29846. /**
  29847. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  29848. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  29849. */
  29850. vars: any;
  29851. /**
  29852. * This array is populated when the SPS is set as 'pickable'.
  29853. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  29854. * Each element of this array is an object `{idx: int, faceId: int}`.
  29855. * `idx` is the picked particle index in the `SPS.particles` array
  29856. * `faceId` is the picked face index counted within this particle.
  29857. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  29858. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  29859. * Use the method SPS.pickedParticle(pickingInfo) instead.
  29860. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  29861. */
  29862. pickedParticles: {
  29863. idx: number;
  29864. faceId: number;
  29865. }[];
  29866. /**
  29867. * This array is populated when the SPS is set as 'pickable'
  29868. * Each key of this array is a submesh index.
  29869. * Each element of this array is a second array defined like this :
  29870. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  29871. * Each element of this second array is an object `{idx: int, faceId: int}`.
  29872. * `idx` is the picked particle index in the `SPS.particles` array
  29873. * `faceId` is the picked face index counted within this particle.
  29874. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  29875. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  29876. */
  29877. pickedBySubMesh: {
  29878. idx: number;
  29879. faceId: number;
  29880. }[][];
  29881. /**
  29882. * This array is populated when `enableDepthSort` is set to true.
  29883. * Each element of this array is an instance of the class DepthSortedParticle.
  29884. */
  29885. depthSortedParticles: DepthSortedParticle[];
  29886. /**
  29887. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  29888. * @hidden
  29889. */
  29890. _bSphereOnly: boolean;
  29891. /**
  29892. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  29893. * @hidden
  29894. */
  29895. _bSphereRadiusFactor: number;
  29896. private _scene;
  29897. private _positions;
  29898. private _indices;
  29899. private _normals;
  29900. private _colors;
  29901. private _uvs;
  29902. private _indices32;
  29903. private _positions32;
  29904. private _normals32;
  29905. private _fixedNormal32;
  29906. private _colors32;
  29907. private _uvs32;
  29908. private _index;
  29909. private _updatable;
  29910. private _pickable;
  29911. private _isVisibilityBoxLocked;
  29912. private _alwaysVisible;
  29913. private _depthSort;
  29914. private _expandable;
  29915. private _shapeCounter;
  29916. private _copy;
  29917. private _color;
  29918. private _computeParticleColor;
  29919. private _computeParticleTexture;
  29920. private _computeParticleRotation;
  29921. private _computeParticleVertex;
  29922. private _computeBoundingBox;
  29923. private _depthSortParticles;
  29924. private _camera;
  29925. private _mustUnrotateFixedNormals;
  29926. private _particlesIntersect;
  29927. private _needs32Bits;
  29928. private _isNotBuilt;
  29929. private _lastParticleId;
  29930. private _idxOfId;
  29931. private _multimaterialEnabled;
  29932. private _useModelMaterial;
  29933. private _indicesByMaterial;
  29934. private _materialIndexes;
  29935. private _depthSortFunction;
  29936. private _materialSortFunction;
  29937. private _materials;
  29938. private _multimaterial;
  29939. private _materialIndexesById;
  29940. private _defaultMaterial;
  29941. private _autoUpdateSubMeshes;
  29942. private _tmpVertex;
  29943. /**
  29944. * Creates a SPS (Solid Particle System) object.
  29945. * @param name (String) is the SPS name, this will be the underlying mesh name.
  29946. * @param scene (Scene) is the scene in which the SPS is added.
  29947. * @param options defines the options of the sps e.g.
  29948. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  29949. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  29950. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  29951. * * 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.
  29952. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  29953. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  29954. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  29955. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  29956. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  29957. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  29958. */
  29959. constructor(name: string, scene: Scene, options?: {
  29960. updatable?: boolean;
  29961. isPickable?: boolean;
  29962. enableDepthSort?: boolean;
  29963. particleIntersection?: boolean;
  29964. boundingSphereOnly?: boolean;
  29965. bSphereRadiusFactor?: number;
  29966. expandable?: boolean;
  29967. useModelMaterial?: boolean;
  29968. enableMultiMaterial?: boolean;
  29969. });
  29970. /**
  29971. * Builds the SPS underlying mesh. Returns a standard Mesh.
  29972. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  29973. * @returns the created mesh
  29974. */
  29975. buildMesh(): Mesh;
  29976. /**
  29977. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  29978. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  29979. * Thus the particles generated from `digest()` have their property `position` set yet.
  29980. * @param mesh ( Mesh ) is the mesh to be digested
  29981. * @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
  29982. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  29983. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  29984. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  29985. * @returns the current SPS
  29986. */
  29987. digest(mesh: Mesh, options?: {
  29988. facetNb?: number;
  29989. number?: number;
  29990. delta?: number;
  29991. storage?: [];
  29992. }): SolidParticleSystem;
  29993. /**
  29994. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  29995. * @hidden
  29996. */
  29997. private _unrotateFixedNormals;
  29998. /**
  29999. * Resets the temporary working copy particle
  30000. * @hidden
  30001. */
  30002. private _resetCopy;
  30003. /**
  30004. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  30005. * @param p the current index in the positions array to be updated
  30006. * @param ind the current index in the indices array
  30007. * @param shape a Vector3 array, the shape geometry
  30008. * @param positions the positions array to be updated
  30009. * @param meshInd the shape indices array
  30010. * @param indices the indices array to be updated
  30011. * @param meshUV the shape uv array
  30012. * @param uvs the uv array to be updated
  30013. * @param meshCol the shape color array
  30014. * @param colors the color array to be updated
  30015. * @param meshNor the shape normals array
  30016. * @param normals the normals array to be updated
  30017. * @param idx the particle index
  30018. * @param idxInShape the particle index in its shape
  30019. * @param options the addShape() method passed options
  30020. * @model the particle model
  30021. * @hidden
  30022. */
  30023. private _meshBuilder;
  30024. /**
  30025. * Returns a shape Vector3 array from positions float array
  30026. * @param positions float array
  30027. * @returns a vector3 array
  30028. * @hidden
  30029. */
  30030. private _posToShape;
  30031. /**
  30032. * Returns a shapeUV array from a float uvs (array deep copy)
  30033. * @param uvs as a float array
  30034. * @returns a shapeUV array
  30035. * @hidden
  30036. */
  30037. private _uvsToShapeUV;
  30038. /**
  30039. * Adds a new particle object in the particles array
  30040. * @param idx particle index in particles array
  30041. * @param id particle id
  30042. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  30043. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  30044. * @param model particle ModelShape object
  30045. * @param shapeId model shape identifier
  30046. * @param idxInShape index of the particle in the current model
  30047. * @param bInfo model bounding info object
  30048. * @param storage target storage array, if any
  30049. * @hidden
  30050. */
  30051. private _addParticle;
  30052. /**
  30053. * Adds some particles to the SPS from the model shape. Returns the shape id.
  30054. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  30055. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  30056. * @param nb (positive integer) the number of particles to be created from this model
  30057. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  30058. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  30059. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  30060. * @returns the number of shapes in the system
  30061. */
  30062. addShape(mesh: Mesh, nb: number, options?: {
  30063. positionFunction?: any;
  30064. vertexFunction?: any;
  30065. storage?: [];
  30066. }): number;
  30067. /**
  30068. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  30069. * @hidden
  30070. */
  30071. private _rebuildParticle;
  30072. /**
  30073. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  30074. * @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.
  30075. * @returns the SPS.
  30076. */
  30077. rebuildMesh(reset?: boolean): SolidParticleSystem;
  30078. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  30079. * Returns an array with the removed particles.
  30080. * 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.
  30081. * The SPS can't be empty so at least one particle needs to remain in place.
  30082. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  30083. * @param start index of the first particle to remove
  30084. * @param end index of the last particle to remove (included)
  30085. * @returns an array populated with the removed particles
  30086. */
  30087. removeParticles(start: number, end: number): SolidParticle[];
  30088. /**
  30089. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  30090. * @param solidParticleArray an array populated with Solid Particles objects
  30091. * @returns the SPS
  30092. */
  30093. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  30094. /**
  30095. * Creates a new particle and modifies the SPS mesh geometry :
  30096. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  30097. * - calls _addParticle() to populate the particle array
  30098. * factorized code from addShape() and insertParticlesFromArray()
  30099. * @param idx particle index in the particles array
  30100. * @param i particle index in its shape
  30101. * @param modelShape particle ModelShape object
  30102. * @param shape shape vertex array
  30103. * @param meshInd shape indices array
  30104. * @param meshUV shape uv array
  30105. * @param meshCol shape color array
  30106. * @param meshNor shape normals array
  30107. * @param bbInfo shape bounding info
  30108. * @param storage target particle storage
  30109. * @options addShape() passed options
  30110. * @hidden
  30111. */
  30112. private _insertNewParticle;
  30113. /**
  30114. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  30115. * This method calls `updateParticle()` for each particle of the SPS.
  30116. * For an animated SPS, it is usually called within the render loop.
  30117. * 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.
  30118. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  30119. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  30120. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  30121. * @returns the SPS.
  30122. */
  30123. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  30124. /**
  30125. * Disposes the SPS.
  30126. */
  30127. dispose(): void;
  30128. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  30129. * idx is the particle index in the SPS
  30130. * faceId is the picked face index counted within this particle.
  30131. * Returns null if the pickInfo can't identify a picked particle.
  30132. * @param pickingInfo (PickingInfo object)
  30133. * @returns {idx: number, faceId: number} or null
  30134. */
  30135. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  30136. idx: number;
  30137. faceId: number;
  30138. }>;
  30139. /**
  30140. * Returns a SolidParticle object from its identifier : particle.id
  30141. * @param id (integer) the particle Id
  30142. * @returns the searched particle or null if not found in the SPS.
  30143. */
  30144. getParticleById(id: number): Nullable<SolidParticle>;
  30145. /**
  30146. * Returns a new array populated with the particles having the passed shapeId.
  30147. * @param shapeId (integer) the shape identifier
  30148. * @returns a new solid particle array
  30149. */
  30150. getParticlesByShapeId(shapeId: number): SolidParticle[];
  30151. /**
  30152. * Populates the passed array "ref" with the particles having the passed shapeId.
  30153. * @param shapeId the shape identifier
  30154. * @returns the SPS
  30155. * @param ref
  30156. */
  30157. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  30158. /**
  30159. * Computes the required SubMeshes according the materials assigned to the particles.
  30160. * @returns the solid particle system.
  30161. * Does nothing if called before the SPS mesh is built.
  30162. */
  30163. computeSubMeshes(): SolidParticleSystem;
  30164. /**
  30165. * Sorts the solid particles by material when MultiMaterial is enabled.
  30166. * Updates the indices32 array.
  30167. * Updates the indicesByMaterial array.
  30168. * Updates the mesh indices array.
  30169. * @returns the SPS
  30170. * @hidden
  30171. */
  30172. private _sortParticlesByMaterial;
  30173. /**
  30174. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  30175. * @hidden
  30176. */
  30177. private _setMaterialIndexesById;
  30178. /**
  30179. * Returns an array with unique values of Materials from the passed array
  30180. * @param array the material array to be checked and filtered
  30181. * @hidden
  30182. */
  30183. private _filterUniqueMaterialId;
  30184. /**
  30185. * Sets a new Standard Material as _defaultMaterial if not already set.
  30186. * @hidden
  30187. */
  30188. private _setDefaultMaterial;
  30189. /**
  30190. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  30191. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30192. * @returns the SPS.
  30193. */
  30194. refreshVisibleSize(): SolidParticleSystem;
  30195. /**
  30196. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  30197. * @param size the size (float) of the visibility box
  30198. * note : this doesn't lock the SPS mesh bounding box.
  30199. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30200. */
  30201. setVisibilityBox(size: number): void;
  30202. /**
  30203. * Gets whether the SPS as always visible or not
  30204. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30205. */
  30206. get isAlwaysVisible(): boolean;
  30207. /**
  30208. * Sets the SPS as always visible or not
  30209. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30210. */
  30211. set isAlwaysVisible(val: boolean);
  30212. /**
  30213. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  30214. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30215. */
  30216. set isVisibilityBoxLocked(val: boolean);
  30217. /**
  30218. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  30219. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30220. */
  30221. get isVisibilityBoxLocked(): boolean;
  30222. /**
  30223. * Tells to `setParticles()` to compute the particle rotations or not.
  30224. * Default value : true. The SPS is faster when it's set to false.
  30225. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  30226. */
  30227. set computeParticleRotation(val: boolean);
  30228. /**
  30229. * Tells to `setParticles()` to compute the particle colors or not.
  30230. * Default value : true. The SPS is faster when it's set to false.
  30231. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  30232. */
  30233. set computeParticleColor(val: boolean);
  30234. set computeParticleTexture(val: boolean);
  30235. /**
  30236. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  30237. * Default value : false. The SPS is faster when it's set to false.
  30238. * Note : the particle custom vertex positions aren't stored values.
  30239. */
  30240. set computeParticleVertex(val: boolean);
  30241. /**
  30242. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  30243. */
  30244. set computeBoundingBox(val: boolean);
  30245. /**
  30246. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  30247. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  30248. * Default : `true`
  30249. */
  30250. set depthSortParticles(val: boolean);
  30251. /**
  30252. * Gets if `setParticles()` computes the particle rotations or not.
  30253. * Default value : true. The SPS is faster when it's set to false.
  30254. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  30255. */
  30256. get computeParticleRotation(): boolean;
  30257. /**
  30258. * Gets if `setParticles()` computes the particle colors or not.
  30259. * Default value : true. The SPS is faster when it's set to false.
  30260. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  30261. */
  30262. get computeParticleColor(): boolean;
  30263. /**
  30264. * Gets if `setParticles()` computes the particle textures or not.
  30265. * Default value : true. The SPS is faster when it's set to false.
  30266. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  30267. */
  30268. get computeParticleTexture(): boolean;
  30269. /**
  30270. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  30271. * Default value : false. The SPS is faster when it's set to false.
  30272. * Note : the particle custom vertex positions aren't stored values.
  30273. */
  30274. get computeParticleVertex(): boolean;
  30275. /**
  30276. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  30277. */
  30278. get computeBoundingBox(): boolean;
  30279. /**
  30280. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  30281. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  30282. * Default : `true`
  30283. */
  30284. get depthSortParticles(): boolean;
  30285. /**
  30286. * Gets if the SPS is created as expandable at construction time.
  30287. * Default : `false`
  30288. */
  30289. get expandable(): boolean;
  30290. /**
  30291. * Gets if the SPS supports the Multi Materials
  30292. */
  30293. get multimaterialEnabled(): boolean;
  30294. /**
  30295. * Gets if the SPS uses the model materials for its own multimaterial.
  30296. */
  30297. get useModelMaterial(): boolean;
  30298. /**
  30299. * The SPS used material array.
  30300. */
  30301. get materials(): Material[];
  30302. /**
  30303. * Sets the SPS MultiMaterial from the passed materials.
  30304. * Note : the passed array is internally copied and not used then by reference.
  30305. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  30306. */
  30307. setMultiMaterial(materials: Material[]): void;
  30308. /**
  30309. * The SPS computed multimaterial object
  30310. */
  30311. get multimaterial(): MultiMaterial;
  30312. set multimaterial(mm: MultiMaterial);
  30313. /**
  30314. * If the subMeshes must be updated on the next call to setParticles()
  30315. */
  30316. get autoUpdateSubMeshes(): boolean;
  30317. set autoUpdateSubMeshes(val: boolean);
  30318. /**
  30319. * This function does nothing. It may be overwritten to set all the particle first values.
  30320. * The SPS doesn't call this function, you may have to call it by your own.
  30321. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  30322. */
  30323. initParticles(): void;
  30324. /**
  30325. * This function does nothing. It may be overwritten to recycle a particle.
  30326. * The SPS doesn't call this function, you may have to call it by your own.
  30327. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  30328. * @param particle The particle to recycle
  30329. * @returns the recycled particle
  30330. */
  30331. recycleParticle(particle: SolidParticle): SolidParticle;
  30332. /**
  30333. * Updates a particle : this function should be overwritten by the user.
  30334. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  30335. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  30336. * @example : just set a particle position or velocity and recycle conditions
  30337. * @param particle The particle to update
  30338. * @returns the updated particle
  30339. */
  30340. updateParticle(particle: SolidParticle): SolidParticle;
  30341. /**
  30342. * Updates a vertex of a particle : it can be overwritten by the user.
  30343. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  30344. * @param particle the current particle
  30345. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  30346. * @param pt the index of the current vertex in the particle shape
  30347. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  30348. * @example : just set a vertex particle position or color
  30349. * @returns the sps
  30350. */
  30351. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  30352. /**
  30353. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  30354. * This does nothing and may be overwritten by the user.
  30355. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30356. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30357. * @param update the boolean update value actually passed to setParticles()
  30358. */
  30359. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  30360. /**
  30361. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  30362. * This will be passed three parameters.
  30363. * This does nothing and may be overwritten by the user.
  30364. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30365. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30366. * @param update the boolean update value actually passed to setParticles()
  30367. */
  30368. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  30369. }
  30370. }
  30371. declare module BABYLON {
  30372. /**
  30373. * Represents one particle of a solid particle system.
  30374. */
  30375. export class SolidParticle {
  30376. /**
  30377. * particle global index
  30378. */
  30379. idx: number;
  30380. /**
  30381. * particle identifier
  30382. */
  30383. id: number;
  30384. /**
  30385. * The color of the particle
  30386. */
  30387. color: Nullable<Color4>;
  30388. /**
  30389. * The world space position of the particle.
  30390. */
  30391. position: Vector3;
  30392. /**
  30393. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  30394. */
  30395. rotation: Vector3;
  30396. /**
  30397. * The world space rotation quaternion of the particle.
  30398. */
  30399. rotationQuaternion: Nullable<Quaternion>;
  30400. /**
  30401. * The scaling of the particle.
  30402. */
  30403. scaling: Vector3;
  30404. /**
  30405. * The uvs of the particle.
  30406. */
  30407. uvs: Vector4;
  30408. /**
  30409. * The current speed of the particle.
  30410. */
  30411. velocity: Vector3;
  30412. /**
  30413. * The pivot point in the particle local space.
  30414. */
  30415. pivot: Vector3;
  30416. /**
  30417. * Must the particle be translated from its pivot point in its local space ?
  30418. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  30419. * Default : false
  30420. */
  30421. translateFromPivot: boolean;
  30422. /**
  30423. * Is the particle active or not ?
  30424. */
  30425. alive: boolean;
  30426. /**
  30427. * Is the particle visible or not ?
  30428. */
  30429. isVisible: boolean;
  30430. /**
  30431. * Index of this particle in the global "positions" array (Internal use)
  30432. * @hidden
  30433. */
  30434. _pos: number;
  30435. /**
  30436. * @hidden Index of this particle in the global "indices" array (Internal use)
  30437. */
  30438. _ind: number;
  30439. /**
  30440. * @hidden ModelShape of this particle (Internal use)
  30441. */
  30442. _model: ModelShape;
  30443. /**
  30444. * ModelShape id of this particle
  30445. */
  30446. shapeId: number;
  30447. /**
  30448. * Index of the particle in its shape id
  30449. */
  30450. idxInShape: number;
  30451. /**
  30452. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  30453. */
  30454. _modelBoundingInfo: BoundingInfo;
  30455. /**
  30456. * @hidden Particle BoundingInfo object (Internal use)
  30457. */
  30458. _boundingInfo: BoundingInfo;
  30459. /**
  30460. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  30461. */
  30462. _sps: SolidParticleSystem;
  30463. /**
  30464. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  30465. */
  30466. _stillInvisible: boolean;
  30467. /**
  30468. * @hidden Last computed particle rotation matrix
  30469. */
  30470. _rotationMatrix: number[];
  30471. /**
  30472. * Parent particle Id, if any.
  30473. * Default null.
  30474. */
  30475. parentId: Nullable<number>;
  30476. /**
  30477. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  30478. */
  30479. materialIndex: Nullable<number>;
  30480. /**
  30481. * Custom object or properties.
  30482. */
  30483. props: Nullable<any>;
  30484. /**
  30485. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  30486. * The possible values are :
  30487. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  30488. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  30489. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  30490. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  30491. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  30492. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  30493. * */
  30494. cullingStrategy: number;
  30495. /**
  30496. * @hidden Internal global position in the SPS.
  30497. */
  30498. _globalPosition: Vector3;
  30499. /**
  30500. * Creates a Solid Particle object.
  30501. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  30502. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  30503. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  30504. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  30505. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  30506. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  30507. * @param shapeId (integer) is the model shape identifier in the SPS.
  30508. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  30509. * @param sps defines the sps it is associated to
  30510. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  30511. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  30512. */
  30513. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  30514. /**
  30515. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  30516. * @param target the particle target
  30517. * @returns the current particle
  30518. */
  30519. copyToRef(target: SolidParticle): SolidParticle;
  30520. /**
  30521. * Legacy support, changed scale to scaling
  30522. */
  30523. get scale(): Vector3;
  30524. /**
  30525. * Legacy support, changed scale to scaling
  30526. */
  30527. set scale(scale: Vector3);
  30528. /**
  30529. * Legacy support, changed quaternion to rotationQuaternion
  30530. */
  30531. get quaternion(): Nullable<Quaternion>;
  30532. /**
  30533. * Legacy support, changed quaternion to rotationQuaternion
  30534. */
  30535. set quaternion(q: Nullable<Quaternion>);
  30536. /**
  30537. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  30538. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  30539. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  30540. * @returns true if it intersects
  30541. */
  30542. intersectsMesh(target: Mesh | SolidParticle): boolean;
  30543. /**
  30544. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  30545. * A particle is in the frustum if its bounding box intersects the frustum
  30546. * @param frustumPlanes defines the frustum to test
  30547. * @returns true if the particle is in the frustum planes
  30548. */
  30549. isInFrustum(frustumPlanes: Plane[]): boolean;
  30550. /**
  30551. * get the rotation matrix of the particle
  30552. * @hidden
  30553. */
  30554. getRotationMatrix(m: Matrix): void;
  30555. }
  30556. /**
  30557. * Represents the shape of the model used by one particle of a solid particle system.
  30558. * SPS internal tool, don't use it manually.
  30559. */
  30560. export class ModelShape {
  30561. /**
  30562. * The shape id
  30563. * @hidden
  30564. */
  30565. shapeID: number;
  30566. /**
  30567. * flat array of model positions (internal use)
  30568. * @hidden
  30569. */
  30570. _shape: Vector3[];
  30571. /**
  30572. * flat array of model UVs (internal use)
  30573. * @hidden
  30574. */
  30575. _shapeUV: number[];
  30576. /**
  30577. * color array of the model
  30578. * @hidden
  30579. */
  30580. _shapeColors: number[];
  30581. /**
  30582. * indices array of the model
  30583. * @hidden
  30584. */
  30585. _indices: number[];
  30586. /**
  30587. * normals array of the model
  30588. * @hidden
  30589. */
  30590. _normals: number[];
  30591. /**
  30592. * length of the shape in the model indices array (internal use)
  30593. * @hidden
  30594. */
  30595. _indicesLength: number;
  30596. /**
  30597. * Custom position function (internal use)
  30598. * @hidden
  30599. */
  30600. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  30601. /**
  30602. * Custom vertex function (internal use)
  30603. * @hidden
  30604. */
  30605. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  30606. /**
  30607. * Model material (internal use)
  30608. * @hidden
  30609. */
  30610. _material: Nullable<Material>;
  30611. /**
  30612. * 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.
  30613. * SPS internal tool, don't use it manually.
  30614. * @hidden
  30615. */
  30616. 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>);
  30617. }
  30618. /**
  30619. * Represents a Depth Sorted Particle in the solid particle system.
  30620. * @hidden
  30621. */
  30622. export class DepthSortedParticle {
  30623. /**
  30624. * Particle index
  30625. */
  30626. idx: number;
  30627. /**
  30628. * Index of the particle in the "indices" array
  30629. */
  30630. ind: number;
  30631. /**
  30632. * Length of the particle shape in the "indices" array
  30633. */
  30634. indicesLength: number;
  30635. /**
  30636. * Squared distance from the particle to the camera
  30637. */
  30638. sqDistance: number;
  30639. /**
  30640. * Material index when used with MultiMaterials
  30641. */
  30642. materialIndex: number;
  30643. /**
  30644. * Creates a new sorted particle
  30645. * @param materialIndex
  30646. */
  30647. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  30648. }
  30649. /**
  30650. * Represents a solid particle vertex
  30651. */
  30652. export class SolidParticleVertex {
  30653. /**
  30654. * Vertex position
  30655. */
  30656. position: Vector3;
  30657. /**
  30658. * Vertex color
  30659. */
  30660. color: Color4;
  30661. /**
  30662. * Vertex UV
  30663. */
  30664. uv: Vector2;
  30665. /**
  30666. * Creates a new solid particle vertex
  30667. */
  30668. constructor();
  30669. /** Vertex x coordinate */
  30670. get x(): number;
  30671. set x(val: number);
  30672. /** Vertex y coordinate */
  30673. get y(): number;
  30674. set y(val: number);
  30675. /** Vertex z coordinate */
  30676. get z(): number;
  30677. set z(val: number);
  30678. }
  30679. }
  30680. declare module BABYLON {
  30681. /**
  30682. * @hidden
  30683. */
  30684. export class _MeshCollisionData {
  30685. _checkCollisions: boolean;
  30686. _collisionMask: number;
  30687. _collisionGroup: number;
  30688. _surroundingMeshes: Nullable<AbstractMesh[]>;
  30689. _collider: Nullable<Collider>;
  30690. _oldPositionForCollisions: Vector3;
  30691. _diffPositionForCollisions: Vector3;
  30692. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  30693. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  30694. }
  30695. }
  30696. declare module BABYLON {
  30697. /** @hidden */
  30698. class _FacetDataStorage {
  30699. facetPositions: Vector3[];
  30700. facetNormals: Vector3[];
  30701. facetPartitioning: number[][];
  30702. facetNb: number;
  30703. partitioningSubdivisions: number;
  30704. partitioningBBoxRatio: number;
  30705. facetDataEnabled: boolean;
  30706. facetParameters: any;
  30707. bbSize: Vector3;
  30708. subDiv: {
  30709. max: number;
  30710. X: number;
  30711. Y: number;
  30712. Z: number;
  30713. };
  30714. facetDepthSort: boolean;
  30715. facetDepthSortEnabled: boolean;
  30716. depthSortedIndices: IndicesArray;
  30717. depthSortedFacets: {
  30718. ind: number;
  30719. sqDistance: number;
  30720. }[];
  30721. facetDepthSortFunction: (f1: {
  30722. ind: number;
  30723. sqDistance: number;
  30724. }, f2: {
  30725. ind: number;
  30726. sqDistance: number;
  30727. }) => number;
  30728. facetDepthSortFrom: Vector3;
  30729. facetDepthSortOrigin: Vector3;
  30730. invertedMatrix: Matrix;
  30731. }
  30732. /**
  30733. * @hidden
  30734. **/
  30735. class _InternalAbstractMeshDataInfo {
  30736. _hasVertexAlpha: boolean;
  30737. _useVertexColors: boolean;
  30738. _numBoneInfluencers: number;
  30739. _applyFog: boolean;
  30740. _receiveShadows: boolean;
  30741. _facetData: _FacetDataStorage;
  30742. _visibility: number;
  30743. _skeleton: Nullable<Skeleton>;
  30744. _layerMask: number;
  30745. _computeBonesUsingShaders: boolean;
  30746. _isActive: boolean;
  30747. _onlyForInstances: boolean;
  30748. _isActiveIntermediate: boolean;
  30749. _onlyForInstancesIntermediate: boolean;
  30750. _actAsRegularMesh: boolean;
  30751. }
  30752. /**
  30753. * Class used to store all common mesh properties
  30754. */
  30755. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  30756. /** No occlusion */
  30757. static OCCLUSION_TYPE_NONE: number;
  30758. /** Occlusion set to optimisitic */
  30759. static OCCLUSION_TYPE_OPTIMISTIC: number;
  30760. /** Occlusion set to strict */
  30761. static OCCLUSION_TYPE_STRICT: number;
  30762. /** Use an accurante occlusion algorithm */
  30763. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  30764. /** Use a conservative occlusion algorithm */
  30765. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  30766. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  30767. * Test order :
  30768. * Is the bounding sphere outside the frustum ?
  30769. * If not, are the bounding box vertices outside the frustum ?
  30770. * It not, then the cullable object is in the frustum.
  30771. */
  30772. static readonly CULLINGSTRATEGY_STANDARD: number;
  30773. /** Culling strategy : Bounding Sphere Only.
  30774. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  30775. * It's also less accurate than the standard because some not visible objects can still be selected.
  30776. * Test : is the bounding sphere outside the frustum ?
  30777. * If not, then the cullable object is in the frustum.
  30778. */
  30779. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  30780. /** Culling strategy : Optimistic Inclusion.
  30781. * This in an inclusion test first, then the standard exclusion test.
  30782. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  30783. * 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.
  30784. * Anyway, it's as accurate as the standard strategy.
  30785. * Test :
  30786. * Is the cullable object bounding sphere center in the frustum ?
  30787. * If not, apply the default culling strategy.
  30788. */
  30789. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  30790. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  30791. * This in an inclusion test first, then the bounding sphere only exclusion test.
  30792. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  30793. * 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.
  30794. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  30795. * Test :
  30796. * Is the cullable object bounding sphere center in the frustum ?
  30797. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  30798. */
  30799. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  30800. /**
  30801. * No billboard
  30802. */
  30803. static get BILLBOARDMODE_NONE(): number;
  30804. /** Billboard on X axis */
  30805. static get BILLBOARDMODE_X(): number;
  30806. /** Billboard on Y axis */
  30807. static get BILLBOARDMODE_Y(): number;
  30808. /** Billboard on Z axis */
  30809. static get BILLBOARDMODE_Z(): number;
  30810. /** Billboard on all axes */
  30811. static get BILLBOARDMODE_ALL(): number;
  30812. /** Billboard on using position instead of orientation */
  30813. static get BILLBOARDMODE_USE_POSITION(): number;
  30814. /** @hidden */
  30815. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  30816. /**
  30817. * The culling strategy to use to check whether the mesh must be rendered or not.
  30818. * This value can be changed at any time and will be used on the next render mesh selection.
  30819. * The possible values are :
  30820. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  30821. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  30822. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  30823. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  30824. * Please read each static variable documentation to get details about the culling process.
  30825. * */
  30826. cullingStrategy: number;
  30827. /**
  30828. * Gets the number of facets in the mesh
  30829. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  30830. */
  30831. get facetNb(): number;
  30832. /**
  30833. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  30834. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  30835. */
  30836. get partitioningSubdivisions(): number;
  30837. set partitioningSubdivisions(nb: number);
  30838. /**
  30839. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  30840. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  30841. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  30842. */
  30843. get partitioningBBoxRatio(): number;
  30844. set partitioningBBoxRatio(ratio: number);
  30845. /**
  30846. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  30847. * Works only for updatable meshes.
  30848. * Doesn't work with multi-materials
  30849. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  30850. */
  30851. get mustDepthSortFacets(): boolean;
  30852. set mustDepthSortFacets(sort: boolean);
  30853. /**
  30854. * The location (Vector3) where the facet depth sort must be computed from.
  30855. * By default, the active camera position.
  30856. * Used only when facet depth sort is enabled
  30857. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  30858. */
  30859. get facetDepthSortFrom(): Vector3;
  30860. set facetDepthSortFrom(location: Vector3);
  30861. /**
  30862. * gets a boolean indicating if facetData is enabled
  30863. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  30864. */
  30865. get isFacetDataEnabled(): boolean;
  30866. /** @hidden */
  30867. _updateNonUniformScalingState(value: boolean): boolean;
  30868. /**
  30869. * An event triggered when this mesh collides with another one
  30870. */
  30871. onCollideObservable: Observable<AbstractMesh>;
  30872. /** Set a function to call when this mesh collides with another one */
  30873. set onCollide(callback: () => void);
  30874. /**
  30875. * An event triggered when the collision's position changes
  30876. */
  30877. onCollisionPositionChangeObservable: Observable<Vector3>;
  30878. /** Set a function to call when the collision's position changes */
  30879. set onCollisionPositionChange(callback: () => void);
  30880. /**
  30881. * An event triggered when material is changed
  30882. */
  30883. onMaterialChangedObservable: Observable<AbstractMesh>;
  30884. /**
  30885. * Gets or sets the orientation for POV movement & rotation
  30886. */
  30887. definedFacingForward: boolean;
  30888. /** @hidden */
  30889. _occlusionQuery: Nullable<WebGLQuery>;
  30890. /** @hidden */
  30891. _renderingGroup: Nullable<RenderingGroup>;
  30892. /**
  30893. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  30894. */
  30895. get visibility(): number;
  30896. /**
  30897. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  30898. */
  30899. set visibility(value: number);
  30900. /** Gets or sets the alpha index used to sort transparent meshes
  30901. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  30902. */
  30903. alphaIndex: number;
  30904. /**
  30905. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  30906. */
  30907. isVisible: boolean;
  30908. /**
  30909. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  30910. */
  30911. isPickable: boolean;
  30912. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  30913. showSubMeshesBoundingBox: boolean;
  30914. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  30915. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  30916. */
  30917. isBlocker: boolean;
  30918. /**
  30919. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  30920. */
  30921. enablePointerMoveEvents: boolean;
  30922. /**
  30923. * Specifies the rendering group id for this mesh (0 by default)
  30924. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  30925. */
  30926. renderingGroupId: number;
  30927. private _material;
  30928. /** Gets or sets current material */
  30929. get material(): Nullable<Material>;
  30930. set material(value: Nullable<Material>);
  30931. /**
  30932. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  30933. * @see http://doc.babylonjs.com/babylon101/shadows
  30934. */
  30935. get receiveShadows(): boolean;
  30936. set receiveShadows(value: boolean);
  30937. /** Defines color to use when rendering outline */
  30938. outlineColor: Color3;
  30939. /** Define width to use when rendering outline */
  30940. outlineWidth: number;
  30941. /** Defines color to use when rendering overlay */
  30942. overlayColor: Color3;
  30943. /** Defines alpha to use when rendering overlay */
  30944. overlayAlpha: number;
  30945. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  30946. get hasVertexAlpha(): boolean;
  30947. set hasVertexAlpha(value: boolean);
  30948. /** 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) */
  30949. get useVertexColors(): boolean;
  30950. set useVertexColors(value: boolean);
  30951. /**
  30952. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  30953. */
  30954. get computeBonesUsingShaders(): boolean;
  30955. set computeBonesUsingShaders(value: boolean);
  30956. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  30957. get numBoneInfluencers(): number;
  30958. set numBoneInfluencers(value: number);
  30959. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  30960. get applyFog(): boolean;
  30961. set applyFog(value: boolean);
  30962. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  30963. useOctreeForRenderingSelection: boolean;
  30964. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  30965. useOctreeForPicking: boolean;
  30966. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  30967. useOctreeForCollisions: boolean;
  30968. /**
  30969. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  30970. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  30971. */
  30972. get layerMask(): number;
  30973. set layerMask(value: number);
  30974. /**
  30975. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  30976. */
  30977. alwaysSelectAsActiveMesh: boolean;
  30978. /**
  30979. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  30980. */
  30981. doNotSyncBoundingInfo: boolean;
  30982. /**
  30983. * Gets or sets the current action manager
  30984. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  30985. */
  30986. actionManager: Nullable<AbstractActionManager>;
  30987. private _meshCollisionData;
  30988. /**
  30989. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  30990. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  30991. */
  30992. ellipsoid: Vector3;
  30993. /**
  30994. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  30995. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  30996. */
  30997. ellipsoidOffset: Vector3;
  30998. /**
  30999. * Gets or sets a collision mask used to mask collisions (default is -1).
  31000. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  31001. */
  31002. get collisionMask(): number;
  31003. set collisionMask(mask: number);
  31004. /**
  31005. * Gets or sets the current collision group mask (-1 by default).
  31006. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  31007. */
  31008. get collisionGroup(): number;
  31009. set collisionGroup(mask: number);
  31010. /**
  31011. * Gets or sets current surrounding meshes (null by default).
  31012. *
  31013. * By default collision detection is tested against every mesh in the scene.
  31014. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  31015. * meshes will be tested for the collision.
  31016. *
  31017. * Note: if set to an empty array no collision will happen when this mesh is moved.
  31018. */
  31019. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  31020. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  31021. /**
  31022. * Defines edge width used when edgesRenderer is enabled
  31023. * @see https://www.babylonjs-playground.com/#10OJSG#13
  31024. */
  31025. edgesWidth: number;
  31026. /**
  31027. * Defines edge color used when edgesRenderer is enabled
  31028. * @see https://www.babylonjs-playground.com/#10OJSG#13
  31029. */
  31030. edgesColor: Color4;
  31031. /** @hidden */
  31032. _edgesRenderer: Nullable<IEdgesRenderer>;
  31033. /** @hidden */
  31034. _masterMesh: Nullable<AbstractMesh>;
  31035. /** @hidden */
  31036. _boundingInfo: Nullable<BoundingInfo>;
  31037. /** @hidden */
  31038. _renderId: number;
  31039. /**
  31040. * Gets or sets the list of subMeshes
  31041. * @see http://doc.babylonjs.com/how_to/multi_materials
  31042. */
  31043. subMeshes: SubMesh[];
  31044. /** @hidden */
  31045. _intersectionsInProgress: AbstractMesh[];
  31046. /** @hidden */
  31047. _unIndexed: boolean;
  31048. /** @hidden */
  31049. _lightSources: Light[];
  31050. /** Gets the list of lights affecting that mesh */
  31051. get lightSources(): Light[];
  31052. /** @hidden */
  31053. get _positions(): Nullable<Vector3[]>;
  31054. /** @hidden */
  31055. _waitingData: {
  31056. lods: Nullable<any>;
  31057. actions: Nullable<any>;
  31058. freezeWorldMatrix: Nullable<boolean>;
  31059. };
  31060. /** @hidden */
  31061. _bonesTransformMatrices: Nullable<Float32Array>;
  31062. /** @hidden */
  31063. _transformMatrixTexture: Nullable<RawTexture>;
  31064. /**
  31065. * Gets or sets a skeleton to apply skining transformations
  31066. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  31067. */
  31068. set skeleton(value: Nullable<Skeleton>);
  31069. get skeleton(): Nullable<Skeleton>;
  31070. /**
  31071. * An event triggered when the mesh is rebuilt.
  31072. */
  31073. onRebuildObservable: Observable<AbstractMesh>;
  31074. /**
  31075. * Creates a new AbstractMesh
  31076. * @param name defines the name of the mesh
  31077. * @param scene defines the hosting scene
  31078. */
  31079. constructor(name: string, scene?: Nullable<Scene>);
  31080. /**
  31081. * Returns the string "AbstractMesh"
  31082. * @returns "AbstractMesh"
  31083. */
  31084. getClassName(): string;
  31085. /**
  31086. * Gets a string representation of the current mesh
  31087. * @param fullDetails defines a boolean indicating if full details must be included
  31088. * @returns a string representation of the current mesh
  31089. */
  31090. toString(fullDetails?: boolean): string;
  31091. /**
  31092. * @hidden
  31093. */
  31094. protected _getEffectiveParent(): Nullable<Node>;
  31095. /** @hidden */
  31096. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  31097. /** @hidden */
  31098. _rebuild(): void;
  31099. /** @hidden */
  31100. _resyncLightSources(): void;
  31101. /** @hidden */
  31102. _resyncLightSource(light: Light): void;
  31103. /** @hidden */
  31104. _unBindEffect(): void;
  31105. /** @hidden */
  31106. _removeLightSource(light: Light, dispose: boolean): void;
  31107. private _markSubMeshesAsDirty;
  31108. /** @hidden */
  31109. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  31110. /** @hidden */
  31111. _markSubMeshesAsAttributesDirty(): void;
  31112. /** @hidden */
  31113. _markSubMeshesAsMiscDirty(): void;
  31114. /**
  31115. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  31116. */
  31117. get scaling(): Vector3;
  31118. set scaling(newScaling: Vector3);
  31119. /**
  31120. * Returns true if the mesh is blocked. Implemented by child classes
  31121. */
  31122. get isBlocked(): boolean;
  31123. /**
  31124. * Returns the mesh itself by default. Implemented by child classes
  31125. * @param camera defines the camera to use to pick the right LOD level
  31126. * @returns the currentAbstractMesh
  31127. */
  31128. getLOD(camera: Camera): Nullable<AbstractMesh>;
  31129. /**
  31130. * Returns 0 by default. Implemented by child classes
  31131. * @returns an integer
  31132. */
  31133. getTotalVertices(): number;
  31134. /**
  31135. * Returns a positive integer : the total number of indices in this mesh geometry.
  31136. * @returns the numner of indices or zero if the mesh has no geometry.
  31137. */
  31138. getTotalIndices(): number;
  31139. /**
  31140. * Returns null by default. Implemented by child classes
  31141. * @returns null
  31142. */
  31143. getIndices(): Nullable<IndicesArray>;
  31144. /**
  31145. * Returns the array of the requested vertex data kind. Implemented by child classes
  31146. * @param kind defines the vertex data kind to use
  31147. * @returns null
  31148. */
  31149. getVerticesData(kind: string): Nullable<FloatArray>;
  31150. /**
  31151. * Sets the vertex data of the mesh geometry for the requested `kind`.
  31152. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  31153. * Note that a new underlying VertexBuffer object is created each call.
  31154. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  31155. * @param kind defines vertex data kind:
  31156. * * VertexBuffer.PositionKind
  31157. * * VertexBuffer.UVKind
  31158. * * VertexBuffer.UV2Kind
  31159. * * VertexBuffer.UV3Kind
  31160. * * VertexBuffer.UV4Kind
  31161. * * VertexBuffer.UV5Kind
  31162. * * VertexBuffer.UV6Kind
  31163. * * VertexBuffer.ColorKind
  31164. * * VertexBuffer.MatricesIndicesKind
  31165. * * VertexBuffer.MatricesIndicesExtraKind
  31166. * * VertexBuffer.MatricesWeightsKind
  31167. * * VertexBuffer.MatricesWeightsExtraKind
  31168. * @param data defines the data source
  31169. * @param updatable defines if the data must be flagged as updatable (or static)
  31170. * @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
  31171. * @returns the current mesh
  31172. */
  31173. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  31174. /**
  31175. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  31176. * If the mesh has no geometry, it is simply returned as it is.
  31177. * @param kind defines vertex data kind:
  31178. * * VertexBuffer.PositionKind
  31179. * * VertexBuffer.UVKind
  31180. * * VertexBuffer.UV2Kind
  31181. * * VertexBuffer.UV3Kind
  31182. * * VertexBuffer.UV4Kind
  31183. * * VertexBuffer.UV5Kind
  31184. * * VertexBuffer.UV6Kind
  31185. * * VertexBuffer.ColorKind
  31186. * * VertexBuffer.MatricesIndicesKind
  31187. * * VertexBuffer.MatricesIndicesExtraKind
  31188. * * VertexBuffer.MatricesWeightsKind
  31189. * * VertexBuffer.MatricesWeightsExtraKind
  31190. * @param data defines the data source
  31191. * @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
  31192. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  31193. * @returns the current mesh
  31194. */
  31195. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  31196. /**
  31197. * Sets the mesh indices,
  31198. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  31199. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  31200. * @param totalVertices Defines the total number of vertices
  31201. * @returns the current mesh
  31202. */
  31203. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  31204. /**
  31205. * Gets a boolean indicating if specific vertex data is present
  31206. * @param kind defines the vertex data kind to use
  31207. * @returns true is data kind is present
  31208. */
  31209. isVerticesDataPresent(kind: string): boolean;
  31210. /**
  31211. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  31212. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  31213. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  31214. * @returns a BoundingInfo
  31215. */
  31216. getBoundingInfo(): BoundingInfo;
  31217. /**
  31218. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  31219. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  31220. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  31221. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  31222. * @returns the current mesh
  31223. */
  31224. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  31225. /**
  31226. * Overwrite the current bounding info
  31227. * @param boundingInfo defines the new bounding info
  31228. * @returns the current mesh
  31229. */
  31230. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  31231. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  31232. get useBones(): boolean;
  31233. /** @hidden */
  31234. _preActivate(): void;
  31235. /** @hidden */
  31236. _preActivateForIntermediateRendering(renderId: number): void;
  31237. /** @hidden */
  31238. _activate(renderId: number, intermediateRendering: boolean): boolean;
  31239. /** @hidden */
  31240. _postActivate(): void;
  31241. /** @hidden */
  31242. _freeze(): void;
  31243. /** @hidden */
  31244. _unFreeze(): void;
  31245. /**
  31246. * Gets the current world matrix
  31247. * @returns a Matrix
  31248. */
  31249. getWorldMatrix(): Matrix;
  31250. /** @hidden */
  31251. _getWorldMatrixDeterminant(): number;
  31252. /**
  31253. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  31254. */
  31255. get isAnInstance(): boolean;
  31256. /**
  31257. * Gets a boolean indicating if this mesh has instances
  31258. */
  31259. get hasInstances(): boolean;
  31260. /**
  31261. * Perform relative position change from the point of view of behind the front of the mesh.
  31262. * This is performed taking into account the meshes current rotation, so you do not have to care.
  31263. * Supports definition of mesh facing forward or backward
  31264. * @param amountRight defines the distance on the right axis
  31265. * @param amountUp defines the distance on the up axis
  31266. * @param amountForward defines the distance on the forward axis
  31267. * @returns the current mesh
  31268. */
  31269. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  31270. /**
  31271. * Calculate relative position change from the point of view of behind the front of the mesh.
  31272. * This is performed taking into account the meshes current rotation, so you do not have to care.
  31273. * Supports definition of mesh facing forward or backward
  31274. * @param amountRight defines the distance on the right axis
  31275. * @param amountUp defines the distance on the up axis
  31276. * @param amountForward defines the distance on the forward axis
  31277. * @returns the new displacement vector
  31278. */
  31279. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  31280. /**
  31281. * Perform relative rotation change from the point of view of behind the front of the mesh.
  31282. * Supports definition of mesh facing forward or backward
  31283. * @param flipBack defines the flip
  31284. * @param twirlClockwise defines the twirl
  31285. * @param tiltRight defines the tilt
  31286. * @returns the current mesh
  31287. */
  31288. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  31289. /**
  31290. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  31291. * Supports definition of mesh facing forward or backward.
  31292. * @param flipBack defines the flip
  31293. * @param twirlClockwise defines the twirl
  31294. * @param tiltRight defines the tilt
  31295. * @returns the new rotation vector
  31296. */
  31297. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  31298. /**
  31299. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  31300. * This means the mesh underlying bounding box and sphere are recomputed.
  31301. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  31302. * @returns the current mesh
  31303. */
  31304. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  31305. /** @hidden */
  31306. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  31307. /** @hidden */
  31308. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  31309. /** @hidden */
  31310. _updateBoundingInfo(): AbstractMesh;
  31311. /** @hidden */
  31312. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  31313. /** @hidden */
  31314. protected _afterComputeWorldMatrix(): void;
  31315. /** @hidden */
  31316. get _effectiveMesh(): AbstractMesh;
  31317. /**
  31318. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  31319. * A mesh is in the frustum if its bounding box intersects the frustum
  31320. * @param frustumPlanes defines the frustum to test
  31321. * @returns true if the mesh is in the frustum planes
  31322. */
  31323. isInFrustum(frustumPlanes: Plane[]): boolean;
  31324. /**
  31325. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  31326. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  31327. * @param frustumPlanes defines the frustum to test
  31328. * @returns true if the mesh is completely in the frustum planes
  31329. */
  31330. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  31331. /**
  31332. * True if the mesh intersects another mesh or a SolidParticle object
  31333. * @param mesh defines a target mesh or SolidParticle to test
  31334. * @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)
  31335. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  31336. * @returns true if there is an intersection
  31337. */
  31338. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  31339. /**
  31340. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  31341. * @param point defines the point to test
  31342. * @returns true if there is an intersection
  31343. */
  31344. intersectsPoint(point: Vector3): boolean;
  31345. /**
  31346. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  31347. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31348. */
  31349. get checkCollisions(): boolean;
  31350. set checkCollisions(collisionEnabled: boolean);
  31351. /**
  31352. * Gets Collider object used to compute collisions (not physics)
  31353. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31354. */
  31355. get collider(): Nullable<Collider>;
  31356. /**
  31357. * Move the mesh using collision engine
  31358. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31359. * @param displacement defines the requested displacement vector
  31360. * @returns the current mesh
  31361. */
  31362. moveWithCollisions(displacement: Vector3): AbstractMesh;
  31363. private _onCollisionPositionChange;
  31364. /** @hidden */
  31365. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  31366. /** @hidden */
  31367. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  31368. /** @hidden */
  31369. _checkCollision(collider: Collider): AbstractMesh;
  31370. /** @hidden */
  31371. _generatePointsArray(): boolean;
  31372. /**
  31373. * Checks if the passed Ray intersects with the mesh
  31374. * @param ray defines the ray to use
  31375. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  31376. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  31377. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  31378. * @returns the picking info
  31379. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  31380. */
  31381. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  31382. /**
  31383. * Clones the current mesh
  31384. * @param name defines the mesh name
  31385. * @param newParent defines the new mesh parent
  31386. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  31387. * @returns the new mesh
  31388. */
  31389. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  31390. /**
  31391. * Disposes all the submeshes of the current meshnp
  31392. * @returns the current mesh
  31393. */
  31394. releaseSubMeshes(): AbstractMesh;
  31395. /**
  31396. * Releases resources associated with this abstract mesh.
  31397. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  31398. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  31399. */
  31400. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  31401. /**
  31402. * Adds the passed mesh as a child to the current mesh
  31403. * @param mesh defines the child mesh
  31404. * @returns the current mesh
  31405. */
  31406. addChild(mesh: AbstractMesh): AbstractMesh;
  31407. /**
  31408. * Removes the passed mesh from the current mesh children list
  31409. * @param mesh defines the child mesh
  31410. * @returns the current mesh
  31411. */
  31412. removeChild(mesh: AbstractMesh): AbstractMesh;
  31413. /** @hidden */
  31414. private _initFacetData;
  31415. /**
  31416. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  31417. * This method can be called within the render loop.
  31418. * 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
  31419. * @returns the current mesh
  31420. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31421. */
  31422. updateFacetData(): AbstractMesh;
  31423. /**
  31424. * Returns the facetLocalNormals array.
  31425. * The normals are expressed in the mesh local spac
  31426. * @returns an array of Vector3
  31427. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31428. */
  31429. getFacetLocalNormals(): Vector3[];
  31430. /**
  31431. * Returns the facetLocalPositions array.
  31432. * The facet positions are expressed in the mesh local space
  31433. * @returns an array of Vector3
  31434. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31435. */
  31436. getFacetLocalPositions(): Vector3[];
  31437. /**
  31438. * Returns the facetLocalPartioning array
  31439. * @returns an array of array of numbers
  31440. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31441. */
  31442. getFacetLocalPartitioning(): number[][];
  31443. /**
  31444. * Returns the i-th facet position in the world system.
  31445. * This method allocates a new Vector3 per call
  31446. * @param i defines the facet index
  31447. * @returns a new Vector3
  31448. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31449. */
  31450. getFacetPosition(i: number): Vector3;
  31451. /**
  31452. * Sets the reference Vector3 with the i-th facet position in the world system
  31453. * @param i defines the facet index
  31454. * @param ref defines the target vector
  31455. * @returns the current mesh
  31456. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31457. */
  31458. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  31459. /**
  31460. * Returns the i-th facet normal in the world system.
  31461. * This method allocates a new Vector3 per call
  31462. * @param i defines the facet index
  31463. * @returns a new Vector3
  31464. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31465. */
  31466. getFacetNormal(i: number): Vector3;
  31467. /**
  31468. * Sets the reference Vector3 with the i-th facet normal in the world system
  31469. * @param i defines the facet index
  31470. * @param ref defines the target vector
  31471. * @returns the current mesh
  31472. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31473. */
  31474. getFacetNormalToRef(i: number, ref: Vector3): this;
  31475. /**
  31476. * 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)
  31477. * @param x defines x coordinate
  31478. * @param y defines y coordinate
  31479. * @param z defines z coordinate
  31480. * @returns the array of facet indexes
  31481. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31482. */
  31483. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  31484. /**
  31485. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  31486. * @param projected sets as the (x,y,z) world projection on the facet
  31487. * @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
  31488. * @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
  31489. * @param x defines x coordinate
  31490. * @param y defines y coordinate
  31491. * @param z defines z coordinate
  31492. * @returns the face index if found (or null instead)
  31493. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31494. */
  31495. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  31496. /**
  31497. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  31498. * @param projected sets as the (x,y,z) local projection on the facet
  31499. * @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
  31500. * @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
  31501. * @param x defines x coordinate
  31502. * @param y defines y coordinate
  31503. * @param z defines z coordinate
  31504. * @returns the face index if found (or null instead)
  31505. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31506. */
  31507. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  31508. /**
  31509. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  31510. * @returns the parameters
  31511. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31512. */
  31513. getFacetDataParameters(): any;
  31514. /**
  31515. * Disables the feature FacetData and frees the related memory
  31516. * @returns the current mesh
  31517. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31518. */
  31519. disableFacetData(): AbstractMesh;
  31520. /**
  31521. * Updates the AbstractMesh indices array
  31522. * @param indices defines the data source
  31523. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  31524. * @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)
  31525. * @returns the current mesh
  31526. */
  31527. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  31528. /**
  31529. * Creates new normals data for the mesh
  31530. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  31531. * @returns the current mesh
  31532. */
  31533. createNormals(updatable: boolean): AbstractMesh;
  31534. /**
  31535. * Align the mesh with a normal
  31536. * @param normal defines the normal to use
  31537. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  31538. * @returns the current mesh
  31539. */
  31540. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  31541. /** @hidden */
  31542. _checkOcclusionQuery(): boolean;
  31543. /**
  31544. * Disables the mesh edge rendering mode
  31545. * @returns the currentAbstractMesh
  31546. */
  31547. disableEdgesRendering(): AbstractMesh;
  31548. /**
  31549. * Enables the edge rendering mode on the mesh.
  31550. * This mode makes the mesh edges visible
  31551. * @param epsilon defines the maximal distance between two angles to detect a face
  31552. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  31553. * @returns the currentAbstractMesh
  31554. * @see https://www.babylonjs-playground.com/#19O9TU#0
  31555. */
  31556. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  31557. }
  31558. }
  31559. declare module BABYLON {
  31560. /**
  31561. * Interface used to define ActionEvent
  31562. */
  31563. export interface IActionEvent {
  31564. /** The mesh or sprite that triggered the action */
  31565. source: any;
  31566. /** The X mouse cursor position at the time of the event */
  31567. pointerX: number;
  31568. /** The Y mouse cursor position at the time of the event */
  31569. pointerY: number;
  31570. /** The mesh that is currently pointed at (can be null) */
  31571. meshUnderPointer: Nullable<AbstractMesh>;
  31572. /** the original (browser) event that triggered the ActionEvent */
  31573. sourceEvent?: any;
  31574. /** additional data for the event */
  31575. additionalData?: any;
  31576. }
  31577. /**
  31578. * ActionEvent is the event being sent when an action is triggered.
  31579. */
  31580. export class ActionEvent implements IActionEvent {
  31581. /** The mesh or sprite that triggered the action */
  31582. source: any;
  31583. /** The X mouse cursor position at the time of the event */
  31584. pointerX: number;
  31585. /** The Y mouse cursor position at the time of the event */
  31586. pointerY: number;
  31587. /** The mesh that is currently pointed at (can be null) */
  31588. meshUnderPointer: Nullable<AbstractMesh>;
  31589. /** the original (browser) event that triggered the ActionEvent */
  31590. sourceEvent?: any;
  31591. /** additional data for the event */
  31592. additionalData?: any;
  31593. /**
  31594. * Creates a new ActionEvent
  31595. * @param source The mesh or sprite that triggered the action
  31596. * @param pointerX The X mouse cursor position at the time of the event
  31597. * @param pointerY The Y mouse cursor position at the time of the event
  31598. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  31599. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  31600. * @param additionalData additional data for the event
  31601. */
  31602. constructor(
  31603. /** The mesh or sprite that triggered the action */
  31604. source: any,
  31605. /** The X mouse cursor position at the time of the event */
  31606. pointerX: number,
  31607. /** The Y mouse cursor position at the time of the event */
  31608. pointerY: number,
  31609. /** The mesh that is currently pointed at (can be null) */
  31610. meshUnderPointer: Nullable<AbstractMesh>,
  31611. /** the original (browser) event that triggered the ActionEvent */
  31612. sourceEvent?: any,
  31613. /** additional data for the event */
  31614. additionalData?: any);
  31615. /**
  31616. * Helper function to auto-create an ActionEvent from a source mesh.
  31617. * @param source The source mesh that triggered the event
  31618. * @param evt The original (browser) event
  31619. * @param additionalData additional data for the event
  31620. * @returns the new ActionEvent
  31621. */
  31622. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  31623. /**
  31624. * Helper function to auto-create an ActionEvent from a source sprite
  31625. * @param source The source sprite that triggered the event
  31626. * @param scene Scene associated with the sprite
  31627. * @param evt The original (browser) event
  31628. * @param additionalData additional data for the event
  31629. * @returns the new ActionEvent
  31630. */
  31631. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  31632. /**
  31633. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  31634. * @param scene the scene where the event occurred
  31635. * @param evt The original (browser) event
  31636. * @returns the new ActionEvent
  31637. */
  31638. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  31639. /**
  31640. * Helper function to auto-create an ActionEvent from a primitive
  31641. * @param prim defines the target primitive
  31642. * @param pointerPos defines the pointer position
  31643. * @param evt The original (browser) event
  31644. * @param additionalData additional data for the event
  31645. * @returns the new ActionEvent
  31646. */
  31647. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  31648. }
  31649. }
  31650. declare module BABYLON {
  31651. /**
  31652. * Abstract class used to decouple action Manager from scene and meshes.
  31653. * Do not instantiate.
  31654. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  31655. */
  31656. export abstract class AbstractActionManager implements IDisposable {
  31657. /** Gets the list of active triggers */
  31658. static Triggers: {
  31659. [key: string]: number;
  31660. };
  31661. /** Gets the cursor to use when hovering items */
  31662. hoverCursor: string;
  31663. /** Gets the list of actions */
  31664. actions: IAction[];
  31665. /**
  31666. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  31667. */
  31668. isRecursive: boolean;
  31669. /**
  31670. * Releases all associated resources
  31671. */
  31672. abstract dispose(): void;
  31673. /**
  31674. * Does this action manager has pointer triggers
  31675. */
  31676. abstract get hasPointerTriggers(): boolean;
  31677. /**
  31678. * Does this action manager has pick triggers
  31679. */
  31680. abstract get hasPickTriggers(): boolean;
  31681. /**
  31682. * Process a specific trigger
  31683. * @param trigger defines the trigger to process
  31684. * @param evt defines the event details to be processed
  31685. */
  31686. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  31687. /**
  31688. * Does this action manager handles actions of any of the given triggers
  31689. * @param triggers defines the triggers to be tested
  31690. * @return a boolean indicating whether one (or more) of the triggers is handled
  31691. */
  31692. abstract hasSpecificTriggers(triggers: number[]): boolean;
  31693. /**
  31694. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  31695. * speed.
  31696. * @param triggerA defines the trigger to be tested
  31697. * @param triggerB defines the trigger to be tested
  31698. * @return a boolean indicating whether one (or more) of the triggers is handled
  31699. */
  31700. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  31701. /**
  31702. * Does this action manager handles actions of a given trigger
  31703. * @param trigger defines the trigger to be tested
  31704. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  31705. * @return whether the trigger is handled
  31706. */
  31707. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  31708. /**
  31709. * Serialize this manager to a JSON object
  31710. * @param name defines the property name to store this manager
  31711. * @returns a JSON representation of this manager
  31712. */
  31713. abstract serialize(name: string): any;
  31714. /**
  31715. * Registers an action to this action manager
  31716. * @param action defines the action to be registered
  31717. * @return the action amended (prepared) after registration
  31718. */
  31719. abstract registerAction(action: IAction): Nullable<IAction>;
  31720. /**
  31721. * Unregisters an action to this action manager
  31722. * @param action defines the action to be unregistered
  31723. * @return a boolean indicating whether the action has been unregistered
  31724. */
  31725. abstract unregisterAction(action: IAction): Boolean;
  31726. /**
  31727. * Does exist one action manager with at least one trigger
  31728. **/
  31729. static get HasTriggers(): boolean;
  31730. /**
  31731. * Does exist one action manager with at least one pick trigger
  31732. **/
  31733. static get HasPickTriggers(): boolean;
  31734. /**
  31735. * Does exist one action manager that handles actions of a given trigger
  31736. * @param trigger defines the trigger to be tested
  31737. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  31738. **/
  31739. static HasSpecificTrigger(trigger: number): boolean;
  31740. }
  31741. }
  31742. declare module BABYLON {
  31743. /**
  31744. * Defines how a node can be built from a string name.
  31745. */
  31746. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  31747. /**
  31748. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  31749. */
  31750. export class Node implements IBehaviorAware<Node> {
  31751. /** @hidden */
  31752. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  31753. private static _NodeConstructors;
  31754. /**
  31755. * Add a new node constructor
  31756. * @param type defines the type name of the node to construct
  31757. * @param constructorFunc defines the constructor function
  31758. */
  31759. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  31760. /**
  31761. * Returns a node constructor based on type name
  31762. * @param type defines the type name
  31763. * @param name defines the new node name
  31764. * @param scene defines the hosting scene
  31765. * @param options defines optional options to transmit to constructors
  31766. * @returns the new constructor or null
  31767. */
  31768. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  31769. /**
  31770. * Gets or sets the name of the node
  31771. */
  31772. name: string;
  31773. /**
  31774. * Gets or sets the id of the node
  31775. */
  31776. id: string;
  31777. /**
  31778. * Gets or sets the unique id of the node
  31779. */
  31780. uniqueId: number;
  31781. /**
  31782. * Gets or sets a string used to store user defined state for the node
  31783. */
  31784. state: string;
  31785. /**
  31786. * Gets or sets an object used to store user defined information for the node
  31787. */
  31788. metadata: any;
  31789. /**
  31790. * For internal use only. Please do not use.
  31791. */
  31792. reservedDataStore: any;
  31793. /**
  31794. * List of inspectable custom properties (used by the Inspector)
  31795. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  31796. */
  31797. inspectableCustomProperties: IInspectable[];
  31798. private _doNotSerialize;
  31799. /**
  31800. * Gets or sets a boolean used to define if the node must be serialized
  31801. */
  31802. get doNotSerialize(): boolean;
  31803. set doNotSerialize(value: boolean);
  31804. /** @hidden */
  31805. _isDisposed: boolean;
  31806. /**
  31807. * Gets a list of Animations associated with the node
  31808. */
  31809. animations: Animation[];
  31810. protected _ranges: {
  31811. [name: string]: Nullable<AnimationRange>;
  31812. };
  31813. /**
  31814. * Callback raised when the node is ready to be used
  31815. */
  31816. onReady: Nullable<(node: Node) => void>;
  31817. private _isEnabled;
  31818. private _isParentEnabled;
  31819. private _isReady;
  31820. /** @hidden */
  31821. _currentRenderId: number;
  31822. private _parentUpdateId;
  31823. /** @hidden */
  31824. _childUpdateId: number;
  31825. /** @hidden */
  31826. _waitingParentId: Nullable<string>;
  31827. /** @hidden */
  31828. _scene: Scene;
  31829. /** @hidden */
  31830. _cache: any;
  31831. private _parentNode;
  31832. private _children;
  31833. /** @hidden */
  31834. _worldMatrix: Matrix;
  31835. /** @hidden */
  31836. _worldMatrixDeterminant: number;
  31837. /** @hidden */
  31838. _worldMatrixDeterminantIsDirty: boolean;
  31839. /** @hidden */
  31840. private _sceneRootNodesIndex;
  31841. /**
  31842. * Gets a boolean indicating if the node has been disposed
  31843. * @returns true if the node was disposed
  31844. */
  31845. isDisposed(): boolean;
  31846. /**
  31847. * Gets or sets the parent of the node (without keeping the current position in the scene)
  31848. * @see https://doc.babylonjs.com/how_to/parenting
  31849. */
  31850. set parent(parent: Nullable<Node>);
  31851. get parent(): Nullable<Node>;
  31852. /** @hidden */
  31853. _addToSceneRootNodes(): void;
  31854. /** @hidden */
  31855. _removeFromSceneRootNodes(): void;
  31856. private _animationPropertiesOverride;
  31857. /**
  31858. * Gets or sets the animation properties override
  31859. */
  31860. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  31861. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  31862. /**
  31863. * Gets a string idenfifying the name of the class
  31864. * @returns "Node" string
  31865. */
  31866. getClassName(): string;
  31867. /** @hidden */
  31868. readonly _isNode: boolean;
  31869. /**
  31870. * An event triggered when the mesh is disposed
  31871. */
  31872. onDisposeObservable: Observable<Node>;
  31873. private _onDisposeObserver;
  31874. /**
  31875. * Sets a callback that will be raised when the node will be disposed
  31876. */
  31877. set onDispose(callback: () => void);
  31878. /**
  31879. * Creates a new Node
  31880. * @param name the name and id to be given to this node
  31881. * @param scene the scene this node will be added to
  31882. */
  31883. constructor(name: string, scene?: Nullable<Scene>);
  31884. /**
  31885. * Gets the scene of the node
  31886. * @returns a scene
  31887. */
  31888. getScene(): Scene;
  31889. /**
  31890. * Gets the engine of the node
  31891. * @returns a Engine
  31892. */
  31893. getEngine(): Engine;
  31894. private _behaviors;
  31895. /**
  31896. * Attach a behavior to the node
  31897. * @see http://doc.babylonjs.com/features/behaviour
  31898. * @param behavior defines the behavior to attach
  31899. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  31900. * @returns the current Node
  31901. */
  31902. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  31903. /**
  31904. * Remove an attached behavior
  31905. * @see http://doc.babylonjs.com/features/behaviour
  31906. * @param behavior defines the behavior to attach
  31907. * @returns the current Node
  31908. */
  31909. removeBehavior(behavior: Behavior<Node>): Node;
  31910. /**
  31911. * Gets the list of attached behaviors
  31912. * @see http://doc.babylonjs.com/features/behaviour
  31913. */
  31914. get behaviors(): Behavior<Node>[];
  31915. /**
  31916. * Gets an attached behavior by name
  31917. * @param name defines the name of the behavior to look for
  31918. * @see http://doc.babylonjs.com/features/behaviour
  31919. * @returns null if behavior was not found else the requested behavior
  31920. */
  31921. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  31922. /**
  31923. * Returns the latest update of the World matrix
  31924. * @returns a Matrix
  31925. */
  31926. getWorldMatrix(): Matrix;
  31927. /** @hidden */
  31928. _getWorldMatrixDeterminant(): number;
  31929. /**
  31930. * Returns directly the latest state of the mesh World matrix.
  31931. * A Matrix is returned.
  31932. */
  31933. get worldMatrixFromCache(): Matrix;
  31934. /** @hidden */
  31935. _initCache(): void;
  31936. /** @hidden */
  31937. updateCache(force?: boolean): void;
  31938. /** @hidden */
  31939. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  31940. /** @hidden */
  31941. _updateCache(ignoreParentClass?: boolean): void;
  31942. /** @hidden */
  31943. _isSynchronized(): boolean;
  31944. /** @hidden */
  31945. _markSyncedWithParent(): void;
  31946. /** @hidden */
  31947. isSynchronizedWithParent(): boolean;
  31948. /** @hidden */
  31949. isSynchronized(): boolean;
  31950. /**
  31951. * Is this node ready to be used/rendered
  31952. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  31953. * @return true if the node is ready
  31954. */
  31955. isReady(completeCheck?: boolean): boolean;
  31956. /**
  31957. * Is this node enabled?
  31958. * 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
  31959. * @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
  31960. * @return whether this node (and its parent) is enabled
  31961. */
  31962. isEnabled(checkAncestors?: boolean): boolean;
  31963. /** @hidden */
  31964. protected _syncParentEnabledState(): void;
  31965. /**
  31966. * Set the enabled state of this node
  31967. * @param value defines the new enabled state
  31968. */
  31969. setEnabled(value: boolean): void;
  31970. /**
  31971. * Is this node a descendant of the given node?
  31972. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  31973. * @param ancestor defines the parent node to inspect
  31974. * @returns a boolean indicating if this node is a descendant of the given node
  31975. */
  31976. isDescendantOf(ancestor: Node): boolean;
  31977. /** @hidden */
  31978. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  31979. /**
  31980. * Will return all nodes that have this node as ascendant
  31981. * @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
  31982. * @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
  31983. * @return all children nodes of all types
  31984. */
  31985. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  31986. /**
  31987. * Get all child-meshes of this node
  31988. * @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)
  31989. * @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
  31990. * @returns an array of AbstractMesh
  31991. */
  31992. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  31993. /**
  31994. * Get all direct children of this node
  31995. * @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
  31996. * @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)
  31997. * @returns an array of Node
  31998. */
  31999. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  32000. /** @hidden */
  32001. _setReady(state: boolean): void;
  32002. /**
  32003. * Get an animation by name
  32004. * @param name defines the name of the animation to look for
  32005. * @returns null if not found else the requested animation
  32006. */
  32007. getAnimationByName(name: string): Nullable<Animation>;
  32008. /**
  32009. * Creates an animation range for this node
  32010. * @param name defines the name of the range
  32011. * @param from defines the starting key
  32012. * @param to defines the end key
  32013. */
  32014. createAnimationRange(name: string, from: number, to: number): void;
  32015. /**
  32016. * Delete a specific animation range
  32017. * @param name defines the name of the range to delete
  32018. * @param deleteFrames defines if animation frames from the range must be deleted as well
  32019. */
  32020. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  32021. /**
  32022. * Get an animation range by name
  32023. * @param name defines the name of the animation range to look for
  32024. * @returns null if not found else the requested animation range
  32025. */
  32026. getAnimationRange(name: string): Nullable<AnimationRange>;
  32027. /**
  32028. * Gets the list of all animation ranges defined on this node
  32029. * @returns an array
  32030. */
  32031. getAnimationRanges(): Nullable<AnimationRange>[];
  32032. /**
  32033. * Will start the animation sequence
  32034. * @param name defines the range frames for animation sequence
  32035. * @param loop defines if the animation should loop (false by default)
  32036. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  32037. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  32038. * @returns the object created for this animation. If range does not exist, it will return null
  32039. */
  32040. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  32041. /**
  32042. * Serialize animation ranges into a JSON compatible object
  32043. * @returns serialization object
  32044. */
  32045. serializeAnimationRanges(): any;
  32046. /**
  32047. * Computes the world matrix of the node
  32048. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  32049. * @returns the world matrix
  32050. */
  32051. computeWorldMatrix(force?: boolean): Matrix;
  32052. /**
  32053. * Releases resources associated with this node.
  32054. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  32055. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  32056. */
  32057. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  32058. /**
  32059. * Parse animation range data from a serialization object and store them into a given node
  32060. * @param node defines where to store the animation ranges
  32061. * @param parsedNode defines the serialization object to read data from
  32062. * @param scene defines the hosting scene
  32063. */
  32064. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  32065. /**
  32066. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  32067. * @param includeDescendants Include bounding info from descendants as well (true by default)
  32068. * @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
  32069. * @returns the new bounding vectors
  32070. */
  32071. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  32072. min: Vector3;
  32073. max: Vector3;
  32074. };
  32075. }
  32076. }
  32077. declare module BABYLON {
  32078. /**
  32079. * @hidden
  32080. */
  32081. export class _IAnimationState {
  32082. key: number;
  32083. repeatCount: number;
  32084. workValue?: any;
  32085. loopMode?: number;
  32086. offsetValue?: any;
  32087. highLimitValue?: any;
  32088. }
  32089. /**
  32090. * Class used to store any kind of animation
  32091. */
  32092. export class Animation {
  32093. /**Name of the animation */
  32094. name: string;
  32095. /**Property to animate */
  32096. targetProperty: string;
  32097. /**The frames per second of the animation */
  32098. framePerSecond: number;
  32099. /**The data type of the animation */
  32100. dataType: number;
  32101. /**The loop mode of the animation */
  32102. loopMode?: number | undefined;
  32103. /**Specifies if blending should be enabled */
  32104. enableBlending?: boolean | undefined;
  32105. /**
  32106. * Use matrix interpolation instead of using direct key value when animating matrices
  32107. */
  32108. static AllowMatricesInterpolation: boolean;
  32109. /**
  32110. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  32111. */
  32112. static AllowMatrixDecomposeForInterpolation: boolean;
  32113. /**
  32114. * Stores the key frames of the animation
  32115. */
  32116. private _keys;
  32117. /**
  32118. * Stores the easing function of the animation
  32119. */
  32120. private _easingFunction;
  32121. /**
  32122. * @hidden Internal use only
  32123. */
  32124. _runtimeAnimations: RuntimeAnimation[];
  32125. /**
  32126. * The set of event that will be linked to this animation
  32127. */
  32128. private _events;
  32129. /**
  32130. * Stores an array of target property paths
  32131. */
  32132. targetPropertyPath: string[];
  32133. /**
  32134. * Stores the blending speed of the animation
  32135. */
  32136. blendingSpeed: number;
  32137. /**
  32138. * Stores the animation ranges for the animation
  32139. */
  32140. private _ranges;
  32141. /**
  32142. * @hidden Internal use
  32143. */
  32144. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  32145. /**
  32146. * Sets up an animation
  32147. * @param property The property to animate
  32148. * @param animationType The animation type to apply
  32149. * @param framePerSecond The frames per second of the animation
  32150. * @param easingFunction The easing function used in the animation
  32151. * @returns The created animation
  32152. */
  32153. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  32154. /**
  32155. * Create and start an animation on a node
  32156. * @param name defines the name of the global animation that will be run on all nodes
  32157. * @param node defines the root node where the animation will take place
  32158. * @param targetProperty defines property to animate
  32159. * @param framePerSecond defines the number of frame per second yo use
  32160. * @param totalFrame defines the number of frames in total
  32161. * @param from defines the initial value
  32162. * @param to defines the final value
  32163. * @param loopMode defines which loop mode you want to use (off by default)
  32164. * @param easingFunction defines the easing function to use (linear by default)
  32165. * @param onAnimationEnd defines the callback to call when animation end
  32166. * @returns the animatable created for this animation
  32167. */
  32168. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  32169. /**
  32170. * Create and start an animation on a node and its descendants
  32171. * @param name defines the name of the global animation that will be run on all nodes
  32172. * @param node defines the root node where the animation will take place
  32173. * @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
  32174. * @param targetProperty defines property to animate
  32175. * @param framePerSecond defines the number of frame per second to use
  32176. * @param totalFrame defines the number of frames in total
  32177. * @param from defines the initial value
  32178. * @param to defines the final value
  32179. * @param loopMode defines which loop mode you want to use (off by default)
  32180. * @param easingFunction defines the easing function to use (linear by default)
  32181. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  32182. * @returns the list of animatables created for all nodes
  32183. * @example https://www.babylonjs-playground.com/#MH0VLI
  32184. */
  32185. 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[]>;
  32186. /**
  32187. * Creates a new animation, merges it with the existing animations and starts it
  32188. * @param name Name of the animation
  32189. * @param node Node which contains the scene that begins the animations
  32190. * @param targetProperty Specifies which property to animate
  32191. * @param framePerSecond The frames per second of the animation
  32192. * @param totalFrame The total number of frames
  32193. * @param from The frame at the beginning of the animation
  32194. * @param to The frame at the end of the animation
  32195. * @param loopMode Specifies the loop mode of the animation
  32196. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  32197. * @param onAnimationEnd Callback to run once the animation is complete
  32198. * @returns Nullable animation
  32199. */
  32200. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  32201. /**
  32202. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  32203. * @param sourceAnimation defines the Animation containing keyframes to convert
  32204. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  32205. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  32206. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  32207. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  32208. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  32209. */
  32210. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  32211. /**
  32212. * Transition property of an host to the target Value
  32213. * @param property The property to transition
  32214. * @param targetValue The target Value of the property
  32215. * @param host The object where the property to animate belongs
  32216. * @param scene Scene used to run the animation
  32217. * @param frameRate Framerate (in frame/s) to use
  32218. * @param transition The transition type we want to use
  32219. * @param duration The duration of the animation, in milliseconds
  32220. * @param onAnimationEnd Callback trigger at the end of the animation
  32221. * @returns Nullable animation
  32222. */
  32223. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  32224. /**
  32225. * Return the array of runtime animations currently using this animation
  32226. */
  32227. get runtimeAnimations(): RuntimeAnimation[];
  32228. /**
  32229. * Specifies if any of the runtime animations are currently running
  32230. */
  32231. get hasRunningRuntimeAnimations(): boolean;
  32232. /**
  32233. * Initializes the animation
  32234. * @param name Name of the animation
  32235. * @param targetProperty Property to animate
  32236. * @param framePerSecond The frames per second of the animation
  32237. * @param dataType The data type of the animation
  32238. * @param loopMode The loop mode of the animation
  32239. * @param enableBlending Specifies if blending should be enabled
  32240. */
  32241. constructor(
  32242. /**Name of the animation */
  32243. name: string,
  32244. /**Property to animate */
  32245. targetProperty: string,
  32246. /**The frames per second of the animation */
  32247. framePerSecond: number,
  32248. /**The data type of the animation */
  32249. dataType: number,
  32250. /**The loop mode of the animation */
  32251. loopMode?: number | undefined,
  32252. /**Specifies if blending should be enabled */
  32253. enableBlending?: boolean | undefined);
  32254. /**
  32255. * Converts the animation to a string
  32256. * @param fullDetails support for multiple levels of logging within scene loading
  32257. * @returns String form of the animation
  32258. */
  32259. toString(fullDetails?: boolean): string;
  32260. /**
  32261. * Add an event to this animation
  32262. * @param event Event to add
  32263. */
  32264. addEvent(event: AnimationEvent): void;
  32265. /**
  32266. * Remove all events found at the given frame
  32267. * @param frame The frame to remove events from
  32268. */
  32269. removeEvents(frame: number): void;
  32270. /**
  32271. * Retrieves all the events from the animation
  32272. * @returns Events from the animation
  32273. */
  32274. getEvents(): AnimationEvent[];
  32275. /**
  32276. * Creates an animation range
  32277. * @param name Name of the animation range
  32278. * @param from Starting frame of the animation range
  32279. * @param to Ending frame of the animation
  32280. */
  32281. createRange(name: string, from: number, to: number): void;
  32282. /**
  32283. * Deletes an animation range by name
  32284. * @param name Name of the animation range to delete
  32285. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  32286. */
  32287. deleteRange(name: string, deleteFrames?: boolean): void;
  32288. /**
  32289. * Gets the animation range by name, or null if not defined
  32290. * @param name Name of the animation range
  32291. * @returns Nullable animation range
  32292. */
  32293. getRange(name: string): Nullable<AnimationRange>;
  32294. /**
  32295. * Gets the key frames from the animation
  32296. * @returns The key frames of the animation
  32297. */
  32298. getKeys(): Array<IAnimationKey>;
  32299. /**
  32300. * Gets the highest frame rate of the animation
  32301. * @returns Highest frame rate of the animation
  32302. */
  32303. getHighestFrame(): number;
  32304. /**
  32305. * Gets the easing function of the animation
  32306. * @returns Easing function of the animation
  32307. */
  32308. getEasingFunction(): IEasingFunction;
  32309. /**
  32310. * Sets the easing function of the animation
  32311. * @param easingFunction A custom mathematical formula for animation
  32312. */
  32313. setEasingFunction(easingFunction: EasingFunction): void;
  32314. /**
  32315. * Interpolates a scalar linearly
  32316. * @param startValue Start value of the animation curve
  32317. * @param endValue End value of the animation curve
  32318. * @param gradient Scalar amount to interpolate
  32319. * @returns Interpolated scalar value
  32320. */
  32321. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  32322. /**
  32323. * Interpolates a scalar cubically
  32324. * @param startValue Start value of the animation curve
  32325. * @param outTangent End tangent of the animation
  32326. * @param endValue End value of the animation curve
  32327. * @param inTangent Start tangent of the animation curve
  32328. * @param gradient Scalar amount to interpolate
  32329. * @returns Interpolated scalar value
  32330. */
  32331. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  32332. /**
  32333. * Interpolates a quaternion using a spherical linear interpolation
  32334. * @param startValue Start value of the animation curve
  32335. * @param endValue End value of the animation curve
  32336. * @param gradient Scalar amount to interpolate
  32337. * @returns Interpolated quaternion value
  32338. */
  32339. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  32340. /**
  32341. * Interpolates a quaternion cubically
  32342. * @param startValue Start value of the animation curve
  32343. * @param outTangent End tangent of the animation curve
  32344. * @param endValue End value of the animation curve
  32345. * @param inTangent Start tangent of the animation curve
  32346. * @param gradient Scalar amount to interpolate
  32347. * @returns Interpolated quaternion value
  32348. */
  32349. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  32350. /**
  32351. * Interpolates a Vector3 linearl
  32352. * @param startValue Start value of the animation curve
  32353. * @param endValue End value of the animation curve
  32354. * @param gradient Scalar amount to interpolate
  32355. * @returns Interpolated scalar value
  32356. */
  32357. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  32358. /**
  32359. * Interpolates a Vector3 cubically
  32360. * @param startValue Start value of the animation curve
  32361. * @param outTangent End tangent of the animation
  32362. * @param endValue End value of the animation curve
  32363. * @param inTangent Start tangent of the animation curve
  32364. * @param gradient Scalar amount to interpolate
  32365. * @returns InterpolatedVector3 value
  32366. */
  32367. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  32368. /**
  32369. * Interpolates a Vector2 linearly
  32370. * @param startValue Start value of the animation curve
  32371. * @param endValue End value of the animation curve
  32372. * @param gradient Scalar amount to interpolate
  32373. * @returns Interpolated Vector2 value
  32374. */
  32375. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  32376. /**
  32377. * Interpolates a Vector2 cubically
  32378. * @param startValue Start value of the animation curve
  32379. * @param outTangent End tangent of the animation
  32380. * @param endValue End value of the animation curve
  32381. * @param inTangent Start tangent of the animation curve
  32382. * @param gradient Scalar amount to interpolate
  32383. * @returns Interpolated Vector2 value
  32384. */
  32385. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  32386. /**
  32387. * Interpolates a size linearly
  32388. * @param startValue Start value of the animation curve
  32389. * @param endValue End value of the animation curve
  32390. * @param gradient Scalar amount to interpolate
  32391. * @returns Interpolated Size value
  32392. */
  32393. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  32394. /**
  32395. * Interpolates a Color3 linearly
  32396. * @param startValue Start value of the animation curve
  32397. * @param endValue End value of the animation curve
  32398. * @param gradient Scalar amount to interpolate
  32399. * @returns Interpolated Color3 value
  32400. */
  32401. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  32402. /**
  32403. * Interpolates a Color4 linearly
  32404. * @param startValue Start value of the animation curve
  32405. * @param endValue End value of the animation curve
  32406. * @param gradient Scalar amount to interpolate
  32407. * @returns Interpolated Color3 value
  32408. */
  32409. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  32410. /**
  32411. * @hidden Internal use only
  32412. */
  32413. _getKeyValue(value: any): any;
  32414. /**
  32415. * @hidden Internal use only
  32416. */
  32417. _interpolate(currentFrame: number, state: _IAnimationState): any;
  32418. /**
  32419. * Defines the function to use to interpolate matrices
  32420. * @param startValue defines the start matrix
  32421. * @param endValue defines the end matrix
  32422. * @param gradient defines the gradient between both matrices
  32423. * @param result defines an optional target matrix where to store the interpolation
  32424. * @returns the interpolated matrix
  32425. */
  32426. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  32427. /**
  32428. * Makes a copy of the animation
  32429. * @returns Cloned animation
  32430. */
  32431. clone(): Animation;
  32432. /**
  32433. * Sets the key frames of the animation
  32434. * @param values The animation key frames to set
  32435. */
  32436. setKeys(values: Array<IAnimationKey>): void;
  32437. /**
  32438. * Serializes the animation to an object
  32439. * @returns Serialized object
  32440. */
  32441. serialize(): any;
  32442. /**
  32443. * Float animation type
  32444. */
  32445. static readonly ANIMATIONTYPE_FLOAT: number;
  32446. /**
  32447. * Vector3 animation type
  32448. */
  32449. static readonly ANIMATIONTYPE_VECTOR3: number;
  32450. /**
  32451. * Quaternion animation type
  32452. */
  32453. static readonly ANIMATIONTYPE_QUATERNION: number;
  32454. /**
  32455. * Matrix animation type
  32456. */
  32457. static readonly ANIMATIONTYPE_MATRIX: number;
  32458. /**
  32459. * Color3 animation type
  32460. */
  32461. static readonly ANIMATIONTYPE_COLOR3: number;
  32462. /**
  32463. * Color3 animation type
  32464. */
  32465. static readonly ANIMATIONTYPE_COLOR4: number;
  32466. /**
  32467. * Vector2 animation type
  32468. */
  32469. static readonly ANIMATIONTYPE_VECTOR2: number;
  32470. /**
  32471. * Size animation type
  32472. */
  32473. static readonly ANIMATIONTYPE_SIZE: number;
  32474. /**
  32475. * Relative Loop Mode
  32476. */
  32477. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  32478. /**
  32479. * Cycle Loop Mode
  32480. */
  32481. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  32482. /**
  32483. * Constant Loop Mode
  32484. */
  32485. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  32486. /** @hidden */
  32487. static _UniversalLerp(left: any, right: any, amount: number): any;
  32488. /**
  32489. * Parses an animation object and creates an animation
  32490. * @param parsedAnimation Parsed animation object
  32491. * @returns Animation object
  32492. */
  32493. static Parse(parsedAnimation: any): Animation;
  32494. /**
  32495. * Appends the serialized animations from the source animations
  32496. * @param source Source containing the animations
  32497. * @param destination Target to store the animations
  32498. */
  32499. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  32500. }
  32501. }
  32502. declare module BABYLON {
  32503. /**
  32504. * Interface containing an array of animations
  32505. */
  32506. export interface IAnimatable {
  32507. /**
  32508. * Array of animations
  32509. */
  32510. animations: Nullable<Array<Animation>>;
  32511. }
  32512. }
  32513. declare module BABYLON {
  32514. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  32515. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32516. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32517. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32518. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32519. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32520. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32521. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32522. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32523. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32524. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32525. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32526. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32527. /**
  32528. * Decorator used to define property that can be serialized as reference to a camera
  32529. * @param sourceName defines the name of the property to decorate
  32530. */
  32531. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32532. /**
  32533. * Class used to help serialization objects
  32534. */
  32535. export class SerializationHelper {
  32536. /** @hidden */
  32537. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  32538. /** @hidden */
  32539. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  32540. /** @hidden */
  32541. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  32542. /** @hidden */
  32543. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  32544. /**
  32545. * Appends the serialized animations from the source animations
  32546. * @param source Source containing the animations
  32547. * @param destination Target to store the animations
  32548. */
  32549. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  32550. /**
  32551. * Static function used to serialized a specific entity
  32552. * @param entity defines the entity to serialize
  32553. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  32554. * @returns a JSON compatible object representing the serialization of the entity
  32555. */
  32556. static Serialize<T>(entity: T, serializationObject?: any): any;
  32557. /**
  32558. * Creates a new entity from a serialization data object
  32559. * @param creationFunction defines a function used to instanciated the new entity
  32560. * @param source defines the source serialization data
  32561. * @param scene defines the hosting scene
  32562. * @param rootUrl defines the root url for resources
  32563. * @returns a new entity
  32564. */
  32565. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  32566. /**
  32567. * Clones an object
  32568. * @param creationFunction defines the function used to instanciate the new object
  32569. * @param source defines the source object
  32570. * @returns the cloned object
  32571. */
  32572. static Clone<T>(creationFunction: () => T, source: T): T;
  32573. /**
  32574. * Instanciates a new object based on a source one (some data will be shared between both object)
  32575. * @param creationFunction defines the function used to instanciate the new object
  32576. * @param source defines the source object
  32577. * @returns the new object
  32578. */
  32579. static Instanciate<T>(creationFunction: () => T, source: T): T;
  32580. }
  32581. }
  32582. declare module BABYLON {
  32583. /**
  32584. * Base class of all the textures in babylon.
  32585. * It groups all the common properties the materials, post process, lights... might need
  32586. * in order to make a correct use of the texture.
  32587. */
  32588. export class BaseTexture implements IAnimatable {
  32589. /**
  32590. * Default anisotropic filtering level for the application.
  32591. * It is set to 4 as a good tradeoff between perf and quality.
  32592. */
  32593. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  32594. /**
  32595. * Gets or sets the unique id of the texture
  32596. */
  32597. uniqueId: number;
  32598. /**
  32599. * Define the name of the texture.
  32600. */
  32601. name: string;
  32602. /**
  32603. * Gets or sets an object used to store user defined information.
  32604. */
  32605. metadata: any;
  32606. /**
  32607. * For internal use only. Please do not use.
  32608. */
  32609. reservedDataStore: any;
  32610. private _hasAlpha;
  32611. /**
  32612. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  32613. */
  32614. set hasAlpha(value: boolean);
  32615. get hasAlpha(): boolean;
  32616. /**
  32617. * Defines if the alpha value should be determined via the rgb values.
  32618. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  32619. */
  32620. getAlphaFromRGB: boolean;
  32621. /**
  32622. * Intensity or strength of the texture.
  32623. * It is commonly used by materials to fine tune the intensity of the texture
  32624. */
  32625. level: number;
  32626. /**
  32627. * Define the UV chanel to use starting from 0 and defaulting to 0.
  32628. * This is part of the texture as textures usually maps to one uv set.
  32629. */
  32630. coordinatesIndex: number;
  32631. private _coordinatesMode;
  32632. /**
  32633. * How a texture is mapped.
  32634. *
  32635. * | Value | Type | Description |
  32636. * | ----- | ----------------------------------- | ----------- |
  32637. * | 0 | EXPLICIT_MODE | |
  32638. * | 1 | SPHERICAL_MODE | |
  32639. * | 2 | PLANAR_MODE | |
  32640. * | 3 | CUBIC_MODE | |
  32641. * | 4 | PROJECTION_MODE | |
  32642. * | 5 | SKYBOX_MODE | |
  32643. * | 6 | INVCUBIC_MODE | |
  32644. * | 7 | EQUIRECTANGULAR_MODE | |
  32645. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  32646. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  32647. */
  32648. set coordinatesMode(value: number);
  32649. get coordinatesMode(): number;
  32650. /**
  32651. * | Value | Type | Description |
  32652. * | ----- | ------------------ | ----------- |
  32653. * | 0 | CLAMP_ADDRESSMODE | |
  32654. * | 1 | WRAP_ADDRESSMODE | |
  32655. * | 2 | MIRROR_ADDRESSMODE | |
  32656. */
  32657. wrapU: number;
  32658. /**
  32659. * | Value | Type | Description |
  32660. * | ----- | ------------------ | ----------- |
  32661. * | 0 | CLAMP_ADDRESSMODE | |
  32662. * | 1 | WRAP_ADDRESSMODE | |
  32663. * | 2 | MIRROR_ADDRESSMODE | |
  32664. */
  32665. wrapV: number;
  32666. /**
  32667. * | Value | Type | Description |
  32668. * | ----- | ------------------ | ----------- |
  32669. * | 0 | CLAMP_ADDRESSMODE | |
  32670. * | 1 | WRAP_ADDRESSMODE | |
  32671. * | 2 | MIRROR_ADDRESSMODE | |
  32672. */
  32673. wrapR: number;
  32674. /**
  32675. * With compliant hardware and browser (supporting anisotropic filtering)
  32676. * this defines the level of anisotropic filtering in the texture.
  32677. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  32678. */
  32679. anisotropicFilteringLevel: number;
  32680. /**
  32681. * Define if the texture is a cube texture or if false a 2d texture.
  32682. */
  32683. get isCube(): boolean;
  32684. set isCube(value: boolean);
  32685. /**
  32686. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  32687. */
  32688. get is3D(): boolean;
  32689. set is3D(value: boolean);
  32690. /**
  32691. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  32692. */
  32693. get is2DArray(): boolean;
  32694. set is2DArray(value: boolean);
  32695. /**
  32696. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  32697. * HDR texture are usually stored in linear space.
  32698. * This only impacts the PBR and Background materials
  32699. */
  32700. gammaSpace: boolean;
  32701. /**
  32702. * Gets or sets whether or not the texture contains RGBD data.
  32703. */
  32704. get isRGBD(): boolean;
  32705. set isRGBD(value: boolean);
  32706. /**
  32707. * Is Z inverted in the texture (useful in a cube texture).
  32708. */
  32709. invertZ: boolean;
  32710. /**
  32711. * Are mip maps generated for this texture or not.
  32712. */
  32713. get noMipmap(): boolean;
  32714. /**
  32715. * @hidden
  32716. */
  32717. lodLevelInAlpha: boolean;
  32718. /**
  32719. * With prefiltered texture, defined the offset used during the prefiltering steps.
  32720. */
  32721. get lodGenerationOffset(): number;
  32722. set lodGenerationOffset(value: number);
  32723. /**
  32724. * With prefiltered texture, defined the scale used during the prefiltering steps.
  32725. */
  32726. get lodGenerationScale(): number;
  32727. set lodGenerationScale(value: number);
  32728. /**
  32729. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  32730. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  32731. * average roughness values.
  32732. */
  32733. get linearSpecularLOD(): boolean;
  32734. set linearSpecularLOD(value: boolean);
  32735. /**
  32736. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  32737. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  32738. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  32739. */
  32740. get irradianceTexture(): Nullable<BaseTexture>;
  32741. set irradianceTexture(value: Nullable<BaseTexture>);
  32742. /**
  32743. * Define if the texture is a render target.
  32744. */
  32745. isRenderTarget: boolean;
  32746. /**
  32747. * Define the unique id of the texture in the scene.
  32748. */
  32749. get uid(): string;
  32750. /**
  32751. * Return a string representation of the texture.
  32752. * @returns the texture as a string
  32753. */
  32754. toString(): string;
  32755. /**
  32756. * Get the class name of the texture.
  32757. * @returns "BaseTexture"
  32758. */
  32759. getClassName(): string;
  32760. private _realTimeFiltering;
  32761. /**
  32762. * Enables realtime filtering on the texture.
  32763. */
  32764. get realTimeFiltering(): boolean;
  32765. set realTimeFiltering(b: boolean);
  32766. private _realTimeFilteringQuality;
  32767. /**
  32768. * Quality switch for realtime filtering
  32769. */
  32770. get realTimeFilteringQuality(): number;
  32771. set realTimeFilteringQuality(n: number);
  32772. /**
  32773. * Define the list of animation attached to the texture.
  32774. */
  32775. animations: Animation[];
  32776. /**
  32777. * An event triggered when the texture is disposed.
  32778. */
  32779. onDisposeObservable: Observable<BaseTexture>;
  32780. private _onDisposeObserver;
  32781. /**
  32782. * Callback triggered when the texture has been disposed.
  32783. * Kept for back compatibility, you can use the onDisposeObservable instead.
  32784. */
  32785. set onDispose(callback: () => void);
  32786. /**
  32787. * Define the current state of the loading sequence when in delayed load mode.
  32788. */
  32789. delayLoadState: number;
  32790. private _scene;
  32791. private _engine;
  32792. /** @hidden */
  32793. _texture: Nullable<InternalTexture>;
  32794. private _uid;
  32795. /**
  32796. * Define if the texture is preventinga material to render or not.
  32797. * If not and the texture is not ready, the engine will use a default black texture instead.
  32798. */
  32799. get isBlocking(): boolean;
  32800. /**
  32801. * Instantiates a new BaseTexture.
  32802. * Base class of all the textures in babylon.
  32803. * It groups all the common properties the materials, post process, lights... might need
  32804. * in order to make a correct use of the texture.
  32805. * @param sceneOrEngine Define the scene or engine the texture blongs to
  32806. */
  32807. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  32808. /**
  32809. * Get the scene the texture belongs to.
  32810. * @returns the scene or null if undefined
  32811. */
  32812. getScene(): Nullable<Scene>;
  32813. /** @hidden */
  32814. protected _getEngine(): Nullable<ThinEngine>;
  32815. /**
  32816. * Get the texture transform matrix used to offset tile the texture for istance.
  32817. * @returns the transformation matrix
  32818. */
  32819. getTextureMatrix(): Matrix;
  32820. /**
  32821. * Get the texture reflection matrix used to rotate/transform the reflection.
  32822. * @returns the reflection matrix
  32823. */
  32824. getReflectionTextureMatrix(): Matrix;
  32825. /**
  32826. * Get the underlying lower level texture from Babylon.
  32827. * @returns the insternal texture
  32828. */
  32829. getInternalTexture(): Nullable<InternalTexture>;
  32830. /**
  32831. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  32832. * @returns true if ready or not blocking
  32833. */
  32834. isReadyOrNotBlocking(): boolean;
  32835. /**
  32836. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  32837. * @returns true if fully ready
  32838. */
  32839. isReady(): boolean;
  32840. private _cachedSize;
  32841. /**
  32842. * Get the size of the texture.
  32843. * @returns the texture size.
  32844. */
  32845. getSize(): ISize;
  32846. /**
  32847. * Get the base size of the texture.
  32848. * It can be different from the size if the texture has been resized for POT for instance
  32849. * @returns the base size
  32850. */
  32851. getBaseSize(): ISize;
  32852. /**
  32853. * Update the sampling mode of the texture.
  32854. * Default is Trilinear mode.
  32855. *
  32856. * | Value | Type | Description |
  32857. * | ----- | ------------------ | ----------- |
  32858. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  32859. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  32860. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  32861. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  32862. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  32863. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  32864. * | 7 | NEAREST_LINEAR | |
  32865. * | 8 | NEAREST_NEAREST | |
  32866. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  32867. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  32868. * | 11 | LINEAR_LINEAR | |
  32869. * | 12 | LINEAR_NEAREST | |
  32870. *
  32871. * > _mag_: magnification filter (close to the viewer)
  32872. * > _min_: minification filter (far from the viewer)
  32873. * > _mip_: filter used between mip map levels
  32874. *@param samplingMode Define the new sampling mode of the texture
  32875. */
  32876. updateSamplingMode(samplingMode: number): void;
  32877. /**
  32878. * Scales the texture if is `canRescale()`
  32879. * @param ratio the resize factor we want to use to rescale
  32880. */
  32881. scale(ratio: number): void;
  32882. /**
  32883. * Get if the texture can rescale.
  32884. */
  32885. get canRescale(): boolean;
  32886. /** @hidden */
  32887. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  32888. /** @hidden */
  32889. _rebuild(): void;
  32890. /**
  32891. * Triggers the load sequence in delayed load mode.
  32892. */
  32893. delayLoad(): void;
  32894. /**
  32895. * Clones the texture.
  32896. * @returns the cloned texture
  32897. */
  32898. clone(): Nullable<BaseTexture>;
  32899. /**
  32900. * Get the texture underlying type (INT, FLOAT...)
  32901. */
  32902. get textureType(): number;
  32903. /**
  32904. * Get the texture underlying format (RGB, RGBA...)
  32905. */
  32906. get textureFormat(): number;
  32907. /**
  32908. * Indicates that textures need to be re-calculated for all materials
  32909. */
  32910. protected _markAllSubMeshesAsTexturesDirty(): void;
  32911. /**
  32912. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  32913. * This will returns an RGBA array buffer containing either in values (0-255) or
  32914. * float values (0-1) depending of the underlying buffer type.
  32915. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  32916. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  32917. * @param buffer defines a user defined buffer to fill with data (can be null)
  32918. * @returns The Array buffer containing the pixels data.
  32919. */
  32920. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  32921. /**
  32922. * Release and destroy the underlying lower level texture aka internalTexture.
  32923. */
  32924. releaseInternalTexture(): void;
  32925. /** @hidden */
  32926. get _lodTextureHigh(): Nullable<BaseTexture>;
  32927. /** @hidden */
  32928. get _lodTextureMid(): Nullable<BaseTexture>;
  32929. /** @hidden */
  32930. get _lodTextureLow(): Nullable<BaseTexture>;
  32931. /**
  32932. * Dispose the texture and release its associated resources.
  32933. */
  32934. dispose(): void;
  32935. /**
  32936. * Serialize the texture into a JSON representation that can be parsed later on.
  32937. * @returns the JSON representation of the texture
  32938. */
  32939. serialize(): any;
  32940. /**
  32941. * Helper function to be called back once a list of texture contains only ready textures.
  32942. * @param textures Define the list of textures to wait for
  32943. * @param callback Define the callback triggered once the entire list will be ready
  32944. */
  32945. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  32946. private static _isScene;
  32947. }
  32948. }
  32949. declare module BABYLON {
  32950. /**
  32951. * Options to be used when creating an effect.
  32952. */
  32953. export interface IEffectCreationOptions {
  32954. /**
  32955. * Atrributes that will be used in the shader.
  32956. */
  32957. attributes: string[];
  32958. /**
  32959. * Uniform varible names that will be set in the shader.
  32960. */
  32961. uniformsNames: string[];
  32962. /**
  32963. * Uniform buffer variable names that will be set in the shader.
  32964. */
  32965. uniformBuffersNames: string[];
  32966. /**
  32967. * Sampler texture variable names that will be set in the shader.
  32968. */
  32969. samplers: string[];
  32970. /**
  32971. * Define statements that will be set in the shader.
  32972. */
  32973. defines: any;
  32974. /**
  32975. * Possible fallbacks for this effect to improve performance when needed.
  32976. */
  32977. fallbacks: Nullable<IEffectFallbacks>;
  32978. /**
  32979. * Callback that will be called when the shader is compiled.
  32980. */
  32981. onCompiled: Nullable<(effect: Effect) => void>;
  32982. /**
  32983. * Callback that will be called if an error occurs during shader compilation.
  32984. */
  32985. onError: Nullable<(effect: Effect, errors: string) => void>;
  32986. /**
  32987. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  32988. */
  32989. indexParameters?: any;
  32990. /**
  32991. * Max number of lights that can be used in the shader.
  32992. */
  32993. maxSimultaneousLights?: number;
  32994. /**
  32995. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  32996. */
  32997. transformFeedbackVaryings?: Nullable<string[]>;
  32998. }
  32999. /**
  33000. * Effect containing vertex and fragment shader that can be executed on an object.
  33001. */
  33002. export class Effect implements IDisposable {
  33003. /**
  33004. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  33005. */
  33006. static ShadersRepository: string;
  33007. /**
  33008. * Enable logging of the shader code when a compilation error occurs
  33009. */
  33010. static LogShaderCodeOnCompilationError: boolean;
  33011. /**
  33012. * Name of the effect.
  33013. */
  33014. name: any;
  33015. /**
  33016. * String container all the define statements that should be set on the shader.
  33017. */
  33018. defines: string;
  33019. /**
  33020. * Callback that will be called when the shader is compiled.
  33021. */
  33022. onCompiled: Nullable<(effect: Effect) => void>;
  33023. /**
  33024. * Callback that will be called if an error occurs during shader compilation.
  33025. */
  33026. onError: Nullable<(effect: Effect, errors: string) => void>;
  33027. /**
  33028. * Callback that will be called when effect is bound.
  33029. */
  33030. onBind: Nullable<(effect: Effect) => void>;
  33031. /**
  33032. * Unique ID of the effect.
  33033. */
  33034. uniqueId: number;
  33035. /**
  33036. * Observable that will be called when the shader is compiled.
  33037. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  33038. */
  33039. onCompileObservable: Observable<Effect>;
  33040. /**
  33041. * Observable that will be called if an error occurs during shader compilation.
  33042. */
  33043. onErrorObservable: Observable<Effect>;
  33044. /** @hidden */
  33045. _onBindObservable: Nullable<Observable<Effect>>;
  33046. /**
  33047. * @hidden
  33048. * Specifies if the effect was previously ready
  33049. */
  33050. _wasPreviouslyReady: boolean;
  33051. /**
  33052. * Observable that will be called when effect is bound.
  33053. */
  33054. get onBindObservable(): Observable<Effect>;
  33055. /** @hidden */
  33056. _bonesComputationForcedToCPU: boolean;
  33057. private static _uniqueIdSeed;
  33058. private _engine;
  33059. private _uniformBuffersNames;
  33060. private _uniformBuffersNamesList;
  33061. private _uniformsNames;
  33062. private _samplerList;
  33063. private _samplers;
  33064. private _isReady;
  33065. private _compilationError;
  33066. private _allFallbacksProcessed;
  33067. private _attributesNames;
  33068. private _attributes;
  33069. private _attributeLocationByName;
  33070. private _uniforms;
  33071. /**
  33072. * Key for the effect.
  33073. * @hidden
  33074. */
  33075. _key: string;
  33076. private _indexParameters;
  33077. private _fallbacks;
  33078. private _vertexSourceCode;
  33079. private _fragmentSourceCode;
  33080. private _vertexSourceCodeOverride;
  33081. private _fragmentSourceCodeOverride;
  33082. private _transformFeedbackVaryings;
  33083. /**
  33084. * Compiled shader to webGL program.
  33085. * @hidden
  33086. */
  33087. _pipelineContext: Nullable<IPipelineContext>;
  33088. private _valueCache;
  33089. private static _baseCache;
  33090. /**
  33091. * Instantiates an effect.
  33092. * An effect can be used to create/manage/execute vertex and fragment shaders.
  33093. * @param baseName Name of the effect.
  33094. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  33095. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  33096. * @param samplers List of sampler variables that will be passed to the shader.
  33097. * @param engine Engine to be used to render the effect
  33098. * @param defines Define statements to be added to the shader.
  33099. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  33100. * @param onCompiled Callback that will be called when the shader is compiled.
  33101. * @param onError Callback that will be called if an error occurs during shader compilation.
  33102. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  33103. */
  33104. 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);
  33105. private _useFinalCode;
  33106. /**
  33107. * Unique key for this effect
  33108. */
  33109. get key(): string;
  33110. /**
  33111. * If the effect has been compiled and prepared.
  33112. * @returns if the effect is compiled and prepared.
  33113. */
  33114. isReady(): boolean;
  33115. private _isReadyInternal;
  33116. /**
  33117. * The engine the effect was initialized with.
  33118. * @returns the engine.
  33119. */
  33120. getEngine(): Engine;
  33121. /**
  33122. * The pipeline context for this effect
  33123. * @returns the associated pipeline context
  33124. */
  33125. getPipelineContext(): Nullable<IPipelineContext>;
  33126. /**
  33127. * The set of names of attribute variables for the shader.
  33128. * @returns An array of attribute names.
  33129. */
  33130. getAttributesNames(): string[];
  33131. /**
  33132. * Returns the attribute at the given index.
  33133. * @param index The index of the attribute.
  33134. * @returns The location of the attribute.
  33135. */
  33136. getAttributeLocation(index: number): number;
  33137. /**
  33138. * Returns the attribute based on the name of the variable.
  33139. * @param name of the attribute to look up.
  33140. * @returns the attribute location.
  33141. */
  33142. getAttributeLocationByName(name: string): number;
  33143. /**
  33144. * The number of attributes.
  33145. * @returns the numnber of attributes.
  33146. */
  33147. getAttributesCount(): number;
  33148. /**
  33149. * Gets the index of a uniform variable.
  33150. * @param uniformName of the uniform to look up.
  33151. * @returns the index.
  33152. */
  33153. getUniformIndex(uniformName: string): number;
  33154. /**
  33155. * Returns the attribute based on the name of the variable.
  33156. * @param uniformName of the uniform to look up.
  33157. * @returns the location of the uniform.
  33158. */
  33159. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  33160. /**
  33161. * Returns an array of sampler variable names
  33162. * @returns The array of sampler variable names.
  33163. */
  33164. getSamplers(): string[];
  33165. /**
  33166. * Returns an array of uniform variable names
  33167. * @returns The array of uniform variable names.
  33168. */
  33169. getUniformNames(): string[];
  33170. /**
  33171. * Returns an array of uniform buffer variable names
  33172. * @returns The array of uniform buffer variable names.
  33173. */
  33174. getUniformBuffersNames(): string[];
  33175. /**
  33176. * Returns the index parameters used to create the effect
  33177. * @returns The index parameters object
  33178. */
  33179. getIndexParameters(): any;
  33180. /**
  33181. * The error from the last compilation.
  33182. * @returns the error string.
  33183. */
  33184. getCompilationError(): string;
  33185. /**
  33186. * Gets a boolean indicating that all fallbacks were used during compilation
  33187. * @returns true if all fallbacks were used
  33188. */
  33189. allFallbacksProcessed(): boolean;
  33190. /**
  33191. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  33192. * @param func The callback to be used.
  33193. */
  33194. executeWhenCompiled(func: (effect: Effect) => void): void;
  33195. private _checkIsReady;
  33196. private _loadShader;
  33197. /**
  33198. * Gets the vertex shader source code of this effect
  33199. */
  33200. get vertexSourceCode(): string;
  33201. /**
  33202. * Gets the fragment shader source code of this effect
  33203. */
  33204. get fragmentSourceCode(): string;
  33205. /**
  33206. * Recompiles the webGL program
  33207. * @param vertexSourceCode The source code for the vertex shader.
  33208. * @param fragmentSourceCode The source code for the fragment shader.
  33209. * @param onCompiled Callback called when completed.
  33210. * @param onError Callback called on error.
  33211. * @hidden
  33212. */
  33213. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  33214. /**
  33215. * Prepares the effect
  33216. * @hidden
  33217. */
  33218. _prepareEffect(): void;
  33219. private _getShaderCodeAndErrorLine;
  33220. private _processCompilationErrors;
  33221. /**
  33222. * Checks if the effect is supported. (Must be called after compilation)
  33223. */
  33224. get isSupported(): boolean;
  33225. /**
  33226. * Binds a texture to the engine to be used as output of the shader.
  33227. * @param channel Name of the output variable.
  33228. * @param texture Texture to bind.
  33229. * @hidden
  33230. */
  33231. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  33232. /**
  33233. * Sets a texture on the engine to be used in the shader.
  33234. * @param channel Name of the sampler variable.
  33235. * @param texture Texture to set.
  33236. */
  33237. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  33238. /**
  33239. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  33240. * @param channel Name of the sampler variable.
  33241. * @param texture Texture to set.
  33242. */
  33243. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  33244. /**
  33245. * Sets an array of textures on the engine to be used in the shader.
  33246. * @param channel Name of the variable.
  33247. * @param textures Textures to set.
  33248. */
  33249. setTextureArray(channel: string, textures: BaseTexture[]): void;
  33250. /**
  33251. * 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)
  33252. * @param channel Name of the sampler variable.
  33253. * @param postProcess Post process to get the input texture from.
  33254. */
  33255. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  33256. /**
  33257. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  33258. * 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)
  33259. * @param channel Name of the sampler variable.
  33260. * @param postProcess Post process to get the output texture from.
  33261. */
  33262. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  33263. /** @hidden */
  33264. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  33265. /** @hidden */
  33266. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  33267. /** @hidden */
  33268. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  33269. /** @hidden */
  33270. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  33271. /**
  33272. * Binds a buffer to a uniform.
  33273. * @param buffer Buffer to bind.
  33274. * @param name Name of the uniform variable to bind to.
  33275. */
  33276. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  33277. /**
  33278. * Binds block to a uniform.
  33279. * @param blockName Name of the block to bind.
  33280. * @param index Index to bind.
  33281. */
  33282. bindUniformBlock(blockName: string, index: number): void;
  33283. /**
  33284. * Sets an interger value on a uniform variable.
  33285. * @param uniformName Name of the variable.
  33286. * @param value Value to be set.
  33287. * @returns this effect.
  33288. */
  33289. setInt(uniformName: string, value: number): Effect;
  33290. /**
  33291. * Sets an int array on a uniform variable.
  33292. * @param uniformName Name of the variable.
  33293. * @param array array to be set.
  33294. * @returns this effect.
  33295. */
  33296. setIntArray(uniformName: string, array: Int32Array): Effect;
  33297. /**
  33298. * 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)
  33299. * @param uniformName Name of the variable.
  33300. * @param array array to be set.
  33301. * @returns this effect.
  33302. */
  33303. setIntArray2(uniformName: string, array: Int32Array): Effect;
  33304. /**
  33305. * 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)
  33306. * @param uniformName Name of the variable.
  33307. * @param array array to be set.
  33308. * @returns this effect.
  33309. */
  33310. setIntArray3(uniformName: string, array: Int32Array): Effect;
  33311. /**
  33312. * 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)
  33313. * @param uniformName Name of the variable.
  33314. * @param array array to be set.
  33315. * @returns this effect.
  33316. */
  33317. setIntArray4(uniformName: string, array: Int32Array): Effect;
  33318. /**
  33319. * Sets an float array on a uniform variable.
  33320. * @param uniformName Name of the variable.
  33321. * @param array array to be set.
  33322. * @returns this effect.
  33323. */
  33324. setFloatArray(uniformName: string, array: Float32Array): Effect;
  33325. /**
  33326. * 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)
  33327. * @param uniformName Name of the variable.
  33328. * @param array array to be set.
  33329. * @returns this effect.
  33330. */
  33331. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  33332. /**
  33333. * 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)
  33334. * @param uniformName Name of the variable.
  33335. * @param array array to be set.
  33336. * @returns this effect.
  33337. */
  33338. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  33339. /**
  33340. * 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)
  33341. * @param uniformName Name of the variable.
  33342. * @param array array to be set.
  33343. * @returns this effect.
  33344. */
  33345. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  33346. /**
  33347. * Sets an array on a uniform variable.
  33348. * @param uniformName Name of the variable.
  33349. * @param array array to be set.
  33350. * @returns this effect.
  33351. */
  33352. setArray(uniformName: string, array: number[]): Effect;
  33353. /**
  33354. * 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)
  33355. * @param uniformName Name of the variable.
  33356. * @param array array to be set.
  33357. * @returns this effect.
  33358. */
  33359. setArray2(uniformName: string, array: number[]): Effect;
  33360. /**
  33361. * 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)
  33362. * @param uniformName Name of the variable.
  33363. * @param array array to be set.
  33364. * @returns this effect.
  33365. */
  33366. setArray3(uniformName: string, array: number[]): Effect;
  33367. /**
  33368. * 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)
  33369. * @param uniformName Name of the variable.
  33370. * @param array array to be set.
  33371. * @returns this effect.
  33372. */
  33373. setArray4(uniformName: string, array: number[]): Effect;
  33374. /**
  33375. * Sets matrices on a uniform variable.
  33376. * @param uniformName Name of the variable.
  33377. * @param matrices matrices to be set.
  33378. * @returns this effect.
  33379. */
  33380. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  33381. /**
  33382. * Sets matrix on a uniform variable.
  33383. * @param uniformName Name of the variable.
  33384. * @param matrix matrix to be set.
  33385. * @returns this effect.
  33386. */
  33387. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  33388. /**
  33389. * 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)
  33390. * @param uniformName Name of the variable.
  33391. * @param matrix matrix to be set.
  33392. * @returns this effect.
  33393. */
  33394. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  33395. /**
  33396. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  33397. * @param uniformName Name of the variable.
  33398. * @param matrix matrix to be set.
  33399. * @returns this effect.
  33400. */
  33401. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  33402. /**
  33403. * Sets a float on a uniform variable.
  33404. * @param uniformName Name of the variable.
  33405. * @param value value to be set.
  33406. * @returns this effect.
  33407. */
  33408. setFloat(uniformName: string, value: number): Effect;
  33409. /**
  33410. * Sets a boolean on a uniform variable.
  33411. * @param uniformName Name of the variable.
  33412. * @param bool value to be set.
  33413. * @returns this effect.
  33414. */
  33415. setBool(uniformName: string, bool: boolean): Effect;
  33416. /**
  33417. * Sets a Vector2 on a uniform variable.
  33418. * @param uniformName Name of the variable.
  33419. * @param vector2 vector2 to be set.
  33420. * @returns this effect.
  33421. */
  33422. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  33423. /**
  33424. * Sets a float2 on a uniform variable.
  33425. * @param uniformName Name of the variable.
  33426. * @param x First float in float2.
  33427. * @param y Second float in float2.
  33428. * @returns this effect.
  33429. */
  33430. setFloat2(uniformName: string, x: number, y: number): Effect;
  33431. /**
  33432. * Sets a Vector3 on a uniform variable.
  33433. * @param uniformName Name of the variable.
  33434. * @param vector3 Value to be set.
  33435. * @returns this effect.
  33436. */
  33437. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  33438. /**
  33439. * Sets a float3 on a uniform variable.
  33440. * @param uniformName Name of the variable.
  33441. * @param x First float in float3.
  33442. * @param y Second float in float3.
  33443. * @param z Third float in float3.
  33444. * @returns this effect.
  33445. */
  33446. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  33447. /**
  33448. * Sets a Vector4 on a uniform variable.
  33449. * @param uniformName Name of the variable.
  33450. * @param vector4 Value to be set.
  33451. * @returns this effect.
  33452. */
  33453. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  33454. /**
  33455. * Sets a float4 on a uniform variable.
  33456. * @param uniformName Name of the variable.
  33457. * @param x First float in float4.
  33458. * @param y Second float in float4.
  33459. * @param z Third float in float4.
  33460. * @param w Fourth float in float4.
  33461. * @returns this effect.
  33462. */
  33463. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  33464. /**
  33465. * Sets a Color3 on a uniform variable.
  33466. * @param uniformName Name of the variable.
  33467. * @param color3 Value to be set.
  33468. * @returns this effect.
  33469. */
  33470. setColor3(uniformName: string, color3: IColor3Like): Effect;
  33471. /**
  33472. * Sets a Color4 on a uniform variable.
  33473. * @param uniformName Name of the variable.
  33474. * @param color3 Value to be set.
  33475. * @param alpha Alpha value to be set.
  33476. * @returns this effect.
  33477. */
  33478. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  33479. /**
  33480. * Sets a Color4 on a uniform variable
  33481. * @param uniformName defines the name of the variable
  33482. * @param color4 defines the value to be set
  33483. * @returns this effect.
  33484. */
  33485. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  33486. /** Release all associated resources */
  33487. dispose(): void;
  33488. /**
  33489. * This function will add a new shader to the shader store
  33490. * @param name the name of the shader
  33491. * @param pixelShader optional pixel shader content
  33492. * @param vertexShader optional vertex shader content
  33493. */
  33494. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  33495. /**
  33496. * Store of each shader (The can be looked up using effect.key)
  33497. */
  33498. static ShadersStore: {
  33499. [key: string]: string;
  33500. };
  33501. /**
  33502. * Store of each included file for a shader (The can be looked up using effect.key)
  33503. */
  33504. static IncludesShadersStore: {
  33505. [key: string]: string;
  33506. };
  33507. /**
  33508. * Resets the cache of effects.
  33509. */
  33510. static ResetCache(): void;
  33511. }
  33512. }
  33513. declare module BABYLON {
  33514. /**
  33515. * Interface used to describe the capabilities of the engine relatively to the current browser
  33516. */
  33517. export interface EngineCapabilities {
  33518. /** Maximum textures units per fragment shader */
  33519. maxTexturesImageUnits: number;
  33520. /** Maximum texture units per vertex shader */
  33521. maxVertexTextureImageUnits: number;
  33522. /** Maximum textures units in the entire pipeline */
  33523. maxCombinedTexturesImageUnits: number;
  33524. /** Maximum texture size */
  33525. maxTextureSize: number;
  33526. /** Maximum texture samples */
  33527. maxSamples?: number;
  33528. /** Maximum cube texture size */
  33529. maxCubemapTextureSize: number;
  33530. /** Maximum render texture size */
  33531. maxRenderTextureSize: number;
  33532. /** Maximum number of vertex attributes */
  33533. maxVertexAttribs: number;
  33534. /** Maximum number of varyings */
  33535. maxVaryingVectors: number;
  33536. /** Maximum number of uniforms per vertex shader */
  33537. maxVertexUniformVectors: number;
  33538. /** Maximum number of uniforms per fragment shader */
  33539. maxFragmentUniformVectors: number;
  33540. /** Defines if standard derivates (dx/dy) are supported */
  33541. standardDerivatives: boolean;
  33542. /** Defines if s3tc texture compression is supported */
  33543. s3tc?: WEBGL_compressed_texture_s3tc;
  33544. /** Defines if pvrtc texture compression is supported */
  33545. pvrtc: any;
  33546. /** Defines if etc1 texture compression is supported */
  33547. etc1: any;
  33548. /** Defines if etc2 texture compression is supported */
  33549. etc2: any;
  33550. /** Defines if astc texture compression is supported */
  33551. astc: any;
  33552. /** Defines if float textures are supported */
  33553. textureFloat: boolean;
  33554. /** Defines if vertex array objects are supported */
  33555. vertexArrayObject: boolean;
  33556. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  33557. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  33558. /** Gets the maximum level of anisotropy supported */
  33559. maxAnisotropy: number;
  33560. /** Defines if instancing is supported */
  33561. instancedArrays: boolean;
  33562. /** Defines if 32 bits indices are supported */
  33563. uintIndices: boolean;
  33564. /** Defines if high precision shaders are supported */
  33565. highPrecisionShaderSupported: boolean;
  33566. /** Defines if depth reading in the fragment shader is supported */
  33567. fragmentDepthSupported: boolean;
  33568. /** Defines if float texture linear filtering is supported*/
  33569. textureFloatLinearFiltering: boolean;
  33570. /** Defines if rendering to float textures is supported */
  33571. textureFloatRender: boolean;
  33572. /** Defines if half float textures are supported*/
  33573. textureHalfFloat: boolean;
  33574. /** Defines if half float texture linear filtering is supported*/
  33575. textureHalfFloatLinearFiltering: boolean;
  33576. /** Defines if rendering to half float textures is supported */
  33577. textureHalfFloatRender: boolean;
  33578. /** Defines if textureLOD shader command is supported */
  33579. textureLOD: boolean;
  33580. /** Defines if draw buffers extension is supported */
  33581. drawBuffersExtension: boolean;
  33582. /** Defines if depth textures are supported */
  33583. depthTextureExtension: boolean;
  33584. /** Defines if float color buffer are supported */
  33585. colorBufferFloat: boolean;
  33586. /** Gets disjoint timer query extension (null if not supported) */
  33587. timerQuery?: EXT_disjoint_timer_query;
  33588. /** Defines if timestamp can be used with timer query */
  33589. canUseTimestampForTimerQuery: boolean;
  33590. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  33591. multiview?: any;
  33592. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  33593. oculusMultiview?: any;
  33594. /** Function used to let the system compiles shaders in background */
  33595. parallelShaderCompile?: {
  33596. COMPLETION_STATUS_KHR: number;
  33597. };
  33598. /** Max number of texture samples for MSAA */
  33599. maxMSAASamples: number;
  33600. /** Defines if the blend min max extension is supported */
  33601. blendMinMax: boolean;
  33602. }
  33603. }
  33604. declare module BABYLON {
  33605. /**
  33606. * @hidden
  33607. **/
  33608. export class DepthCullingState {
  33609. private _isDepthTestDirty;
  33610. private _isDepthMaskDirty;
  33611. private _isDepthFuncDirty;
  33612. private _isCullFaceDirty;
  33613. private _isCullDirty;
  33614. private _isZOffsetDirty;
  33615. private _isFrontFaceDirty;
  33616. private _depthTest;
  33617. private _depthMask;
  33618. private _depthFunc;
  33619. private _cull;
  33620. private _cullFace;
  33621. private _zOffset;
  33622. private _frontFace;
  33623. /**
  33624. * Initializes the state.
  33625. */
  33626. constructor();
  33627. get isDirty(): boolean;
  33628. get zOffset(): number;
  33629. set zOffset(value: number);
  33630. get cullFace(): Nullable<number>;
  33631. set cullFace(value: Nullable<number>);
  33632. get cull(): Nullable<boolean>;
  33633. set cull(value: Nullable<boolean>);
  33634. get depthFunc(): Nullable<number>;
  33635. set depthFunc(value: Nullable<number>);
  33636. get depthMask(): boolean;
  33637. set depthMask(value: boolean);
  33638. get depthTest(): boolean;
  33639. set depthTest(value: boolean);
  33640. get frontFace(): Nullable<number>;
  33641. set frontFace(value: Nullable<number>);
  33642. reset(): void;
  33643. apply(gl: WebGLRenderingContext): void;
  33644. }
  33645. }
  33646. declare module BABYLON {
  33647. /**
  33648. * @hidden
  33649. **/
  33650. export class StencilState {
  33651. /** 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 */
  33652. static readonly ALWAYS: number;
  33653. /** Passed to stencilOperation to specify that stencil value must be kept */
  33654. static readonly KEEP: number;
  33655. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33656. static readonly REPLACE: number;
  33657. private _isStencilTestDirty;
  33658. private _isStencilMaskDirty;
  33659. private _isStencilFuncDirty;
  33660. private _isStencilOpDirty;
  33661. private _stencilTest;
  33662. private _stencilMask;
  33663. private _stencilFunc;
  33664. private _stencilFuncRef;
  33665. private _stencilFuncMask;
  33666. private _stencilOpStencilFail;
  33667. private _stencilOpDepthFail;
  33668. private _stencilOpStencilDepthPass;
  33669. get isDirty(): boolean;
  33670. get stencilFunc(): number;
  33671. set stencilFunc(value: number);
  33672. get stencilFuncRef(): number;
  33673. set stencilFuncRef(value: number);
  33674. get stencilFuncMask(): number;
  33675. set stencilFuncMask(value: number);
  33676. get stencilOpStencilFail(): number;
  33677. set stencilOpStencilFail(value: number);
  33678. get stencilOpDepthFail(): number;
  33679. set stencilOpDepthFail(value: number);
  33680. get stencilOpStencilDepthPass(): number;
  33681. set stencilOpStencilDepthPass(value: number);
  33682. get stencilMask(): number;
  33683. set stencilMask(value: number);
  33684. get stencilTest(): boolean;
  33685. set stencilTest(value: boolean);
  33686. constructor();
  33687. reset(): void;
  33688. apply(gl: WebGLRenderingContext): void;
  33689. }
  33690. }
  33691. declare module BABYLON {
  33692. /**
  33693. * @hidden
  33694. **/
  33695. export class AlphaState {
  33696. private _isAlphaBlendDirty;
  33697. private _isBlendFunctionParametersDirty;
  33698. private _isBlendEquationParametersDirty;
  33699. private _isBlendConstantsDirty;
  33700. private _alphaBlend;
  33701. private _blendFunctionParameters;
  33702. private _blendEquationParameters;
  33703. private _blendConstants;
  33704. /**
  33705. * Initializes the state.
  33706. */
  33707. constructor();
  33708. get isDirty(): boolean;
  33709. get alphaBlend(): boolean;
  33710. set alphaBlend(value: boolean);
  33711. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  33712. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  33713. setAlphaEquationParameters(rgb: number, alpha: number): void;
  33714. reset(): void;
  33715. apply(gl: WebGLRenderingContext): void;
  33716. }
  33717. }
  33718. declare module BABYLON {
  33719. /** @hidden */
  33720. export class WebGL2ShaderProcessor implements IShaderProcessor {
  33721. attributeProcessor(attribute: string): string;
  33722. varyingProcessor(varying: string, isFragment: boolean): string;
  33723. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  33724. }
  33725. }
  33726. declare module BABYLON {
  33727. /**
  33728. * Interface for attribute information associated with buffer instanciation
  33729. */
  33730. export interface InstancingAttributeInfo {
  33731. /**
  33732. * Name of the GLSL attribute
  33733. * if attribute index is not specified, this is used to retrieve the index from the effect
  33734. */
  33735. attributeName: string;
  33736. /**
  33737. * Index/offset of the attribute in the vertex shader
  33738. * if not specified, this will be computes from the name.
  33739. */
  33740. index?: number;
  33741. /**
  33742. * size of the attribute, 1, 2, 3 or 4
  33743. */
  33744. attributeSize: number;
  33745. /**
  33746. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  33747. */
  33748. offset: number;
  33749. /**
  33750. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  33751. * default to 1
  33752. */
  33753. divisor?: number;
  33754. /**
  33755. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  33756. * default is FLOAT
  33757. */
  33758. attributeType?: number;
  33759. /**
  33760. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  33761. */
  33762. normalized?: boolean;
  33763. }
  33764. }
  33765. declare module BABYLON {
  33766. interface ThinEngine {
  33767. /**
  33768. * Update a video texture
  33769. * @param texture defines the texture to update
  33770. * @param video defines the video element to use
  33771. * @param invertY defines if data must be stored with Y axis inverted
  33772. */
  33773. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  33774. }
  33775. }
  33776. declare module BABYLON {
  33777. /**
  33778. * Settings for finer control over video usage
  33779. */
  33780. export interface VideoTextureSettings {
  33781. /**
  33782. * Applies `autoplay` to video, if specified
  33783. */
  33784. autoPlay?: boolean;
  33785. /**
  33786. * Applies `loop` to video, if specified
  33787. */
  33788. loop?: boolean;
  33789. /**
  33790. * Automatically updates internal texture from video at every frame in the render loop
  33791. */
  33792. autoUpdateTexture: boolean;
  33793. /**
  33794. * Image src displayed during the video loading or until the user interacts with the video.
  33795. */
  33796. poster?: string;
  33797. }
  33798. /**
  33799. * If you want to display a video in your scene, this is the special texture for that.
  33800. * This special texture works similar to other textures, with the exception of a few parameters.
  33801. * @see https://doc.babylonjs.com/how_to/video_texture
  33802. */
  33803. export class VideoTexture extends Texture {
  33804. /**
  33805. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  33806. */
  33807. readonly autoUpdateTexture: boolean;
  33808. /**
  33809. * The video instance used by the texture internally
  33810. */
  33811. readonly video: HTMLVideoElement;
  33812. private _onUserActionRequestedObservable;
  33813. /**
  33814. * Event triggerd when a dom action is required by the user to play the video.
  33815. * This happens due to recent changes in browser policies preventing video to auto start.
  33816. */
  33817. get onUserActionRequestedObservable(): Observable<Texture>;
  33818. private _generateMipMaps;
  33819. private _stillImageCaptured;
  33820. private _displayingPosterTexture;
  33821. private _settings;
  33822. private _createInternalTextureOnEvent;
  33823. private _frameId;
  33824. private _currentSrc;
  33825. /**
  33826. * Creates a video texture.
  33827. * If you want to display a video in your scene, this is the special texture for that.
  33828. * This special texture works similar to other textures, with the exception of a few parameters.
  33829. * @see https://doc.babylonjs.com/how_to/video_texture
  33830. * @param name optional name, will detect from video source, if not defined
  33831. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  33832. * @param scene is obviously the current scene.
  33833. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  33834. * @param invertY is false by default but can be used to invert video on Y axis
  33835. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  33836. * @param settings allows finer control over video usage
  33837. */
  33838. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  33839. private _getName;
  33840. private _getVideo;
  33841. private _createInternalTexture;
  33842. private reset;
  33843. /**
  33844. * @hidden Internal method to initiate `update`.
  33845. */
  33846. _rebuild(): void;
  33847. /**
  33848. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  33849. */
  33850. update(): void;
  33851. /**
  33852. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  33853. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  33854. */
  33855. updateTexture(isVisible: boolean): void;
  33856. protected _updateInternalTexture: () => void;
  33857. /**
  33858. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  33859. * @param url New url.
  33860. */
  33861. updateURL(url: string): void;
  33862. /**
  33863. * Clones the texture.
  33864. * @returns the cloned texture
  33865. */
  33866. clone(): VideoTexture;
  33867. /**
  33868. * Dispose the texture and release its associated resources.
  33869. */
  33870. dispose(): void;
  33871. /**
  33872. * Creates a video texture straight from a stream.
  33873. * @param scene Define the scene the texture should be created in
  33874. * @param stream Define the stream the texture should be created from
  33875. * @returns The created video texture as a promise
  33876. */
  33877. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  33878. /**
  33879. * Creates a video texture straight from your WebCam video feed.
  33880. * @param scene Define the scene the texture should be created in
  33881. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  33882. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  33883. * @returns The created video texture as a promise
  33884. */
  33885. static CreateFromWebCamAsync(scene: Scene, constraints: {
  33886. minWidth: number;
  33887. maxWidth: number;
  33888. minHeight: number;
  33889. maxHeight: number;
  33890. deviceId: string;
  33891. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  33892. /**
  33893. * Creates a video texture straight from your WebCam video feed.
  33894. * @param scene Define the scene the texture should be created in
  33895. * @param onReady Define a callback to triggered once the texture will be ready
  33896. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  33897. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  33898. */
  33899. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  33900. minWidth: number;
  33901. maxWidth: number;
  33902. minHeight: number;
  33903. maxHeight: number;
  33904. deviceId: string;
  33905. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  33906. }
  33907. }
  33908. declare module BABYLON {
  33909. /**
  33910. * Defines the interface used by objects working like Scene
  33911. * @hidden
  33912. */
  33913. export interface ISceneLike {
  33914. _addPendingData(data: any): void;
  33915. _removePendingData(data: any): void;
  33916. offlineProvider: IOfflineProvider;
  33917. }
  33918. /** Interface defining initialization parameters for Engine class */
  33919. export interface EngineOptions extends WebGLContextAttributes {
  33920. /**
  33921. * Defines if the engine should no exceed a specified device ratio
  33922. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  33923. */
  33924. limitDeviceRatio?: number;
  33925. /**
  33926. * Defines if webvr should be enabled automatically
  33927. * @see http://doc.babylonjs.com/how_to/webvr_camera
  33928. */
  33929. autoEnableWebVR?: boolean;
  33930. /**
  33931. * Defines if webgl2 should be turned off even if supported
  33932. * @see http://doc.babylonjs.com/features/webgl2
  33933. */
  33934. disableWebGL2Support?: boolean;
  33935. /**
  33936. * Defines if webaudio should be initialized as well
  33937. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33938. */
  33939. audioEngine?: boolean;
  33940. /**
  33941. * Defines if animations should run using a deterministic lock step
  33942. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33943. */
  33944. deterministicLockstep?: boolean;
  33945. /** Defines the maximum steps to use with deterministic lock step mode */
  33946. lockstepMaxSteps?: number;
  33947. /** Defines the seconds between each deterministic lock step */
  33948. timeStep?: number;
  33949. /**
  33950. * Defines that engine should ignore context lost events
  33951. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  33952. */
  33953. doNotHandleContextLost?: boolean;
  33954. /**
  33955. * Defines that engine should ignore modifying touch action attribute and style
  33956. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  33957. */
  33958. doNotHandleTouchAction?: boolean;
  33959. /**
  33960. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  33961. */
  33962. useHighPrecisionFloats?: boolean;
  33963. }
  33964. /**
  33965. * The base engine class (root of all engines)
  33966. */
  33967. export class ThinEngine {
  33968. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  33969. static ExceptionList: ({
  33970. key: string;
  33971. capture: string;
  33972. captureConstraint: number;
  33973. targets: string[];
  33974. } | {
  33975. key: string;
  33976. capture: null;
  33977. captureConstraint: null;
  33978. targets: string[];
  33979. })[];
  33980. /** @hidden */
  33981. static _TextureLoaders: IInternalTextureLoader[];
  33982. /**
  33983. * Returns the current npm package of the sdk
  33984. */
  33985. static get NpmPackage(): string;
  33986. /**
  33987. * Returns the current version of the framework
  33988. */
  33989. static get Version(): string;
  33990. /**
  33991. * Returns a string describing the current engine
  33992. */
  33993. get description(): string;
  33994. /**
  33995. * Gets or sets the epsilon value used by collision engine
  33996. */
  33997. static CollisionsEpsilon: number;
  33998. /**
  33999. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  34000. */
  34001. static get ShadersRepository(): string;
  34002. static set ShadersRepository(value: string);
  34003. /** @hidden */
  34004. _shaderProcessor: IShaderProcessor;
  34005. /**
  34006. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  34007. */
  34008. forcePOTTextures: boolean;
  34009. /**
  34010. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  34011. */
  34012. isFullscreen: boolean;
  34013. /**
  34014. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  34015. */
  34016. cullBackFaces: boolean;
  34017. /**
  34018. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  34019. */
  34020. renderEvenInBackground: boolean;
  34021. /**
  34022. * Gets or sets a boolean indicating that cache can be kept between frames
  34023. */
  34024. preventCacheWipeBetweenFrames: boolean;
  34025. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  34026. validateShaderPrograms: boolean;
  34027. /**
  34028. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  34029. * This can provide greater z depth for distant objects.
  34030. */
  34031. useReverseDepthBuffer: boolean;
  34032. /**
  34033. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  34034. */
  34035. disableUniformBuffers: boolean;
  34036. /** @hidden */
  34037. _uniformBuffers: UniformBuffer[];
  34038. /**
  34039. * Gets a boolean indicating that the engine supports uniform buffers
  34040. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  34041. */
  34042. get supportsUniformBuffers(): boolean;
  34043. /** @hidden */
  34044. _gl: WebGLRenderingContext;
  34045. /** @hidden */
  34046. _webGLVersion: number;
  34047. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  34048. protected _windowIsBackground: boolean;
  34049. protected _creationOptions: EngineOptions;
  34050. protected _highPrecisionShadersAllowed: boolean;
  34051. /** @hidden */
  34052. get _shouldUseHighPrecisionShader(): boolean;
  34053. /**
  34054. * Gets a boolean indicating that only power of 2 textures are supported
  34055. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  34056. */
  34057. get needPOTTextures(): boolean;
  34058. /** @hidden */
  34059. _badOS: boolean;
  34060. /** @hidden */
  34061. _badDesktopOS: boolean;
  34062. private _hardwareScalingLevel;
  34063. /** @hidden */
  34064. _caps: EngineCapabilities;
  34065. private _isStencilEnable;
  34066. private _glVersion;
  34067. private _glRenderer;
  34068. private _glVendor;
  34069. /** @hidden */
  34070. _videoTextureSupported: boolean;
  34071. protected _renderingQueueLaunched: boolean;
  34072. protected _activeRenderLoops: (() => void)[];
  34073. /**
  34074. * Observable signaled when a context lost event is raised
  34075. */
  34076. onContextLostObservable: Observable<ThinEngine>;
  34077. /**
  34078. * Observable signaled when a context restored event is raised
  34079. */
  34080. onContextRestoredObservable: Observable<ThinEngine>;
  34081. private _onContextLost;
  34082. private _onContextRestored;
  34083. protected _contextWasLost: boolean;
  34084. /** @hidden */
  34085. _doNotHandleContextLost: boolean;
  34086. /**
  34087. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  34088. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  34089. */
  34090. get doNotHandleContextLost(): boolean;
  34091. set doNotHandleContextLost(value: boolean);
  34092. /**
  34093. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  34094. */
  34095. disableVertexArrayObjects: boolean;
  34096. /** @hidden */
  34097. protected _colorWrite: boolean;
  34098. /** @hidden */
  34099. protected _colorWriteChanged: boolean;
  34100. /** @hidden */
  34101. protected _depthCullingState: DepthCullingState;
  34102. /** @hidden */
  34103. protected _stencilState: StencilState;
  34104. /** @hidden */
  34105. _alphaState: AlphaState;
  34106. /** @hidden */
  34107. _alphaMode: number;
  34108. /** @hidden */
  34109. _alphaEquation: number;
  34110. /** @hidden */
  34111. _internalTexturesCache: InternalTexture[];
  34112. /** @hidden */
  34113. protected _activeChannel: number;
  34114. private _currentTextureChannel;
  34115. /** @hidden */
  34116. protected _boundTexturesCache: {
  34117. [key: string]: Nullable<InternalTexture>;
  34118. };
  34119. /** @hidden */
  34120. protected _currentEffect: Nullable<Effect>;
  34121. /** @hidden */
  34122. protected _currentProgram: Nullable<WebGLProgram>;
  34123. private _compiledEffects;
  34124. private _vertexAttribArraysEnabled;
  34125. /** @hidden */
  34126. protected _cachedViewport: Nullable<IViewportLike>;
  34127. private _cachedVertexArrayObject;
  34128. /** @hidden */
  34129. protected _cachedVertexBuffers: any;
  34130. /** @hidden */
  34131. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  34132. /** @hidden */
  34133. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  34134. /** @hidden */
  34135. _currentRenderTarget: Nullable<InternalTexture>;
  34136. private _uintIndicesCurrentlySet;
  34137. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  34138. /** @hidden */
  34139. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  34140. /** @hidden */
  34141. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  34142. private _currentBufferPointers;
  34143. private _currentInstanceLocations;
  34144. private _currentInstanceBuffers;
  34145. private _textureUnits;
  34146. /** @hidden */
  34147. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  34148. /** @hidden */
  34149. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  34150. /** @hidden */
  34151. _boundRenderFunction: any;
  34152. private _vaoRecordInProgress;
  34153. private _mustWipeVertexAttributes;
  34154. private _emptyTexture;
  34155. private _emptyCubeTexture;
  34156. private _emptyTexture3D;
  34157. private _emptyTexture2DArray;
  34158. /** @hidden */
  34159. _frameHandler: number;
  34160. private _nextFreeTextureSlots;
  34161. private _maxSimultaneousTextures;
  34162. private _activeRequests;
  34163. /** @hidden */
  34164. _transformTextureUrl: Nullable<(url: string) => string>;
  34165. protected get _supportsHardwareTextureRescaling(): boolean;
  34166. private _framebufferDimensionsObject;
  34167. /**
  34168. * sets the object from which width and height will be taken from when getting render width and height
  34169. * Will fallback to the gl object
  34170. * @param dimensions the framebuffer width and height that will be used.
  34171. */
  34172. set framebufferDimensionsObject(dimensions: Nullable<{
  34173. framebufferWidth: number;
  34174. framebufferHeight: number;
  34175. }>);
  34176. /**
  34177. * Gets the current viewport
  34178. */
  34179. get currentViewport(): Nullable<IViewportLike>;
  34180. /**
  34181. * Gets the default empty texture
  34182. */
  34183. get emptyTexture(): InternalTexture;
  34184. /**
  34185. * Gets the default empty 3D texture
  34186. */
  34187. get emptyTexture3D(): InternalTexture;
  34188. /**
  34189. * Gets the default empty 2D array texture
  34190. */
  34191. get emptyTexture2DArray(): InternalTexture;
  34192. /**
  34193. * Gets the default empty cube texture
  34194. */
  34195. get emptyCubeTexture(): InternalTexture;
  34196. /**
  34197. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  34198. */
  34199. readonly premultipliedAlpha: boolean;
  34200. /**
  34201. * Observable event triggered before each texture is initialized
  34202. */
  34203. onBeforeTextureInitObservable: Observable<Texture>;
  34204. /**
  34205. * Creates a new engine
  34206. * @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
  34207. * @param antialias defines enable antialiasing (default: false)
  34208. * @param options defines further options to be sent to the getContext() function
  34209. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  34210. */
  34211. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  34212. private _rebuildInternalTextures;
  34213. private _rebuildEffects;
  34214. /**
  34215. * Gets a boolean indicating if all created effects are ready
  34216. * @returns true if all effects are ready
  34217. */
  34218. areAllEffectsReady(): boolean;
  34219. protected _rebuildBuffers(): void;
  34220. protected _initGLContext(): void;
  34221. /**
  34222. * Gets version of the current webGL context
  34223. */
  34224. get webGLVersion(): number;
  34225. /**
  34226. * Gets a string idenfifying the name of the class
  34227. * @returns "Engine" string
  34228. */
  34229. getClassName(): string;
  34230. /**
  34231. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  34232. */
  34233. get isStencilEnable(): boolean;
  34234. /** @hidden */
  34235. _prepareWorkingCanvas(): void;
  34236. /**
  34237. * Reset the texture cache to empty state
  34238. */
  34239. resetTextureCache(): void;
  34240. /**
  34241. * Gets an object containing information about the current webGL context
  34242. * @returns an object containing the vender, the renderer and the version of the current webGL context
  34243. */
  34244. getGlInfo(): {
  34245. vendor: string;
  34246. renderer: string;
  34247. version: string;
  34248. };
  34249. /**
  34250. * Defines the hardware scaling level.
  34251. * By default the hardware scaling level is computed from the window device ratio.
  34252. * 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.
  34253. * @param level defines the level to use
  34254. */
  34255. setHardwareScalingLevel(level: number): void;
  34256. /**
  34257. * Gets the current hardware scaling level.
  34258. * By default the hardware scaling level is computed from the window device ratio.
  34259. * 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.
  34260. * @returns a number indicating the current hardware scaling level
  34261. */
  34262. getHardwareScalingLevel(): number;
  34263. /**
  34264. * Gets the list of loaded textures
  34265. * @returns an array containing all loaded textures
  34266. */
  34267. getLoadedTexturesCache(): InternalTexture[];
  34268. /**
  34269. * Gets the object containing all engine capabilities
  34270. * @returns the EngineCapabilities object
  34271. */
  34272. getCaps(): EngineCapabilities;
  34273. /**
  34274. * stop executing a render loop function and remove it from the execution array
  34275. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  34276. */
  34277. stopRenderLoop(renderFunction?: () => void): void;
  34278. /** @hidden */
  34279. _renderLoop(): void;
  34280. /**
  34281. * Gets the HTML canvas attached with the current webGL context
  34282. * @returns a HTML canvas
  34283. */
  34284. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  34285. /**
  34286. * Gets host window
  34287. * @returns the host window object
  34288. */
  34289. getHostWindow(): Nullable<Window>;
  34290. /**
  34291. * Gets the current render width
  34292. * @param useScreen defines if screen size must be used (or the current render target if any)
  34293. * @returns a number defining the current render width
  34294. */
  34295. getRenderWidth(useScreen?: boolean): number;
  34296. /**
  34297. * Gets the current render height
  34298. * @param useScreen defines if screen size must be used (or the current render target if any)
  34299. * @returns a number defining the current render height
  34300. */
  34301. getRenderHeight(useScreen?: boolean): number;
  34302. /**
  34303. * Can be used to override the current requestAnimationFrame requester.
  34304. * @hidden
  34305. */
  34306. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  34307. /**
  34308. * Register and execute a render loop. The engine can have more than one render function
  34309. * @param renderFunction defines the function to continuously execute
  34310. */
  34311. runRenderLoop(renderFunction: () => void): void;
  34312. /**
  34313. * Clear the current render buffer or the current render target (if any is set up)
  34314. * @param color defines the color to use
  34315. * @param backBuffer defines if the back buffer must be cleared
  34316. * @param depth defines if the depth buffer must be cleared
  34317. * @param stencil defines if the stencil buffer must be cleared
  34318. */
  34319. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  34320. private _viewportCached;
  34321. /** @hidden */
  34322. _viewport(x: number, y: number, width: number, height: number): void;
  34323. /**
  34324. * Set the WebGL's viewport
  34325. * @param viewport defines the viewport element to be used
  34326. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  34327. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  34328. */
  34329. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  34330. /**
  34331. * Begin a new frame
  34332. */
  34333. beginFrame(): void;
  34334. /**
  34335. * Enf the current frame
  34336. */
  34337. endFrame(): void;
  34338. /**
  34339. * Resize the view according to the canvas' size
  34340. */
  34341. resize(): void;
  34342. /**
  34343. * Force a specific size of the canvas
  34344. * @param width defines the new canvas' width
  34345. * @param height defines the new canvas' height
  34346. */
  34347. setSize(width: number, height: number): void;
  34348. /**
  34349. * Binds the frame buffer to the specified texture.
  34350. * @param texture The texture to render to or null for the default canvas
  34351. * @param faceIndex The face of the texture to render to in case of cube texture
  34352. * @param requiredWidth The width of the target to render to
  34353. * @param requiredHeight The height of the target to render to
  34354. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  34355. * @param lodLevel defines the lod level to bind to the frame buffer
  34356. * @param layer defines the 2d array index to bind to frame buffer to
  34357. */
  34358. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  34359. /** @hidden */
  34360. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  34361. /**
  34362. * Unbind the current render target texture from the webGL context
  34363. * @param texture defines the render target texture to unbind
  34364. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  34365. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  34366. */
  34367. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  34368. /**
  34369. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  34370. */
  34371. flushFramebuffer(): void;
  34372. /**
  34373. * Unbind the current render target and bind the default framebuffer
  34374. */
  34375. restoreDefaultFramebuffer(): void;
  34376. /** @hidden */
  34377. protected _resetVertexBufferBinding(): void;
  34378. /**
  34379. * Creates a vertex buffer
  34380. * @param data the data for the vertex buffer
  34381. * @returns the new WebGL static buffer
  34382. */
  34383. createVertexBuffer(data: DataArray): DataBuffer;
  34384. private _createVertexBuffer;
  34385. /**
  34386. * Creates a dynamic vertex buffer
  34387. * @param data the data for the dynamic vertex buffer
  34388. * @returns the new WebGL dynamic buffer
  34389. */
  34390. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  34391. protected _resetIndexBufferBinding(): void;
  34392. /**
  34393. * Creates a new index buffer
  34394. * @param indices defines the content of the index buffer
  34395. * @param updatable defines if the index buffer must be updatable
  34396. * @returns a new webGL buffer
  34397. */
  34398. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  34399. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  34400. /**
  34401. * Bind a webGL buffer to the webGL context
  34402. * @param buffer defines the buffer to bind
  34403. */
  34404. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  34405. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  34406. private bindBuffer;
  34407. /**
  34408. * update the bound buffer with the given data
  34409. * @param data defines the data to update
  34410. */
  34411. updateArrayBuffer(data: Float32Array): void;
  34412. private _vertexAttribPointer;
  34413. /** @hidden */
  34414. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  34415. private _bindVertexBuffersAttributes;
  34416. /**
  34417. * Records a vertex array object
  34418. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  34419. * @param vertexBuffers defines the list of vertex buffers to store
  34420. * @param indexBuffer defines the index buffer to store
  34421. * @param effect defines the effect to store
  34422. * @returns the new vertex array object
  34423. */
  34424. recordVertexArrayObject(vertexBuffers: {
  34425. [key: string]: VertexBuffer;
  34426. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  34427. /**
  34428. * Bind a specific vertex array object
  34429. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  34430. * @param vertexArrayObject defines the vertex array object to bind
  34431. * @param indexBuffer defines the index buffer to bind
  34432. */
  34433. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  34434. /**
  34435. * Bind webGl buffers directly to the webGL context
  34436. * @param vertexBuffer defines the vertex buffer to bind
  34437. * @param indexBuffer defines the index buffer to bind
  34438. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  34439. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  34440. * @param effect defines the effect associated with the vertex buffer
  34441. */
  34442. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  34443. private _unbindVertexArrayObject;
  34444. /**
  34445. * Bind a list of vertex buffers to the webGL context
  34446. * @param vertexBuffers defines the list of vertex buffers to bind
  34447. * @param indexBuffer defines the index buffer to bind
  34448. * @param effect defines the effect associated with the vertex buffers
  34449. */
  34450. bindBuffers(vertexBuffers: {
  34451. [key: string]: Nullable<VertexBuffer>;
  34452. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  34453. /**
  34454. * Unbind all instance attributes
  34455. */
  34456. unbindInstanceAttributes(): void;
  34457. /**
  34458. * Release and free the memory of a vertex array object
  34459. * @param vao defines the vertex array object to delete
  34460. */
  34461. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  34462. /** @hidden */
  34463. _releaseBuffer(buffer: DataBuffer): boolean;
  34464. protected _deleteBuffer(buffer: DataBuffer): void;
  34465. /**
  34466. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  34467. * @param instancesBuffer defines the webGL buffer to update and bind
  34468. * @param data defines the data to store in the buffer
  34469. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  34470. */
  34471. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  34472. /**
  34473. * Bind the content of a webGL buffer used with instantiation
  34474. * @param instancesBuffer defines the webGL buffer to bind
  34475. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  34476. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  34477. */
  34478. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  34479. /**
  34480. * Disable the instance attribute corresponding to the name in parameter
  34481. * @param name defines the name of the attribute to disable
  34482. */
  34483. disableInstanceAttributeByName(name: string): void;
  34484. /**
  34485. * Disable the instance attribute corresponding to the location in parameter
  34486. * @param attributeLocation defines the attribute location of the attribute to disable
  34487. */
  34488. disableInstanceAttribute(attributeLocation: number): void;
  34489. /**
  34490. * Disable the attribute corresponding to the location in parameter
  34491. * @param attributeLocation defines the attribute location of the attribute to disable
  34492. */
  34493. disableAttributeByIndex(attributeLocation: number): void;
  34494. /**
  34495. * Send a draw order
  34496. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  34497. * @param indexStart defines the starting index
  34498. * @param indexCount defines the number of index to draw
  34499. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34500. */
  34501. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  34502. /**
  34503. * Draw a list of points
  34504. * @param verticesStart defines the index of first vertex to draw
  34505. * @param verticesCount defines the count of vertices to draw
  34506. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34507. */
  34508. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  34509. /**
  34510. * Draw a list of unindexed primitives
  34511. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  34512. * @param verticesStart defines the index of first vertex to draw
  34513. * @param verticesCount defines the count of vertices to draw
  34514. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34515. */
  34516. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  34517. /**
  34518. * Draw a list of indexed primitives
  34519. * @param fillMode defines the primitive to use
  34520. * @param indexStart defines the starting index
  34521. * @param indexCount defines the number of index to draw
  34522. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34523. */
  34524. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  34525. /**
  34526. * Draw a list of unindexed primitives
  34527. * @param fillMode defines the primitive to use
  34528. * @param verticesStart defines the index of first vertex to draw
  34529. * @param verticesCount defines the count of vertices to draw
  34530. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34531. */
  34532. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  34533. private _drawMode;
  34534. /** @hidden */
  34535. protected _reportDrawCall(): void;
  34536. /** @hidden */
  34537. _releaseEffect(effect: Effect): void;
  34538. /** @hidden */
  34539. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34540. /**
  34541. * Create a new effect (used to store vertex/fragment shaders)
  34542. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  34543. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  34544. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  34545. * @param samplers defines an array of string used to represent textures
  34546. * @param defines defines the string containing the defines to use to compile the shaders
  34547. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  34548. * @param onCompiled defines a function to call when the effect creation is successful
  34549. * @param onError defines a function to call when the effect creation has failed
  34550. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  34551. * @returns the new Effect
  34552. */
  34553. 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;
  34554. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  34555. private _compileShader;
  34556. private _compileRawShader;
  34557. /** @hidden */
  34558. _getShaderSource(shader: WebGLShader): Nullable<string>;
  34559. /**
  34560. * Directly creates a webGL program
  34561. * @param pipelineContext defines the pipeline context to attach to
  34562. * @param vertexCode defines the vertex shader code to use
  34563. * @param fragmentCode defines the fragment shader code to use
  34564. * @param context defines the webGL context to use (if not set, the current one will be used)
  34565. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  34566. * @returns the new webGL program
  34567. */
  34568. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34569. /**
  34570. * Creates a webGL program
  34571. * @param pipelineContext defines the pipeline context to attach to
  34572. * @param vertexCode defines the vertex shader code to use
  34573. * @param fragmentCode defines the fragment shader code to use
  34574. * @param defines defines the string containing the defines to use to compile the shaders
  34575. * @param context defines the webGL context to use (if not set, the current one will be used)
  34576. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  34577. * @returns the new webGL program
  34578. */
  34579. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34580. /**
  34581. * Creates a new pipeline context
  34582. * @returns the new pipeline
  34583. */
  34584. createPipelineContext(): IPipelineContext;
  34585. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34586. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  34587. /** @hidden */
  34588. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  34589. /** @hidden */
  34590. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  34591. /** @hidden */
  34592. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  34593. /**
  34594. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  34595. * @param pipelineContext defines the pipeline context to use
  34596. * @param uniformsNames defines the list of uniform names
  34597. * @returns an array of webGL uniform locations
  34598. */
  34599. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  34600. /**
  34601. * Gets the lsit of active attributes for a given webGL program
  34602. * @param pipelineContext defines the pipeline context to use
  34603. * @param attributesNames defines the list of attribute names to get
  34604. * @returns an array of indices indicating the offset of each attribute
  34605. */
  34606. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  34607. /**
  34608. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  34609. * @param effect defines the effect to activate
  34610. */
  34611. enableEffect(effect: Nullable<Effect>): void;
  34612. /**
  34613. * Set the value of an uniform to a number (int)
  34614. * @param uniform defines the webGL uniform location where to store the value
  34615. * @param value defines the int number to store
  34616. */
  34617. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  34618. /**
  34619. * Set the value of an uniform to an array of int32
  34620. * @param uniform defines the webGL uniform location where to store the value
  34621. * @param array defines the array of int32 to store
  34622. */
  34623. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34624. /**
  34625. * Set the value of an uniform to an array of int32 (stored as vec2)
  34626. * @param uniform defines the webGL uniform location where to store the value
  34627. * @param array defines the array of int32 to store
  34628. */
  34629. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34630. /**
  34631. * Set the value of an uniform to an array of int32 (stored as vec3)
  34632. * @param uniform defines the webGL uniform location where to store the value
  34633. * @param array defines the array of int32 to store
  34634. */
  34635. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34636. /**
  34637. * Set the value of an uniform to an array of int32 (stored as vec4)
  34638. * @param uniform defines the webGL uniform location where to store the value
  34639. * @param array defines the array of int32 to store
  34640. */
  34641. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34642. /**
  34643. * Set the value of an uniform to an array of number
  34644. * @param uniform defines the webGL uniform location where to store the value
  34645. * @param array defines the array of number to store
  34646. */
  34647. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34648. /**
  34649. * Set the value of an uniform to an array of number (stored as vec2)
  34650. * @param uniform defines the webGL uniform location where to store the value
  34651. * @param array defines the array of number to store
  34652. */
  34653. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34654. /**
  34655. * Set the value of an uniform to an array of number (stored as vec3)
  34656. * @param uniform defines the webGL uniform location where to store the value
  34657. * @param array defines the array of number to store
  34658. */
  34659. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34660. /**
  34661. * Set the value of an uniform to an array of number (stored as vec4)
  34662. * @param uniform defines the webGL uniform location where to store the value
  34663. * @param array defines the array of number to store
  34664. */
  34665. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34666. /**
  34667. * Set the value of an uniform to an array of float32 (stored as matrices)
  34668. * @param uniform defines the webGL uniform location where to store the value
  34669. * @param matrices defines the array of float32 to store
  34670. */
  34671. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  34672. /**
  34673. * Set the value of an uniform to a matrix (3x3)
  34674. * @param uniform defines the webGL uniform location where to store the value
  34675. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  34676. */
  34677. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  34678. /**
  34679. * Set the value of an uniform to a matrix (2x2)
  34680. * @param uniform defines the webGL uniform location where to store the value
  34681. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  34682. */
  34683. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  34684. /**
  34685. * Set the value of an uniform to a number (float)
  34686. * @param uniform defines the webGL uniform location where to store the value
  34687. * @param value defines the float number to store
  34688. */
  34689. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  34690. /**
  34691. * Set the value of an uniform to a vec2
  34692. * @param uniform defines the webGL uniform location where to store the value
  34693. * @param x defines the 1st component of the value
  34694. * @param y defines the 2nd component of the value
  34695. */
  34696. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  34697. /**
  34698. * Set the value of an uniform to a vec3
  34699. * @param uniform defines the webGL uniform location where to store the value
  34700. * @param x defines the 1st component of the value
  34701. * @param y defines the 2nd component of the value
  34702. * @param z defines the 3rd component of the value
  34703. */
  34704. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  34705. /**
  34706. * Set the value of an uniform to a vec4
  34707. * @param uniform defines the webGL uniform location where to store the value
  34708. * @param x defines the 1st component of the value
  34709. * @param y defines the 2nd component of the value
  34710. * @param z defines the 3rd component of the value
  34711. * @param w defines the 4th component of the value
  34712. */
  34713. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  34714. /**
  34715. * Apply all cached states (depth, culling, stencil and alpha)
  34716. */
  34717. applyStates(): void;
  34718. /**
  34719. * Enable or disable color writing
  34720. * @param enable defines the state to set
  34721. */
  34722. setColorWrite(enable: boolean): void;
  34723. /**
  34724. * Gets a boolean indicating if color writing is enabled
  34725. * @returns the current color writing state
  34726. */
  34727. getColorWrite(): boolean;
  34728. /**
  34729. * Gets the depth culling state manager
  34730. */
  34731. get depthCullingState(): DepthCullingState;
  34732. /**
  34733. * Gets the alpha state manager
  34734. */
  34735. get alphaState(): AlphaState;
  34736. /**
  34737. * Gets the stencil state manager
  34738. */
  34739. get stencilState(): StencilState;
  34740. /**
  34741. * Clears the list of texture accessible through engine.
  34742. * This can help preventing texture load conflict due to name collision.
  34743. */
  34744. clearInternalTexturesCache(): void;
  34745. /**
  34746. * Force the entire cache to be cleared
  34747. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  34748. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  34749. */
  34750. wipeCaches(bruteForce?: boolean): void;
  34751. /** @hidden */
  34752. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  34753. min: number;
  34754. mag: number;
  34755. };
  34756. /** @hidden */
  34757. _createTexture(): WebGLTexture;
  34758. /**
  34759. * Usually called from Texture.ts.
  34760. * Passed information to create a WebGLTexture
  34761. * @param url defines a value which contains one of the following:
  34762. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  34763. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  34764. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  34765. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  34766. * @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)
  34767. * @param scene needed for loading to the correct scene
  34768. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  34769. * @param onLoad optional callback to be called upon successful completion
  34770. * @param onError optional callback to be called upon failure
  34771. * @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
  34772. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  34773. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  34774. * @param forcedExtension defines the extension to use to pick the right loader
  34775. * @param mimeType defines an optional mime type
  34776. * @returns a InternalTexture for assignment back into BABYLON.Texture
  34777. */
  34778. createTexture(url: 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>, mimeType?: string): InternalTexture;
  34779. /**
  34780. * Loads an image as an HTMLImageElement.
  34781. * @param input url string, ArrayBuffer, or Blob to load
  34782. * @param onLoad callback called when the image successfully loads
  34783. * @param onError callback called when the image fails to load
  34784. * @param offlineProvider offline provider for caching
  34785. * @param mimeType optional mime type
  34786. * @returns the HTMLImageElement of the loaded image
  34787. * @hidden
  34788. */
  34789. static _FileToolsLoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  34790. /**
  34791. * @hidden
  34792. */
  34793. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  34794. private _unpackFlipYCached;
  34795. /**
  34796. * In case you are sharing the context with other applications, it might
  34797. * be interested to not cache the unpack flip y state to ensure a consistent
  34798. * value would be set.
  34799. */
  34800. enableUnpackFlipYCached: boolean;
  34801. /** @hidden */
  34802. _unpackFlipY(value: boolean): void;
  34803. /** @hidden */
  34804. _getUnpackAlignement(): number;
  34805. private _getTextureTarget;
  34806. /**
  34807. * Update the sampling mode of a given texture
  34808. * @param samplingMode defines the required sampling mode
  34809. * @param texture defines the texture to update
  34810. * @param generateMipMaps defines whether to generate mipmaps for the texture
  34811. */
  34812. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  34813. /**
  34814. * Update the sampling mode of a given texture
  34815. * @param texture defines the texture to update
  34816. * @param wrapU defines the texture wrap mode of the u coordinates
  34817. * @param wrapV defines the texture wrap mode of the v coordinates
  34818. * @param wrapR defines the texture wrap mode of the r coordinates
  34819. */
  34820. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  34821. /** @hidden */
  34822. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  34823. width: number;
  34824. height: number;
  34825. layers?: number;
  34826. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  34827. /** @hidden */
  34828. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  34829. /** @hidden */
  34830. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  34831. /**
  34832. * Update a portion of an internal texture
  34833. * @param texture defines the texture to update
  34834. * @param imageData defines the data to store into the texture
  34835. * @param xOffset defines the x coordinates of the update rectangle
  34836. * @param yOffset defines the y coordinates of the update rectangle
  34837. * @param width defines the width of the update rectangle
  34838. * @param height defines the height of the update rectangle
  34839. * @param faceIndex defines the face index if texture is a cube (0 by default)
  34840. * @param lod defines the lod level to update (0 by default)
  34841. */
  34842. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  34843. /** @hidden */
  34844. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  34845. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  34846. private _prepareWebGLTexture;
  34847. /** @hidden */
  34848. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  34849. private _getDepthStencilBuffer;
  34850. /** @hidden */
  34851. _releaseFramebufferObjects(texture: InternalTexture): void;
  34852. /** @hidden */
  34853. _releaseTexture(texture: InternalTexture): void;
  34854. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  34855. protected _setProgram(program: WebGLProgram): void;
  34856. protected _boundUniforms: {
  34857. [key: number]: WebGLUniformLocation;
  34858. };
  34859. /**
  34860. * Binds an effect to the webGL context
  34861. * @param effect defines the effect to bind
  34862. */
  34863. bindSamplers(effect: Effect): void;
  34864. private _activateCurrentTexture;
  34865. /** @hidden */
  34866. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  34867. /** @hidden */
  34868. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  34869. /**
  34870. * Unbind all textures from the webGL context
  34871. */
  34872. unbindAllTextures(): void;
  34873. /**
  34874. * Sets a texture to the according uniform.
  34875. * @param channel The texture channel
  34876. * @param uniform The uniform to set
  34877. * @param texture The texture to apply
  34878. */
  34879. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  34880. private _bindSamplerUniformToChannel;
  34881. private _getTextureWrapMode;
  34882. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  34883. /**
  34884. * Sets an array of texture to the webGL context
  34885. * @param channel defines the channel where the texture array must be set
  34886. * @param uniform defines the associated uniform location
  34887. * @param textures defines the array of textures to bind
  34888. */
  34889. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  34890. /** @hidden */
  34891. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  34892. private _setTextureParameterFloat;
  34893. private _setTextureParameterInteger;
  34894. /**
  34895. * Unbind all vertex attributes from the webGL context
  34896. */
  34897. unbindAllAttributes(): void;
  34898. /**
  34899. * 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
  34900. */
  34901. releaseEffects(): void;
  34902. /**
  34903. * Dispose and release all associated resources
  34904. */
  34905. dispose(): void;
  34906. /**
  34907. * Attach a new callback raised when context lost event is fired
  34908. * @param callback defines the callback to call
  34909. */
  34910. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  34911. /**
  34912. * Attach a new callback raised when context restored event is fired
  34913. * @param callback defines the callback to call
  34914. */
  34915. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  34916. /**
  34917. * Get the current error code of the webGL context
  34918. * @returns the error code
  34919. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  34920. */
  34921. getError(): number;
  34922. private _canRenderToFloatFramebuffer;
  34923. private _canRenderToHalfFloatFramebuffer;
  34924. private _canRenderToFramebuffer;
  34925. /** @hidden */
  34926. _getWebGLTextureType(type: number): number;
  34927. /** @hidden */
  34928. _getInternalFormat(format: number): number;
  34929. /** @hidden */
  34930. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  34931. /** @hidden */
  34932. _getRGBAMultiSampleBufferFormat(type: number): number;
  34933. /** @hidden */
  34934. _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;
  34935. /**
  34936. * Loads a file from a url
  34937. * @param url url to load
  34938. * @param onSuccess callback called when the file successfully loads
  34939. * @param onProgress callback called while file is loading (if the server supports this mode)
  34940. * @param offlineProvider defines the offline provider for caching
  34941. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34942. * @param onError callback called when the file fails to load
  34943. * @returns a file request object
  34944. * @hidden
  34945. */
  34946. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  34947. /**
  34948. * Reads pixels from the current frame buffer. Please note that this function can be slow
  34949. * @param x defines the x coordinate of the rectangle where pixels must be read
  34950. * @param y defines the y coordinate of the rectangle where pixels must be read
  34951. * @param width defines the width of the rectangle where pixels must be read
  34952. * @param height defines the height of the rectangle where pixels must be read
  34953. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  34954. * @returns a Uint8Array containing RGBA colors
  34955. */
  34956. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  34957. private static _isSupported;
  34958. /**
  34959. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  34960. * @returns true if the engine can be created
  34961. * @ignorenaming
  34962. */
  34963. static isSupported(): boolean;
  34964. /**
  34965. * Find the next highest power of two.
  34966. * @param x Number to start search from.
  34967. * @return Next highest power of two.
  34968. */
  34969. static CeilingPOT(x: number): number;
  34970. /**
  34971. * Find the next lowest power of two.
  34972. * @param x Number to start search from.
  34973. * @return Next lowest power of two.
  34974. */
  34975. static FloorPOT(x: number): number;
  34976. /**
  34977. * Find the nearest power of two.
  34978. * @param x Number to start search from.
  34979. * @return Next nearest power of two.
  34980. */
  34981. static NearestPOT(x: number): number;
  34982. /**
  34983. * Get the closest exponent of two
  34984. * @param value defines the value to approximate
  34985. * @param max defines the maximum value to return
  34986. * @param mode defines how to define the closest value
  34987. * @returns closest exponent of two of the given value
  34988. */
  34989. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  34990. /**
  34991. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  34992. * @param func - the function to be called
  34993. * @param requester - the object that will request the next frame. Falls back to window.
  34994. * @returns frame number
  34995. */
  34996. static QueueNewFrame(func: () => void, requester?: any): number;
  34997. /**
  34998. * Gets host document
  34999. * @returns the host document object
  35000. */
  35001. getHostDocument(): Nullable<Document>;
  35002. }
  35003. }
  35004. declare module BABYLON {
  35005. /**
  35006. * Class representing spherical harmonics coefficients to the 3rd degree
  35007. */
  35008. export class SphericalHarmonics {
  35009. /**
  35010. * Defines whether or not the harmonics have been prescaled for rendering.
  35011. */
  35012. preScaled: boolean;
  35013. /**
  35014. * The l0,0 coefficients of the spherical harmonics
  35015. */
  35016. l00: Vector3;
  35017. /**
  35018. * The l1,-1 coefficients of the spherical harmonics
  35019. */
  35020. l1_1: Vector3;
  35021. /**
  35022. * The l1,0 coefficients of the spherical harmonics
  35023. */
  35024. l10: Vector3;
  35025. /**
  35026. * The l1,1 coefficients of the spherical harmonics
  35027. */
  35028. l11: Vector3;
  35029. /**
  35030. * The l2,-2 coefficients of the spherical harmonics
  35031. */
  35032. l2_2: Vector3;
  35033. /**
  35034. * The l2,-1 coefficients of the spherical harmonics
  35035. */
  35036. l2_1: Vector3;
  35037. /**
  35038. * The l2,0 coefficients of the spherical harmonics
  35039. */
  35040. l20: Vector3;
  35041. /**
  35042. * The l2,1 coefficients of the spherical harmonics
  35043. */
  35044. l21: Vector3;
  35045. /**
  35046. * The l2,2 coefficients of the spherical harmonics
  35047. */
  35048. l22: Vector3;
  35049. /**
  35050. * Adds a light to the spherical harmonics
  35051. * @param direction the direction of the light
  35052. * @param color the color of the light
  35053. * @param deltaSolidAngle the delta solid angle of the light
  35054. */
  35055. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  35056. /**
  35057. * Scales the spherical harmonics by the given amount
  35058. * @param scale the amount to scale
  35059. */
  35060. scaleInPlace(scale: number): void;
  35061. /**
  35062. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  35063. *
  35064. * ```
  35065. * E_lm = A_l * L_lm
  35066. * ```
  35067. *
  35068. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  35069. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  35070. * the scaling factors are given in equation 9.
  35071. */
  35072. convertIncidentRadianceToIrradiance(): void;
  35073. /**
  35074. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  35075. *
  35076. * ```
  35077. * L = (1/pi) * E * rho
  35078. * ```
  35079. *
  35080. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  35081. */
  35082. convertIrradianceToLambertianRadiance(): void;
  35083. /**
  35084. * Integrates the reconstruction coefficients directly in to the SH preventing further
  35085. * required operations at run time.
  35086. *
  35087. * This is simply done by scaling back the SH with Ylm constants parameter.
  35088. * The trigonometric part being applied by the shader at run time.
  35089. */
  35090. preScaleForRendering(): void;
  35091. /**
  35092. * Constructs a spherical harmonics from an array.
  35093. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  35094. * @returns the spherical harmonics
  35095. */
  35096. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  35097. /**
  35098. * Gets the spherical harmonics from polynomial
  35099. * @param polynomial the spherical polynomial
  35100. * @returns the spherical harmonics
  35101. */
  35102. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  35103. }
  35104. /**
  35105. * Class representing spherical polynomial coefficients to the 3rd degree
  35106. */
  35107. export class SphericalPolynomial {
  35108. private _harmonics;
  35109. /**
  35110. * The spherical harmonics used to create the polynomials.
  35111. */
  35112. get preScaledHarmonics(): SphericalHarmonics;
  35113. /**
  35114. * The x coefficients of the spherical polynomial
  35115. */
  35116. x: Vector3;
  35117. /**
  35118. * The y coefficients of the spherical polynomial
  35119. */
  35120. y: Vector3;
  35121. /**
  35122. * The z coefficients of the spherical polynomial
  35123. */
  35124. z: Vector3;
  35125. /**
  35126. * The xx coefficients of the spherical polynomial
  35127. */
  35128. xx: Vector3;
  35129. /**
  35130. * The yy coefficients of the spherical polynomial
  35131. */
  35132. yy: Vector3;
  35133. /**
  35134. * The zz coefficients of the spherical polynomial
  35135. */
  35136. zz: Vector3;
  35137. /**
  35138. * The xy coefficients of the spherical polynomial
  35139. */
  35140. xy: Vector3;
  35141. /**
  35142. * The yz coefficients of the spherical polynomial
  35143. */
  35144. yz: Vector3;
  35145. /**
  35146. * The zx coefficients of the spherical polynomial
  35147. */
  35148. zx: Vector3;
  35149. /**
  35150. * Adds an ambient color to the spherical polynomial
  35151. * @param color the color to add
  35152. */
  35153. addAmbient(color: Color3): void;
  35154. /**
  35155. * Scales the spherical polynomial by the given amount
  35156. * @param scale the amount to scale
  35157. */
  35158. scaleInPlace(scale: number): void;
  35159. /**
  35160. * Gets the spherical polynomial from harmonics
  35161. * @param harmonics the spherical harmonics
  35162. * @returns the spherical polynomial
  35163. */
  35164. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  35165. /**
  35166. * Constructs a spherical polynomial from an array.
  35167. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  35168. * @returns the spherical polynomial
  35169. */
  35170. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  35171. }
  35172. }
  35173. declare module BABYLON {
  35174. /**
  35175. * Defines the source of the internal texture
  35176. */
  35177. export enum InternalTextureSource {
  35178. /**
  35179. * The source of the texture data is unknown
  35180. */
  35181. Unknown = 0,
  35182. /**
  35183. * Texture data comes from an URL
  35184. */
  35185. Url = 1,
  35186. /**
  35187. * Texture data is only used for temporary storage
  35188. */
  35189. Temp = 2,
  35190. /**
  35191. * Texture data comes from raw data (ArrayBuffer)
  35192. */
  35193. Raw = 3,
  35194. /**
  35195. * Texture content is dynamic (video or dynamic texture)
  35196. */
  35197. Dynamic = 4,
  35198. /**
  35199. * Texture content is generated by rendering to it
  35200. */
  35201. RenderTarget = 5,
  35202. /**
  35203. * Texture content is part of a multi render target process
  35204. */
  35205. MultiRenderTarget = 6,
  35206. /**
  35207. * Texture data comes from a cube data file
  35208. */
  35209. Cube = 7,
  35210. /**
  35211. * Texture data comes from a raw cube data
  35212. */
  35213. CubeRaw = 8,
  35214. /**
  35215. * Texture data come from a prefiltered cube data file
  35216. */
  35217. CubePrefiltered = 9,
  35218. /**
  35219. * Texture content is raw 3D data
  35220. */
  35221. Raw3D = 10,
  35222. /**
  35223. * Texture content is raw 2D array data
  35224. */
  35225. Raw2DArray = 11,
  35226. /**
  35227. * Texture content is a depth texture
  35228. */
  35229. Depth = 12,
  35230. /**
  35231. * Texture data comes from a raw cube data encoded with RGBD
  35232. */
  35233. CubeRawRGBD = 13
  35234. }
  35235. /**
  35236. * Class used to store data associated with WebGL texture data for the engine
  35237. * This class should not be used directly
  35238. */
  35239. export class InternalTexture {
  35240. /** @hidden */
  35241. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  35242. /**
  35243. * Defines if the texture is ready
  35244. */
  35245. isReady: boolean;
  35246. /**
  35247. * Defines if the texture is a cube texture
  35248. */
  35249. isCube: boolean;
  35250. /**
  35251. * Defines if the texture contains 3D data
  35252. */
  35253. is3D: boolean;
  35254. /**
  35255. * Defines if the texture contains 2D array data
  35256. */
  35257. is2DArray: boolean;
  35258. /**
  35259. * Defines if the texture contains multiview data
  35260. */
  35261. isMultiview: boolean;
  35262. /**
  35263. * Gets the URL used to load this texture
  35264. */
  35265. url: string;
  35266. /**
  35267. * Gets the sampling mode of the texture
  35268. */
  35269. samplingMode: number;
  35270. /**
  35271. * Gets a boolean indicating if the texture needs mipmaps generation
  35272. */
  35273. generateMipMaps: boolean;
  35274. /**
  35275. * Gets the number of samples used by the texture (WebGL2+ only)
  35276. */
  35277. samples: number;
  35278. /**
  35279. * Gets the type of the texture (int, float...)
  35280. */
  35281. type: number;
  35282. /**
  35283. * Gets the format of the texture (RGB, RGBA...)
  35284. */
  35285. format: number;
  35286. /**
  35287. * Observable called when the texture is loaded
  35288. */
  35289. onLoadedObservable: Observable<InternalTexture>;
  35290. /**
  35291. * Gets the width of the texture
  35292. */
  35293. width: number;
  35294. /**
  35295. * Gets the height of the texture
  35296. */
  35297. height: number;
  35298. /**
  35299. * Gets the depth of the texture
  35300. */
  35301. depth: number;
  35302. /**
  35303. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  35304. */
  35305. baseWidth: number;
  35306. /**
  35307. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  35308. */
  35309. baseHeight: number;
  35310. /**
  35311. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  35312. */
  35313. baseDepth: number;
  35314. /**
  35315. * Gets a boolean indicating if the texture is inverted on Y axis
  35316. */
  35317. invertY: boolean;
  35318. /** @hidden */
  35319. _invertVScale: boolean;
  35320. /** @hidden */
  35321. _associatedChannel: number;
  35322. /** @hidden */
  35323. _source: InternalTextureSource;
  35324. /** @hidden */
  35325. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  35326. /** @hidden */
  35327. _bufferView: Nullable<ArrayBufferView>;
  35328. /** @hidden */
  35329. _bufferViewArray: Nullable<ArrayBufferView[]>;
  35330. /** @hidden */
  35331. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  35332. /** @hidden */
  35333. _size: number;
  35334. /** @hidden */
  35335. _extension: string;
  35336. /** @hidden */
  35337. _files: Nullable<string[]>;
  35338. /** @hidden */
  35339. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  35340. /** @hidden */
  35341. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  35342. /** @hidden */
  35343. _framebuffer: Nullable<WebGLFramebuffer>;
  35344. /** @hidden */
  35345. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  35346. /** @hidden */
  35347. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  35348. /** @hidden */
  35349. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  35350. /** @hidden */
  35351. _attachments: Nullable<number[]>;
  35352. /** @hidden */
  35353. _cachedCoordinatesMode: Nullable<number>;
  35354. /** @hidden */
  35355. _cachedWrapU: Nullable<number>;
  35356. /** @hidden */
  35357. _cachedWrapV: Nullable<number>;
  35358. /** @hidden */
  35359. _cachedWrapR: Nullable<number>;
  35360. /** @hidden */
  35361. _cachedAnisotropicFilteringLevel: Nullable<number>;
  35362. /** @hidden */
  35363. _isDisabled: boolean;
  35364. /** @hidden */
  35365. _compression: Nullable<string>;
  35366. /** @hidden */
  35367. _generateStencilBuffer: boolean;
  35368. /** @hidden */
  35369. _generateDepthBuffer: boolean;
  35370. /** @hidden */
  35371. _comparisonFunction: number;
  35372. /** @hidden */
  35373. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  35374. /** @hidden */
  35375. _lodGenerationScale: number;
  35376. /** @hidden */
  35377. _lodGenerationOffset: number;
  35378. /** @hidden */
  35379. _depthStencilTexture: Nullable<InternalTexture>;
  35380. /** @hidden */
  35381. _colorTextureArray: Nullable<WebGLTexture>;
  35382. /** @hidden */
  35383. _depthStencilTextureArray: Nullable<WebGLTexture>;
  35384. /** @hidden */
  35385. _lodTextureHigh: Nullable<BaseTexture>;
  35386. /** @hidden */
  35387. _lodTextureMid: Nullable<BaseTexture>;
  35388. /** @hidden */
  35389. _lodTextureLow: Nullable<BaseTexture>;
  35390. /** @hidden */
  35391. _isRGBD: boolean;
  35392. /** @hidden */
  35393. _linearSpecularLOD: boolean;
  35394. /** @hidden */
  35395. _irradianceTexture: Nullable<BaseTexture>;
  35396. /** @hidden */
  35397. _webGLTexture: Nullable<WebGLTexture>;
  35398. /** @hidden */
  35399. _references: number;
  35400. private _engine;
  35401. /**
  35402. * Gets the Engine the texture belongs to.
  35403. * @returns The babylon engine
  35404. */
  35405. getEngine(): ThinEngine;
  35406. /**
  35407. * Gets the data source type of the texture
  35408. */
  35409. get source(): InternalTextureSource;
  35410. /**
  35411. * Creates a new InternalTexture
  35412. * @param engine defines the engine to use
  35413. * @param source defines the type of data that will be used
  35414. * @param delayAllocation if the texture allocation should be delayed (default: false)
  35415. */
  35416. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  35417. /**
  35418. * Increments the number of references (ie. the number of Texture that point to it)
  35419. */
  35420. incrementReferences(): void;
  35421. /**
  35422. * Change the size of the texture (not the size of the content)
  35423. * @param width defines the new width
  35424. * @param height defines the new height
  35425. * @param depth defines the new depth (1 by default)
  35426. */
  35427. updateSize(width: int, height: int, depth?: int): void;
  35428. /** @hidden */
  35429. _rebuild(): void;
  35430. /** @hidden */
  35431. _swapAndDie(target: InternalTexture): void;
  35432. /**
  35433. * Dispose the current allocated resources
  35434. */
  35435. dispose(): void;
  35436. }
  35437. }
  35438. declare module BABYLON {
  35439. /**
  35440. * Class used to work with sound analyzer using fast fourier transform (FFT)
  35441. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35442. */
  35443. export class Analyser {
  35444. /**
  35445. * Gets or sets the smoothing
  35446. * @ignorenaming
  35447. */
  35448. SMOOTHING: number;
  35449. /**
  35450. * Gets or sets the FFT table size
  35451. * @ignorenaming
  35452. */
  35453. FFT_SIZE: number;
  35454. /**
  35455. * Gets or sets the bar graph amplitude
  35456. * @ignorenaming
  35457. */
  35458. BARGRAPHAMPLITUDE: number;
  35459. /**
  35460. * Gets or sets the position of the debug canvas
  35461. * @ignorenaming
  35462. */
  35463. DEBUGCANVASPOS: {
  35464. x: number;
  35465. y: number;
  35466. };
  35467. /**
  35468. * Gets or sets the debug canvas size
  35469. * @ignorenaming
  35470. */
  35471. DEBUGCANVASSIZE: {
  35472. width: number;
  35473. height: number;
  35474. };
  35475. private _byteFreqs;
  35476. private _byteTime;
  35477. private _floatFreqs;
  35478. private _webAudioAnalyser;
  35479. private _debugCanvas;
  35480. private _debugCanvasContext;
  35481. private _scene;
  35482. private _registerFunc;
  35483. private _audioEngine;
  35484. /**
  35485. * Creates a new analyser
  35486. * @param scene defines hosting scene
  35487. */
  35488. constructor(scene: Scene);
  35489. /**
  35490. * Get the number of data values you will have to play with for the visualization
  35491. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  35492. * @returns a number
  35493. */
  35494. getFrequencyBinCount(): number;
  35495. /**
  35496. * Gets the current frequency data as a byte array
  35497. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  35498. * @returns a Uint8Array
  35499. */
  35500. getByteFrequencyData(): Uint8Array;
  35501. /**
  35502. * Gets the current waveform as a byte array
  35503. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  35504. * @returns a Uint8Array
  35505. */
  35506. getByteTimeDomainData(): Uint8Array;
  35507. /**
  35508. * Gets the current frequency data as a float array
  35509. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  35510. * @returns a Float32Array
  35511. */
  35512. getFloatFrequencyData(): Float32Array;
  35513. /**
  35514. * Renders the debug canvas
  35515. */
  35516. drawDebugCanvas(): void;
  35517. /**
  35518. * Stops rendering the debug canvas and removes it
  35519. */
  35520. stopDebugCanvas(): void;
  35521. /**
  35522. * Connects two audio nodes
  35523. * @param inputAudioNode defines first node to connect
  35524. * @param outputAudioNode defines second node to connect
  35525. */
  35526. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  35527. /**
  35528. * Releases all associated resources
  35529. */
  35530. dispose(): void;
  35531. }
  35532. }
  35533. declare module BABYLON {
  35534. /**
  35535. * This represents an audio engine and it is responsible
  35536. * to play, synchronize and analyse sounds throughout the application.
  35537. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35538. */
  35539. export interface IAudioEngine extends IDisposable {
  35540. /**
  35541. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  35542. */
  35543. readonly canUseWebAudio: boolean;
  35544. /**
  35545. * Gets the current AudioContext if available.
  35546. */
  35547. readonly audioContext: Nullable<AudioContext>;
  35548. /**
  35549. * The master gain node defines the global audio volume of your audio engine.
  35550. */
  35551. readonly masterGain: GainNode;
  35552. /**
  35553. * Gets whether or not mp3 are supported by your browser.
  35554. */
  35555. readonly isMP3supported: boolean;
  35556. /**
  35557. * Gets whether or not ogg are supported by your browser.
  35558. */
  35559. readonly isOGGsupported: boolean;
  35560. /**
  35561. * Defines if Babylon should emit a warning if WebAudio is not supported.
  35562. * @ignoreNaming
  35563. */
  35564. WarnedWebAudioUnsupported: boolean;
  35565. /**
  35566. * Defines if the audio engine relies on a custom unlocked button.
  35567. * In this case, the embedded button will not be displayed.
  35568. */
  35569. useCustomUnlockedButton: boolean;
  35570. /**
  35571. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  35572. */
  35573. readonly unlocked: boolean;
  35574. /**
  35575. * Event raised when audio has been unlocked on the browser.
  35576. */
  35577. onAudioUnlockedObservable: Observable<AudioEngine>;
  35578. /**
  35579. * Event raised when audio has been locked on the browser.
  35580. */
  35581. onAudioLockedObservable: Observable<AudioEngine>;
  35582. /**
  35583. * Flags the audio engine in Locked state.
  35584. * This happens due to new browser policies preventing audio to autoplay.
  35585. */
  35586. lock(): void;
  35587. /**
  35588. * Unlocks the audio engine once a user action has been done on the dom.
  35589. * This is helpful to resume play once browser policies have been satisfied.
  35590. */
  35591. unlock(): void;
  35592. /**
  35593. * Gets the global volume sets on the master gain.
  35594. * @returns the global volume if set or -1 otherwise
  35595. */
  35596. getGlobalVolume(): number;
  35597. /**
  35598. * Sets the global volume of your experience (sets on the master gain).
  35599. * @param newVolume Defines the new global volume of the application
  35600. */
  35601. setGlobalVolume(newVolume: number): void;
  35602. /**
  35603. * Connect the audio engine to an audio analyser allowing some amazing
  35604. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35605. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35606. * @param analyser The analyser to connect to the engine
  35607. */
  35608. connectToAnalyser(analyser: Analyser): void;
  35609. }
  35610. /**
  35611. * This represents the default audio engine used in babylon.
  35612. * It is responsible to play, synchronize and analyse sounds throughout the application.
  35613. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35614. */
  35615. export class AudioEngine implements IAudioEngine {
  35616. private _audioContext;
  35617. private _audioContextInitialized;
  35618. private _muteButton;
  35619. private _hostElement;
  35620. /**
  35621. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  35622. */
  35623. canUseWebAudio: boolean;
  35624. /**
  35625. * The master gain node defines the global audio volume of your audio engine.
  35626. */
  35627. masterGain: GainNode;
  35628. /**
  35629. * Defines if Babylon should emit a warning if WebAudio is not supported.
  35630. * @ignoreNaming
  35631. */
  35632. WarnedWebAudioUnsupported: boolean;
  35633. /**
  35634. * Gets whether or not mp3 are supported by your browser.
  35635. */
  35636. isMP3supported: boolean;
  35637. /**
  35638. * Gets whether or not ogg are supported by your browser.
  35639. */
  35640. isOGGsupported: boolean;
  35641. /**
  35642. * Gets whether audio has been unlocked on the device.
  35643. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  35644. * a user interaction has happened.
  35645. */
  35646. unlocked: boolean;
  35647. /**
  35648. * Defines if the audio engine relies on a custom unlocked button.
  35649. * In this case, the embedded button will not be displayed.
  35650. */
  35651. useCustomUnlockedButton: boolean;
  35652. /**
  35653. * Event raised when audio has been unlocked on the browser.
  35654. */
  35655. onAudioUnlockedObservable: Observable<AudioEngine>;
  35656. /**
  35657. * Event raised when audio has been locked on the browser.
  35658. */
  35659. onAudioLockedObservable: Observable<AudioEngine>;
  35660. /**
  35661. * Gets the current AudioContext if available.
  35662. */
  35663. get audioContext(): Nullable<AudioContext>;
  35664. private _connectedAnalyser;
  35665. /**
  35666. * Instantiates a new audio engine.
  35667. *
  35668. * There should be only one per page as some browsers restrict the number
  35669. * of audio contexts you can create.
  35670. * @param hostElement defines the host element where to display the mute icon if necessary
  35671. */
  35672. constructor(hostElement?: Nullable<HTMLElement>);
  35673. /**
  35674. * Flags the audio engine in Locked state.
  35675. * This happens due to new browser policies preventing audio to autoplay.
  35676. */
  35677. lock(): void;
  35678. /**
  35679. * Unlocks the audio engine once a user action has been done on the dom.
  35680. * This is helpful to resume play once browser policies have been satisfied.
  35681. */
  35682. unlock(): void;
  35683. private _resumeAudioContext;
  35684. private _initializeAudioContext;
  35685. private _tryToRun;
  35686. private _triggerRunningState;
  35687. private _triggerSuspendedState;
  35688. private _displayMuteButton;
  35689. private _moveButtonToTopLeft;
  35690. private _onResize;
  35691. private _hideMuteButton;
  35692. /**
  35693. * Destroy and release the resources associated with the audio ccontext.
  35694. */
  35695. dispose(): void;
  35696. /**
  35697. * Gets the global volume sets on the master gain.
  35698. * @returns the global volume if set or -1 otherwise
  35699. */
  35700. getGlobalVolume(): number;
  35701. /**
  35702. * Sets the global volume of your experience (sets on the master gain).
  35703. * @param newVolume Defines the new global volume of the application
  35704. */
  35705. setGlobalVolume(newVolume: number): void;
  35706. /**
  35707. * Connect the audio engine to an audio analyser allowing some amazing
  35708. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35709. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35710. * @param analyser The analyser to connect to the engine
  35711. */
  35712. connectToAnalyser(analyser: Analyser): void;
  35713. }
  35714. }
  35715. declare module BABYLON {
  35716. /**
  35717. * Interface used to present a loading screen while loading a scene
  35718. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35719. */
  35720. export interface ILoadingScreen {
  35721. /**
  35722. * Function called to display the loading screen
  35723. */
  35724. displayLoadingUI: () => void;
  35725. /**
  35726. * Function called to hide the loading screen
  35727. */
  35728. hideLoadingUI: () => void;
  35729. /**
  35730. * Gets or sets the color to use for the background
  35731. */
  35732. loadingUIBackgroundColor: string;
  35733. /**
  35734. * Gets or sets the text to display while loading
  35735. */
  35736. loadingUIText: string;
  35737. }
  35738. /**
  35739. * Class used for the default loading screen
  35740. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35741. */
  35742. export class DefaultLoadingScreen implements ILoadingScreen {
  35743. private _renderingCanvas;
  35744. private _loadingText;
  35745. private _loadingDivBackgroundColor;
  35746. private _loadingDiv;
  35747. private _loadingTextDiv;
  35748. /** Gets or sets the logo url to use for the default loading screen */
  35749. static DefaultLogoUrl: string;
  35750. /** Gets or sets the spinner url to use for the default loading screen */
  35751. static DefaultSpinnerUrl: string;
  35752. /**
  35753. * Creates a new default loading screen
  35754. * @param _renderingCanvas defines the canvas used to render the scene
  35755. * @param _loadingText defines the default text to display
  35756. * @param _loadingDivBackgroundColor defines the default background color
  35757. */
  35758. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  35759. /**
  35760. * Function called to display the loading screen
  35761. */
  35762. displayLoadingUI(): void;
  35763. /**
  35764. * Function called to hide the loading screen
  35765. */
  35766. hideLoadingUI(): void;
  35767. /**
  35768. * Gets or sets the text to display while loading
  35769. */
  35770. set loadingUIText(text: string);
  35771. get loadingUIText(): string;
  35772. /**
  35773. * Gets or sets the color to use for the background
  35774. */
  35775. get loadingUIBackgroundColor(): string;
  35776. set loadingUIBackgroundColor(color: string);
  35777. private _resizeLoadingUI;
  35778. }
  35779. }
  35780. declare module BABYLON {
  35781. /**
  35782. * Interface for any object that can request an animation frame
  35783. */
  35784. export interface ICustomAnimationFrameRequester {
  35785. /**
  35786. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  35787. */
  35788. renderFunction?: Function;
  35789. /**
  35790. * Called to request the next frame to render to
  35791. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  35792. */
  35793. requestAnimationFrame: Function;
  35794. /**
  35795. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  35796. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  35797. */
  35798. requestID?: number;
  35799. }
  35800. }
  35801. declare module BABYLON {
  35802. /**
  35803. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  35804. */
  35805. export class PerformanceMonitor {
  35806. private _enabled;
  35807. private _rollingFrameTime;
  35808. private _lastFrameTimeMs;
  35809. /**
  35810. * constructor
  35811. * @param frameSampleSize The number of samples required to saturate the sliding window
  35812. */
  35813. constructor(frameSampleSize?: number);
  35814. /**
  35815. * Samples current frame
  35816. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  35817. */
  35818. sampleFrame(timeMs?: number): void;
  35819. /**
  35820. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  35821. */
  35822. get averageFrameTime(): number;
  35823. /**
  35824. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  35825. */
  35826. get averageFrameTimeVariance(): number;
  35827. /**
  35828. * Returns the frame time of the most recent frame
  35829. */
  35830. get instantaneousFrameTime(): number;
  35831. /**
  35832. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  35833. */
  35834. get averageFPS(): number;
  35835. /**
  35836. * Returns the average framerate in frames per second using the most recent frame time
  35837. */
  35838. get instantaneousFPS(): number;
  35839. /**
  35840. * Returns true if enough samples have been taken to completely fill the sliding window
  35841. */
  35842. get isSaturated(): boolean;
  35843. /**
  35844. * Enables contributions to the sliding window sample set
  35845. */
  35846. enable(): void;
  35847. /**
  35848. * Disables contributions to the sliding window sample set
  35849. * Samples will not be interpolated over the disabled period
  35850. */
  35851. disable(): void;
  35852. /**
  35853. * Returns true if sampling is enabled
  35854. */
  35855. get isEnabled(): boolean;
  35856. /**
  35857. * Resets performance monitor
  35858. */
  35859. reset(): void;
  35860. }
  35861. /**
  35862. * RollingAverage
  35863. *
  35864. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  35865. */
  35866. export class RollingAverage {
  35867. /**
  35868. * Current average
  35869. */
  35870. average: number;
  35871. /**
  35872. * Current variance
  35873. */
  35874. variance: number;
  35875. protected _samples: Array<number>;
  35876. protected _sampleCount: number;
  35877. protected _pos: number;
  35878. protected _m2: number;
  35879. /**
  35880. * constructor
  35881. * @param length The number of samples required to saturate the sliding window
  35882. */
  35883. constructor(length: number);
  35884. /**
  35885. * Adds a sample to the sample set
  35886. * @param v The sample value
  35887. */
  35888. add(v: number): void;
  35889. /**
  35890. * Returns previously added values or null if outside of history or outside the sliding window domain
  35891. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  35892. * @return Value previously recorded with add() or null if outside of range
  35893. */
  35894. history(i: number): number;
  35895. /**
  35896. * Returns true if enough samples have been taken to completely fill the sliding window
  35897. * @return true if sample-set saturated
  35898. */
  35899. isSaturated(): boolean;
  35900. /**
  35901. * Resets the rolling average (equivalent to 0 samples taken so far)
  35902. */
  35903. reset(): void;
  35904. /**
  35905. * Wraps a value around the sample range boundaries
  35906. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  35907. * @return Wrapped position in sample range
  35908. */
  35909. protected _wrapPosition(i: number): number;
  35910. }
  35911. }
  35912. declare module BABYLON {
  35913. /**
  35914. * This class is used to track a performance counter which is number based.
  35915. * The user has access to many properties which give statistics of different nature.
  35916. *
  35917. * The implementer can track two kinds of Performance Counter: time and count.
  35918. * 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.
  35919. * 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.
  35920. */
  35921. export class PerfCounter {
  35922. /**
  35923. * Gets or sets a global boolean to turn on and off all the counters
  35924. */
  35925. static Enabled: boolean;
  35926. /**
  35927. * Returns the smallest value ever
  35928. */
  35929. get min(): number;
  35930. /**
  35931. * Returns the biggest value ever
  35932. */
  35933. get max(): number;
  35934. /**
  35935. * Returns the average value since the performance counter is running
  35936. */
  35937. get average(): number;
  35938. /**
  35939. * Returns the average value of the last second the counter was monitored
  35940. */
  35941. get lastSecAverage(): number;
  35942. /**
  35943. * Returns the current value
  35944. */
  35945. get current(): number;
  35946. /**
  35947. * Gets the accumulated total
  35948. */
  35949. get total(): number;
  35950. /**
  35951. * Gets the total value count
  35952. */
  35953. get count(): number;
  35954. /**
  35955. * Creates a new counter
  35956. */
  35957. constructor();
  35958. /**
  35959. * Call this method to start monitoring a new frame.
  35960. * 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.
  35961. */
  35962. fetchNewFrame(): void;
  35963. /**
  35964. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  35965. * @param newCount the count value to add to the monitored count
  35966. * @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.
  35967. */
  35968. addCount(newCount: number, fetchResult: boolean): void;
  35969. /**
  35970. * Start monitoring this performance counter
  35971. */
  35972. beginMonitoring(): void;
  35973. /**
  35974. * Compute the time lapsed since the previous beginMonitoring() call.
  35975. * @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
  35976. */
  35977. endMonitoring(newFrame?: boolean): void;
  35978. private _fetchResult;
  35979. private _startMonitoringTime;
  35980. private _min;
  35981. private _max;
  35982. private _average;
  35983. private _current;
  35984. private _totalValueCount;
  35985. private _totalAccumulated;
  35986. private _lastSecAverage;
  35987. private _lastSecAccumulated;
  35988. private _lastSecTime;
  35989. private _lastSecValueCount;
  35990. }
  35991. }
  35992. declare module BABYLON {
  35993. interface ThinEngine {
  35994. /**
  35995. * Sets alpha constants used by some alpha blending modes
  35996. * @param r defines the red component
  35997. * @param g defines the green component
  35998. * @param b defines the blue component
  35999. * @param a defines the alpha component
  36000. */
  36001. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  36002. /**
  36003. * Sets the current alpha mode
  36004. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  36005. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  36006. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  36007. */
  36008. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  36009. /**
  36010. * Gets the current alpha mode
  36011. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  36012. * @returns the current alpha mode
  36013. */
  36014. getAlphaMode(): number;
  36015. /**
  36016. * Sets the current alpha equation
  36017. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  36018. */
  36019. setAlphaEquation(equation: number): void;
  36020. /**
  36021. * Gets the current alpha equation.
  36022. * @returns the current alpha equation
  36023. */
  36024. getAlphaEquation(): number;
  36025. }
  36026. }
  36027. declare module BABYLON {
  36028. interface ThinEngine {
  36029. /** @hidden */
  36030. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  36031. }
  36032. }
  36033. declare module BABYLON {
  36034. /**
  36035. * Defines the interface used by display changed events
  36036. */
  36037. export interface IDisplayChangedEventArgs {
  36038. /** Gets the vrDisplay object (if any) */
  36039. vrDisplay: Nullable<any>;
  36040. /** Gets a boolean indicating if webVR is supported */
  36041. vrSupported: boolean;
  36042. }
  36043. /**
  36044. * Defines the interface used by objects containing a viewport (like a camera)
  36045. */
  36046. interface IViewportOwnerLike {
  36047. /**
  36048. * Gets or sets the viewport
  36049. */
  36050. viewport: IViewportLike;
  36051. }
  36052. /**
  36053. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  36054. */
  36055. export class Engine extends ThinEngine {
  36056. /** Defines that alpha blending is disabled */
  36057. static readonly ALPHA_DISABLE: number;
  36058. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  36059. static readonly ALPHA_ADD: number;
  36060. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  36061. static readonly ALPHA_COMBINE: number;
  36062. /** Defines that alpha blending to DEST - SRC * DEST */
  36063. static readonly ALPHA_SUBTRACT: number;
  36064. /** Defines that alpha blending to SRC * DEST */
  36065. static readonly ALPHA_MULTIPLY: number;
  36066. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  36067. static readonly ALPHA_MAXIMIZED: number;
  36068. /** Defines that alpha blending to SRC + DEST */
  36069. static readonly ALPHA_ONEONE: number;
  36070. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  36071. static readonly ALPHA_PREMULTIPLIED: number;
  36072. /**
  36073. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  36074. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  36075. */
  36076. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  36077. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  36078. static readonly ALPHA_INTERPOLATE: number;
  36079. /**
  36080. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  36081. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  36082. */
  36083. static readonly ALPHA_SCREENMODE: number;
  36084. /** Defines that the ressource is not delayed*/
  36085. static readonly DELAYLOADSTATE_NONE: number;
  36086. /** Defines that the ressource was successfully delay loaded */
  36087. static readonly DELAYLOADSTATE_LOADED: number;
  36088. /** Defines that the ressource is currently delay loading */
  36089. static readonly DELAYLOADSTATE_LOADING: number;
  36090. /** Defines that the ressource is delayed and has not started loading */
  36091. static readonly DELAYLOADSTATE_NOTLOADED: number;
  36092. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  36093. static readonly NEVER: number;
  36094. /** 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 */
  36095. static readonly ALWAYS: number;
  36096. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  36097. static readonly LESS: number;
  36098. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  36099. static readonly EQUAL: number;
  36100. /** 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 */
  36101. static readonly LEQUAL: number;
  36102. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  36103. static readonly GREATER: number;
  36104. /** 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 */
  36105. static readonly GEQUAL: number;
  36106. /** 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 */
  36107. static readonly NOTEQUAL: number;
  36108. /** Passed to stencilOperation to specify that stencil value must be kept */
  36109. static readonly KEEP: number;
  36110. /** Passed to stencilOperation to specify that stencil value must be replaced */
  36111. static readonly REPLACE: number;
  36112. /** Passed to stencilOperation to specify that stencil value must be incremented */
  36113. static readonly INCR: number;
  36114. /** Passed to stencilOperation to specify that stencil value must be decremented */
  36115. static readonly DECR: number;
  36116. /** Passed to stencilOperation to specify that stencil value must be inverted */
  36117. static readonly INVERT: number;
  36118. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  36119. static readonly INCR_WRAP: number;
  36120. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  36121. static readonly DECR_WRAP: number;
  36122. /** Texture is not repeating outside of 0..1 UVs */
  36123. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  36124. /** Texture is repeating outside of 0..1 UVs */
  36125. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  36126. /** Texture is repeating and mirrored */
  36127. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  36128. /** ALPHA */
  36129. static readonly TEXTUREFORMAT_ALPHA: number;
  36130. /** LUMINANCE */
  36131. static readonly TEXTUREFORMAT_LUMINANCE: number;
  36132. /** LUMINANCE_ALPHA */
  36133. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  36134. /** RGB */
  36135. static readonly TEXTUREFORMAT_RGB: number;
  36136. /** RGBA */
  36137. static readonly TEXTUREFORMAT_RGBA: number;
  36138. /** RED */
  36139. static readonly TEXTUREFORMAT_RED: number;
  36140. /** RED (2nd reference) */
  36141. static readonly TEXTUREFORMAT_R: number;
  36142. /** RG */
  36143. static readonly TEXTUREFORMAT_RG: number;
  36144. /** RED_INTEGER */
  36145. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  36146. /** RED_INTEGER (2nd reference) */
  36147. static readonly TEXTUREFORMAT_R_INTEGER: number;
  36148. /** RG_INTEGER */
  36149. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  36150. /** RGB_INTEGER */
  36151. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  36152. /** RGBA_INTEGER */
  36153. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  36154. /** UNSIGNED_BYTE */
  36155. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  36156. /** UNSIGNED_BYTE (2nd reference) */
  36157. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  36158. /** FLOAT */
  36159. static readonly TEXTURETYPE_FLOAT: number;
  36160. /** HALF_FLOAT */
  36161. static readonly TEXTURETYPE_HALF_FLOAT: number;
  36162. /** BYTE */
  36163. static readonly TEXTURETYPE_BYTE: number;
  36164. /** SHORT */
  36165. static readonly TEXTURETYPE_SHORT: number;
  36166. /** UNSIGNED_SHORT */
  36167. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  36168. /** INT */
  36169. static readonly TEXTURETYPE_INT: number;
  36170. /** UNSIGNED_INT */
  36171. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  36172. /** UNSIGNED_SHORT_4_4_4_4 */
  36173. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  36174. /** UNSIGNED_SHORT_5_5_5_1 */
  36175. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  36176. /** UNSIGNED_SHORT_5_6_5 */
  36177. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  36178. /** UNSIGNED_INT_2_10_10_10_REV */
  36179. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  36180. /** UNSIGNED_INT_24_8 */
  36181. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  36182. /** UNSIGNED_INT_10F_11F_11F_REV */
  36183. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  36184. /** UNSIGNED_INT_5_9_9_9_REV */
  36185. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  36186. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  36187. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  36188. /** nearest is mag = nearest and min = nearest and mip = linear */
  36189. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  36190. /** Bilinear is mag = linear and min = linear and mip = nearest */
  36191. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  36192. /** Trilinear is mag = linear and min = linear and mip = linear */
  36193. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  36194. /** nearest is mag = nearest and min = nearest and mip = linear */
  36195. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  36196. /** Bilinear is mag = linear and min = linear and mip = nearest */
  36197. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  36198. /** Trilinear is mag = linear and min = linear and mip = linear */
  36199. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  36200. /** mag = nearest and min = nearest and mip = nearest */
  36201. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  36202. /** mag = nearest and min = linear and mip = nearest */
  36203. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  36204. /** mag = nearest and min = linear and mip = linear */
  36205. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  36206. /** mag = nearest and min = linear and mip = none */
  36207. static readonly TEXTURE_NEAREST_LINEAR: number;
  36208. /** mag = nearest and min = nearest and mip = none */
  36209. static readonly TEXTURE_NEAREST_NEAREST: number;
  36210. /** mag = linear and min = nearest and mip = nearest */
  36211. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  36212. /** mag = linear and min = nearest and mip = linear */
  36213. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  36214. /** mag = linear and min = linear and mip = none */
  36215. static readonly TEXTURE_LINEAR_LINEAR: number;
  36216. /** mag = linear and min = nearest and mip = none */
  36217. static readonly TEXTURE_LINEAR_NEAREST: number;
  36218. /** Explicit coordinates mode */
  36219. static readonly TEXTURE_EXPLICIT_MODE: number;
  36220. /** Spherical coordinates mode */
  36221. static readonly TEXTURE_SPHERICAL_MODE: number;
  36222. /** Planar coordinates mode */
  36223. static readonly TEXTURE_PLANAR_MODE: number;
  36224. /** Cubic coordinates mode */
  36225. static readonly TEXTURE_CUBIC_MODE: number;
  36226. /** Projection coordinates mode */
  36227. static readonly TEXTURE_PROJECTION_MODE: number;
  36228. /** Skybox coordinates mode */
  36229. static readonly TEXTURE_SKYBOX_MODE: number;
  36230. /** Inverse Cubic coordinates mode */
  36231. static readonly TEXTURE_INVCUBIC_MODE: number;
  36232. /** Equirectangular coordinates mode */
  36233. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  36234. /** Equirectangular Fixed coordinates mode */
  36235. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  36236. /** Equirectangular Fixed Mirrored coordinates mode */
  36237. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  36238. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  36239. static readonly SCALEMODE_FLOOR: number;
  36240. /** Defines that texture rescaling will look for the nearest power of 2 size */
  36241. static readonly SCALEMODE_NEAREST: number;
  36242. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  36243. static readonly SCALEMODE_CEILING: number;
  36244. /**
  36245. * Returns the current npm package of the sdk
  36246. */
  36247. static get NpmPackage(): string;
  36248. /**
  36249. * Returns the current version of the framework
  36250. */
  36251. static get Version(): string;
  36252. /** Gets the list of created engines */
  36253. static get Instances(): Engine[];
  36254. /**
  36255. * Gets the latest created engine
  36256. */
  36257. static get LastCreatedEngine(): Nullable<Engine>;
  36258. /**
  36259. * Gets the latest created scene
  36260. */
  36261. static get LastCreatedScene(): Nullable<Scene>;
  36262. /**
  36263. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  36264. * @param flag defines which part of the materials must be marked as dirty
  36265. * @param predicate defines a predicate used to filter which materials should be affected
  36266. */
  36267. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  36268. /**
  36269. * Method called to create the default loading screen.
  36270. * This can be overriden in your own app.
  36271. * @param canvas The rendering canvas element
  36272. * @returns The loading screen
  36273. */
  36274. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  36275. /**
  36276. * Method called to create the default rescale post process on each engine.
  36277. */
  36278. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  36279. /**
  36280. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  36281. **/
  36282. enableOfflineSupport: boolean;
  36283. /**
  36284. * 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)
  36285. **/
  36286. disableManifestCheck: boolean;
  36287. /**
  36288. * Gets the list of created scenes
  36289. */
  36290. scenes: Scene[];
  36291. /**
  36292. * Event raised when a new scene is created
  36293. */
  36294. onNewSceneAddedObservable: Observable<Scene>;
  36295. /**
  36296. * Gets the list of created postprocesses
  36297. */
  36298. postProcesses: PostProcess[];
  36299. /**
  36300. * Gets a boolean indicating if the pointer is currently locked
  36301. */
  36302. isPointerLock: boolean;
  36303. /**
  36304. * Observable event triggered each time the rendering canvas is resized
  36305. */
  36306. onResizeObservable: Observable<Engine>;
  36307. /**
  36308. * Observable event triggered each time the canvas loses focus
  36309. */
  36310. onCanvasBlurObservable: Observable<Engine>;
  36311. /**
  36312. * Observable event triggered each time the canvas gains focus
  36313. */
  36314. onCanvasFocusObservable: Observable<Engine>;
  36315. /**
  36316. * Observable event triggered each time the canvas receives pointerout event
  36317. */
  36318. onCanvasPointerOutObservable: Observable<PointerEvent>;
  36319. /**
  36320. * Observable raised when the engine begins a new frame
  36321. */
  36322. onBeginFrameObservable: Observable<Engine>;
  36323. /**
  36324. * If set, will be used to request the next animation frame for the render loop
  36325. */
  36326. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  36327. /**
  36328. * Observable raised when the engine ends the current frame
  36329. */
  36330. onEndFrameObservable: Observable<Engine>;
  36331. /**
  36332. * Observable raised when the engine is about to compile a shader
  36333. */
  36334. onBeforeShaderCompilationObservable: Observable<Engine>;
  36335. /**
  36336. * Observable raised when the engine has jsut compiled a shader
  36337. */
  36338. onAfterShaderCompilationObservable: Observable<Engine>;
  36339. /**
  36340. * Gets the audio engine
  36341. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36342. * @ignorenaming
  36343. */
  36344. static audioEngine: IAudioEngine;
  36345. /**
  36346. * Default AudioEngine factory responsible of creating the Audio Engine.
  36347. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  36348. */
  36349. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  36350. /**
  36351. * Default offline support factory responsible of creating a tool used to store data locally.
  36352. * By default, this will create a Database object if the workload has been embedded.
  36353. */
  36354. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  36355. private _loadingScreen;
  36356. private _pointerLockRequested;
  36357. private _rescalePostProcess;
  36358. private _deterministicLockstep;
  36359. private _lockstepMaxSteps;
  36360. private _timeStep;
  36361. protected get _supportsHardwareTextureRescaling(): boolean;
  36362. private _fps;
  36363. private _deltaTime;
  36364. /** @hidden */
  36365. _drawCalls: PerfCounter;
  36366. /** Gets or sets the tab index to set to the rendering canvas. 1 is the minimum value to set to be able to capture keyboard events */
  36367. canvasTabIndex: number;
  36368. /**
  36369. * Turn this value on if you want to pause FPS computation when in background
  36370. */
  36371. disablePerformanceMonitorInBackground: boolean;
  36372. private _performanceMonitor;
  36373. /**
  36374. * Gets the performance monitor attached to this engine
  36375. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  36376. */
  36377. get performanceMonitor(): PerformanceMonitor;
  36378. private _onFocus;
  36379. private _onBlur;
  36380. private _onCanvasPointerOut;
  36381. private _onCanvasBlur;
  36382. private _onCanvasFocus;
  36383. private _onFullscreenChange;
  36384. private _onPointerLockChange;
  36385. /**
  36386. * Gets the HTML element used to attach event listeners
  36387. * @returns a HTML element
  36388. */
  36389. getInputElement(): Nullable<HTMLElement>;
  36390. /**
  36391. * Creates a new engine
  36392. * @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
  36393. * @param antialias defines enable antialiasing (default: false)
  36394. * @param options defines further options to be sent to the getContext() function
  36395. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  36396. */
  36397. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  36398. /**
  36399. * Gets current aspect ratio
  36400. * @param viewportOwner defines the camera to use to get the aspect ratio
  36401. * @param useScreen defines if screen size must be used (or the current render target if any)
  36402. * @returns a number defining the aspect ratio
  36403. */
  36404. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  36405. /**
  36406. * Gets current screen aspect ratio
  36407. * @returns a number defining the aspect ratio
  36408. */
  36409. getScreenAspectRatio(): number;
  36410. /**
  36411. * Gets the client rect of the HTML canvas attached with the current webGL context
  36412. * @returns a client rectanglee
  36413. */
  36414. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  36415. /**
  36416. * Gets the client rect of the HTML element used for events
  36417. * @returns a client rectanglee
  36418. */
  36419. getInputElementClientRect(): Nullable<ClientRect>;
  36420. /**
  36421. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  36422. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36423. * @returns true if engine is in deterministic lock step mode
  36424. */
  36425. isDeterministicLockStep(): boolean;
  36426. /**
  36427. * Gets the max steps when engine is running in deterministic lock step
  36428. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36429. * @returns the max steps
  36430. */
  36431. getLockstepMaxSteps(): number;
  36432. /**
  36433. * Returns the time in ms between steps when using deterministic lock step.
  36434. * @returns time step in (ms)
  36435. */
  36436. getTimeStep(): number;
  36437. /**
  36438. * Force the mipmap generation for the given render target texture
  36439. * @param texture defines the render target texture to use
  36440. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  36441. */
  36442. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  36443. /** States */
  36444. /**
  36445. * Set various states to the webGL context
  36446. * @param culling defines backface culling state
  36447. * @param zOffset defines the value to apply to zOffset (0 by default)
  36448. * @param force defines if states must be applied even if cache is up to date
  36449. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  36450. */
  36451. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  36452. /**
  36453. * Set the z offset to apply to current rendering
  36454. * @param value defines the offset to apply
  36455. */
  36456. setZOffset(value: number): void;
  36457. /**
  36458. * Gets the current value of the zOffset
  36459. * @returns the current zOffset state
  36460. */
  36461. getZOffset(): number;
  36462. /**
  36463. * Enable or disable depth buffering
  36464. * @param enable defines the state to set
  36465. */
  36466. setDepthBuffer(enable: boolean): void;
  36467. /**
  36468. * Gets a boolean indicating if depth writing is enabled
  36469. * @returns the current depth writing state
  36470. */
  36471. getDepthWrite(): boolean;
  36472. /**
  36473. * Enable or disable depth writing
  36474. * @param enable defines the state to set
  36475. */
  36476. setDepthWrite(enable: boolean): void;
  36477. /**
  36478. * Gets a boolean indicating if stencil buffer is enabled
  36479. * @returns the current stencil buffer state
  36480. */
  36481. getStencilBuffer(): boolean;
  36482. /**
  36483. * Enable or disable the stencil buffer
  36484. * @param enable defines if the stencil buffer must be enabled or disabled
  36485. */
  36486. setStencilBuffer(enable: boolean): void;
  36487. /**
  36488. * Gets the current stencil mask
  36489. * @returns a number defining the new stencil mask to use
  36490. */
  36491. getStencilMask(): number;
  36492. /**
  36493. * Sets the current stencil mask
  36494. * @param mask defines the new stencil mask to use
  36495. */
  36496. setStencilMask(mask: number): void;
  36497. /**
  36498. * Gets the current stencil function
  36499. * @returns a number defining the stencil function to use
  36500. */
  36501. getStencilFunction(): number;
  36502. /**
  36503. * Gets the current stencil reference value
  36504. * @returns a number defining the stencil reference value to use
  36505. */
  36506. getStencilFunctionReference(): number;
  36507. /**
  36508. * Gets the current stencil mask
  36509. * @returns a number defining the stencil mask to use
  36510. */
  36511. getStencilFunctionMask(): number;
  36512. /**
  36513. * Sets the current stencil function
  36514. * @param stencilFunc defines the new stencil function to use
  36515. */
  36516. setStencilFunction(stencilFunc: number): void;
  36517. /**
  36518. * Sets the current stencil reference
  36519. * @param reference defines the new stencil reference to use
  36520. */
  36521. setStencilFunctionReference(reference: number): void;
  36522. /**
  36523. * Sets the current stencil mask
  36524. * @param mask defines the new stencil mask to use
  36525. */
  36526. setStencilFunctionMask(mask: number): void;
  36527. /**
  36528. * Gets the current stencil operation when stencil fails
  36529. * @returns a number defining stencil operation to use when stencil fails
  36530. */
  36531. getStencilOperationFail(): number;
  36532. /**
  36533. * Gets the current stencil operation when depth fails
  36534. * @returns a number defining stencil operation to use when depth fails
  36535. */
  36536. getStencilOperationDepthFail(): number;
  36537. /**
  36538. * Gets the current stencil operation when stencil passes
  36539. * @returns a number defining stencil operation to use when stencil passes
  36540. */
  36541. getStencilOperationPass(): number;
  36542. /**
  36543. * Sets the stencil operation to use when stencil fails
  36544. * @param operation defines the stencil operation to use when stencil fails
  36545. */
  36546. setStencilOperationFail(operation: number): void;
  36547. /**
  36548. * Sets the stencil operation to use when depth fails
  36549. * @param operation defines the stencil operation to use when depth fails
  36550. */
  36551. setStencilOperationDepthFail(operation: number): void;
  36552. /**
  36553. * Sets the stencil operation to use when stencil passes
  36554. * @param operation defines the stencil operation to use when stencil passes
  36555. */
  36556. setStencilOperationPass(operation: number): void;
  36557. /**
  36558. * Sets a boolean indicating if the dithering state is enabled or disabled
  36559. * @param value defines the dithering state
  36560. */
  36561. setDitheringState(value: boolean): void;
  36562. /**
  36563. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  36564. * @param value defines the rasterizer state
  36565. */
  36566. setRasterizerState(value: boolean): void;
  36567. /**
  36568. * Gets the current depth function
  36569. * @returns a number defining the depth function
  36570. */
  36571. getDepthFunction(): Nullable<number>;
  36572. /**
  36573. * Sets the current depth function
  36574. * @param depthFunc defines the function to use
  36575. */
  36576. setDepthFunction(depthFunc: number): void;
  36577. /**
  36578. * Sets the current depth function to GREATER
  36579. */
  36580. setDepthFunctionToGreater(): void;
  36581. /**
  36582. * Sets the current depth function to GEQUAL
  36583. */
  36584. setDepthFunctionToGreaterOrEqual(): void;
  36585. /**
  36586. * Sets the current depth function to LESS
  36587. */
  36588. setDepthFunctionToLess(): void;
  36589. /**
  36590. * Sets the current depth function to LEQUAL
  36591. */
  36592. setDepthFunctionToLessOrEqual(): void;
  36593. private _cachedStencilBuffer;
  36594. private _cachedStencilFunction;
  36595. private _cachedStencilMask;
  36596. private _cachedStencilOperationPass;
  36597. private _cachedStencilOperationFail;
  36598. private _cachedStencilOperationDepthFail;
  36599. private _cachedStencilReference;
  36600. /**
  36601. * Caches the the state of the stencil buffer
  36602. */
  36603. cacheStencilState(): void;
  36604. /**
  36605. * Restores the state of the stencil buffer
  36606. */
  36607. restoreStencilState(): void;
  36608. /**
  36609. * Directly set the WebGL Viewport
  36610. * @param x defines the x coordinate of the viewport (in screen space)
  36611. * @param y defines the y coordinate of the viewport (in screen space)
  36612. * @param width defines the width of the viewport (in screen space)
  36613. * @param height defines the height of the viewport (in screen space)
  36614. * @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
  36615. */
  36616. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  36617. /**
  36618. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  36619. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  36620. * @param y defines the y-coordinate of the corner of the clear rectangle
  36621. * @param width defines the width of the clear rectangle
  36622. * @param height defines the height of the clear rectangle
  36623. * @param clearColor defines the clear color
  36624. */
  36625. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  36626. /**
  36627. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  36628. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  36629. * @param y defines the y-coordinate of the corner of the clear rectangle
  36630. * @param width defines the width of the clear rectangle
  36631. * @param height defines the height of the clear rectangle
  36632. */
  36633. enableScissor(x: number, y: number, width: number, height: number): void;
  36634. /**
  36635. * Disable previously set scissor test rectangle
  36636. */
  36637. disableScissor(): void;
  36638. protected _reportDrawCall(): void;
  36639. /**
  36640. * Initializes a webVR display and starts listening to display change events
  36641. * The onVRDisplayChangedObservable will be notified upon these changes
  36642. * @returns The onVRDisplayChangedObservable
  36643. */
  36644. initWebVR(): Observable<IDisplayChangedEventArgs>;
  36645. /** @hidden */
  36646. _prepareVRComponent(): void;
  36647. /** @hidden */
  36648. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  36649. /** @hidden */
  36650. _submitVRFrame(): void;
  36651. /**
  36652. * Call this function to leave webVR mode
  36653. * Will do nothing if webVR is not supported or if there is no webVR device
  36654. * @see http://doc.babylonjs.com/how_to/webvr_camera
  36655. */
  36656. disableVR(): void;
  36657. /**
  36658. * Gets a boolean indicating that the system is in VR mode and is presenting
  36659. * @returns true if VR mode is engaged
  36660. */
  36661. isVRPresenting(): boolean;
  36662. /** @hidden */
  36663. _requestVRFrame(): void;
  36664. /** @hidden */
  36665. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36666. /**
  36667. * Gets the source code of the vertex shader associated with a specific webGL program
  36668. * @param program defines the program to use
  36669. * @returns a string containing the source code of the vertex shader associated with the program
  36670. */
  36671. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  36672. /**
  36673. * Gets the source code of the fragment shader associated with a specific webGL program
  36674. * @param program defines the program to use
  36675. * @returns a string containing the source code of the fragment shader associated with the program
  36676. */
  36677. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  36678. /**
  36679. * Sets a depth stencil texture from a render target to the according uniform.
  36680. * @param channel The texture channel
  36681. * @param uniform The uniform to set
  36682. * @param texture The render target texture containing the depth stencil texture to apply
  36683. */
  36684. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  36685. /**
  36686. * Sets a texture to the webGL context from a postprocess
  36687. * @param channel defines the channel to use
  36688. * @param postProcess defines the source postprocess
  36689. */
  36690. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  36691. /**
  36692. * Binds the output of the passed in post process to the texture channel specified
  36693. * @param channel The channel the texture should be bound to
  36694. * @param postProcess The post process which's output should be bound
  36695. */
  36696. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  36697. protected _rebuildBuffers(): void;
  36698. /** @hidden */
  36699. _renderFrame(): void;
  36700. _renderLoop(): void;
  36701. /** @hidden */
  36702. _renderViews(): boolean;
  36703. /**
  36704. * Toggle full screen mode
  36705. * @param requestPointerLock defines if a pointer lock should be requested from the user
  36706. */
  36707. switchFullscreen(requestPointerLock: boolean): void;
  36708. /**
  36709. * Enters full screen mode
  36710. * @param requestPointerLock defines if a pointer lock should be requested from the user
  36711. */
  36712. enterFullscreen(requestPointerLock: boolean): void;
  36713. /**
  36714. * Exits full screen mode
  36715. */
  36716. exitFullscreen(): void;
  36717. /**
  36718. * Enters Pointerlock mode
  36719. */
  36720. enterPointerlock(): void;
  36721. /**
  36722. * Exits Pointerlock mode
  36723. */
  36724. exitPointerlock(): void;
  36725. /**
  36726. * Begin a new frame
  36727. */
  36728. beginFrame(): void;
  36729. /**
  36730. * Enf the current frame
  36731. */
  36732. endFrame(): void;
  36733. resize(): void;
  36734. /**
  36735. * Force a specific size of the canvas
  36736. * @param width defines the new canvas' width
  36737. * @param height defines the new canvas' height
  36738. */
  36739. setSize(width: number, height: number): void;
  36740. /**
  36741. * Updates a dynamic vertex buffer.
  36742. * @param vertexBuffer the vertex buffer to update
  36743. * @param data the data used to update the vertex buffer
  36744. * @param byteOffset the byte offset of the data
  36745. * @param byteLength the byte length of the data
  36746. */
  36747. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  36748. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  36749. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36750. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36751. _releaseTexture(texture: InternalTexture): void;
  36752. /**
  36753. * @hidden
  36754. * Rescales a texture
  36755. * @param source input texutre
  36756. * @param destination destination texture
  36757. * @param scene scene to use to render the resize
  36758. * @param internalFormat format to use when resizing
  36759. * @param onComplete callback to be called when resize has completed
  36760. */
  36761. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  36762. /**
  36763. * Gets the current framerate
  36764. * @returns a number representing the framerate
  36765. */
  36766. getFps(): number;
  36767. /**
  36768. * Gets the time spent between current and previous frame
  36769. * @returns a number representing the delta time in ms
  36770. */
  36771. getDeltaTime(): number;
  36772. private _measureFps;
  36773. /** @hidden */
  36774. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  36775. /**
  36776. * Update a dynamic index buffer
  36777. * @param indexBuffer defines the target index buffer
  36778. * @param indices defines the data to update
  36779. * @param offset defines the offset in the target index buffer where update should start
  36780. */
  36781. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  36782. /**
  36783. * Updates the sample count of a render target texture
  36784. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  36785. * @param texture defines the texture to update
  36786. * @param samples defines the sample count to set
  36787. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  36788. */
  36789. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  36790. /**
  36791. * Updates a depth texture Comparison Mode and Function.
  36792. * If the comparison Function is equal to 0, the mode will be set to none.
  36793. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  36794. * @param texture The texture to set the comparison function for
  36795. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  36796. */
  36797. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  36798. /**
  36799. * Creates a webGL buffer to use with instanciation
  36800. * @param capacity defines the size of the buffer
  36801. * @returns the webGL buffer
  36802. */
  36803. createInstancesBuffer(capacity: number): DataBuffer;
  36804. /**
  36805. * Delete a webGL buffer used with instanciation
  36806. * @param buffer defines the webGL buffer to delete
  36807. */
  36808. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  36809. private _clientWaitAsync;
  36810. /** @hidden */
  36811. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  36812. dispose(): void;
  36813. private _disableTouchAction;
  36814. /**
  36815. * Display the loading screen
  36816. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36817. */
  36818. displayLoadingUI(): void;
  36819. /**
  36820. * Hide the loading screen
  36821. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36822. */
  36823. hideLoadingUI(): void;
  36824. /**
  36825. * Gets the current loading screen object
  36826. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36827. */
  36828. get loadingScreen(): ILoadingScreen;
  36829. /**
  36830. * Sets the current loading screen object
  36831. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36832. */
  36833. set loadingScreen(loadingScreen: ILoadingScreen);
  36834. /**
  36835. * Sets the current loading screen text
  36836. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36837. */
  36838. set loadingUIText(text: string);
  36839. /**
  36840. * Sets the current loading screen background color
  36841. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36842. */
  36843. set loadingUIBackgroundColor(color: string);
  36844. /** Pointerlock and fullscreen */
  36845. /**
  36846. * Ask the browser to promote the current element to pointerlock mode
  36847. * @param element defines the DOM element to promote
  36848. */
  36849. static _RequestPointerlock(element: HTMLElement): void;
  36850. /**
  36851. * Asks the browser to exit pointerlock mode
  36852. */
  36853. static _ExitPointerlock(): void;
  36854. /**
  36855. * Ask the browser to promote the current element to fullscreen rendering mode
  36856. * @param element defines the DOM element to promote
  36857. */
  36858. static _RequestFullscreen(element: HTMLElement): void;
  36859. /**
  36860. * Asks the browser to exit fullscreen mode
  36861. */
  36862. static _ExitFullscreen(): void;
  36863. }
  36864. }
  36865. declare module BABYLON {
  36866. /**
  36867. * The engine store class is responsible to hold all the instances of Engine and Scene created
  36868. * during the life time of the application.
  36869. */
  36870. export class EngineStore {
  36871. /** Gets the list of created engines */
  36872. static Instances: Engine[];
  36873. /** @hidden */
  36874. static _LastCreatedScene: Nullable<Scene>;
  36875. /**
  36876. * Gets the latest created engine
  36877. */
  36878. static get LastCreatedEngine(): Nullable<Engine>;
  36879. /**
  36880. * Gets the latest created scene
  36881. */
  36882. static get LastCreatedScene(): Nullable<Scene>;
  36883. /**
  36884. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  36885. * @ignorenaming
  36886. */
  36887. static UseFallbackTexture: boolean;
  36888. /**
  36889. * Texture content used if a texture cannot loaded
  36890. * @ignorenaming
  36891. */
  36892. static FallbackTexture: string;
  36893. }
  36894. }
  36895. declare module BABYLON {
  36896. /**
  36897. * Helper class that provides a small promise polyfill
  36898. */
  36899. export class PromisePolyfill {
  36900. /**
  36901. * Static function used to check if the polyfill is required
  36902. * If this is the case then the function will inject the polyfill to window.Promise
  36903. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  36904. */
  36905. static Apply(force?: boolean): void;
  36906. }
  36907. }
  36908. declare module BABYLON {
  36909. /**
  36910. * Interface for screenshot methods with describe argument called `size` as object with options
  36911. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  36912. */
  36913. export interface IScreenshotSize {
  36914. /**
  36915. * number in pixels for canvas height
  36916. */
  36917. height?: number;
  36918. /**
  36919. * multiplier allowing render at a higher or lower resolution
  36920. * If value is defined then height and width will be ignored and taken from camera
  36921. */
  36922. precision?: number;
  36923. /**
  36924. * number in pixels for canvas width
  36925. */
  36926. width?: number;
  36927. }
  36928. }
  36929. declare module BABYLON {
  36930. interface IColor4Like {
  36931. r: float;
  36932. g: float;
  36933. b: float;
  36934. a: float;
  36935. }
  36936. /**
  36937. * Class containing a set of static utilities functions
  36938. */
  36939. export class Tools {
  36940. /**
  36941. * Gets or sets the base URL to use to load assets
  36942. */
  36943. static get BaseUrl(): string;
  36944. static set BaseUrl(value: string);
  36945. /**
  36946. * Enable/Disable Custom HTTP Request Headers globally.
  36947. * default = false
  36948. * @see CustomRequestHeaders
  36949. */
  36950. static UseCustomRequestHeaders: boolean;
  36951. /**
  36952. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  36953. * i.e. when loading files, where the server/service expects an Authorization header
  36954. */
  36955. static CustomRequestHeaders: {
  36956. [key: string]: string;
  36957. };
  36958. /**
  36959. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  36960. */
  36961. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  36962. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  36963. /**
  36964. * Default behaviour for cors in the application.
  36965. * It can be a string if the expected behavior is identical in the entire app.
  36966. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  36967. */
  36968. static get CorsBehavior(): string | ((url: string | string[]) => string);
  36969. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  36970. /**
  36971. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  36972. * @ignorenaming
  36973. */
  36974. static get UseFallbackTexture(): boolean;
  36975. static set UseFallbackTexture(value: boolean);
  36976. /**
  36977. * Use this object to register external classes like custom textures or material
  36978. * to allow the laoders to instantiate them
  36979. */
  36980. static get RegisteredExternalClasses(): {
  36981. [key: string]: Object;
  36982. };
  36983. static set RegisteredExternalClasses(classes: {
  36984. [key: string]: Object;
  36985. });
  36986. /**
  36987. * Texture content used if a texture cannot loaded
  36988. * @ignorenaming
  36989. */
  36990. static get fallbackTexture(): string;
  36991. static set fallbackTexture(value: string);
  36992. /**
  36993. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  36994. * @param u defines the coordinate on X axis
  36995. * @param v defines the coordinate on Y axis
  36996. * @param width defines the width of the source data
  36997. * @param height defines the height of the source data
  36998. * @param pixels defines the source byte array
  36999. * @param color defines the output color
  37000. */
  37001. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  37002. /**
  37003. * Interpolates between a and b via alpha
  37004. * @param a The lower value (returned when alpha = 0)
  37005. * @param b The upper value (returned when alpha = 1)
  37006. * @param alpha The interpolation-factor
  37007. * @return The mixed value
  37008. */
  37009. static Mix(a: number, b: number, alpha: number): number;
  37010. /**
  37011. * Tries to instantiate a new object from a given class name
  37012. * @param className defines the class name to instantiate
  37013. * @returns the new object or null if the system was not able to do the instantiation
  37014. */
  37015. static Instantiate(className: string): any;
  37016. /**
  37017. * Provides a slice function that will work even on IE
  37018. * @param data defines the array to slice
  37019. * @param start defines the start of the data (optional)
  37020. * @param end defines the end of the data (optional)
  37021. * @returns the new sliced array
  37022. */
  37023. static Slice<T>(data: T, start?: number, end?: number): T;
  37024. /**
  37025. * Polyfill for setImmediate
  37026. * @param action defines the action to execute after the current execution block
  37027. */
  37028. static SetImmediate(action: () => void): void;
  37029. /**
  37030. * Function indicating if a number is an exponent of 2
  37031. * @param value defines the value to test
  37032. * @returns true if the value is an exponent of 2
  37033. */
  37034. static IsExponentOfTwo(value: number): boolean;
  37035. private static _tmpFloatArray;
  37036. /**
  37037. * Returns the nearest 32-bit single precision float representation of a Number
  37038. * @param value A Number. If the parameter is of a different type, it will get converted
  37039. * to a number or to NaN if it cannot be converted
  37040. * @returns number
  37041. */
  37042. static FloatRound(value: number): number;
  37043. /**
  37044. * Extracts the filename from a path
  37045. * @param path defines the path to use
  37046. * @returns the filename
  37047. */
  37048. static GetFilename(path: string): string;
  37049. /**
  37050. * Extracts the "folder" part of a path (everything before the filename).
  37051. * @param uri The URI to extract the info from
  37052. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  37053. * @returns The "folder" part of the path
  37054. */
  37055. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  37056. /**
  37057. * Extracts text content from a DOM element hierarchy
  37058. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  37059. */
  37060. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  37061. /**
  37062. * Convert an angle in radians to degrees
  37063. * @param angle defines the angle to convert
  37064. * @returns the angle in degrees
  37065. */
  37066. static ToDegrees(angle: number): number;
  37067. /**
  37068. * Convert an angle in degrees to radians
  37069. * @param angle defines the angle to convert
  37070. * @returns the angle in radians
  37071. */
  37072. static ToRadians(angle: number): number;
  37073. /**
  37074. * Returns an array if obj is not an array
  37075. * @param obj defines the object to evaluate as an array
  37076. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  37077. * @returns either obj directly if obj is an array or a new array containing obj
  37078. */
  37079. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  37080. /**
  37081. * Gets the pointer prefix to use
  37082. * @returns "pointer" if touch is enabled. Else returns "mouse"
  37083. */
  37084. static GetPointerPrefix(): string;
  37085. /**
  37086. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  37087. * @param url define the url we are trying
  37088. * @param element define the dom element where to configure the cors policy
  37089. */
  37090. static SetCorsBehavior(url: string | string[], element: {
  37091. crossOrigin: string | null;
  37092. }): void;
  37093. /**
  37094. * Removes unwanted characters from an url
  37095. * @param url defines the url to clean
  37096. * @returns the cleaned url
  37097. */
  37098. static CleanUrl(url: string): string;
  37099. /**
  37100. * Gets or sets a function used to pre-process url before using them to load assets
  37101. */
  37102. static get PreprocessUrl(): (url: string) => string;
  37103. static set PreprocessUrl(processor: (url: string) => string);
  37104. /**
  37105. * Loads an image as an HTMLImageElement.
  37106. * @param input url string, ArrayBuffer, or Blob to load
  37107. * @param onLoad callback called when the image successfully loads
  37108. * @param onError callback called when the image fails to load
  37109. * @param offlineProvider offline provider for caching
  37110. * @param mimeType optional mime type
  37111. * @returns the HTMLImageElement of the loaded image
  37112. */
  37113. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  37114. /**
  37115. * Loads a file from a url
  37116. * @param url url string, ArrayBuffer, or Blob to load
  37117. * @param onSuccess callback called when the file successfully loads
  37118. * @param onProgress callback called while file is loading (if the server supports this mode)
  37119. * @param offlineProvider defines the offline provider for caching
  37120. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  37121. * @param onError callback called when the file fails to load
  37122. * @returns a file request object
  37123. */
  37124. 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;
  37125. /**
  37126. * Loads a file from a url
  37127. * @param url the file url to load
  37128. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  37129. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  37130. */
  37131. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  37132. /**
  37133. * Load a script (identified by an url). When the url returns, the
  37134. * content of this file is added into a new script element, attached to the DOM (body element)
  37135. * @param scriptUrl defines the url of the script to laod
  37136. * @param onSuccess defines the callback called when the script is loaded
  37137. * @param onError defines the callback to call if an error occurs
  37138. * @param scriptId defines the id of the script element
  37139. */
  37140. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  37141. /**
  37142. * Load an asynchronous script (identified by an url). When the url returns, the
  37143. * content of this file is added into a new script element, attached to the DOM (body element)
  37144. * @param scriptUrl defines the url of the script to laod
  37145. * @param scriptId defines the id of the script element
  37146. * @returns a promise request object
  37147. */
  37148. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  37149. /**
  37150. * Loads a file from a blob
  37151. * @param fileToLoad defines the blob to use
  37152. * @param callback defines the callback to call when data is loaded
  37153. * @param progressCallback defines the callback to call during loading process
  37154. * @returns a file request object
  37155. */
  37156. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  37157. /**
  37158. * Reads a file from a File object
  37159. * @param file defines the file to load
  37160. * @param onSuccess defines the callback to call when data is loaded
  37161. * @param onProgress defines the callback to call during loading process
  37162. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  37163. * @param onError defines the callback to call when an error occurs
  37164. * @returns a file request object
  37165. */
  37166. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  37167. /**
  37168. * Creates a data url from a given string content
  37169. * @param content defines the content to convert
  37170. * @returns the new data url link
  37171. */
  37172. static FileAsURL(content: string): string;
  37173. /**
  37174. * Format the given number to a specific decimal format
  37175. * @param value defines the number to format
  37176. * @param decimals defines the number of decimals to use
  37177. * @returns the formatted string
  37178. */
  37179. static Format(value: number, decimals?: number): string;
  37180. /**
  37181. * Tries to copy an object by duplicating every property
  37182. * @param source defines the source object
  37183. * @param destination defines the target object
  37184. * @param doNotCopyList defines a list of properties to avoid
  37185. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  37186. */
  37187. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  37188. /**
  37189. * Gets a boolean indicating if the given object has no own property
  37190. * @param obj defines the object to test
  37191. * @returns true if object has no own property
  37192. */
  37193. static IsEmpty(obj: any): boolean;
  37194. /**
  37195. * Function used to register events at window level
  37196. * @param windowElement defines the Window object to use
  37197. * @param events defines the events to register
  37198. */
  37199. static RegisterTopRootEvents(windowElement: Window, events: {
  37200. name: string;
  37201. handler: Nullable<(e: FocusEvent) => any>;
  37202. }[]): void;
  37203. /**
  37204. * Function used to unregister events from window level
  37205. * @param windowElement defines the Window object to use
  37206. * @param events defines the events to unregister
  37207. */
  37208. static UnregisterTopRootEvents(windowElement: Window, events: {
  37209. name: string;
  37210. handler: Nullable<(e: FocusEvent) => any>;
  37211. }[]): void;
  37212. /**
  37213. * @ignore
  37214. */
  37215. static _ScreenshotCanvas: HTMLCanvasElement;
  37216. /**
  37217. * Dumps the current bound framebuffer
  37218. * @param width defines the rendering width
  37219. * @param height defines the rendering height
  37220. * @param engine defines the hosting engine
  37221. * @param successCallback defines the callback triggered once the data are available
  37222. * @param mimeType defines the mime type of the result
  37223. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  37224. */
  37225. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  37226. /**
  37227. * Converts the canvas data to blob.
  37228. * This acts as a polyfill for browsers not supporting the to blob function.
  37229. * @param canvas Defines the canvas to extract the data from
  37230. * @param successCallback Defines the callback triggered once the data are available
  37231. * @param mimeType Defines the mime type of the result
  37232. */
  37233. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  37234. /**
  37235. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  37236. * @param successCallback defines the callback triggered once the data are available
  37237. * @param mimeType defines the mime type of the result
  37238. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  37239. */
  37240. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  37241. /**
  37242. * Downloads a blob in the browser
  37243. * @param blob defines the blob to download
  37244. * @param fileName defines the name of the downloaded file
  37245. */
  37246. static Download(blob: Blob, fileName: string): void;
  37247. /**
  37248. * Captures a screenshot of the current rendering
  37249. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  37250. * @param engine defines the rendering engine
  37251. * @param camera defines the source camera
  37252. * @param size This parameter can be set to a single number or to an object with the
  37253. * following (optional) properties: precision, width, height. If a single number is passed,
  37254. * it will be used for both width and height. If an object is passed, the screenshot size
  37255. * will be derived from the parameters. The precision property is a multiplier allowing
  37256. * rendering at a higher or lower resolution
  37257. * @param successCallback defines the callback receives a single parameter which contains the
  37258. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  37259. * src parameter of an <img> to display it
  37260. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  37261. * Check your browser for supported MIME types
  37262. */
  37263. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  37264. /**
  37265. * Captures a screenshot of the current rendering
  37266. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  37267. * @param engine defines the rendering engine
  37268. * @param camera defines the source camera
  37269. * @param size This parameter can be set to a single number or to an object with the
  37270. * following (optional) properties: precision, width, height. If a single number is passed,
  37271. * it will be used for both width and height. If an object is passed, the screenshot size
  37272. * will be derived from the parameters. The precision property is a multiplier allowing
  37273. * rendering at a higher or lower resolution
  37274. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  37275. * Check your browser for supported MIME types
  37276. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  37277. * to the src parameter of an <img> to display it
  37278. */
  37279. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  37280. /**
  37281. * Generates an image screenshot from the specified camera.
  37282. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  37283. * @param engine The engine to use for rendering
  37284. * @param camera The camera to use for rendering
  37285. * @param size This parameter can be set to a single number or to an object with the
  37286. * following (optional) properties: precision, width, height. If a single number is passed,
  37287. * it will be used for both width and height. If an object is passed, the screenshot size
  37288. * will be derived from the parameters. The precision property is a multiplier allowing
  37289. * rendering at a higher or lower resolution
  37290. * @param successCallback The callback receives a single parameter which contains the
  37291. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  37292. * src parameter of an <img> to display it
  37293. * @param mimeType The MIME type of the screenshot image (default: image/png).
  37294. * Check your browser for supported MIME types
  37295. * @param samples Texture samples (default: 1)
  37296. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  37297. * @param fileName A name for for the downloaded file.
  37298. */
  37299. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  37300. /**
  37301. * Generates an image screenshot from the specified camera.
  37302. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  37303. * @param engine The engine to use for rendering
  37304. * @param camera The camera to use for rendering
  37305. * @param size This parameter can be set to a single number or to an object with the
  37306. * following (optional) properties: precision, width, height. If a single number is passed,
  37307. * it will be used for both width and height. If an object is passed, the screenshot size
  37308. * will be derived from the parameters. The precision property is a multiplier allowing
  37309. * rendering at a higher or lower resolution
  37310. * @param mimeType The MIME type of the screenshot image (default: image/png).
  37311. * Check your browser for supported MIME types
  37312. * @param samples Texture samples (default: 1)
  37313. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  37314. * @param fileName A name for for the downloaded file.
  37315. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  37316. * to the src parameter of an <img> to display it
  37317. */
  37318. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  37319. /**
  37320. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  37321. * Be aware Math.random() could cause collisions, but:
  37322. * "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"
  37323. * @returns a pseudo random id
  37324. */
  37325. static RandomId(): string;
  37326. /**
  37327. * Test if the given uri is a base64 string
  37328. * @param uri The uri to test
  37329. * @return True if the uri is a base64 string or false otherwise
  37330. */
  37331. static IsBase64(uri: string): boolean;
  37332. /**
  37333. * Decode the given base64 uri.
  37334. * @param uri The uri to decode
  37335. * @return The decoded base64 data.
  37336. */
  37337. static DecodeBase64(uri: string): ArrayBuffer;
  37338. /**
  37339. * Gets the absolute url.
  37340. * @param url the input url
  37341. * @return the absolute url
  37342. */
  37343. static GetAbsoluteUrl(url: string): string;
  37344. /**
  37345. * No log
  37346. */
  37347. static readonly NoneLogLevel: number;
  37348. /**
  37349. * Only message logs
  37350. */
  37351. static readonly MessageLogLevel: number;
  37352. /**
  37353. * Only warning logs
  37354. */
  37355. static readonly WarningLogLevel: number;
  37356. /**
  37357. * Only error logs
  37358. */
  37359. static readonly ErrorLogLevel: number;
  37360. /**
  37361. * All logs
  37362. */
  37363. static readonly AllLogLevel: number;
  37364. /**
  37365. * Gets a value indicating the number of loading errors
  37366. * @ignorenaming
  37367. */
  37368. static get errorsCount(): number;
  37369. /**
  37370. * Callback called when a new log is added
  37371. */
  37372. static OnNewCacheEntry: (entry: string) => void;
  37373. /**
  37374. * Log a message to the console
  37375. * @param message defines the message to log
  37376. */
  37377. static Log(message: string): void;
  37378. /**
  37379. * Write a warning message to the console
  37380. * @param message defines the message to log
  37381. */
  37382. static Warn(message: string): void;
  37383. /**
  37384. * Write an error message to the console
  37385. * @param message defines the message to log
  37386. */
  37387. static Error(message: string): void;
  37388. /**
  37389. * Gets current log cache (list of logs)
  37390. */
  37391. static get LogCache(): string;
  37392. /**
  37393. * Clears the log cache
  37394. */
  37395. static ClearLogCache(): void;
  37396. /**
  37397. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  37398. */
  37399. static set LogLevels(level: number);
  37400. /**
  37401. * Checks if the window object exists
  37402. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  37403. */
  37404. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  37405. /**
  37406. * No performance log
  37407. */
  37408. static readonly PerformanceNoneLogLevel: number;
  37409. /**
  37410. * Use user marks to log performance
  37411. */
  37412. static readonly PerformanceUserMarkLogLevel: number;
  37413. /**
  37414. * Log performance to the console
  37415. */
  37416. static readonly PerformanceConsoleLogLevel: number;
  37417. private static _performance;
  37418. /**
  37419. * Sets the current performance log level
  37420. */
  37421. static set PerformanceLogLevel(level: number);
  37422. private static _StartPerformanceCounterDisabled;
  37423. private static _EndPerformanceCounterDisabled;
  37424. private static _StartUserMark;
  37425. private static _EndUserMark;
  37426. private static _StartPerformanceConsole;
  37427. private static _EndPerformanceConsole;
  37428. /**
  37429. * Starts a performance counter
  37430. */
  37431. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  37432. /**
  37433. * Ends a specific performance coutner
  37434. */
  37435. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  37436. /**
  37437. * Gets either window.performance.now() if supported or Date.now() else
  37438. */
  37439. static get Now(): number;
  37440. /**
  37441. * This method will return the name of the class used to create the instance of the given object.
  37442. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  37443. * @param object the object to get the class name from
  37444. * @param isType defines if the object is actually a type
  37445. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  37446. */
  37447. static GetClassName(object: any, isType?: boolean): string;
  37448. /**
  37449. * Gets the first element of an array satisfying a given predicate
  37450. * @param array defines the array to browse
  37451. * @param predicate defines the predicate to use
  37452. * @returns null if not found or the element
  37453. */
  37454. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  37455. /**
  37456. * This method will return the name of the full name of the class, including its owning module (if any).
  37457. * 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).
  37458. * @param object the object to get the class name from
  37459. * @param isType defines if the object is actually a type
  37460. * @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.
  37461. * @ignorenaming
  37462. */
  37463. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  37464. /**
  37465. * Returns a promise that resolves after the given amount of time.
  37466. * @param delay Number of milliseconds to delay
  37467. * @returns Promise that resolves after the given amount of time
  37468. */
  37469. static DelayAsync(delay: number): Promise<void>;
  37470. /**
  37471. * Utility function to detect if the current user agent is Safari
  37472. * @returns whether or not the current user agent is safari
  37473. */
  37474. static IsSafari(): boolean;
  37475. }
  37476. /**
  37477. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  37478. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  37479. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  37480. * @param name The name of the class, case should be preserved
  37481. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  37482. */
  37483. export function className(name: string, module?: string): (target: Object) => void;
  37484. /**
  37485. * An implementation of a loop for asynchronous functions.
  37486. */
  37487. export class AsyncLoop {
  37488. /**
  37489. * Defines the number of iterations for the loop
  37490. */
  37491. iterations: number;
  37492. /**
  37493. * Defines the current index of the loop.
  37494. */
  37495. index: number;
  37496. private _done;
  37497. private _fn;
  37498. private _successCallback;
  37499. /**
  37500. * Constructor.
  37501. * @param iterations the number of iterations.
  37502. * @param func the function to run each iteration
  37503. * @param successCallback the callback that will be called upon succesful execution
  37504. * @param offset starting offset.
  37505. */
  37506. constructor(
  37507. /**
  37508. * Defines the number of iterations for the loop
  37509. */
  37510. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  37511. /**
  37512. * Execute the next iteration. Must be called after the last iteration was finished.
  37513. */
  37514. executeNext(): void;
  37515. /**
  37516. * Break the loop and run the success callback.
  37517. */
  37518. breakLoop(): void;
  37519. /**
  37520. * Create and run an async loop.
  37521. * @param iterations the number of iterations.
  37522. * @param fn the function to run each iteration
  37523. * @param successCallback the callback that will be called upon succesful execution
  37524. * @param offset starting offset.
  37525. * @returns the created async loop object
  37526. */
  37527. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  37528. /**
  37529. * A for-loop that will run a given number of iterations synchronous and the rest async.
  37530. * @param iterations total number of iterations
  37531. * @param syncedIterations number of synchronous iterations in each async iteration.
  37532. * @param fn the function to call each iteration.
  37533. * @param callback a success call back that will be called when iterating stops.
  37534. * @param breakFunction a break condition (optional)
  37535. * @param timeout timeout settings for the setTimeout function. default - 0.
  37536. * @returns the created async loop object
  37537. */
  37538. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  37539. }
  37540. }
  37541. declare module BABYLON {
  37542. /**
  37543. * This class implement a typical dictionary using a string as key and the generic type T as value.
  37544. * The underlying implementation relies on an associative array to ensure the best performances.
  37545. * The value can be anything including 'null' but except 'undefined'
  37546. */
  37547. export class StringDictionary<T> {
  37548. /**
  37549. * This will clear this dictionary and copy the content from the 'source' one.
  37550. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  37551. * @param source the dictionary to take the content from and copy to this dictionary
  37552. */
  37553. copyFrom(source: StringDictionary<T>): void;
  37554. /**
  37555. * Get a value based from its key
  37556. * @param key the given key to get the matching value from
  37557. * @return the value if found, otherwise undefined is returned
  37558. */
  37559. get(key: string): T | undefined;
  37560. /**
  37561. * Get a value from its key or add it if it doesn't exist.
  37562. * This method will ensure you that a given key/data will be present in the dictionary.
  37563. * @param key the given key to get the matching value from
  37564. * @param factory the factory that will create the value if the key is not present in the dictionary.
  37565. * The factory will only be invoked if there's no data for the given key.
  37566. * @return the value corresponding to the key.
  37567. */
  37568. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  37569. /**
  37570. * Get a value from its key if present in the dictionary otherwise add it
  37571. * @param key the key to get the value from
  37572. * @param val if there's no such key/value pair in the dictionary add it with this value
  37573. * @return the value corresponding to the key
  37574. */
  37575. getOrAdd(key: string, val: T): T;
  37576. /**
  37577. * Check if there's a given key in the dictionary
  37578. * @param key the key to check for
  37579. * @return true if the key is present, false otherwise
  37580. */
  37581. contains(key: string): boolean;
  37582. /**
  37583. * Add a new key and its corresponding value
  37584. * @param key the key to add
  37585. * @param value the value corresponding to the key
  37586. * @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
  37587. */
  37588. add(key: string, value: T): boolean;
  37589. /**
  37590. * Update a specific value associated to a key
  37591. * @param key defines the key to use
  37592. * @param value defines the value to store
  37593. * @returns true if the value was updated (or false if the key was not found)
  37594. */
  37595. set(key: string, value: T): boolean;
  37596. /**
  37597. * Get the element of the given key and remove it from the dictionary
  37598. * @param key defines the key to search
  37599. * @returns the value associated with the key or null if not found
  37600. */
  37601. getAndRemove(key: string): Nullable<T>;
  37602. /**
  37603. * Remove a key/value from the dictionary.
  37604. * @param key the key to remove
  37605. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  37606. */
  37607. remove(key: string): boolean;
  37608. /**
  37609. * Clear the whole content of the dictionary
  37610. */
  37611. clear(): void;
  37612. /**
  37613. * Gets the current count
  37614. */
  37615. get count(): number;
  37616. /**
  37617. * Execute a callback on each key/val of the dictionary.
  37618. * Note that you can remove any element in this dictionary in the callback implementation
  37619. * @param callback the callback to execute on a given key/value pair
  37620. */
  37621. forEach(callback: (key: string, val: T) => void): void;
  37622. /**
  37623. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  37624. * If the callback returns null or undefined the method will iterate to the next key/value pair
  37625. * Note that you can remove any element in this dictionary in the callback implementation
  37626. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  37627. * @returns the first item
  37628. */
  37629. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  37630. private _count;
  37631. private _data;
  37632. }
  37633. }
  37634. declare module BABYLON {
  37635. /** @hidden */
  37636. export interface ICollisionCoordinator {
  37637. createCollider(): Collider;
  37638. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  37639. init(scene: Scene): void;
  37640. }
  37641. /** @hidden */
  37642. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  37643. private _scene;
  37644. private _scaledPosition;
  37645. private _scaledVelocity;
  37646. private _finalPosition;
  37647. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  37648. createCollider(): Collider;
  37649. init(scene: Scene): void;
  37650. private _collideWithWorld;
  37651. }
  37652. }
  37653. declare module BABYLON {
  37654. /**
  37655. * Class used to manage all inputs for the scene.
  37656. */
  37657. export class InputManager {
  37658. /** The distance in pixel that you have to move to prevent some events */
  37659. static DragMovementThreshold: number;
  37660. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  37661. static LongPressDelay: number;
  37662. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  37663. static DoubleClickDelay: number;
  37664. /** If you need to check double click without raising a single click at first click, enable this flag */
  37665. static ExclusiveDoubleClickMode: boolean;
  37666. private _wheelEventName;
  37667. private _onPointerMove;
  37668. private _onPointerDown;
  37669. private _onPointerUp;
  37670. private _initClickEvent;
  37671. private _initActionManager;
  37672. private _delayedSimpleClick;
  37673. private _delayedSimpleClickTimeout;
  37674. private _previousDelayedSimpleClickTimeout;
  37675. private _meshPickProceed;
  37676. private _previousButtonPressed;
  37677. private _currentPickResult;
  37678. private _previousPickResult;
  37679. private _totalPointersPressed;
  37680. private _doubleClickOccured;
  37681. private _pointerOverMesh;
  37682. private _pickedDownMesh;
  37683. private _pickedUpMesh;
  37684. private _pointerX;
  37685. private _pointerY;
  37686. private _unTranslatedPointerX;
  37687. private _unTranslatedPointerY;
  37688. private _startingPointerPosition;
  37689. private _previousStartingPointerPosition;
  37690. private _startingPointerTime;
  37691. private _previousStartingPointerTime;
  37692. private _pointerCaptures;
  37693. private _onKeyDown;
  37694. private _onKeyUp;
  37695. private _onCanvasFocusObserver;
  37696. private _onCanvasBlurObserver;
  37697. private _scene;
  37698. /**
  37699. * Creates a new InputManager
  37700. * @param scene defines the hosting scene
  37701. */
  37702. constructor(scene: Scene);
  37703. /**
  37704. * Gets the mesh that is currently under the pointer
  37705. */
  37706. get meshUnderPointer(): Nullable<AbstractMesh>;
  37707. /**
  37708. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  37709. */
  37710. get unTranslatedPointer(): Vector2;
  37711. /**
  37712. * Gets or sets the current on-screen X position of the pointer
  37713. */
  37714. get pointerX(): number;
  37715. set pointerX(value: number);
  37716. /**
  37717. * Gets or sets the current on-screen Y position of the pointer
  37718. */
  37719. get pointerY(): number;
  37720. set pointerY(value: number);
  37721. private _updatePointerPosition;
  37722. private _processPointerMove;
  37723. private _setRayOnPointerInfo;
  37724. private _checkPrePointerObservable;
  37725. /**
  37726. * Use this method to simulate a pointer move on a mesh
  37727. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37728. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37729. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37730. */
  37731. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  37732. /**
  37733. * Use this method to simulate a pointer down on a mesh
  37734. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37735. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37736. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37737. */
  37738. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  37739. private _processPointerDown;
  37740. /** @hidden */
  37741. _isPointerSwiping(): boolean;
  37742. /**
  37743. * Use this method to simulate a pointer up on a mesh
  37744. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37745. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37746. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37747. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  37748. */
  37749. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  37750. private _processPointerUp;
  37751. /**
  37752. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  37753. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  37754. * @returns true if the pointer was captured
  37755. */
  37756. isPointerCaptured(pointerId?: number): boolean;
  37757. /**
  37758. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  37759. * @param attachUp defines if you want to attach events to pointerup
  37760. * @param attachDown defines if you want to attach events to pointerdown
  37761. * @param attachMove defines if you want to attach events to pointermove
  37762. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  37763. */
  37764. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  37765. /**
  37766. * Detaches all event handlers
  37767. */
  37768. detachControl(): void;
  37769. /**
  37770. * Force the value of meshUnderPointer
  37771. * @param mesh defines the mesh to use
  37772. */
  37773. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  37774. /**
  37775. * Gets the mesh under the pointer
  37776. * @returns a Mesh or null if no mesh is under the pointer
  37777. */
  37778. getPointerOverMesh(): Nullable<AbstractMesh>;
  37779. }
  37780. }
  37781. declare module BABYLON {
  37782. /**
  37783. * This class defines the direct association between an animation and a target
  37784. */
  37785. export class TargetedAnimation {
  37786. /**
  37787. * Animation to perform
  37788. */
  37789. animation: Animation;
  37790. /**
  37791. * Target to animate
  37792. */
  37793. target: any;
  37794. /**
  37795. * Serialize the object
  37796. * @returns the JSON object representing the current entity
  37797. */
  37798. serialize(): any;
  37799. }
  37800. /**
  37801. * Use this class to create coordinated animations on multiple targets
  37802. */
  37803. export class AnimationGroup implements IDisposable {
  37804. /** The name of the animation group */
  37805. name: string;
  37806. private _scene;
  37807. private _targetedAnimations;
  37808. private _animatables;
  37809. private _from;
  37810. private _to;
  37811. private _isStarted;
  37812. private _isPaused;
  37813. private _speedRatio;
  37814. private _loopAnimation;
  37815. private _isAdditive;
  37816. /**
  37817. * Gets or sets the unique id of the node
  37818. */
  37819. uniqueId: number;
  37820. /**
  37821. * This observable will notify when one animation have ended
  37822. */
  37823. onAnimationEndObservable: Observable<TargetedAnimation>;
  37824. /**
  37825. * Observer raised when one animation loops
  37826. */
  37827. onAnimationLoopObservable: Observable<TargetedAnimation>;
  37828. /**
  37829. * Observer raised when all animations have looped
  37830. */
  37831. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  37832. /**
  37833. * This observable will notify when all animations have ended.
  37834. */
  37835. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  37836. /**
  37837. * This observable will notify when all animations have paused.
  37838. */
  37839. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  37840. /**
  37841. * This observable will notify when all animations are playing.
  37842. */
  37843. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  37844. /**
  37845. * Gets the first frame
  37846. */
  37847. get from(): number;
  37848. /**
  37849. * Gets the last frame
  37850. */
  37851. get to(): number;
  37852. /**
  37853. * Define if the animations are started
  37854. */
  37855. get isStarted(): boolean;
  37856. /**
  37857. * Gets a value indicating that the current group is playing
  37858. */
  37859. get isPlaying(): boolean;
  37860. /**
  37861. * Gets or sets the speed ratio to use for all animations
  37862. */
  37863. get speedRatio(): number;
  37864. /**
  37865. * Gets or sets the speed ratio to use for all animations
  37866. */
  37867. set speedRatio(value: number);
  37868. /**
  37869. * Gets or sets if all animations should loop or not
  37870. */
  37871. get loopAnimation(): boolean;
  37872. set loopAnimation(value: boolean);
  37873. /**
  37874. * Gets or sets if all animations should be evaluated additively
  37875. */
  37876. get isAdditive(): boolean;
  37877. set isAdditive(value: boolean);
  37878. /**
  37879. * Gets the targeted animations for this animation group
  37880. */
  37881. get targetedAnimations(): Array<TargetedAnimation>;
  37882. /**
  37883. * returning the list of animatables controlled by this animation group.
  37884. */
  37885. get animatables(): Array<Animatable>;
  37886. /**
  37887. * Instantiates a new Animation Group.
  37888. * This helps managing several animations at once.
  37889. * @see http://doc.babylonjs.com/how_to/group
  37890. * @param name Defines the name of the group
  37891. * @param scene Defines the scene the group belongs to
  37892. */
  37893. constructor(
  37894. /** The name of the animation group */
  37895. name: string, scene?: Nullable<Scene>);
  37896. /**
  37897. * Add an animation (with its target) in the group
  37898. * @param animation defines the animation we want to add
  37899. * @param target defines the target of the animation
  37900. * @returns the TargetedAnimation object
  37901. */
  37902. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  37903. /**
  37904. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  37905. * It can add constant keys at begin or end
  37906. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  37907. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  37908. * @returns the animation group
  37909. */
  37910. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  37911. private _animationLoopCount;
  37912. private _animationLoopFlags;
  37913. private _processLoop;
  37914. /**
  37915. * Start all animations on given targets
  37916. * @param loop defines if animations must loop
  37917. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  37918. * @param from defines the from key (optional)
  37919. * @param to defines the to key (optional)
  37920. * @param isAdditive defines the additive state for the resulting animatables (optional)
  37921. * @returns the current animation group
  37922. */
  37923. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  37924. /**
  37925. * Pause all animations
  37926. * @returns the animation group
  37927. */
  37928. pause(): AnimationGroup;
  37929. /**
  37930. * Play all animations to initial state
  37931. * This function will start() the animations if they were not started or will restart() them if they were paused
  37932. * @param loop defines if animations must loop
  37933. * @returns the animation group
  37934. */
  37935. play(loop?: boolean): AnimationGroup;
  37936. /**
  37937. * Reset all animations to initial state
  37938. * @returns the animation group
  37939. */
  37940. reset(): AnimationGroup;
  37941. /**
  37942. * Restart animations from key 0
  37943. * @returns the animation group
  37944. */
  37945. restart(): AnimationGroup;
  37946. /**
  37947. * Stop all animations
  37948. * @returns the animation group
  37949. */
  37950. stop(): AnimationGroup;
  37951. /**
  37952. * Set animation weight for all animatables
  37953. * @param weight defines the weight to use
  37954. * @return the animationGroup
  37955. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  37956. */
  37957. setWeightForAllAnimatables(weight: number): AnimationGroup;
  37958. /**
  37959. * Synchronize and normalize all animatables with a source animatable
  37960. * @param root defines the root animatable to synchronize with
  37961. * @return the animationGroup
  37962. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  37963. */
  37964. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  37965. /**
  37966. * Goes to a specific frame in this animation group
  37967. * @param frame the frame number to go to
  37968. * @return the animationGroup
  37969. */
  37970. goToFrame(frame: number): AnimationGroup;
  37971. /**
  37972. * Dispose all associated resources
  37973. */
  37974. dispose(): void;
  37975. private _checkAnimationGroupEnded;
  37976. /**
  37977. * Clone the current animation group and returns a copy
  37978. * @param newName defines the name of the new group
  37979. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  37980. * @returns the new aniamtion group
  37981. */
  37982. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  37983. /**
  37984. * Serializes the animationGroup to an object
  37985. * @returns Serialized object
  37986. */
  37987. serialize(): any;
  37988. /**
  37989. * Returns a new AnimationGroup object parsed from the source provided.
  37990. * @param parsedAnimationGroup defines the source
  37991. * @param scene defines the scene that will receive the animationGroup
  37992. * @returns a new AnimationGroup
  37993. */
  37994. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  37995. /**
  37996. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  37997. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  37998. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  37999. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  38000. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  38001. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  38002. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  38003. */
  38004. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  38005. /**
  38006. * Returns the string "AnimationGroup"
  38007. * @returns "AnimationGroup"
  38008. */
  38009. getClassName(): string;
  38010. /**
  38011. * Creates a detailled string about the object
  38012. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  38013. * @returns a string representing the object
  38014. */
  38015. toString(fullDetails?: boolean): string;
  38016. }
  38017. }
  38018. declare module BABYLON {
  38019. /**
  38020. * Define an interface for all classes that will hold resources
  38021. */
  38022. export interface IDisposable {
  38023. /**
  38024. * Releases all held resources
  38025. */
  38026. dispose(): void;
  38027. }
  38028. /** Interface defining initialization parameters for Scene class */
  38029. export interface SceneOptions {
  38030. /**
  38031. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  38032. * It will improve performance when the number of geometries becomes important.
  38033. */
  38034. useGeometryUniqueIdsMap?: boolean;
  38035. /**
  38036. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  38037. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  38038. */
  38039. useMaterialMeshMap?: boolean;
  38040. /**
  38041. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  38042. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  38043. */
  38044. useClonedMeshMap?: boolean;
  38045. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  38046. virtual?: boolean;
  38047. }
  38048. /**
  38049. * Represents a scene to be rendered by the engine.
  38050. * @see http://doc.babylonjs.com/features/scene
  38051. */
  38052. export class Scene extends AbstractScene implements IAnimatable {
  38053. /** The fog is deactivated */
  38054. static readonly FOGMODE_NONE: number;
  38055. /** The fog density is following an exponential function */
  38056. static readonly FOGMODE_EXP: number;
  38057. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  38058. static readonly FOGMODE_EXP2: number;
  38059. /** The fog density is following a linear function. */
  38060. static readonly FOGMODE_LINEAR: number;
  38061. /**
  38062. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  38063. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38064. */
  38065. static MinDeltaTime: number;
  38066. /**
  38067. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  38068. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38069. */
  38070. static MaxDeltaTime: number;
  38071. /**
  38072. * Factory used to create the default material.
  38073. * @param name The name of the material to create
  38074. * @param scene The scene to create the material for
  38075. * @returns The default material
  38076. */
  38077. static DefaultMaterialFactory(scene: Scene): Material;
  38078. /**
  38079. * Factory used to create the a collision coordinator.
  38080. * @returns The collision coordinator
  38081. */
  38082. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  38083. /** @hidden */
  38084. _inputManager: InputManager;
  38085. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  38086. cameraToUseForPointers: Nullable<Camera>;
  38087. /** @hidden */
  38088. readonly _isScene: boolean;
  38089. /** @hidden */
  38090. _blockEntityCollection: boolean;
  38091. /**
  38092. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  38093. */
  38094. autoClear: boolean;
  38095. /**
  38096. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  38097. */
  38098. autoClearDepthAndStencil: boolean;
  38099. /**
  38100. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  38101. */
  38102. clearColor: Color4;
  38103. /**
  38104. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  38105. */
  38106. ambientColor: Color3;
  38107. /**
  38108. * This is use to store the default BRDF lookup for PBR materials in your scene.
  38109. * It should only be one of the following (if not the default embedded one):
  38110. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  38111. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  38112. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  38113. * The material properties need to be setup according to the type of texture in use.
  38114. */
  38115. environmentBRDFTexture: BaseTexture;
  38116. /** @hidden */
  38117. protected _environmentTexture: Nullable<BaseTexture>;
  38118. /**
  38119. * Texture used in all pbr material as the reflection texture.
  38120. * As in the majority of the scene they are the same (exception for multi room and so on),
  38121. * this is easier to reference from here than from all the materials.
  38122. */
  38123. get environmentTexture(): Nullable<BaseTexture>;
  38124. /**
  38125. * Texture used in all pbr material as the reflection texture.
  38126. * As in the majority of the scene they are the same (exception for multi room and so on),
  38127. * this is easier to set here than in all the materials.
  38128. */
  38129. set environmentTexture(value: Nullable<BaseTexture>);
  38130. /** @hidden */
  38131. protected _environmentIntensity: number;
  38132. /**
  38133. * Intensity of the environment in all pbr material.
  38134. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  38135. * As in the majority of the scene they are the same (exception for multi room and so on),
  38136. * this is easier to reference from here than from all the materials.
  38137. */
  38138. get environmentIntensity(): number;
  38139. /**
  38140. * Intensity of the environment in all pbr material.
  38141. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  38142. * As in the majority of the scene they are the same (exception for multi room and so on),
  38143. * this is easier to set here than in all the materials.
  38144. */
  38145. set environmentIntensity(value: number);
  38146. /** @hidden */
  38147. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  38148. /**
  38149. * Default image processing configuration used either in the rendering
  38150. * Forward main pass or through the imageProcessingPostProcess if present.
  38151. * As in the majority of the scene they are the same (exception for multi camera),
  38152. * this is easier to reference from here than from all the materials and post process.
  38153. *
  38154. * No setter as we it is a shared configuration, you can set the values instead.
  38155. */
  38156. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  38157. private _forceWireframe;
  38158. /**
  38159. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  38160. */
  38161. set forceWireframe(value: boolean);
  38162. get forceWireframe(): boolean;
  38163. private _skipFrustumClipping;
  38164. /**
  38165. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  38166. */
  38167. set skipFrustumClipping(value: boolean);
  38168. get skipFrustumClipping(): boolean;
  38169. private _forcePointsCloud;
  38170. /**
  38171. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  38172. */
  38173. set forcePointsCloud(value: boolean);
  38174. get forcePointsCloud(): boolean;
  38175. /**
  38176. * Gets or sets the active clipplane 1
  38177. */
  38178. clipPlane: Nullable<Plane>;
  38179. /**
  38180. * Gets or sets the active clipplane 2
  38181. */
  38182. clipPlane2: Nullable<Plane>;
  38183. /**
  38184. * Gets or sets the active clipplane 3
  38185. */
  38186. clipPlane3: Nullable<Plane>;
  38187. /**
  38188. * Gets or sets the active clipplane 4
  38189. */
  38190. clipPlane4: Nullable<Plane>;
  38191. /**
  38192. * Gets or sets the active clipplane 5
  38193. */
  38194. clipPlane5: Nullable<Plane>;
  38195. /**
  38196. * Gets or sets the active clipplane 6
  38197. */
  38198. clipPlane6: Nullable<Plane>;
  38199. /**
  38200. * Gets or sets a boolean indicating if animations are enabled
  38201. */
  38202. animationsEnabled: boolean;
  38203. private _animationPropertiesOverride;
  38204. /**
  38205. * Gets or sets the animation properties override
  38206. */
  38207. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  38208. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  38209. /**
  38210. * Gets or sets a boolean indicating if a constant deltatime has to be used
  38211. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  38212. */
  38213. useConstantAnimationDeltaTime: boolean;
  38214. /**
  38215. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  38216. * Please note that it requires to run a ray cast through the scene on every frame
  38217. */
  38218. constantlyUpdateMeshUnderPointer: boolean;
  38219. /**
  38220. * Defines the HTML cursor to use when hovering over interactive elements
  38221. */
  38222. hoverCursor: string;
  38223. /**
  38224. * Defines the HTML default cursor to use (empty by default)
  38225. */
  38226. defaultCursor: string;
  38227. /**
  38228. * Defines whether cursors are handled by the scene.
  38229. */
  38230. doNotHandleCursors: boolean;
  38231. /**
  38232. * This is used to call preventDefault() on pointer down
  38233. * in order to block unwanted artifacts like system double clicks
  38234. */
  38235. preventDefaultOnPointerDown: boolean;
  38236. /**
  38237. * This is used to call preventDefault() on pointer up
  38238. * in order to block unwanted artifacts like system double clicks
  38239. */
  38240. preventDefaultOnPointerUp: boolean;
  38241. /**
  38242. * Gets or sets user defined metadata
  38243. */
  38244. metadata: any;
  38245. /**
  38246. * For internal use only. Please do not use.
  38247. */
  38248. reservedDataStore: any;
  38249. /**
  38250. * Gets the name of the plugin used to load this scene (null by default)
  38251. */
  38252. loadingPluginName: string;
  38253. /**
  38254. * Use this array to add regular expressions used to disable offline support for specific urls
  38255. */
  38256. disableOfflineSupportExceptionRules: RegExp[];
  38257. /**
  38258. * An event triggered when the scene is disposed.
  38259. */
  38260. onDisposeObservable: Observable<Scene>;
  38261. private _onDisposeObserver;
  38262. /** Sets a function to be executed when this scene is disposed. */
  38263. set onDispose(callback: () => void);
  38264. /**
  38265. * An event triggered before rendering the scene (right after animations and physics)
  38266. */
  38267. onBeforeRenderObservable: Observable<Scene>;
  38268. private _onBeforeRenderObserver;
  38269. /** Sets a function to be executed before rendering this scene */
  38270. set beforeRender(callback: Nullable<() => void>);
  38271. /**
  38272. * An event triggered after rendering the scene
  38273. */
  38274. onAfterRenderObservable: Observable<Scene>;
  38275. /**
  38276. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  38277. */
  38278. onAfterRenderCameraObservable: Observable<Camera>;
  38279. private _onAfterRenderObserver;
  38280. /** Sets a function to be executed after rendering this scene */
  38281. set afterRender(callback: Nullable<() => void>);
  38282. /**
  38283. * An event triggered before animating the scene
  38284. */
  38285. onBeforeAnimationsObservable: Observable<Scene>;
  38286. /**
  38287. * An event triggered after animations processing
  38288. */
  38289. onAfterAnimationsObservable: Observable<Scene>;
  38290. /**
  38291. * An event triggered before draw calls are ready to be sent
  38292. */
  38293. onBeforeDrawPhaseObservable: Observable<Scene>;
  38294. /**
  38295. * An event triggered after draw calls have been sent
  38296. */
  38297. onAfterDrawPhaseObservable: Observable<Scene>;
  38298. /**
  38299. * An event triggered when the scene is ready
  38300. */
  38301. onReadyObservable: Observable<Scene>;
  38302. /**
  38303. * An event triggered before rendering a camera
  38304. */
  38305. onBeforeCameraRenderObservable: Observable<Camera>;
  38306. private _onBeforeCameraRenderObserver;
  38307. /** Sets a function to be executed before rendering a camera*/
  38308. set beforeCameraRender(callback: () => void);
  38309. /**
  38310. * An event triggered after rendering a camera
  38311. */
  38312. onAfterCameraRenderObservable: Observable<Camera>;
  38313. private _onAfterCameraRenderObserver;
  38314. /** Sets a function to be executed after rendering a camera*/
  38315. set afterCameraRender(callback: () => void);
  38316. /**
  38317. * An event triggered when active meshes evaluation is about to start
  38318. */
  38319. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  38320. /**
  38321. * An event triggered when active meshes evaluation is done
  38322. */
  38323. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  38324. /**
  38325. * An event triggered when particles rendering is about to start
  38326. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  38327. */
  38328. onBeforeParticlesRenderingObservable: Observable<Scene>;
  38329. /**
  38330. * An event triggered when particles rendering is done
  38331. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  38332. */
  38333. onAfterParticlesRenderingObservable: Observable<Scene>;
  38334. /**
  38335. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  38336. */
  38337. onDataLoadedObservable: Observable<Scene>;
  38338. /**
  38339. * An event triggered when a camera is created
  38340. */
  38341. onNewCameraAddedObservable: Observable<Camera>;
  38342. /**
  38343. * An event triggered when a camera is removed
  38344. */
  38345. onCameraRemovedObservable: Observable<Camera>;
  38346. /**
  38347. * An event triggered when a light is created
  38348. */
  38349. onNewLightAddedObservable: Observable<Light>;
  38350. /**
  38351. * An event triggered when a light is removed
  38352. */
  38353. onLightRemovedObservable: Observable<Light>;
  38354. /**
  38355. * An event triggered when a geometry is created
  38356. */
  38357. onNewGeometryAddedObservable: Observable<Geometry>;
  38358. /**
  38359. * An event triggered when a geometry is removed
  38360. */
  38361. onGeometryRemovedObservable: Observable<Geometry>;
  38362. /**
  38363. * An event triggered when a transform node is created
  38364. */
  38365. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  38366. /**
  38367. * An event triggered when a transform node is removed
  38368. */
  38369. onTransformNodeRemovedObservable: Observable<TransformNode>;
  38370. /**
  38371. * An event triggered when a mesh is created
  38372. */
  38373. onNewMeshAddedObservable: Observable<AbstractMesh>;
  38374. /**
  38375. * An event triggered when a mesh is removed
  38376. */
  38377. onMeshRemovedObservable: Observable<AbstractMesh>;
  38378. /**
  38379. * An event triggered when a skeleton is created
  38380. */
  38381. onNewSkeletonAddedObservable: Observable<Skeleton>;
  38382. /**
  38383. * An event triggered when a skeleton is removed
  38384. */
  38385. onSkeletonRemovedObservable: Observable<Skeleton>;
  38386. /**
  38387. * An event triggered when a material is created
  38388. */
  38389. onNewMaterialAddedObservable: Observable<Material>;
  38390. /**
  38391. * An event triggered when a material is removed
  38392. */
  38393. onMaterialRemovedObservable: Observable<Material>;
  38394. /**
  38395. * An event triggered when a texture is created
  38396. */
  38397. onNewTextureAddedObservable: Observable<BaseTexture>;
  38398. /**
  38399. * An event triggered when a texture is removed
  38400. */
  38401. onTextureRemovedObservable: Observable<BaseTexture>;
  38402. /**
  38403. * An event triggered when render targets are about to be rendered
  38404. * Can happen multiple times per frame.
  38405. */
  38406. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  38407. /**
  38408. * An event triggered when render targets were rendered.
  38409. * Can happen multiple times per frame.
  38410. */
  38411. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  38412. /**
  38413. * An event triggered before calculating deterministic simulation step
  38414. */
  38415. onBeforeStepObservable: Observable<Scene>;
  38416. /**
  38417. * An event triggered after calculating deterministic simulation step
  38418. */
  38419. onAfterStepObservable: Observable<Scene>;
  38420. /**
  38421. * An event triggered when the activeCamera property is updated
  38422. */
  38423. onActiveCameraChanged: Observable<Scene>;
  38424. /**
  38425. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  38426. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  38427. * 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)
  38428. */
  38429. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  38430. /**
  38431. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  38432. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  38433. * 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)
  38434. */
  38435. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  38436. /**
  38437. * This Observable will when a mesh has been imported into the scene.
  38438. */
  38439. onMeshImportedObservable: Observable<AbstractMesh>;
  38440. /**
  38441. * This Observable will when an animation file has been imported into the scene.
  38442. */
  38443. onAnimationFileImportedObservable: Observable<Scene>;
  38444. /**
  38445. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  38446. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  38447. */
  38448. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  38449. /** @hidden */
  38450. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  38451. /**
  38452. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  38453. */
  38454. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  38455. /**
  38456. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  38457. */
  38458. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  38459. /**
  38460. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  38461. */
  38462. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  38463. /** Callback called when a pointer move is detected */
  38464. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  38465. /** Callback called when a pointer down is detected */
  38466. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  38467. /** Callback called when a pointer up is detected */
  38468. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  38469. /** Callback called when a pointer pick is detected */
  38470. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  38471. /**
  38472. * 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).
  38473. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  38474. */
  38475. onPrePointerObservable: Observable<PointerInfoPre>;
  38476. /**
  38477. * Observable event triggered each time an input event is received from the rendering canvas
  38478. */
  38479. onPointerObservable: Observable<PointerInfo>;
  38480. /**
  38481. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  38482. */
  38483. get unTranslatedPointer(): Vector2;
  38484. /**
  38485. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  38486. */
  38487. static get DragMovementThreshold(): number;
  38488. static set DragMovementThreshold(value: number);
  38489. /**
  38490. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  38491. */
  38492. static get LongPressDelay(): number;
  38493. static set LongPressDelay(value: number);
  38494. /**
  38495. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  38496. */
  38497. static get DoubleClickDelay(): number;
  38498. static set DoubleClickDelay(value: number);
  38499. /** If you need to check double click without raising a single click at first click, enable this flag */
  38500. static get ExclusiveDoubleClickMode(): boolean;
  38501. static set ExclusiveDoubleClickMode(value: boolean);
  38502. /** @hidden */
  38503. _mirroredCameraPosition: Nullable<Vector3>;
  38504. /**
  38505. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  38506. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  38507. */
  38508. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  38509. /**
  38510. * Observable event triggered each time an keyboard event is received from the hosting window
  38511. */
  38512. onKeyboardObservable: Observable<KeyboardInfo>;
  38513. private _useRightHandedSystem;
  38514. /**
  38515. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  38516. */
  38517. set useRightHandedSystem(value: boolean);
  38518. get useRightHandedSystem(): boolean;
  38519. private _timeAccumulator;
  38520. private _currentStepId;
  38521. private _currentInternalStep;
  38522. /**
  38523. * Sets the step Id used by deterministic lock step
  38524. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38525. * @param newStepId defines the step Id
  38526. */
  38527. setStepId(newStepId: number): void;
  38528. /**
  38529. * Gets the step Id used by deterministic lock step
  38530. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38531. * @returns the step Id
  38532. */
  38533. getStepId(): number;
  38534. /**
  38535. * Gets the internal step used by deterministic lock step
  38536. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38537. * @returns the internal step
  38538. */
  38539. getInternalStep(): number;
  38540. private _fogEnabled;
  38541. /**
  38542. * Gets or sets a boolean indicating if fog is enabled on this scene
  38543. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38544. * (Default is true)
  38545. */
  38546. set fogEnabled(value: boolean);
  38547. get fogEnabled(): boolean;
  38548. private _fogMode;
  38549. /**
  38550. * Gets or sets the fog mode to use
  38551. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38552. * | mode | value |
  38553. * | --- | --- |
  38554. * | FOGMODE_NONE | 0 |
  38555. * | FOGMODE_EXP | 1 |
  38556. * | FOGMODE_EXP2 | 2 |
  38557. * | FOGMODE_LINEAR | 3 |
  38558. */
  38559. set fogMode(value: number);
  38560. get fogMode(): number;
  38561. /**
  38562. * Gets or sets the fog color to use
  38563. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38564. * (Default is Color3(0.2, 0.2, 0.3))
  38565. */
  38566. fogColor: Color3;
  38567. /**
  38568. * Gets or sets the fog density to use
  38569. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38570. * (Default is 0.1)
  38571. */
  38572. fogDensity: number;
  38573. /**
  38574. * Gets or sets the fog start distance to use
  38575. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38576. * (Default is 0)
  38577. */
  38578. fogStart: number;
  38579. /**
  38580. * Gets or sets the fog end distance to use
  38581. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38582. * (Default is 1000)
  38583. */
  38584. fogEnd: number;
  38585. private _shadowsEnabled;
  38586. /**
  38587. * Gets or sets a boolean indicating if shadows are enabled on this scene
  38588. */
  38589. set shadowsEnabled(value: boolean);
  38590. get shadowsEnabled(): boolean;
  38591. private _lightsEnabled;
  38592. /**
  38593. * Gets or sets a boolean indicating if lights are enabled on this scene
  38594. */
  38595. set lightsEnabled(value: boolean);
  38596. get lightsEnabled(): boolean;
  38597. /** All of the active cameras added to this scene. */
  38598. activeCameras: Camera[];
  38599. /** @hidden */
  38600. _activeCamera: Nullable<Camera>;
  38601. /** Gets or sets the current active camera */
  38602. get activeCamera(): Nullable<Camera>;
  38603. set activeCamera(value: Nullable<Camera>);
  38604. private _defaultMaterial;
  38605. /** The default material used on meshes when no material is affected */
  38606. get defaultMaterial(): Material;
  38607. /** The default material used on meshes when no material is affected */
  38608. set defaultMaterial(value: Material);
  38609. private _texturesEnabled;
  38610. /**
  38611. * Gets or sets a boolean indicating if textures are enabled on this scene
  38612. */
  38613. set texturesEnabled(value: boolean);
  38614. get texturesEnabled(): boolean;
  38615. /**
  38616. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  38617. */
  38618. physicsEnabled: boolean;
  38619. /**
  38620. * Gets or sets a boolean indicating if particles are enabled on this scene
  38621. */
  38622. particlesEnabled: boolean;
  38623. /**
  38624. * Gets or sets a boolean indicating if sprites are enabled on this scene
  38625. */
  38626. spritesEnabled: boolean;
  38627. private _skeletonsEnabled;
  38628. /**
  38629. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  38630. */
  38631. set skeletonsEnabled(value: boolean);
  38632. get skeletonsEnabled(): boolean;
  38633. /**
  38634. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  38635. */
  38636. lensFlaresEnabled: boolean;
  38637. /**
  38638. * Gets or sets a boolean indicating if collisions are enabled on this scene
  38639. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  38640. */
  38641. collisionsEnabled: boolean;
  38642. private _collisionCoordinator;
  38643. /** @hidden */
  38644. get collisionCoordinator(): ICollisionCoordinator;
  38645. /**
  38646. * Defines the gravity applied to this scene (used only for collisions)
  38647. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  38648. */
  38649. gravity: Vector3;
  38650. /**
  38651. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  38652. */
  38653. postProcessesEnabled: boolean;
  38654. /**
  38655. * The list of postprocesses added to the scene
  38656. */
  38657. postProcesses: PostProcess[];
  38658. /**
  38659. * Gets the current postprocess manager
  38660. */
  38661. postProcessManager: PostProcessManager;
  38662. /**
  38663. * Gets or sets a boolean indicating if render targets are enabled on this scene
  38664. */
  38665. renderTargetsEnabled: boolean;
  38666. /**
  38667. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  38668. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  38669. */
  38670. dumpNextRenderTargets: boolean;
  38671. /**
  38672. * The list of user defined render targets added to the scene
  38673. */
  38674. customRenderTargets: RenderTargetTexture[];
  38675. /**
  38676. * Defines if texture loading must be delayed
  38677. * If true, textures will only be loaded when they need to be rendered
  38678. */
  38679. useDelayedTextureLoading: boolean;
  38680. /**
  38681. * Gets the list of meshes imported to the scene through SceneLoader
  38682. */
  38683. importedMeshesFiles: String[];
  38684. /**
  38685. * Gets or sets a boolean indicating if probes are enabled on this scene
  38686. */
  38687. probesEnabled: boolean;
  38688. /**
  38689. * Gets or sets the current offline provider to use to store scene data
  38690. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  38691. */
  38692. offlineProvider: IOfflineProvider;
  38693. /**
  38694. * Gets or sets the action manager associated with the scene
  38695. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  38696. */
  38697. actionManager: AbstractActionManager;
  38698. private _meshesForIntersections;
  38699. /**
  38700. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  38701. */
  38702. proceduralTexturesEnabled: boolean;
  38703. private _engine;
  38704. private _totalVertices;
  38705. /** @hidden */
  38706. _activeIndices: PerfCounter;
  38707. /** @hidden */
  38708. _activeParticles: PerfCounter;
  38709. /** @hidden */
  38710. _activeBones: PerfCounter;
  38711. private _animationRatio;
  38712. /** @hidden */
  38713. _animationTimeLast: number;
  38714. /** @hidden */
  38715. _animationTime: number;
  38716. /**
  38717. * Gets or sets a general scale for animation speed
  38718. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  38719. */
  38720. animationTimeScale: number;
  38721. /** @hidden */
  38722. _cachedMaterial: Nullable<Material>;
  38723. /** @hidden */
  38724. _cachedEffect: Nullable<Effect>;
  38725. /** @hidden */
  38726. _cachedVisibility: Nullable<number>;
  38727. private _renderId;
  38728. private _frameId;
  38729. private _executeWhenReadyTimeoutId;
  38730. private _intermediateRendering;
  38731. private _viewUpdateFlag;
  38732. private _projectionUpdateFlag;
  38733. /** @hidden */
  38734. _toBeDisposed: Nullable<IDisposable>[];
  38735. private _activeRequests;
  38736. /** @hidden */
  38737. _pendingData: any[];
  38738. private _isDisposed;
  38739. /**
  38740. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  38741. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  38742. */
  38743. dispatchAllSubMeshesOfActiveMeshes: boolean;
  38744. private _activeMeshes;
  38745. private _processedMaterials;
  38746. private _renderTargets;
  38747. /** @hidden */
  38748. _activeParticleSystems: SmartArray<IParticleSystem>;
  38749. private _activeSkeletons;
  38750. private _softwareSkinnedMeshes;
  38751. private _renderingManager;
  38752. /** @hidden */
  38753. _activeAnimatables: Animatable[];
  38754. private _transformMatrix;
  38755. private _sceneUbo;
  38756. /** @hidden */
  38757. _viewMatrix: Matrix;
  38758. private _projectionMatrix;
  38759. /** @hidden */
  38760. _forcedViewPosition: Nullable<Vector3>;
  38761. /** @hidden */
  38762. _frustumPlanes: Plane[];
  38763. /**
  38764. * Gets the list of frustum planes (built from the active camera)
  38765. */
  38766. get frustumPlanes(): Plane[];
  38767. /**
  38768. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  38769. * This is useful if there are more lights that the maximum simulteanous authorized
  38770. */
  38771. requireLightSorting: boolean;
  38772. /** @hidden */
  38773. readonly useMaterialMeshMap: boolean;
  38774. /** @hidden */
  38775. readonly useClonedMeshMap: boolean;
  38776. private _externalData;
  38777. private _uid;
  38778. /**
  38779. * @hidden
  38780. * Backing store of defined scene components.
  38781. */
  38782. _components: ISceneComponent[];
  38783. /**
  38784. * @hidden
  38785. * Backing store of defined scene components.
  38786. */
  38787. _serializableComponents: ISceneSerializableComponent[];
  38788. /**
  38789. * List of components to register on the next registration step.
  38790. */
  38791. private _transientComponents;
  38792. /**
  38793. * Registers the transient components if needed.
  38794. */
  38795. private _registerTransientComponents;
  38796. /**
  38797. * @hidden
  38798. * Add a component to the scene.
  38799. * Note that the ccomponent could be registered on th next frame if this is called after
  38800. * the register component stage.
  38801. * @param component Defines the component to add to the scene
  38802. */
  38803. _addComponent(component: ISceneComponent): void;
  38804. /**
  38805. * @hidden
  38806. * Gets a component from the scene.
  38807. * @param name defines the name of the component to retrieve
  38808. * @returns the component or null if not present
  38809. */
  38810. _getComponent(name: string): Nullable<ISceneComponent>;
  38811. /**
  38812. * @hidden
  38813. * Defines the actions happening before camera updates.
  38814. */
  38815. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  38816. /**
  38817. * @hidden
  38818. * Defines the actions happening before clear the canvas.
  38819. */
  38820. _beforeClearStage: Stage<SimpleStageAction>;
  38821. /**
  38822. * @hidden
  38823. * Defines the actions when collecting render targets for the frame.
  38824. */
  38825. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  38826. /**
  38827. * @hidden
  38828. * Defines the actions happening for one camera in the frame.
  38829. */
  38830. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  38831. /**
  38832. * @hidden
  38833. * Defines the actions happening during the per mesh ready checks.
  38834. */
  38835. _isReadyForMeshStage: Stage<MeshStageAction>;
  38836. /**
  38837. * @hidden
  38838. * Defines the actions happening before evaluate active mesh checks.
  38839. */
  38840. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  38841. /**
  38842. * @hidden
  38843. * Defines the actions happening during the evaluate sub mesh checks.
  38844. */
  38845. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  38846. /**
  38847. * @hidden
  38848. * Defines the actions happening during the active mesh stage.
  38849. */
  38850. _activeMeshStage: Stage<ActiveMeshStageAction>;
  38851. /**
  38852. * @hidden
  38853. * Defines the actions happening during the per camera render target step.
  38854. */
  38855. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  38856. /**
  38857. * @hidden
  38858. * Defines the actions happening just before the active camera is drawing.
  38859. */
  38860. _beforeCameraDrawStage: Stage<CameraStageAction>;
  38861. /**
  38862. * @hidden
  38863. * Defines the actions happening just before a render target is drawing.
  38864. */
  38865. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  38866. /**
  38867. * @hidden
  38868. * Defines the actions happening just before a rendering group is drawing.
  38869. */
  38870. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  38871. /**
  38872. * @hidden
  38873. * Defines the actions happening just before a mesh is drawing.
  38874. */
  38875. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  38876. /**
  38877. * @hidden
  38878. * Defines the actions happening just after a mesh has been drawn.
  38879. */
  38880. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  38881. /**
  38882. * @hidden
  38883. * Defines the actions happening just after a rendering group has been drawn.
  38884. */
  38885. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  38886. /**
  38887. * @hidden
  38888. * Defines the actions happening just after the active camera has been drawn.
  38889. */
  38890. _afterCameraDrawStage: Stage<CameraStageAction>;
  38891. /**
  38892. * @hidden
  38893. * Defines the actions happening just after a render target has been drawn.
  38894. */
  38895. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  38896. /**
  38897. * @hidden
  38898. * Defines the actions happening just after rendering all cameras and computing intersections.
  38899. */
  38900. _afterRenderStage: Stage<SimpleStageAction>;
  38901. /**
  38902. * @hidden
  38903. * Defines the actions happening when a pointer move event happens.
  38904. */
  38905. _pointerMoveStage: Stage<PointerMoveStageAction>;
  38906. /**
  38907. * @hidden
  38908. * Defines the actions happening when a pointer down event happens.
  38909. */
  38910. _pointerDownStage: Stage<PointerUpDownStageAction>;
  38911. /**
  38912. * @hidden
  38913. * Defines the actions happening when a pointer up event happens.
  38914. */
  38915. _pointerUpStage: Stage<PointerUpDownStageAction>;
  38916. /**
  38917. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  38918. */
  38919. private geometriesByUniqueId;
  38920. /**
  38921. * Creates a new Scene
  38922. * @param engine defines the engine to use to render this scene
  38923. * @param options defines the scene options
  38924. */
  38925. constructor(engine: Engine, options?: SceneOptions);
  38926. /**
  38927. * Gets a string idenfifying the name of the class
  38928. * @returns "Scene" string
  38929. */
  38930. getClassName(): string;
  38931. private _defaultMeshCandidates;
  38932. /**
  38933. * @hidden
  38934. */
  38935. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  38936. private _defaultSubMeshCandidates;
  38937. /**
  38938. * @hidden
  38939. */
  38940. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  38941. /**
  38942. * Sets the default candidate providers for the scene.
  38943. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  38944. * and getCollidingSubMeshCandidates to their default function
  38945. */
  38946. setDefaultCandidateProviders(): void;
  38947. /**
  38948. * Gets the mesh that is currently under the pointer
  38949. */
  38950. get meshUnderPointer(): Nullable<AbstractMesh>;
  38951. /**
  38952. * Gets or sets the current on-screen X position of the pointer
  38953. */
  38954. get pointerX(): number;
  38955. set pointerX(value: number);
  38956. /**
  38957. * Gets or sets the current on-screen Y position of the pointer
  38958. */
  38959. get pointerY(): number;
  38960. set pointerY(value: number);
  38961. /**
  38962. * Gets the cached material (ie. the latest rendered one)
  38963. * @returns the cached material
  38964. */
  38965. getCachedMaterial(): Nullable<Material>;
  38966. /**
  38967. * Gets the cached effect (ie. the latest rendered one)
  38968. * @returns the cached effect
  38969. */
  38970. getCachedEffect(): Nullable<Effect>;
  38971. /**
  38972. * Gets the cached visibility state (ie. the latest rendered one)
  38973. * @returns the cached visibility state
  38974. */
  38975. getCachedVisibility(): Nullable<number>;
  38976. /**
  38977. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  38978. * @param material defines the current material
  38979. * @param effect defines the current effect
  38980. * @param visibility defines the current visibility state
  38981. * @returns true if one parameter is not cached
  38982. */
  38983. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  38984. /**
  38985. * Gets the engine associated with the scene
  38986. * @returns an Engine
  38987. */
  38988. getEngine(): Engine;
  38989. /**
  38990. * Gets the total number of vertices rendered per frame
  38991. * @returns the total number of vertices rendered per frame
  38992. */
  38993. getTotalVertices(): number;
  38994. /**
  38995. * Gets the performance counter for total vertices
  38996. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  38997. */
  38998. get totalVerticesPerfCounter(): PerfCounter;
  38999. /**
  39000. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  39001. * @returns the total number of active indices rendered per frame
  39002. */
  39003. getActiveIndices(): number;
  39004. /**
  39005. * Gets the performance counter for active indices
  39006. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39007. */
  39008. get totalActiveIndicesPerfCounter(): PerfCounter;
  39009. /**
  39010. * Gets the total number of active particles rendered per frame
  39011. * @returns the total number of active particles rendered per frame
  39012. */
  39013. getActiveParticles(): number;
  39014. /**
  39015. * Gets the performance counter for active particles
  39016. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39017. */
  39018. get activeParticlesPerfCounter(): PerfCounter;
  39019. /**
  39020. * Gets the total number of active bones rendered per frame
  39021. * @returns the total number of active bones rendered per frame
  39022. */
  39023. getActiveBones(): number;
  39024. /**
  39025. * Gets the performance counter for active bones
  39026. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39027. */
  39028. get activeBonesPerfCounter(): PerfCounter;
  39029. /**
  39030. * Gets the array of active meshes
  39031. * @returns an array of AbstractMesh
  39032. */
  39033. getActiveMeshes(): SmartArray<AbstractMesh>;
  39034. /**
  39035. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  39036. * @returns a number
  39037. */
  39038. getAnimationRatio(): number;
  39039. /**
  39040. * Gets an unique Id for the current render phase
  39041. * @returns a number
  39042. */
  39043. getRenderId(): number;
  39044. /**
  39045. * Gets an unique Id for the current frame
  39046. * @returns a number
  39047. */
  39048. getFrameId(): number;
  39049. /** Call this function if you want to manually increment the render Id*/
  39050. incrementRenderId(): void;
  39051. private _createUbo;
  39052. /**
  39053. * Use this method to simulate a pointer move on a mesh
  39054. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39055. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39056. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39057. * @returns the current scene
  39058. */
  39059. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  39060. /**
  39061. * Use this method to simulate a pointer down on a mesh
  39062. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39063. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39064. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39065. * @returns the current scene
  39066. */
  39067. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  39068. /**
  39069. * Use this method to simulate a pointer up on a mesh
  39070. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39071. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39072. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39073. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  39074. * @returns the current scene
  39075. */
  39076. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  39077. /**
  39078. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  39079. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  39080. * @returns true if the pointer was captured
  39081. */
  39082. isPointerCaptured(pointerId?: number): boolean;
  39083. /**
  39084. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  39085. * @param attachUp defines if you want to attach events to pointerup
  39086. * @param attachDown defines if you want to attach events to pointerdown
  39087. * @param attachMove defines if you want to attach events to pointermove
  39088. */
  39089. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  39090. /** Detaches all event handlers*/
  39091. detachControl(): void;
  39092. /**
  39093. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  39094. * Delay loaded resources are not taking in account
  39095. * @return true if all required resources are ready
  39096. */
  39097. isReady(): boolean;
  39098. /** Resets all cached information relative to material (including effect and visibility) */
  39099. resetCachedMaterial(): void;
  39100. /**
  39101. * Registers a function to be called before every frame render
  39102. * @param func defines the function to register
  39103. */
  39104. registerBeforeRender(func: () => void): void;
  39105. /**
  39106. * Unregisters a function called before every frame render
  39107. * @param func defines the function to unregister
  39108. */
  39109. unregisterBeforeRender(func: () => void): void;
  39110. /**
  39111. * Registers a function to be called after every frame render
  39112. * @param func defines the function to register
  39113. */
  39114. registerAfterRender(func: () => void): void;
  39115. /**
  39116. * Unregisters a function called after every frame render
  39117. * @param func defines the function to unregister
  39118. */
  39119. unregisterAfterRender(func: () => void): void;
  39120. private _executeOnceBeforeRender;
  39121. /**
  39122. * The provided function will run before render once and will be disposed afterwards.
  39123. * A timeout delay can be provided so that the function will be executed in N ms.
  39124. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  39125. * @param func The function to be executed.
  39126. * @param timeout optional delay in ms
  39127. */
  39128. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  39129. /** @hidden */
  39130. _addPendingData(data: any): void;
  39131. /** @hidden */
  39132. _removePendingData(data: any): void;
  39133. /**
  39134. * Returns the number of items waiting to be loaded
  39135. * @returns the number of items waiting to be loaded
  39136. */
  39137. getWaitingItemsCount(): number;
  39138. /**
  39139. * Returns a boolean indicating if the scene is still loading data
  39140. */
  39141. get isLoading(): boolean;
  39142. /**
  39143. * Registers a function to be executed when the scene is ready
  39144. * @param {Function} func - the function to be executed
  39145. */
  39146. executeWhenReady(func: () => void): void;
  39147. /**
  39148. * Returns a promise that resolves when the scene is ready
  39149. * @returns A promise that resolves when the scene is ready
  39150. */
  39151. whenReadyAsync(): Promise<void>;
  39152. /** @hidden */
  39153. _checkIsReady(): void;
  39154. /**
  39155. * Gets all animatable attached to the scene
  39156. */
  39157. get animatables(): Animatable[];
  39158. /**
  39159. * Resets the last animation time frame.
  39160. * Useful to override when animations start running when loading a scene for the first time.
  39161. */
  39162. resetLastAnimationTimeFrame(): void;
  39163. /**
  39164. * Gets the current view matrix
  39165. * @returns a Matrix
  39166. */
  39167. getViewMatrix(): Matrix;
  39168. /**
  39169. * Gets the current projection matrix
  39170. * @returns a Matrix
  39171. */
  39172. getProjectionMatrix(): Matrix;
  39173. /**
  39174. * Gets the current transform matrix
  39175. * @returns a Matrix made of View * Projection
  39176. */
  39177. getTransformMatrix(): Matrix;
  39178. /**
  39179. * Sets the current transform matrix
  39180. * @param viewL defines the View matrix to use
  39181. * @param projectionL defines the Projection matrix to use
  39182. * @param viewR defines the right View matrix to use (if provided)
  39183. * @param projectionR defines the right Projection matrix to use (if provided)
  39184. */
  39185. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  39186. /**
  39187. * Gets the uniform buffer used to store scene data
  39188. * @returns a UniformBuffer
  39189. */
  39190. getSceneUniformBuffer(): UniformBuffer;
  39191. /**
  39192. * Gets an unique (relatively to the current scene) Id
  39193. * @returns an unique number for the scene
  39194. */
  39195. getUniqueId(): number;
  39196. /**
  39197. * Add a mesh to the list of scene's meshes
  39198. * @param newMesh defines the mesh to add
  39199. * @param recursive if all child meshes should also be added to the scene
  39200. */
  39201. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  39202. /**
  39203. * Remove a mesh for the list of scene's meshes
  39204. * @param toRemove defines the mesh to remove
  39205. * @param recursive if all child meshes should also be removed from the scene
  39206. * @returns the index where the mesh was in the mesh list
  39207. */
  39208. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  39209. /**
  39210. * Add a transform node to the list of scene's transform nodes
  39211. * @param newTransformNode defines the transform node to add
  39212. */
  39213. addTransformNode(newTransformNode: TransformNode): void;
  39214. /**
  39215. * Remove a transform node for the list of scene's transform nodes
  39216. * @param toRemove defines the transform node to remove
  39217. * @returns the index where the transform node was in the transform node list
  39218. */
  39219. removeTransformNode(toRemove: TransformNode): number;
  39220. /**
  39221. * Remove a skeleton for the list of scene's skeletons
  39222. * @param toRemove defines the skeleton to remove
  39223. * @returns the index where the skeleton was in the skeleton list
  39224. */
  39225. removeSkeleton(toRemove: Skeleton): number;
  39226. /**
  39227. * Remove a morph target for the list of scene's morph targets
  39228. * @param toRemove defines the morph target to remove
  39229. * @returns the index where the morph target was in the morph target list
  39230. */
  39231. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  39232. /**
  39233. * Remove a light for the list of scene's lights
  39234. * @param toRemove defines the light to remove
  39235. * @returns the index where the light was in the light list
  39236. */
  39237. removeLight(toRemove: Light): number;
  39238. /**
  39239. * Remove a camera for the list of scene's cameras
  39240. * @param toRemove defines the camera to remove
  39241. * @returns the index where the camera was in the camera list
  39242. */
  39243. removeCamera(toRemove: Camera): number;
  39244. /**
  39245. * Remove a particle system for the list of scene's particle systems
  39246. * @param toRemove defines the particle system to remove
  39247. * @returns the index where the particle system was in the particle system list
  39248. */
  39249. removeParticleSystem(toRemove: IParticleSystem): number;
  39250. /**
  39251. * Remove a animation for the list of scene's animations
  39252. * @param toRemove defines the animation to remove
  39253. * @returns the index where the animation was in the animation list
  39254. */
  39255. removeAnimation(toRemove: Animation): number;
  39256. /**
  39257. * Will stop the animation of the given target
  39258. * @param target - the target
  39259. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  39260. * @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)
  39261. */
  39262. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  39263. /**
  39264. * Removes the given animation group from this scene.
  39265. * @param toRemove The animation group to remove
  39266. * @returns The index of the removed animation group
  39267. */
  39268. removeAnimationGroup(toRemove: AnimationGroup): number;
  39269. /**
  39270. * Removes the given multi-material from this scene.
  39271. * @param toRemove The multi-material to remove
  39272. * @returns The index of the removed multi-material
  39273. */
  39274. removeMultiMaterial(toRemove: MultiMaterial): number;
  39275. /**
  39276. * Removes the given material from this scene.
  39277. * @param toRemove The material to remove
  39278. * @returns The index of the removed material
  39279. */
  39280. removeMaterial(toRemove: Material): number;
  39281. /**
  39282. * Removes the given action manager from this scene.
  39283. * @param toRemove The action manager to remove
  39284. * @returns The index of the removed action manager
  39285. */
  39286. removeActionManager(toRemove: AbstractActionManager): number;
  39287. /**
  39288. * Removes the given texture from this scene.
  39289. * @param toRemove The texture to remove
  39290. * @returns The index of the removed texture
  39291. */
  39292. removeTexture(toRemove: BaseTexture): number;
  39293. /**
  39294. * Adds the given light to this scene
  39295. * @param newLight The light to add
  39296. */
  39297. addLight(newLight: Light): void;
  39298. /**
  39299. * Sorts the list list based on light priorities
  39300. */
  39301. sortLightsByPriority(): void;
  39302. /**
  39303. * Adds the given camera to this scene
  39304. * @param newCamera The camera to add
  39305. */
  39306. addCamera(newCamera: Camera): void;
  39307. /**
  39308. * Adds the given skeleton to this scene
  39309. * @param newSkeleton The skeleton to add
  39310. */
  39311. addSkeleton(newSkeleton: Skeleton): void;
  39312. /**
  39313. * Adds the given particle system to this scene
  39314. * @param newParticleSystem The particle system to add
  39315. */
  39316. addParticleSystem(newParticleSystem: IParticleSystem): void;
  39317. /**
  39318. * Adds the given animation to this scene
  39319. * @param newAnimation The animation to add
  39320. */
  39321. addAnimation(newAnimation: Animation): void;
  39322. /**
  39323. * Adds the given animation group to this scene.
  39324. * @param newAnimationGroup The animation group to add
  39325. */
  39326. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  39327. /**
  39328. * Adds the given multi-material to this scene
  39329. * @param newMultiMaterial The multi-material to add
  39330. */
  39331. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  39332. /**
  39333. * Adds the given material to this scene
  39334. * @param newMaterial The material to add
  39335. */
  39336. addMaterial(newMaterial: Material): void;
  39337. /**
  39338. * Adds the given morph target to this scene
  39339. * @param newMorphTargetManager The morph target to add
  39340. */
  39341. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  39342. /**
  39343. * Adds the given geometry to this scene
  39344. * @param newGeometry The geometry to add
  39345. */
  39346. addGeometry(newGeometry: Geometry): void;
  39347. /**
  39348. * Adds the given action manager to this scene
  39349. * @param newActionManager The action manager to add
  39350. */
  39351. addActionManager(newActionManager: AbstractActionManager): void;
  39352. /**
  39353. * Adds the given texture to this scene.
  39354. * @param newTexture The texture to add
  39355. */
  39356. addTexture(newTexture: BaseTexture): void;
  39357. /**
  39358. * Switch active camera
  39359. * @param newCamera defines the new active camera
  39360. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  39361. */
  39362. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  39363. /**
  39364. * sets the active camera of the scene using its ID
  39365. * @param id defines the camera's ID
  39366. * @return the new active camera or null if none found.
  39367. */
  39368. setActiveCameraByID(id: string): Nullable<Camera>;
  39369. /**
  39370. * sets the active camera of the scene using its name
  39371. * @param name defines the camera's name
  39372. * @returns the new active camera or null if none found.
  39373. */
  39374. setActiveCameraByName(name: string): Nullable<Camera>;
  39375. /**
  39376. * get an animation group using its name
  39377. * @param name defines the material's name
  39378. * @return the animation group or null if none found.
  39379. */
  39380. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  39381. /**
  39382. * Get a material using its unique id
  39383. * @param uniqueId defines the material's unique id
  39384. * @return the material or null if none found.
  39385. */
  39386. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  39387. /**
  39388. * get a material using its id
  39389. * @param id defines the material's ID
  39390. * @return the material or null if none found.
  39391. */
  39392. getMaterialByID(id: string): Nullable<Material>;
  39393. /**
  39394. * Gets a the last added material using a given id
  39395. * @param id defines the material's ID
  39396. * @return the last material with the given id or null if none found.
  39397. */
  39398. getLastMaterialByID(id: string): Nullable<Material>;
  39399. /**
  39400. * Gets a material using its name
  39401. * @param name defines the material's name
  39402. * @return the material or null if none found.
  39403. */
  39404. getMaterialByName(name: string): Nullable<Material>;
  39405. /**
  39406. * Get a texture using its unique id
  39407. * @param uniqueId defines the texture's unique id
  39408. * @return the texture or null if none found.
  39409. */
  39410. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  39411. /**
  39412. * Gets a camera using its id
  39413. * @param id defines the id to look for
  39414. * @returns the camera or null if not found
  39415. */
  39416. getCameraByID(id: string): Nullable<Camera>;
  39417. /**
  39418. * Gets a camera using its unique id
  39419. * @param uniqueId defines the unique id to look for
  39420. * @returns the camera or null if not found
  39421. */
  39422. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  39423. /**
  39424. * Gets a camera using its name
  39425. * @param name defines the camera's name
  39426. * @return the camera or null if none found.
  39427. */
  39428. getCameraByName(name: string): Nullable<Camera>;
  39429. /**
  39430. * Gets a bone using its id
  39431. * @param id defines the bone's id
  39432. * @return the bone or null if not found
  39433. */
  39434. getBoneByID(id: string): Nullable<Bone>;
  39435. /**
  39436. * Gets a bone using its id
  39437. * @param name defines the bone's name
  39438. * @return the bone or null if not found
  39439. */
  39440. getBoneByName(name: string): Nullable<Bone>;
  39441. /**
  39442. * Gets a light node using its name
  39443. * @param name defines the the light's name
  39444. * @return the light or null if none found.
  39445. */
  39446. getLightByName(name: string): Nullable<Light>;
  39447. /**
  39448. * Gets a light node using its id
  39449. * @param id defines the light's id
  39450. * @return the light or null if none found.
  39451. */
  39452. getLightByID(id: string): Nullable<Light>;
  39453. /**
  39454. * Gets a light node using its scene-generated unique ID
  39455. * @param uniqueId defines the light's unique id
  39456. * @return the light or null if none found.
  39457. */
  39458. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  39459. /**
  39460. * Gets a particle system by id
  39461. * @param id defines the particle system id
  39462. * @return the corresponding system or null if none found
  39463. */
  39464. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  39465. /**
  39466. * Gets a geometry using its ID
  39467. * @param id defines the geometry's id
  39468. * @return the geometry or null if none found.
  39469. */
  39470. getGeometryByID(id: string): Nullable<Geometry>;
  39471. private _getGeometryByUniqueID;
  39472. /**
  39473. * Add a new geometry to this scene
  39474. * @param geometry defines the geometry to be added to the scene.
  39475. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  39476. * @return a boolean defining if the geometry was added or not
  39477. */
  39478. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  39479. /**
  39480. * Removes an existing geometry
  39481. * @param geometry defines the geometry to be removed from the scene
  39482. * @return a boolean defining if the geometry was removed or not
  39483. */
  39484. removeGeometry(geometry: Geometry): boolean;
  39485. /**
  39486. * Gets the list of geometries attached to the scene
  39487. * @returns an array of Geometry
  39488. */
  39489. getGeometries(): Geometry[];
  39490. /**
  39491. * Gets the first added mesh found of a given ID
  39492. * @param id defines the id to search for
  39493. * @return the mesh found or null if not found at all
  39494. */
  39495. getMeshByID(id: string): Nullable<AbstractMesh>;
  39496. /**
  39497. * Gets a list of meshes using their id
  39498. * @param id defines the id to search for
  39499. * @returns a list of meshes
  39500. */
  39501. getMeshesByID(id: string): Array<AbstractMesh>;
  39502. /**
  39503. * Gets the first added transform node found of a given ID
  39504. * @param id defines the id to search for
  39505. * @return the found transform node or null if not found at all.
  39506. */
  39507. getTransformNodeByID(id: string): Nullable<TransformNode>;
  39508. /**
  39509. * Gets a transform node with its auto-generated unique id
  39510. * @param uniqueId efines the unique id to search for
  39511. * @return the found transform node or null if not found at all.
  39512. */
  39513. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  39514. /**
  39515. * Gets a list of transform nodes using their id
  39516. * @param id defines the id to search for
  39517. * @returns a list of transform nodes
  39518. */
  39519. getTransformNodesByID(id: string): Array<TransformNode>;
  39520. /**
  39521. * Gets a mesh with its auto-generated unique id
  39522. * @param uniqueId defines the unique id to search for
  39523. * @return the found mesh or null if not found at all.
  39524. */
  39525. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  39526. /**
  39527. * Gets a the last added mesh using a given id
  39528. * @param id defines the id to search for
  39529. * @return the found mesh or null if not found at all.
  39530. */
  39531. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  39532. /**
  39533. * Gets a the last added node (Mesh, Camera, Light) using a given id
  39534. * @param id defines the id to search for
  39535. * @return the found node or null if not found at all
  39536. */
  39537. getLastEntryByID(id: string): Nullable<Node>;
  39538. /**
  39539. * Gets a node (Mesh, Camera, Light) using a given id
  39540. * @param id defines the id to search for
  39541. * @return the found node or null if not found at all
  39542. */
  39543. getNodeByID(id: string): Nullable<Node>;
  39544. /**
  39545. * Gets a node (Mesh, Camera, Light) using a given name
  39546. * @param name defines the name to search for
  39547. * @return the found node or null if not found at all.
  39548. */
  39549. getNodeByName(name: string): Nullable<Node>;
  39550. /**
  39551. * Gets a mesh using a given name
  39552. * @param name defines the name to search for
  39553. * @return the found mesh or null if not found at all.
  39554. */
  39555. getMeshByName(name: string): Nullable<AbstractMesh>;
  39556. /**
  39557. * Gets a transform node using a given name
  39558. * @param name defines the name to search for
  39559. * @return the found transform node or null if not found at all.
  39560. */
  39561. getTransformNodeByName(name: string): Nullable<TransformNode>;
  39562. /**
  39563. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  39564. * @param id defines the id to search for
  39565. * @return the found skeleton or null if not found at all.
  39566. */
  39567. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  39568. /**
  39569. * Gets a skeleton using a given auto generated unique id
  39570. * @param uniqueId defines the unique id to search for
  39571. * @return the found skeleton or null if not found at all.
  39572. */
  39573. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  39574. /**
  39575. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  39576. * @param id defines the id to search for
  39577. * @return the found skeleton or null if not found at all.
  39578. */
  39579. getSkeletonById(id: string): Nullable<Skeleton>;
  39580. /**
  39581. * Gets a skeleton using a given name
  39582. * @param name defines the name to search for
  39583. * @return the found skeleton or null if not found at all.
  39584. */
  39585. getSkeletonByName(name: string): Nullable<Skeleton>;
  39586. /**
  39587. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  39588. * @param id defines the id to search for
  39589. * @return the found morph target manager or null if not found at all.
  39590. */
  39591. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  39592. /**
  39593. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  39594. * @param id defines the id to search for
  39595. * @return the found morph target or null if not found at all.
  39596. */
  39597. getMorphTargetById(id: string): Nullable<MorphTarget>;
  39598. /**
  39599. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  39600. * @param name defines the name to search for
  39601. * @return the found morph target or null if not found at all.
  39602. */
  39603. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  39604. /**
  39605. * Gets a boolean indicating if the given mesh is active
  39606. * @param mesh defines the mesh to look for
  39607. * @returns true if the mesh is in the active list
  39608. */
  39609. isActiveMesh(mesh: AbstractMesh): boolean;
  39610. /**
  39611. * Return a unique id as a string which can serve as an identifier for the scene
  39612. */
  39613. get uid(): string;
  39614. /**
  39615. * Add an externaly attached data from its key.
  39616. * This method call will fail and return false, if such key already exists.
  39617. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  39618. * @param key the unique key that identifies the data
  39619. * @param data the data object to associate to the key for this Engine instance
  39620. * @return true if no such key were already present and the data was added successfully, false otherwise
  39621. */
  39622. addExternalData<T>(key: string, data: T): boolean;
  39623. /**
  39624. * Get an externaly attached data from its key
  39625. * @param key the unique key that identifies the data
  39626. * @return the associated data, if present (can be null), or undefined if not present
  39627. */
  39628. getExternalData<T>(key: string): Nullable<T>;
  39629. /**
  39630. * Get an externaly attached data from its key, create it using a factory if it's not already present
  39631. * @param key the unique key that identifies the data
  39632. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  39633. * @return the associated data, can be null if the factory returned null.
  39634. */
  39635. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  39636. /**
  39637. * Remove an externaly attached data from the Engine instance
  39638. * @param key the unique key that identifies the data
  39639. * @return true if the data was successfully removed, false if it doesn't exist
  39640. */
  39641. removeExternalData(key: string): boolean;
  39642. private _evaluateSubMesh;
  39643. /**
  39644. * Clear the processed materials smart array preventing retention point in material dispose.
  39645. */
  39646. freeProcessedMaterials(): void;
  39647. private _preventFreeActiveMeshesAndRenderingGroups;
  39648. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  39649. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  39650. * when disposing several meshes in a row or a hierarchy of meshes.
  39651. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  39652. */
  39653. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  39654. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  39655. /**
  39656. * Clear the active meshes smart array preventing retention point in mesh dispose.
  39657. */
  39658. freeActiveMeshes(): void;
  39659. /**
  39660. * Clear the info related to rendering groups preventing retention points during dispose.
  39661. */
  39662. freeRenderingGroups(): void;
  39663. /** @hidden */
  39664. _isInIntermediateRendering(): boolean;
  39665. /**
  39666. * Lambda returning the list of potentially active meshes.
  39667. */
  39668. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  39669. /**
  39670. * Lambda returning the list of potentially active sub meshes.
  39671. */
  39672. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  39673. /**
  39674. * Lambda returning the list of potentially intersecting sub meshes.
  39675. */
  39676. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  39677. /**
  39678. * Lambda returning the list of potentially colliding sub meshes.
  39679. */
  39680. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  39681. private _activeMeshesFrozen;
  39682. private _skipEvaluateActiveMeshesCompletely;
  39683. /**
  39684. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  39685. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  39686. * @returns the current scene
  39687. */
  39688. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  39689. /**
  39690. * Use this function to restart evaluating active meshes on every frame
  39691. * @returns the current scene
  39692. */
  39693. unfreezeActiveMeshes(): Scene;
  39694. private _evaluateActiveMeshes;
  39695. private _activeMesh;
  39696. /**
  39697. * Update the transform matrix to update from the current active camera
  39698. * @param force defines a boolean used to force the update even if cache is up to date
  39699. */
  39700. updateTransformMatrix(force?: boolean): void;
  39701. private _bindFrameBuffer;
  39702. /** @hidden */
  39703. _allowPostProcessClearColor: boolean;
  39704. /** @hidden */
  39705. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  39706. private _processSubCameras;
  39707. private _checkIntersections;
  39708. /** @hidden */
  39709. _advancePhysicsEngineStep(step: number): void;
  39710. /**
  39711. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  39712. */
  39713. getDeterministicFrameTime: () => number;
  39714. /** @hidden */
  39715. _animate(): void;
  39716. /** Execute all animations (for a frame) */
  39717. animate(): void;
  39718. /**
  39719. * Render the scene
  39720. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  39721. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  39722. */
  39723. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  39724. /**
  39725. * Freeze all materials
  39726. * A frozen material will not be updatable but should be faster to render
  39727. */
  39728. freezeMaterials(): void;
  39729. /**
  39730. * Unfreeze all materials
  39731. * A frozen material will not be updatable but should be faster to render
  39732. */
  39733. unfreezeMaterials(): void;
  39734. /**
  39735. * Releases all held ressources
  39736. */
  39737. dispose(): void;
  39738. /**
  39739. * Gets if the scene is already disposed
  39740. */
  39741. get isDisposed(): boolean;
  39742. /**
  39743. * Call this function to reduce memory footprint of the scene.
  39744. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  39745. */
  39746. clearCachedVertexData(): void;
  39747. /**
  39748. * This function will remove the local cached buffer data from texture.
  39749. * It will save memory but will prevent the texture from being rebuilt
  39750. */
  39751. cleanCachedTextureBuffer(): void;
  39752. /**
  39753. * Get the world extend vectors with an optional filter
  39754. *
  39755. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  39756. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  39757. */
  39758. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  39759. min: Vector3;
  39760. max: Vector3;
  39761. };
  39762. /**
  39763. * Creates a ray that can be used to pick in the scene
  39764. * @param x defines the x coordinate of the origin (on-screen)
  39765. * @param y defines the y coordinate of the origin (on-screen)
  39766. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  39767. * @param camera defines the camera to use for the picking
  39768. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  39769. * @returns a Ray
  39770. */
  39771. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  39772. /**
  39773. * Creates a ray that can be used to pick in the scene
  39774. * @param x defines the x coordinate of the origin (on-screen)
  39775. * @param y defines the y coordinate of the origin (on-screen)
  39776. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  39777. * @param result defines the ray where to store the picking ray
  39778. * @param camera defines the camera to use for the picking
  39779. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  39780. * @returns the current scene
  39781. */
  39782. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  39783. /**
  39784. * Creates a ray that can be used to pick in the scene
  39785. * @param x defines the x coordinate of the origin (on-screen)
  39786. * @param y defines the y coordinate of the origin (on-screen)
  39787. * @param camera defines the camera to use for the picking
  39788. * @returns a Ray
  39789. */
  39790. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  39791. /**
  39792. * Creates a ray that can be used to pick in the scene
  39793. * @param x defines the x coordinate of the origin (on-screen)
  39794. * @param y defines the y coordinate of the origin (on-screen)
  39795. * @param result defines the ray where to store the picking ray
  39796. * @param camera defines the camera to use for the picking
  39797. * @returns the current scene
  39798. */
  39799. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  39800. /** Launch a ray to try to pick a mesh in the scene
  39801. * @param x position on screen
  39802. * @param y position on screen
  39803. * @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
  39804. * @param fastCheck defines if the first intersection will be used (and not the closest)
  39805. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  39806. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  39807. * @returns a PickingInfo
  39808. */
  39809. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  39810. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  39811. * @param x position on screen
  39812. * @param y position on screen
  39813. * @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
  39814. * @param fastCheck defines if the first intersection will be used (and not the closest)
  39815. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  39816. * @returns a PickingInfo (Please note that some info will not be set like distance, bv, bu and everything that cannot be capture by only using bounding infos)
  39817. */
  39818. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  39819. /** Use the given ray to pick a mesh in the scene
  39820. * @param ray The ray to use to pick meshes
  39821. * @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
  39822. * @param fastCheck defines if the first intersection will be used (and not the closest)
  39823. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  39824. * @returns a PickingInfo
  39825. */
  39826. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  39827. /**
  39828. * Launch a ray to try to pick a mesh in the scene
  39829. * @param x X position on screen
  39830. * @param y Y position on screen
  39831. * @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
  39832. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  39833. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  39834. * @returns an array of PickingInfo
  39835. */
  39836. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  39837. /**
  39838. * Launch a ray to try to pick a mesh in the scene
  39839. * @param ray Ray to use
  39840. * @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
  39841. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  39842. * @returns an array of PickingInfo
  39843. */
  39844. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  39845. /**
  39846. * Force the value of meshUnderPointer
  39847. * @param mesh defines the mesh to use
  39848. */
  39849. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  39850. /**
  39851. * Gets the mesh under the pointer
  39852. * @returns a Mesh or null if no mesh is under the pointer
  39853. */
  39854. getPointerOverMesh(): Nullable<AbstractMesh>;
  39855. /** @hidden */
  39856. _rebuildGeometries(): void;
  39857. /** @hidden */
  39858. _rebuildTextures(): void;
  39859. private _getByTags;
  39860. /**
  39861. * Get a list of meshes by tags
  39862. * @param tagsQuery defines the tags query to use
  39863. * @param forEach defines a predicate used to filter results
  39864. * @returns an array of Mesh
  39865. */
  39866. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  39867. /**
  39868. * Get a list of cameras by tags
  39869. * @param tagsQuery defines the tags query to use
  39870. * @param forEach defines a predicate used to filter results
  39871. * @returns an array of Camera
  39872. */
  39873. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  39874. /**
  39875. * Get a list of lights by tags
  39876. * @param tagsQuery defines the tags query to use
  39877. * @param forEach defines a predicate used to filter results
  39878. * @returns an array of Light
  39879. */
  39880. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  39881. /**
  39882. * Get a list of materials by tags
  39883. * @param tagsQuery defines the tags query to use
  39884. * @param forEach defines a predicate used to filter results
  39885. * @returns an array of Material
  39886. */
  39887. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  39888. /**
  39889. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  39890. * This allowed control for front to back rendering or reversly depending of the special needs.
  39891. *
  39892. * @param renderingGroupId The rendering group id corresponding to its index
  39893. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  39894. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  39895. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  39896. */
  39897. 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;
  39898. /**
  39899. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  39900. *
  39901. * @param renderingGroupId The rendering group id corresponding to its index
  39902. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  39903. * @param depth Automatically clears depth between groups if true and autoClear is true.
  39904. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  39905. */
  39906. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  39907. /**
  39908. * Gets the current auto clear configuration for one rendering group of the rendering
  39909. * manager.
  39910. * @param index the rendering group index to get the information for
  39911. * @returns The auto clear setup for the requested rendering group
  39912. */
  39913. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  39914. private _blockMaterialDirtyMechanism;
  39915. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  39916. get blockMaterialDirtyMechanism(): boolean;
  39917. set blockMaterialDirtyMechanism(value: boolean);
  39918. /**
  39919. * Will flag all materials as dirty to trigger new shader compilation
  39920. * @param flag defines the flag used to specify which material part must be marked as dirty
  39921. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  39922. */
  39923. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  39924. /** @hidden */
  39925. _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;
  39926. /** @hidden */
  39927. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  39928. /** @hidden */
  39929. _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;
  39930. /** @hidden */
  39931. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  39932. /** @hidden */
  39933. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  39934. /** @hidden */
  39935. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  39936. }
  39937. }
  39938. declare module BABYLON {
  39939. /**
  39940. * Set of assets to keep when moving a scene into an asset container.
  39941. */
  39942. export class KeepAssets extends AbstractScene {
  39943. }
  39944. /**
  39945. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  39946. */
  39947. export class InstantiatedEntries {
  39948. /**
  39949. * List of new root nodes (eg. nodes with no parent)
  39950. */
  39951. rootNodes: TransformNode[];
  39952. /**
  39953. * List of new skeletons
  39954. */
  39955. skeletons: Skeleton[];
  39956. /**
  39957. * List of new animation groups
  39958. */
  39959. animationGroups: AnimationGroup[];
  39960. }
  39961. /**
  39962. * Container with a set of assets that can be added or removed from a scene.
  39963. */
  39964. export class AssetContainer extends AbstractScene {
  39965. private _wasAddedToScene;
  39966. /**
  39967. * The scene the AssetContainer belongs to.
  39968. */
  39969. scene: Scene;
  39970. /**
  39971. * Instantiates an AssetContainer.
  39972. * @param scene The scene the AssetContainer belongs to.
  39973. */
  39974. constructor(scene: Scene);
  39975. /**
  39976. * Instantiate or clone all meshes and add the new ones to the scene.
  39977. * Skeletons and animation groups will all be cloned
  39978. * @param nameFunction defines an optional function used to get new names for clones
  39979. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  39980. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  39981. */
  39982. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  39983. /**
  39984. * Adds all the assets from the container to the scene.
  39985. */
  39986. addAllToScene(): void;
  39987. /**
  39988. * Removes all the assets in the container from the scene
  39989. */
  39990. removeAllFromScene(): void;
  39991. /**
  39992. * Disposes all the assets in the container
  39993. */
  39994. dispose(): void;
  39995. private _moveAssets;
  39996. /**
  39997. * Removes all the assets contained in the scene and adds them to the container.
  39998. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  39999. */
  40000. moveAllFromScene(keepAssets?: KeepAssets): void;
  40001. /**
  40002. * 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.
  40003. * @returns the root mesh
  40004. */
  40005. createRootMesh(): Mesh;
  40006. /**
  40007. * Merge animations (direct and animation groups) from this asset container into a scene
  40008. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  40009. * @param animatables set of animatables to retarget to a node from the scene
  40010. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  40011. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  40012. */
  40013. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  40014. }
  40015. }
  40016. declare module BABYLON {
  40017. /**
  40018. * Defines how the parser contract is defined.
  40019. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  40020. */
  40021. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  40022. /**
  40023. * Defines how the individual parser contract is defined.
  40024. * These parser can parse an individual asset
  40025. */
  40026. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  40027. /**
  40028. * Base class of the scene acting as a container for the different elements composing a scene.
  40029. * This class is dynamically extended by the different components of the scene increasing
  40030. * flexibility and reducing coupling
  40031. */
  40032. export abstract class AbstractScene {
  40033. /**
  40034. * Stores the list of available parsers in the application.
  40035. */
  40036. private static _BabylonFileParsers;
  40037. /**
  40038. * Stores the list of available individual parsers in the application.
  40039. */
  40040. private static _IndividualBabylonFileParsers;
  40041. /**
  40042. * Adds a parser in the list of available ones
  40043. * @param name Defines the name of the parser
  40044. * @param parser Defines the parser to add
  40045. */
  40046. static AddParser(name: string, parser: BabylonFileParser): void;
  40047. /**
  40048. * Gets a general parser from the list of avaialble ones
  40049. * @param name Defines the name of the parser
  40050. * @returns the requested parser or null
  40051. */
  40052. static GetParser(name: string): Nullable<BabylonFileParser>;
  40053. /**
  40054. * Adds n individual parser in the list of available ones
  40055. * @param name Defines the name of the parser
  40056. * @param parser Defines the parser to add
  40057. */
  40058. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  40059. /**
  40060. * Gets an individual parser from the list of avaialble ones
  40061. * @param name Defines the name of the parser
  40062. * @returns the requested parser or null
  40063. */
  40064. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  40065. /**
  40066. * Parser json data and populate both a scene and its associated container object
  40067. * @param jsonData Defines the data to parse
  40068. * @param scene Defines the scene to parse the data for
  40069. * @param container Defines the container attached to the parsing sequence
  40070. * @param rootUrl Defines the root url of the data
  40071. */
  40072. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  40073. /**
  40074. * Gets the list of root nodes (ie. nodes with no parent)
  40075. */
  40076. rootNodes: Node[];
  40077. /** All of the cameras added to this scene
  40078. * @see http://doc.babylonjs.com/babylon101/cameras
  40079. */
  40080. cameras: Camera[];
  40081. /**
  40082. * All of the lights added to this scene
  40083. * @see http://doc.babylonjs.com/babylon101/lights
  40084. */
  40085. lights: Light[];
  40086. /**
  40087. * All of the (abstract) meshes added to this scene
  40088. */
  40089. meshes: AbstractMesh[];
  40090. /**
  40091. * The list of skeletons added to the scene
  40092. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  40093. */
  40094. skeletons: Skeleton[];
  40095. /**
  40096. * All of the particle systems added to this scene
  40097. * @see http://doc.babylonjs.com/babylon101/particles
  40098. */
  40099. particleSystems: IParticleSystem[];
  40100. /**
  40101. * Gets a list of Animations associated with the scene
  40102. */
  40103. animations: Animation[];
  40104. /**
  40105. * All of the animation groups added to this scene
  40106. * @see http://doc.babylonjs.com/how_to/group
  40107. */
  40108. animationGroups: AnimationGroup[];
  40109. /**
  40110. * All of the multi-materials added to this scene
  40111. * @see http://doc.babylonjs.com/how_to/multi_materials
  40112. */
  40113. multiMaterials: MultiMaterial[];
  40114. /**
  40115. * All of the materials added to this scene
  40116. * In the context of a Scene, it is not supposed to be modified manually.
  40117. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  40118. * Note also that the order of the Material within the array is not significant and might change.
  40119. * @see http://doc.babylonjs.com/babylon101/materials
  40120. */
  40121. materials: Material[];
  40122. /**
  40123. * The list of morph target managers added to the scene
  40124. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  40125. */
  40126. morphTargetManagers: MorphTargetManager[];
  40127. /**
  40128. * The list of geometries used in the scene.
  40129. */
  40130. geometries: Geometry[];
  40131. /**
  40132. * All of the tranform nodes added to this scene
  40133. * In the context of a Scene, it is not supposed to be modified manually.
  40134. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  40135. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  40136. * @see http://doc.babylonjs.com/how_to/transformnode
  40137. */
  40138. transformNodes: TransformNode[];
  40139. /**
  40140. * ActionManagers available on the scene.
  40141. */
  40142. actionManagers: AbstractActionManager[];
  40143. /**
  40144. * Textures to keep.
  40145. */
  40146. textures: BaseTexture[];
  40147. /**
  40148. * Environment texture for the scene
  40149. */
  40150. environmentTexture: Nullable<BaseTexture>;
  40151. /**
  40152. * @returns all meshes, lights, cameras, transformNodes and bones
  40153. */
  40154. getNodes(): Array<Node>;
  40155. }
  40156. }
  40157. declare module BABYLON {
  40158. /**
  40159. * Interface used to define options for Sound class
  40160. */
  40161. export interface ISoundOptions {
  40162. /**
  40163. * Does the sound autoplay once loaded.
  40164. */
  40165. autoplay?: boolean;
  40166. /**
  40167. * Does the sound loop after it finishes playing once.
  40168. */
  40169. loop?: boolean;
  40170. /**
  40171. * Sound's volume
  40172. */
  40173. volume?: number;
  40174. /**
  40175. * Is it a spatial sound?
  40176. */
  40177. spatialSound?: boolean;
  40178. /**
  40179. * Maximum distance to hear that sound
  40180. */
  40181. maxDistance?: number;
  40182. /**
  40183. * Uses user defined attenuation function
  40184. */
  40185. useCustomAttenuation?: boolean;
  40186. /**
  40187. * Define the roll off factor of spatial sounds.
  40188. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40189. */
  40190. rolloffFactor?: number;
  40191. /**
  40192. * Define the reference distance the sound should be heard perfectly.
  40193. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40194. */
  40195. refDistance?: number;
  40196. /**
  40197. * Define the distance attenuation model the sound will follow.
  40198. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40199. */
  40200. distanceModel?: string;
  40201. /**
  40202. * Defines the playback speed (1 by default)
  40203. */
  40204. playbackRate?: number;
  40205. /**
  40206. * Defines if the sound is from a streaming source
  40207. */
  40208. streaming?: boolean;
  40209. /**
  40210. * Defines an optional length (in seconds) inside the sound file
  40211. */
  40212. length?: number;
  40213. /**
  40214. * Defines an optional offset (in seconds) inside the sound file
  40215. */
  40216. offset?: number;
  40217. /**
  40218. * If true, URLs will not be required to state the audio file codec to use.
  40219. */
  40220. skipCodecCheck?: boolean;
  40221. }
  40222. /**
  40223. * Defines a sound that can be played in the application.
  40224. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  40225. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  40226. */
  40227. export class Sound {
  40228. /**
  40229. * The name of the sound in the scene.
  40230. */
  40231. name: string;
  40232. /**
  40233. * Does the sound autoplay once loaded.
  40234. */
  40235. autoplay: boolean;
  40236. /**
  40237. * Does the sound loop after it finishes playing once.
  40238. */
  40239. loop: boolean;
  40240. /**
  40241. * Does the sound use a custom attenuation curve to simulate the falloff
  40242. * happening when the source gets further away from the camera.
  40243. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  40244. */
  40245. useCustomAttenuation: boolean;
  40246. /**
  40247. * The sound track id this sound belongs to.
  40248. */
  40249. soundTrackId: number;
  40250. /**
  40251. * Is this sound currently played.
  40252. */
  40253. isPlaying: boolean;
  40254. /**
  40255. * Is this sound currently paused.
  40256. */
  40257. isPaused: boolean;
  40258. /**
  40259. * Does this sound enables spatial sound.
  40260. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40261. */
  40262. spatialSound: boolean;
  40263. /**
  40264. * Define the reference distance the sound should be heard perfectly.
  40265. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40266. */
  40267. refDistance: number;
  40268. /**
  40269. * Define the roll off factor of spatial sounds.
  40270. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40271. */
  40272. rolloffFactor: number;
  40273. /**
  40274. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  40275. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40276. */
  40277. maxDistance: number;
  40278. /**
  40279. * Define the distance attenuation model the sound will follow.
  40280. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40281. */
  40282. distanceModel: string;
  40283. /**
  40284. * @hidden
  40285. * Back Compat
  40286. **/
  40287. onended: () => any;
  40288. /**
  40289. * Gets or sets an object used to store user defined information for the sound.
  40290. */
  40291. metadata: any;
  40292. /**
  40293. * Observable event when the current playing sound finishes.
  40294. */
  40295. onEndedObservable: Observable<Sound>;
  40296. private _panningModel;
  40297. private _playbackRate;
  40298. private _streaming;
  40299. private _startTime;
  40300. private _startOffset;
  40301. private _position;
  40302. /** @hidden */
  40303. _positionInEmitterSpace: boolean;
  40304. private _localDirection;
  40305. private _volume;
  40306. private _isReadyToPlay;
  40307. private _isDirectional;
  40308. private _readyToPlayCallback;
  40309. private _audioBuffer;
  40310. private _soundSource;
  40311. private _streamingSource;
  40312. private _soundPanner;
  40313. private _soundGain;
  40314. private _inputAudioNode;
  40315. private _outputAudioNode;
  40316. private _coneInnerAngle;
  40317. private _coneOuterAngle;
  40318. private _coneOuterGain;
  40319. private _scene;
  40320. private _connectedTransformNode;
  40321. private _customAttenuationFunction;
  40322. private _registerFunc;
  40323. private _isOutputConnected;
  40324. private _htmlAudioElement;
  40325. private _urlType;
  40326. private _length?;
  40327. private _offset?;
  40328. /** @hidden */
  40329. static _SceneComponentInitialization: (scene: Scene) => void;
  40330. /**
  40331. * Create a sound and attach it to a scene
  40332. * @param name Name of your sound
  40333. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  40334. * @param scene defines the scene the sound belongs to
  40335. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  40336. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  40337. */
  40338. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  40339. /**
  40340. * Release the sound and its associated resources
  40341. */
  40342. dispose(): void;
  40343. /**
  40344. * Gets if the sounds is ready to be played or not.
  40345. * @returns true if ready, otherwise false
  40346. */
  40347. isReady(): boolean;
  40348. private _soundLoaded;
  40349. /**
  40350. * Sets the data of the sound from an audiobuffer
  40351. * @param audioBuffer The audioBuffer containing the data
  40352. */
  40353. setAudioBuffer(audioBuffer: AudioBuffer): void;
  40354. /**
  40355. * Updates the current sounds options such as maxdistance, loop...
  40356. * @param options A JSON object containing values named as the object properties
  40357. */
  40358. updateOptions(options: ISoundOptions): void;
  40359. private _createSpatialParameters;
  40360. private _updateSpatialParameters;
  40361. /**
  40362. * Switch the panning model to HRTF:
  40363. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  40364. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40365. */
  40366. switchPanningModelToHRTF(): void;
  40367. /**
  40368. * Switch the panning model to Equal Power:
  40369. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  40370. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40371. */
  40372. switchPanningModelToEqualPower(): void;
  40373. private _switchPanningModel;
  40374. /**
  40375. * Connect this sound to a sound track audio node like gain...
  40376. * @param soundTrackAudioNode the sound track audio node to connect to
  40377. */
  40378. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  40379. /**
  40380. * Transform this sound into a directional source
  40381. * @param coneInnerAngle Size of the inner cone in degree
  40382. * @param coneOuterAngle Size of the outer cone in degree
  40383. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  40384. */
  40385. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  40386. /**
  40387. * Gets or sets the inner angle for the directional cone.
  40388. */
  40389. get directionalConeInnerAngle(): number;
  40390. /**
  40391. * Gets or sets the inner angle for the directional cone.
  40392. */
  40393. set directionalConeInnerAngle(value: number);
  40394. /**
  40395. * Gets or sets the outer angle for the directional cone.
  40396. */
  40397. get directionalConeOuterAngle(): number;
  40398. /**
  40399. * Gets or sets the outer angle for the directional cone.
  40400. */
  40401. set directionalConeOuterAngle(value: number);
  40402. /**
  40403. * Sets the position of the emitter if spatial sound is enabled
  40404. * @param newPosition Defines the new posisiton
  40405. */
  40406. setPosition(newPosition: Vector3): void;
  40407. /**
  40408. * Sets the local direction of the emitter if spatial sound is enabled
  40409. * @param newLocalDirection Defines the new local direction
  40410. */
  40411. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  40412. private _updateDirection;
  40413. /** @hidden */
  40414. updateDistanceFromListener(): void;
  40415. /**
  40416. * Sets a new custom attenuation function for the sound.
  40417. * @param callback Defines the function used for the attenuation
  40418. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  40419. */
  40420. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  40421. /**
  40422. * Play the sound
  40423. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  40424. * @param offset (optional) Start the sound at a specific time in seconds
  40425. * @param length (optional) Sound duration (in seconds)
  40426. */
  40427. play(time?: number, offset?: number, length?: number): void;
  40428. private _onended;
  40429. /**
  40430. * Stop the sound
  40431. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  40432. */
  40433. stop(time?: number): void;
  40434. /**
  40435. * Put the sound in pause
  40436. */
  40437. pause(): void;
  40438. /**
  40439. * Sets a dedicated volume for this sounds
  40440. * @param newVolume Define the new volume of the sound
  40441. * @param time Define time for gradual change to new volume
  40442. */
  40443. setVolume(newVolume: number, time?: number): void;
  40444. /**
  40445. * Set the sound play back rate
  40446. * @param newPlaybackRate Define the playback rate the sound should be played at
  40447. */
  40448. setPlaybackRate(newPlaybackRate: number): void;
  40449. /**
  40450. * Gets the volume of the sound.
  40451. * @returns the volume of the sound
  40452. */
  40453. getVolume(): number;
  40454. /**
  40455. * Attach the sound to a dedicated mesh
  40456. * @param transformNode The transform node to connect the sound with
  40457. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  40458. */
  40459. attachToMesh(transformNode: TransformNode): void;
  40460. /**
  40461. * Detach the sound from the previously attached mesh
  40462. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  40463. */
  40464. detachFromMesh(): void;
  40465. private _onRegisterAfterWorldMatrixUpdate;
  40466. /**
  40467. * Clone the current sound in the scene.
  40468. * @returns the new sound clone
  40469. */
  40470. clone(): Nullable<Sound>;
  40471. /**
  40472. * Gets the current underlying audio buffer containing the data
  40473. * @returns the audio buffer
  40474. */
  40475. getAudioBuffer(): Nullable<AudioBuffer>;
  40476. /**
  40477. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  40478. * @returns the source node
  40479. */
  40480. getSoundSource(): Nullable<AudioBufferSourceNode>;
  40481. /**
  40482. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  40483. * @returns the gain node
  40484. */
  40485. getSoundGain(): Nullable<GainNode>;
  40486. /**
  40487. * Serializes the Sound in a JSON representation
  40488. * @returns the JSON representation of the sound
  40489. */
  40490. serialize(): any;
  40491. /**
  40492. * Parse a JSON representation of a sound to innstantiate in a given scene
  40493. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  40494. * @param scene Define the scene the new parsed sound should be created in
  40495. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  40496. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  40497. * @returns the newly parsed sound
  40498. */
  40499. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  40500. }
  40501. }
  40502. declare module BABYLON {
  40503. /**
  40504. * This defines an action helpful to play a defined sound on a triggered action.
  40505. */
  40506. export class PlaySoundAction extends Action {
  40507. private _sound;
  40508. /**
  40509. * Instantiate the action
  40510. * @param triggerOptions defines the trigger options
  40511. * @param sound defines the sound to play
  40512. * @param condition defines the trigger related conditions
  40513. */
  40514. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  40515. /** @hidden */
  40516. _prepare(): void;
  40517. /**
  40518. * Execute the action and play the sound.
  40519. */
  40520. execute(): void;
  40521. /**
  40522. * Serializes the actions and its related information.
  40523. * @param parent defines the object to serialize in
  40524. * @returns the serialized object
  40525. */
  40526. serialize(parent: any): any;
  40527. }
  40528. /**
  40529. * This defines an action helpful to stop a defined sound on a triggered action.
  40530. */
  40531. export class StopSoundAction extends Action {
  40532. private _sound;
  40533. /**
  40534. * Instantiate the action
  40535. * @param triggerOptions defines the trigger options
  40536. * @param sound defines the sound to stop
  40537. * @param condition defines the trigger related conditions
  40538. */
  40539. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  40540. /** @hidden */
  40541. _prepare(): void;
  40542. /**
  40543. * Execute the action and stop the sound.
  40544. */
  40545. execute(): void;
  40546. /**
  40547. * Serializes the actions and its related information.
  40548. * @param parent defines the object to serialize in
  40549. * @returns the serialized object
  40550. */
  40551. serialize(parent: any): any;
  40552. }
  40553. }
  40554. declare module BABYLON {
  40555. /**
  40556. * This defines an action responsible to change the value of a property
  40557. * by interpolating between its current value and the newly set one once triggered.
  40558. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  40559. */
  40560. export class InterpolateValueAction extends Action {
  40561. /**
  40562. * Defines the path of the property where the value should be interpolated
  40563. */
  40564. propertyPath: string;
  40565. /**
  40566. * Defines the target value at the end of the interpolation.
  40567. */
  40568. value: any;
  40569. /**
  40570. * Defines the time it will take for the property to interpolate to the value.
  40571. */
  40572. duration: number;
  40573. /**
  40574. * Defines if the other scene animations should be stopped when the action has been triggered
  40575. */
  40576. stopOtherAnimations?: boolean;
  40577. /**
  40578. * Defines a callback raised once the interpolation animation has been done.
  40579. */
  40580. onInterpolationDone?: () => void;
  40581. /**
  40582. * Observable triggered once the interpolation animation has been done.
  40583. */
  40584. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  40585. private _target;
  40586. private _effectiveTarget;
  40587. private _property;
  40588. /**
  40589. * Instantiate the action
  40590. * @param triggerOptions defines the trigger options
  40591. * @param target defines the object containing the value to interpolate
  40592. * @param propertyPath defines the path to the property in the target object
  40593. * @param value defines the target value at the end of the interpolation
  40594. * @param duration deines the time it will take for the property to interpolate to the value.
  40595. * @param condition defines the trigger related conditions
  40596. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  40597. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  40598. */
  40599. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  40600. /** @hidden */
  40601. _prepare(): void;
  40602. /**
  40603. * Execute the action starts the value interpolation.
  40604. */
  40605. execute(): void;
  40606. /**
  40607. * Serializes the actions and its related information.
  40608. * @param parent defines the object to serialize in
  40609. * @returns the serialized object
  40610. */
  40611. serialize(parent: any): any;
  40612. }
  40613. }
  40614. declare module BABYLON {
  40615. /**
  40616. * Options allowed during the creation of a sound track.
  40617. */
  40618. export interface ISoundTrackOptions {
  40619. /**
  40620. * The volume the sound track should take during creation
  40621. */
  40622. volume?: number;
  40623. /**
  40624. * Define if the sound track is the main sound track of the scene
  40625. */
  40626. mainTrack?: boolean;
  40627. }
  40628. /**
  40629. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  40630. * It will be also used in a future release to apply effects on a specific track.
  40631. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  40632. */
  40633. export class SoundTrack {
  40634. /**
  40635. * The unique identifier of the sound track in the scene.
  40636. */
  40637. id: number;
  40638. /**
  40639. * The list of sounds included in the sound track.
  40640. */
  40641. soundCollection: Array<Sound>;
  40642. private _outputAudioNode;
  40643. private _scene;
  40644. private _connectedAnalyser;
  40645. private _options;
  40646. private _isInitialized;
  40647. /**
  40648. * Creates a new sound track.
  40649. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  40650. * @param scene Define the scene the sound track belongs to
  40651. * @param options
  40652. */
  40653. constructor(scene: Scene, options?: ISoundTrackOptions);
  40654. private _initializeSoundTrackAudioGraph;
  40655. /**
  40656. * Release the sound track and its associated resources
  40657. */
  40658. dispose(): void;
  40659. /**
  40660. * Adds a sound to this sound track
  40661. * @param sound define the cound to add
  40662. * @ignoreNaming
  40663. */
  40664. AddSound(sound: Sound): void;
  40665. /**
  40666. * Removes a sound to this sound track
  40667. * @param sound define the cound to remove
  40668. * @ignoreNaming
  40669. */
  40670. RemoveSound(sound: Sound): void;
  40671. /**
  40672. * Set a global volume for the full sound track.
  40673. * @param newVolume Define the new volume of the sound track
  40674. */
  40675. setVolume(newVolume: number): void;
  40676. /**
  40677. * Switch the panning model to HRTF:
  40678. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  40679. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40680. */
  40681. switchPanningModelToHRTF(): void;
  40682. /**
  40683. * Switch the panning model to Equal Power:
  40684. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  40685. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40686. */
  40687. switchPanningModelToEqualPower(): void;
  40688. /**
  40689. * Connect the sound track to an audio analyser allowing some amazing
  40690. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  40691. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  40692. * @param analyser The analyser to connect to the engine
  40693. */
  40694. connectToAnalyser(analyser: Analyser): void;
  40695. }
  40696. }
  40697. declare module BABYLON {
  40698. interface AbstractScene {
  40699. /**
  40700. * The list of sounds used in the scene.
  40701. */
  40702. sounds: Nullable<Array<Sound>>;
  40703. }
  40704. interface Scene {
  40705. /**
  40706. * @hidden
  40707. * Backing field
  40708. */
  40709. _mainSoundTrack: SoundTrack;
  40710. /**
  40711. * The main sound track played by the scene.
  40712. * It cotains your primary collection of sounds.
  40713. */
  40714. mainSoundTrack: SoundTrack;
  40715. /**
  40716. * The list of sound tracks added to the scene
  40717. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  40718. */
  40719. soundTracks: Nullable<Array<SoundTrack>>;
  40720. /**
  40721. * Gets a sound using a given name
  40722. * @param name defines the name to search for
  40723. * @return the found sound or null if not found at all.
  40724. */
  40725. getSoundByName(name: string): Nullable<Sound>;
  40726. /**
  40727. * Gets or sets if audio support is enabled
  40728. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  40729. */
  40730. audioEnabled: boolean;
  40731. /**
  40732. * Gets or sets if audio will be output to headphones
  40733. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  40734. */
  40735. headphone: boolean;
  40736. /**
  40737. * Gets or sets custom audio listener position provider
  40738. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  40739. */
  40740. audioListenerPositionProvider: Nullable<() => Vector3>;
  40741. /**
  40742. * Gets or sets a refresh rate when using 3D audio positioning
  40743. */
  40744. audioPositioningRefreshRate: number;
  40745. }
  40746. /**
  40747. * Defines the sound scene component responsible to manage any sounds
  40748. * in a given scene.
  40749. */
  40750. export class AudioSceneComponent implements ISceneSerializableComponent {
  40751. /**
  40752. * The component name helpfull to identify the component in the list of scene components.
  40753. */
  40754. readonly name: string;
  40755. /**
  40756. * The scene the component belongs to.
  40757. */
  40758. scene: Scene;
  40759. private _audioEnabled;
  40760. /**
  40761. * Gets whether audio is enabled or not.
  40762. * Please use related enable/disable method to switch state.
  40763. */
  40764. get audioEnabled(): boolean;
  40765. private _headphone;
  40766. /**
  40767. * Gets whether audio is outputing to headphone or not.
  40768. * Please use the according Switch methods to change output.
  40769. */
  40770. get headphone(): boolean;
  40771. /**
  40772. * Gets or sets a refresh rate when using 3D audio positioning
  40773. */
  40774. audioPositioningRefreshRate: number;
  40775. private _audioListenerPositionProvider;
  40776. /**
  40777. * Gets the current audio listener position provider
  40778. */
  40779. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  40780. /**
  40781. * Sets a custom listener position for all sounds in the scene
  40782. * By default, this is the position of the first active camera
  40783. */
  40784. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  40785. /**
  40786. * Creates a new instance of the component for the given scene
  40787. * @param scene Defines the scene to register the component in
  40788. */
  40789. constructor(scene: Scene);
  40790. /**
  40791. * Registers the component in a given scene
  40792. */
  40793. register(): void;
  40794. /**
  40795. * Rebuilds the elements related to this component in case of
  40796. * context lost for instance.
  40797. */
  40798. rebuild(): void;
  40799. /**
  40800. * Serializes the component data to the specified json object
  40801. * @param serializationObject The object to serialize to
  40802. */
  40803. serialize(serializationObject: any): void;
  40804. /**
  40805. * Adds all the elements from the container to the scene
  40806. * @param container the container holding the elements
  40807. */
  40808. addFromContainer(container: AbstractScene): void;
  40809. /**
  40810. * Removes all the elements in the container from the scene
  40811. * @param container contains the elements to remove
  40812. * @param dispose if the removed element should be disposed (default: false)
  40813. */
  40814. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  40815. /**
  40816. * Disposes the component and the associated ressources.
  40817. */
  40818. dispose(): void;
  40819. /**
  40820. * Disables audio in the associated scene.
  40821. */
  40822. disableAudio(): void;
  40823. /**
  40824. * Enables audio in the associated scene.
  40825. */
  40826. enableAudio(): void;
  40827. /**
  40828. * Switch audio to headphone output.
  40829. */
  40830. switchAudioModeForHeadphones(): void;
  40831. /**
  40832. * Switch audio to normal speakers.
  40833. */
  40834. switchAudioModeForNormalSpeakers(): void;
  40835. private _cachedCameraDirection;
  40836. private _cachedCameraPosition;
  40837. private _lastCheck;
  40838. private _afterRender;
  40839. }
  40840. }
  40841. declare module BABYLON {
  40842. /**
  40843. * Wraps one or more Sound objects and selects one with random weight for playback.
  40844. */
  40845. export class WeightedSound {
  40846. /** When true a Sound will be selected and played when the current playing Sound completes. */
  40847. loop: boolean;
  40848. private _coneInnerAngle;
  40849. private _coneOuterAngle;
  40850. private _volume;
  40851. /** A Sound is currently playing. */
  40852. isPlaying: boolean;
  40853. /** A Sound is currently paused. */
  40854. isPaused: boolean;
  40855. private _sounds;
  40856. private _weights;
  40857. private _currentIndex?;
  40858. /**
  40859. * Creates a new WeightedSound from the list of sounds given.
  40860. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  40861. * @param sounds Array of Sounds that will be selected from.
  40862. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  40863. */
  40864. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  40865. /**
  40866. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  40867. */
  40868. get directionalConeInnerAngle(): number;
  40869. /**
  40870. * The size of cone in degress for a directional sound in which there will be no attenuation.
  40871. */
  40872. set directionalConeInnerAngle(value: number);
  40873. /**
  40874. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  40875. * Listener angles between innerAngle and outerAngle will falloff linearly.
  40876. */
  40877. get directionalConeOuterAngle(): number;
  40878. /**
  40879. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  40880. * Listener angles between innerAngle and outerAngle will falloff linearly.
  40881. */
  40882. set directionalConeOuterAngle(value: number);
  40883. /**
  40884. * Playback volume.
  40885. */
  40886. get volume(): number;
  40887. /**
  40888. * Playback volume.
  40889. */
  40890. set volume(value: number);
  40891. private _onended;
  40892. /**
  40893. * Suspend playback
  40894. */
  40895. pause(): void;
  40896. /**
  40897. * Stop playback
  40898. */
  40899. stop(): void;
  40900. /**
  40901. * Start playback.
  40902. * @param startOffset Position the clip head at a specific time in seconds.
  40903. */
  40904. play(startOffset?: number): void;
  40905. }
  40906. }
  40907. declare module BABYLON {
  40908. /**
  40909. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  40910. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  40911. */
  40912. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  40913. /**
  40914. * Gets the name of the behavior.
  40915. */
  40916. get name(): string;
  40917. /**
  40918. * The easing function used by animations
  40919. */
  40920. static EasingFunction: BackEase;
  40921. /**
  40922. * The easing mode used by animations
  40923. */
  40924. static EasingMode: number;
  40925. /**
  40926. * The duration of the animation, in milliseconds
  40927. */
  40928. transitionDuration: number;
  40929. /**
  40930. * Length of the distance animated by the transition when lower radius is reached
  40931. */
  40932. lowerRadiusTransitionRange: number;
  40933. /**
  40934. * Length of the distance animated by the transition when upper radius is reached
  40935. */
  40936. upperRadiusTransitionRange: number;
  40937. private _autoTransitionRange;
  40938. /**
  40939. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  40940. */
  40941. get autoTransitionRange(): boolean;
  40942. /**
  40943. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  40944. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  40945. */
  40946. set autoTransitionRange(value: boolean);
  40947. private _attachedCamera;
  40948. private _onAfterCheckInputsObserver;
  40949. private _onMeshTargetChangedObserver;
  40950. /**
  40951. * Initializes the behavior.
  40952. */
  40953. init(): void;
  40954. /**
  40955. * Attaches the behavior to its arc rotate camera.
  40956. * @param camera Defines the camera to attach the behavior to
  40957. */
  40958. attach(camera: ArcRotateCamera): void;
  40959. /**
  40960. * Detaches the behavior from its current arc rotate camera.
  40961. */
  40962. detach(): void;
  40963. private _radiusIsAnimating;
  40964. private _radiusBounceTransition;
  40965. private _animatables;
  40966. private _cachedWheelPrecision;
  40967. /**
  40968. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  40969. * @param radiusLimit The limit to check against.
  40970. * @return Bool to indicate if at limit.
  40971. */
  40972. private _isRadiusAtLimit;
  40973. /**
  40974. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  40975. * @param radiusDelta The delta by which to animate to. Can be negative.
  40976. */
  40977. private _applyBoundRadiusAnimation;
  40978. /**
  40979. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  40980. */
  40981. protected _clearAnimationLocks(): void;
  40982. /**
  40983. * Stops and removes all animations that have been applied to the camera
  40984. */
  40985. stopAllAnimations(): void;
  40986. }
  40987. }
  40988. declare module BABYLON {
  40989. /**
  40990. * 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.
  40991. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  40992. */
  40993. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  40994. /**
  40995. * Gets the name of the behavior.
  40996. */
  40997. get name(): string;
  40998. private _mode;
  40999. private _radiusScale;
  41000. private _positionScale;
  41001. private _defaultElevation;
  41002. private _elevationReturnTime;
  41003. private _elevationReturnWaitTime;
  41004. private _zoomStopsAnimation;
  41005. private _framingTime;
  41006. /**
  41007. * The easing function used by animations
  41008. */
  41009. static EasingFunction: ExponentialEase;
  41010. /**
  41011. * The easing mode used by animations
  41012. */
  41013. static EasingMode: number;
  41014. /**
  41015. * Sets the current mode used by the behavior
  41016. */
  41017. set mode(mode: number);
  41018. /**
  41019. * Gets current mode used by the behavior.
  41020. */
  41021. get mode(): number;
  41022. /**
  41023. * Sets the scale applied to the radius (1 by default)
  41024. */
  41025. set radiusScale(radius: number);
  41026. /**
  41027. * Gets the scale applied to the radius
  41028. */
  41029. get radiusScale(): number;
  41030. /**
  41031. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  41032. */
  41033. set positionScale(scale: number);
  41034. /**
  41035. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  41036. */
  41037. get positionScale(): number;
  41038. /**
  41039. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  41040. * behaviour is triggered, in radians.
  41041. */
  41042. set defaultElevation(elevation: number);
  41043. /**
  41044. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  41045. * behaviour is triggered, in radians.
  41046. */
  41047. get defaultElevation(): number;
  41048. /**
  41049. * Sets the time (in milliseconds) taken to return to the default beta position.
  41050. * Negative value indicates camera should not return to default.
  41051. */
  41052. set elevationReturnTime(speed: number);
  41053. /**
  41054. * Gets the time (in milliseconds) taken to return to the default beta position.
  41055. * Negative value indicates camera should not return to default.
  41056. */
  41057. get elevationReturnTime(): number;
  41058. /**
  41059. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  41060. */
  41061. set elevationReturnWaitTime(time: number);
  41062. /**
  41063. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  41064. */
  41065. get elevationReturnWaitTime(): number;
  41066. /**
  41067. * Sets the flag that indicates if user zooming should stop animation.
  41068. */
  41069. set zoomStopsAnimation(flag: boolean);
  41070. /**
  41071. * Gets the flag that indicates if user zooming should stop animation.
  41072. */
  41073. get zoomStopsAnimation(): boolean;
  41074. /**
  41075. * Sets the transition time when framing the mesh, in milliseconds
  41076. */
  41077. set framingTime(time: number);
  41078. /**
  41079. * Gets the transition time when framing the mesh, in milliseconds
  41080. */
  41081. get framingTime(): number;
  41082. /**
  41083. * Define if the behavior should automatically change the configured
  41084. * camera limits and sensibilities.
  41085. */
  41086. autoCorrectCameraLimitsAndSensibility: boolean;
  41087. private _onPrePointerObservableObserver;
  41088. private _onAfterCheckInputsObserver;
  41089. private _onMeshTargetChangedObserver;
  41090. private _attachedCamera;
  41091. private _isPointerDown;
  41092. private _lastInteractionTime;
  41093. /**
  41094. * Initializes the behavior.
  41095. */
  41096. init(): void;
  41097. /**
  41098. * Attaches the behavior to its arc rotate camera.
  41099. * @param camera Defines the camera to attach the behavior to
  41100. */
  41101. attach(camera: ArcRotateCamera): void;
  41102. /**
  41103. * Detaches the behavior from its current arc rotate camera.
  41104. */
  41105. detach(): void;
  41106. private _animatables;
  41107. private _betaIsAnimating;
  41108. private _betaTransition;
  41109. private _radiusTransition;
  41110. private _vectorTransition;
  41111. /**
  41112. * Targets the given mesh and updates zoom level accordingly.
  41113. * @param mesh The mesh to target.
  41114. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41115. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41116. */
  41117. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41118. /**
  41119. * Targets the given mesh with its children and updates zoom level accordingly.
  41120. * @param mesh The mesh to target.
  41121. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41122. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41123. */
  41124. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41125. /**
  41126. * Targets the given meshes with their children and updates zoom level accordingly.
  41127. * @param meshes The mesh to target.
  41128. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41129. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41130. */
  41131. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41132. /**
  41133. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  41134. * @param minimumWorld Determines the smaller position of the bounding box extend
  41135. * @param maximumWorld Determines the bigger position of the bounding box extend
  41136. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41137. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41138. */
  41139. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41140. /**
  41141. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  41142. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  41143. * frustum width.
  41144. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  41145. * to fully enclose the mesh in the viewing frustum.
  41146. */
  41147. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  41148. /**
  41149. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  41150. * is automatically returned to its default position (expected to be above ground plane).
  41151. */
  41152. private _maintainCameraAboveGround;
  41153. /**
  41154. * Returns the frustum slope based on the canvas ratio and camera FOV
  41155. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  41156. */
  41157. private _getFrustumSlope;
  41158. /**
  41159. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  41160. */
  41161. private _clearAnimationLocks;
  41162. /**
  41163. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  41164. */
  41165. private _applyUserInteraction;
  41166. /**
  41167. * Stops and removes all animations that have been applied to the camera
  41168. */
  41169. stopAllAnimations(): void;
  41170. /**
  41171. * Gets a value indicating if the user is moving the camera
  41172. */
  41173. get isUserIsMoving(): boolean;
  41174. /**
  41175. * The camera can move all the way towards the mesh.
  41176. */
  41177. static IgnoreBoundsSizeMode: number;
  41178. /**
  41179. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  41180. */
  41181. static FitFrustumSidesMode: number;
  41182. }
  41183. }
  41184. declare module BABYLON {
  41185. /**
  41186. * Base class for Camera Pointer Inputs.
  41187. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  41188. * for example usage.
  41189. */
  41190. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  41191. /**
  41192. * Defines the camera the input is attached to.
  41193. */
  41194. abstract camera: Camera;
  41195. /**
  41196. * Whether keyboard modifier keys are pressed at time of last mouse event.
  41197. */
  41198. protected _altKey: boolean;
  41199. protected _ctrlKey: boolean;
  41200. protected _metaKey: boolean;
  41201. protected _shiftKey: boolean;
  41202. /**
  41203. * Which mouse buttons were pressed at time of last mouse event.
  41204. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  41205. */
  41206. protected _buttonsPressed: number;
  41207. /**
  41208. * Defines the buttons associated with the input to handle camera move.
  41209. */
  41210. buttons: number[];
  41211. /**
  41212. * Attach the input controls to a specific dom element to get the input from.
  41213. * @param element Defines the element the controls should be listened from
  41214. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41215. */
  41216. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41217. /**
  41218. * Detach the current controls from the specified dom element.
  41219. * @param element Defines the element to stop listening the inputs from
  41220. */
  41221. detachControl(element: Nullable<HTMLElement>): void;
  41222. /**
  41223. * Gets the class name of the current input.
  41224. * @returns the class name
  41225. */
  41226. getClassName(): string;
  41227. /**
  41228. * Get the friendly name associated with the input class.
  41229. * @returns the input friendly name
  41230. */
  41231. getSimpleName(): string;
  41232. /**
  41233. * Called on pointer POINTERDOUBLETAP event.
  41234. * Override this method to provide functionality on POINTERDOUBLETAP event.
  41235. */
  41236. protected onDoubleTap(type: string): void;
  41237. /**
  41238. * Called on pointer POINTERMOVE event if only a single touch is active.
  41239. * Override this method to provide functionality.
  41240. */
  41241. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41242. /**
  41243. * Called on pointer POINTERMOVE event if multiple touches are active.
  41244. * Override this method to provide functionality.
  41245. */
  41246. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41247. /**
  41248. * Called on JS contextmenu event.
  41249. * Override this method to provide functionality.
  41250. */
  41251. protected onContextMenu(evt: PointerEvent): void;
  41252. /**
  41253. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  41254. * press.
  41255. * Override this method to provide functionality.
  41256. */
  41257. protected onButtonDown(evt: PointerEvent): void;
  41258. /**
  41259. * Called each time a new POINTERUP event occurs. Ie, for each button
  41260. * release.
  41261. * Override this method to provide functionality.
  41262. */
  41263. protected onButtonUp(evt: PointerEvent): void;
  41264. /**
  41265. * Called when window becomes inactive.
  41266. * Override this method to provide functionality.
  41267. */
  41268. protected onLostFocus(): void;
  41269. private _pointerInput;
  41270. private _observer;
  41271. private _onLostFocus;
  41272. private pointA;
  41273. private pointB;
  41274. }
  41275. }
  41276. declare module BABYLON {
  41277. /**
  41278. * Manage the pointers inputs to control an arc rotate camera.
  41279. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41280. */
  41281. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  41282. /**
  41283. * Defines the camera the input is attached to.
  41284. */
  41285. camera: ArcRotateCamera;
  41286. /**
  41287. * Gets the class name of the current input.
  41288. * @returns the class name
  41289. */
  41290. getClassName(): string;
  41291. /**
  41292. * Defines the buttons associated with the input to handle camera move.
  41293. */
  41294. buttons: number[];
  41295. /**
  41296. * Defines the pointer angular sensibility along the X axis or how fast is
  41297. * the camera rotating.
  41298. */
  41299. angularSensibilityX: number;
  41300. /**
  41301. * Defines the pointer angular sensibility along the Y axis or how fast is
  41302. * the camera rotating.
  41303. */
  41304. angularSensibilityY: number;
  41305. /**
  41306. * Defines the pointer pinch precision or how fast is the camera zooming.
  41307. */
  41308. pinchPrecision: number;
  41309. /**
  41310. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  41311. * from 0.
  41312. * It defines the percentage of current camera.radius to use as delta when
  41313. * pinch zoom is used.
  41314. */
  41315. pinchDeltaPercentage: number;
  41316. /**
  41317. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  41318. * that any object in the plane at the camera's target point will scale
  41319. * perfectly with finger motion.
  41320. * Overrides pinchDeltaPercentage and pinchPrecision.
  41321. */
  41322. useNaturalPinchZoom: boolean;
  41323. /**
  41324. * Defines the pointer panning sensibility or how fast is the camera moving.
  41325. */
  41326. panningSensibility: number;
  41327. /**
  41328. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  41329. */
  41330. multiTouchPanning: boolean;
  41331. /**
  41332. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  41333. * zoom (pinch) through multitouch.
  41334. */
  41335. multiTouchPanAndZoom: boolean;
  41336. /**
  41337. * Revers pinch action direction.
  41338. */
  41339. pinchInwards: boolean;
  41340. private _isPanClick;
  41341. private _twoFingerActivityCount;
  41342. private _isPinching;
  41343. /**
  41344. * Called on pointer POINTERMOVE event if only a single touch is active.
  41345. */
  41346. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41347. /**
  41348. * Called on pointer POINTERDOUBLETAP event.
  41349. */
  41350. protected onDoubleTap(type: string): void;
  41351. /**
  41352. * Called on pointer POINTERMOVE event if multiple touches are active.
  41353. */
  41354. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41355. /**
  41356. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  41357. * press.
  41358. */
  41359. protected onButtonDown(evt: PointerEvent): void;
  41360. /**
  41361. * Called each time a new POINTERUP event occurs. Ie, for each button
  41362. * release.
  41363. */
  41364. protected onButtonUp(evt: PointerEvent): void;
  41365. /**
  41366. * Called when window becomes inactive.
  41367. */
  41368. protected onLostFocus(): void;
  41369. }
  41370. }
  41371. declare module BABYLON {
  41372. /**
  41373. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  41374. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41375. */
  41376. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  41377. /**
  41378. * Defines the camera the input is attached to.
  41379. */
  41380. camera: ArcRotateCamera;
  41381. /**
  41382. * Defines the list of key codes associated with the up action (increase alpha)
  41383. */
  41384. keysUp: number[];
  41385. /**
  41386. * Defines the list of key codes associated with the down action (decrease alpha)
  41387. */
  41388. keysDown: number[];
  41389. /**
  41390. * Defines the list of key codes associated with the left action (increase beta)
  41391. */
  41392. keysLeft: number[];
  41393. /**
  41394. * Defines the list of key codes associated with the right action (decrease beta)
  41395. */
  41396. keysRight: number[];
  41397. /**
  41398. * Defines the list of key codes associated with the reset action.
  41399. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  41400. */
  41401. keysReset: number[];
  41402. /**
  41403. * Defines the panning sensibility of the inputs.
  41404. * (How fast is the camera panning)
  41405. */
  41406. panningSensibility: number;
  41407. /**
  41408. * Defines the zooming sensibility of the inputs.
  41409. * (How fast is the camera zooming)
  41410. */
  41411. zoomingSensibility: number;
  41412. /**
  41413. * Defines whether maintaining the alt key down switch the movement mode from
  41414. * orientation to zoom.
  41415. */
  41416. useAltToZoom: boolean;
  41417. /**
  41418. * Rotation speed of the camera
  41419. */
  41420. angularSpeed: number;
  41421. private _keys;
  41422. private _ctrlPressed;
  41423. private _altPressed;
  41424. private _onCanvasBlurObserver;
  41425. private _onKeyboardObserver;
  41426. private _engine;
  41427. private _scene;
  41428. /**
  41429. * Attach the input controls to a specific dom element to get the input from.
  41430. * @param element Defines the element the controls should be listened from
  41431. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41432. */
  41433. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41434. /**
  41435. * Detach the current controls from the specified dom element.
  41436. * @param element Defines the element to stop listening the inputs from
  41437. */
  41438. detachControl(element: Nullable<HTMLElement>): void;
  41439. /**
  41440. * Update the current camera state depending on the inputs that have been used this frame.
  41441. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41442. */
  41443. checkInputs(): void;
  41444. /**
  41445. * Gets the class name of the current intput.
  41446. * @returns the class name
  41447. */
  41448. getClassName(): string;
  41449. /**
  41450. * Get the friendly name associated with the input class.
  41451. * @returns the input friendly name
  41452. */
  41453. getSimpleName(): string;
  41454. }
  41455. }
  41456. declare module BABYLON {
  41457. /**
  41458. * Manage the mouse wheel inputs to control an arc rotate camera.
  41459. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41460. */
  41461. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  41462. /**
  41463. * Defines the camera the input is attached to.
  41464. */
  41465. camera: ArcRotateCamera;
  41466. /**
  41467. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  41468. */
  41469. wheelPrecision: number;
  41470. /**
  41471. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41472. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41473. */
  41474. wheelDeltaPercentage: number;
  41475. private _wheel;
  41476. private _observer;
  41477. private computeDeltaFromMouseWheelLegacyEvent;
  41478. /**
  41479. * Attach the input controls to a specific dom element to get the input from.
  41480. * @param element Defines the element the controls should be listened from
  41481. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41482. */
  41483. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41484. /**
  41485. * Detach the current controls from the specified dom element.
  41486. * @param element Defines the element to stop listening the inputs from
  41487. */
  41488. detachControl(element: Nullable<HTMLElement>): void;
  41489. /**
  41490. * Gets the class name of the current intput.
  41491. * @returns the class name
  41492. */
  41493. getClassName(): string;
  41494. /**
  41495. * Get the friendly name associated with the input class.
  41496. * @returns the input friendly name
  41497. */
  41498. getSimpleName(): string;
  41499. }
  41500. }
  41501. declare module BABYLON {
  41502. /**
  41503. * Default Inputs manager for the ArcRotateCamera.
  41504. * It groups all the default supported inputs for ease of use.
  41505. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41506. */
  41507. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  41508. /**
  41509. * Instantiates a new ArcRotateCameraInputsManager.
  41510. * @param camera Defines the camera the inputs belong to
  41511. */
  41512. constructor(camera: ArcRotateCamera);
  41513. /**
  41514. * Add mouse wheel input support to the input manager.
  41515. * @returns the current input manager
  41516. */
  41517. addMouseWheel(): ArcRotateCameraInputsManager;
  41518. /**
  41519. * Add pointers input support to the input manager.
  41520. * @returns the current input manager
  41521. */
  41522. addPointers(): ArcRotateCameraInputsManager;
  41523. /**
  41524. * Add keyboard input support to the input manager.
  41525. * @returns the current input manager
  41526. */
  41527. addKeyboard(): ArcRotateCameraInputsManager;
  41528. }
  41529. }
  41530. declare module BABYLON {
  41531. /**
  41532. * This represents an orbital type of camera.
  41533. *
  41534. * 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.
  41535. * 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.
  41536. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  41537. */
  41538. export class ArcRotateCamera extends TargetCamera {
  41539. /**
  41540. * Defines the rotation angle of the camera along the longitudinal axis.
  41541. */
  41542. alpha: number;
  41543. /**
  41544. * Defines the rotation angle of the camera along the latitudinal axis.
  41545. */
  41546. beta: number;
  41547. /**
  41548. * Defines the radius of the camera from it s target point.
  41549. */
  41550. radius: number;
  41551. protected _target: Vector3;
  41552. protected _targetHost: Nullable<AbstractMesh>;
  41553. /**
  41554. * Defines the target point of the camera.
  41555. * The camera looks towards it form the radius distance.
  41556. */
  41557. get target(): Vector3;
  41558. set target(value: Vector3);
  41559. /**
  41560. * Define the current local position of the camera in the scene
  41561. */
  41562. get position(): Vector3;
  41563. set position(newPosition: Vector3);
  41564. protected _upVector: Vector3;
  41565. protected _upToYMatrix: Matrix;
  41566. protected _YToUpMatrix: Matrix;
  41567. /**
  41568. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  41569. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  41570. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  41571. */
  41572. set upVector(vec: Vector3);
  41573. get upVector(): Vector3;
  41574. /**
  41575. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  41576. */
  41577. setMatUp(): void;
  41578. /**
  41579. * Current inertia value on the longitudinal axis.
  41580. * The bigger this number the longer it will take for the camera to stop.
  41581. */
  41582. inertialAlphaOffset: number;
  41583. /**
  41584. * Current inertia value on the latitudinal axis.
  41585. * The bigger this number the longer it will take for the camera to stop.
  41586. */
  41587. inertialBetaOffset: number;
  41588. /**
  41589. * Current inertia value on the radius axis.
  41590. * The bigger this number the longer it will take for the camera to stop.
  41591. */
  41592. inertialRadiusOffset: number;
  41593. /**
  41594. * Minimum allowed angle on the longitudinal axis.
  41595. * This can help limiting how the Camera is able to move in the scene.
  41596. */
  41597. lowerAlphaLimit: Nullable<number>;
  41598. /**
  41599. * Maximum allowed angle on the longitudinal axis.
  41600. * This can help limiting how the Camera is able to move in the scene.
  41601. */
  41602. upperAlphaLimit: Nullable<number>;
  41603. /**
  41604. * Minimum allowed angle on the latitudinal axis.
  41605. * This can help limiting how the Camera is able to move in the scene.
  41606. */
  41607. lowerBetaLimit: number;
  41608. /**
  41609. * Maximum allowed angle on the latitudinal axis.
  41610. * This can help limiting how the Camera is able to move in the scene.
  41611. */
  41612. upperBetaLimit: number;
  41613. /**
  41614. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  41615. * This can help limiting how the Camera is able to move in the scene.
  41616. */
  41617. lowerRadiusLimit: Nullable<number>;
  41618. /**
  41619. * Maximum allowed distance of the camera to the target (The camera can not get further).
  41620. * This can help limiting how the Camera is able to move in the scene.
  41621. */
  41622. upperRadiusLimit: Nullable<number>;
  41623. /**
  41624. * Defines the current inertia value used during panning of the camera along the X axis.
  41625. */
  41626. inertialPanningX: number;
  41627. /**
  41628. * Defines the current inertia value used during panning of the camera along the Y axis.
  41629. */
  41630. inertialPanningY: number;
  41631. /**
  41632. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  41633. * Basically if your fingers moves away from more than this distance you will be considered
  41634. * in pinch mode.
  41635. */
  41636. pinchToPanMaxDistance: number;
  41637. /**
  41638. * Defines the maximum distance the camera can pan.
  41639. * This could help keeping the cammera always in your scene.
  41640. */
  41641. panningDistanceLimit: Nullable<number>;
  41642. /**
  41643. * Defines the target of the camera before paning.
  41644. */
  41645. panningOriginTarget: Vector3;
  41646. /**
  41647. * Defines the value of the inertia used during panning.
  41648. * 0 would mean stop inertia and one would mean no decelleration at all.
  41649. */
  41650. panningInertia: number;
  41651. /**
  41652. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  41653. */
  41654. get angularSensibilityX(): number;
  41655. set angularSensibilityX(value: number);
  41656. /**
  41657. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  41658. */
  41659. get angularSensibilityY(): number;
  41660. set angularSensibilityY(value: number);
  41661. /**
  41662. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  41663. */
  41664. get pinchPrecision(): number;
  41665. set pinchPrecision(value: number);
  41666. /**
  41667. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  41668. * It will be used instead of pinchDeltaPrecision if different from 0.
  41669. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  41670. */
  41671. get pinchDeltaPercentage(): number;
  41672. set pinchDeltaPercentage(value: number);
  41673. /**
  41674. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  41675. * and pinch delta percentage.
  41676. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  41677. * that any object in the plane at the camera's target point will scale
  41678. * perfectly with finger motion.
  41679. */
  41680. get useNaturalPinchZoom(): boolean;
  41681. set useNaturalPinchZoom(value: boolean);
  41682. /**
  41683. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  41684. */
  41685. get panningSensibility(): number;
  41686. set panningSensibility(value: number);
  41687. /**
  41688. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  41689. */
  41690. get keysUp(): number[];
  41691. set keysUp(value: number[]);
  41692. /**
  41693. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  41694. */
  41695. get keysDown(): number[];
  41696. set keysDown(value: number[]);
  41697. /**
  41698. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  41699. */
  41700. get keysLeft(): number[];
  41701. set keysLeft(value: number[]);
  41702. /**
  41703. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  41704. */
  41705. get keysRight(): number[];
  41706. set keysRight(value: number[]);
  41707. /**
  41708. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  41709. */
  41710. get wheelPrecision(): number;
  41711. set wheelPrecision(value: number);
  41712. /**
  41713. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  41714. * It will be used instead of pinchDeltaPrecision if different from 0.
  41715. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  41716. */
  41717. get wheelDeltaPercentage(): number;
  41718. set wheelDeltaPercentage(value: number);
  41719. /**
  41720. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  41721. */
  41722. zoomOnFactor: number;
  41723. /**
  41724. * Defines a screen offset for the camera position.
  41725. */
  41726. targetScreenOffset: Vector2;
  41727. /**
  41728. * Allows the camera to be completely reversed.
  41729. * If false the camera can not arrive upside down.
  41730. */
  41731. allowUpsideDown: boolean;
  41732. /**
  41733. * Define if double tap/click is used to restore the previously saved state of the camera.
  41734. */
  41735. useInputToRestoreState: boolean;
  41736. /** @hidden */
  41737. _viewMatrix: Matrix;
  41738. /** @hidden */
  41739. _useCtrlForPanning: boolean;
  41740. /** @hidden */
  41741. _panningMouseButton: number;
  41742. /**
  41743. * Defines the input associated to the camera.
  41744. */
  41745. inputs: ArcRotateCameraInputsManager;
  41746. /** @hidden */
  41747. _reset: () => void;
  41748. /**
  41749. * Defines the allowed panning axis.
  41750. */
  41751. panningAxis: Vector3;
  41752. protected _localDirection: Vector3;
  41753. protected _transformedDirection: Vector3;
  41754. private _bouncingBehavior;
  41755. /**
  41756. * Gets the bouncing behavior of the camera if it has been enabled.
  41757. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  41758. */
  41759. get bouncingBehavior(): Nullable<BouncingBehavior>;
  41760. /**
  41761. * Defines if the bouncing behavior of the camera is enabled on the camera.
  41762. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  41763. */
  41764. get useBouncingBehavior(): boolean;
  41765. set useBouncingBehavior(value: boolean);
  41766. private _framingBehavior;
  41767. /**
  41768. * Gets the framing behavior of the camera if it has been enabled.
  41769. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  41770. */
  41771. get framingBehavior(): Nullable<FramingBehavior>;
  41772. /**
  41773. * Defines if the framing behavior of the camera is enabled on the camera.
  41774. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  41775. */
  41776. get useFramingBehavior(): boolean;
  41777. set useFramingBehavior(value: boolean);
  41778. private _autoRotationBehavior;
  41779. /**
  41780. * Gets the auto rotation behavior of the camera if it has been enabled.
  41781. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  41782. */
  41783. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  41784. /**
  41785. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  41786. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  41787. */
  41788. get useAutoRotationBehavior(): boolean;
  41789. set useAutoRotationBehavior(value: boolean);
  41790. /**
  41791. * Observable triggered when the mesh target has been changed on the camera.
  41792. */
  41793. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  41794. /**
  41795. * Event raised when the camera is colliding with a mesh.
  41796. */
  41797. onCollide: (collidedMesh: AbstractMesh) => void;
  41798. /**
  41799. * Defines whether the camera should check collision with the objects oh the scene.
  41800. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  41801. */
  41802. checkCollisions: boolean;
  41803. /**
  41804. * Defines the collision radius of the camera.
  41805. * This simulates a sphere around the camera.
  41806. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  41807. */
  41808. collisionRadius: Vector3;
  41809. protected _collider: Collider;
  41810. protected _previousPosition: Vector3;
  41811. protected _collisionVelocity: Vector3;
  41812. protected _newPosition: Vector3;
  41813. protected _previousAlpha: number;
  41814. protected _previousBeta: number;
  41815. protected _previousRadius: number;
  41816. protected _collisionTriggered: boolean;
  41817. protected _targetBoundingCenter: Nullable<Vector3>;
  41818. private _computationVector;
  41819. /**
  41820. * Instantiates a new ArcRotateCamera in a given scene
  41821. * @param name Defines the name of the camera
  41822. * @param alpha Defines the camera rotation along the logitudinal axis
  41823. * @param beta Defines the camera rotation along the latitudinal axis
  41824. * @param radius Defines the camera distance from its target
  41825. * @param target Defines the camera target
  41826. * @param scene Defines the scene the camera belongs to
  41827. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  41828. */
  41829. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  41830. /** @hidden */
  41831. _initCache(): void;
  41832. /** @hidden */
  41833. _updateCache(ignoreParentClass?: boolean): void;
  41834. protected _getTargetPosition(): Vector3;
  41835. private _storedAlpha;
  41836. private _storedBeta;
  41837. private _storedRadius;
  41838. private _storedTarget;
  41839. private _storedTargetScreenOffset;
  41840. /**
  41841. * Stores the current state of the camera (alpha, beta, radius and target)
  41842. * @returns the camera itself
  41843. */
  41844. storeState(): Camera;
  41845. /**
  41846. * @hidden
  41847. * Restored camera state. You must call storeState() first
  41848. */
  41849. _restoreStateValues(): boolean;
  41850. /** @hidden */
  41851. _isSynchronizedViewMatrix(): boolean;
  41852. /**
  41853. * Attached controls to the current camera.
  41854. * @param element Defines the element the controls should be listened from
  41855. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41856. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  41857. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  41858. */
  41859. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  41860. /**
  41861. * Detach the current controls from the camera.
  41862. * The camera will stop reacting to inputs.
  41863. * @param element Defines the element to stop listening the inputs from
  41864. */
  41865. detachControl(element: HTMLElement): void;
  41866. /** @hidden */
  41867. _checkInputs(): void;
  41868. protected _checkLimits(): void;
  41869. /**
  41870. * Rebuilds angles (alpha, beta) and radius from the give position and target
  41871. */
  41872. rebuildAnglesAndRadius(): void;
  41873. /**
  41874. * Use a position to define the current camera related information like alpha, beta and radius
  41875. * @param position Defines the position to set the camera at
  41876. */
  41877. setPosition(position: Vector3): void;
  41878. /**
  41879. * Defines the target the camera should look at.
  41880. * This will automatically adapt alpha beta and radius to fit within the new target.
  41881. * @param target Defines the new target as a Vector or a mesh
  41882. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  41883. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  41884. */
  41885. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  41886. /** @hidden */
  41887. _getViewMatrix(): Matrix;
  41888. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  41889. /**
  41890. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  41891. * @param meshes Defines the mesh to zoom on
  41892. * @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)
  41893. */
  41894. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  41895. /**
  41896. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  41897. * The target will be changed but the radius
  41898. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  41899. * @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)
  41900. */
  41901. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  41902. min: Vector3;
  41903. max: Vector3;
  41904. distance: number;
  41905. }, doNotUpdateMaxZ?: boolean): void;
  41906. /**
  41907. * @override
  41908. * Override Camera.createRigCamera
  41909. */
  41910. createRigCamera(name: string, cameraIndex: number): Camera;
  41911. /**
  41912. * @hidden
  41913. * @override
  41914. * Override Camera._updateRigCameras
  41915. */
  41916. _updateRigCameras(): void;
  41917. /**
  41918. * Destroy the camera and release the current resources hold by it.
  41919. */
  41920. dispose(): void;
  41921. /**
  41922. * Gets the current object class name.
  41923. * @return the class name
  41924. */
  41925. getClassName(): string;
  41926. }
  41927. }
  41928. declare module BABYLON {
  41929. /**
  41930. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  41931. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  41932. */
  41933. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  41934. /**
  41935. * Gets the name of the behavior.
  41936. */
  41937. get name(): string;
  41938. private _zoomStopsAnimation;
  41939. private _idleRotationSpeed;
  41940. private _idleRotationWaitTime;
  41941. private _idleRotationSpinupTime;
  41942. /**
  41943. * Sets the flag that indicates if user zooming should stop animation.
  41944. */
  41945. set zoomStopsAnimation(flag: boolean);
  41946. /**
  41947. * Gets the flag that indicates if user zooming should stop animation.
  41948. */
  41949. get zoomStopsAnimation(): boolean;
  41950. /**
  41951. * Sets the default speed at which the camera rotates around the model.
  41952. */
  41953. set idleRotationSpeed(speed: number);
  41954. /**
  41955. * Gets the default speed at which the camera rotates around the model.
  41956. */
  41957. get idleRotationSpeed(): number;
  41958. /**
  41959. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  41960. */
  41961. set idleRotationWaitTime(time: number);
  41962. /**
  41963. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  41964. */
  41965. get idleRotationWaitTime(): number;
  41966. /**
  41967. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  41968. */
  41969. set idleRotationSpinupTime(time: number);
  41970. /**
  41971. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  41972. */
  41973. get idleRotationSpinupTime(): number;
  41974. /**
  41975. * Gets a value indicating if the camera is currently rotating because of this behavior
  41976. */
  41977. get rotationInProgress(): boolean;
  41978. private _onPrePointerObservableObserver;
  41979. private _onAfterCheckInputsObserver;
  41980. private _attachedCamera;
  41981. private _isPointerDown;
  41982. private _lastFrameTime;
  41983. private _lastInteractionTime;
  41984. private _cameraRotationSpeed;
  41985. /**
  41986. * Initializes the behavior.
  41987. */
  41988. init(): void;
  41989. /**
  41990. * Attaches the behavior to its arc rotate camera.
  41991. * @param camera Defines the camera to attach the behavior to
  41992. */
  41993. attach(camera: ArcRotateCamera): void;
  41994. /**
  41995. * Detaches the behavior from its current arc rotate camera.
  41996. */
  41997. detach(): void;
  41998. /**
  41999. * Returns true if user is scrolling.
  42000. * @return true if user is scrolling.
  42001. */
  42002. private _userIsZooming;
  42003. private _lastFrameRadius;
  42004. private _shouldAnimationStopForInteraction;
  42005. /**
  42006. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  42007. */
  42008. private _applyUserInteraction;
  42009. private _userIsMoving;
  42010. }
  42011. }
  42012. declare module BABYLON {
  42013. /**
  42014. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  42015. */
  42016. export class AttachToBoxBehavior implements Behavior<Mesh> {
  42017. private ui;
  42018. /**
  42019. * The name of the behavior
  42020. */
  42021. name: string;
  42022. /**
  42023. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  42024. */
  42025. distanceAwayFromFace: number;
  42026. /**
  42027. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  42028. */
  42029. distanceAwayFromBottomOfFace: number;
  42030. private _faceVectors;
  42031. private _target;
  42032. private _scene;
  42033. private _onRenderObserver;
  42034. private _tmpMatrix;
  42035. private _tmpVector;
  42036. /**
  42037. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  42038. * @param ui The transform node that should be attched to the mesh
  42039. */
  42040. constructor(ui: TransformNode);
  42041. /**
  42042. * Initializes the behavior
  42043. */
  42044. init(): void;
  42045. private _closestFace;
  42046. private _zeroVector;
  42047. private _lookAtTmpMatrix;
  42048. private _lookAtToRef;
  42049. /**
  42050. * Attaches the AttachToBoxBehavior to the passed in mesh
  42051. * @param target The mesh that the specified node will be attached to
  42052. */
  42053. attach(target: Mesh): void;
  42054. /**
  42055. * Detaches the behavior from the mesh
  42056. */
  42057. detach(): void;
  42058. }
  42059. }
  42060. declare module BABYLON {
  42061. /**
  42062. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  42063. */
  42064. export class FadeInOutBehavior implements Behavior<Mesh> {
  42065. /**
  42066. * Time in milliseconds to delay before fading in (Default: 0)
  42067. */
  42068. delay: number;
  42069. /**
  42070. * Time in milliseconds for the mesh to fade in (Default: 300)
  42071. */
  42072. fadeInTime: number;
  42073. private _millisecondsPerFrame;
  42074. private _hovered;
  42075. private _hoverValue;
  42076. private _ownerNode;
  42077. /**
  42078. * Instatiates the FadeInOutBehavior
  42079. */
  42080. constructor();
  42081. /**
  42082. * The name of the behavior
  42083. */
  42084. get name(): string;
  42085. /**
  42086. * Initializes the behavior
  42087. */
  42088. init(): void;
  42089. /**
  42090. * Attaches the fade behavior on the passed in mesh
  42091. * @param ownerNode The mesh that will be faded in/out once attached
  42092. */
  42093. attach(ownerNode: Mesh): void;
  42094. /**
  42095. * Detaches the behavior from the mesh
  42096. */
  42097. detach(): void;
  42098. /**
  42099. * Triggers the mesh to begin fading in or out
  42100. * @param value if the object should fade in or out (true to fade in)
  42101. */
  42102. fadeIn(value: boolean): void;
  42103. private _update;
  42104. private _setAllVisibility;
  42105. }
  42106. }
  42107. declare module BABYLON {
  42108. /**
  42109. * Class containing a set of static utilities functions for managing Pivots
  42110. * @hidden
  42111. */
  42112. export class PivotTools {
  42113. private static _PivotCached;
  42114. private static _OldPivotPoint;
  42115. private static _PivotTranslation;
  42116. private static _PivotTmpVector;
  42117. /** @hidden */
  42118. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  42119. /** @hidden */
  42120. static _RestorePivotPoint(mesh: AbstractMesh): void;
  42121. }
  42122. }
  42123. declare module BABYLON {
  42124. /**
  42125. * Class containing static functions to help procedurally build meshes
  42126. */
  42127. export class PlaneBuilder {
  42128. /**
  42129. * Creates a plane mesh
  42130. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  42131. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  42132. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  42133. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42134. * * 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
  42135. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42136. * @param name defines the name of the mesh
  42137. * @param options defines the options used to create the mesh
  42138. * @param scene defines the hosting scene
  42139. * @returns the plane mesh
  42140. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  42141. */
  42142. static CreatePlane(name: string, options: {
  42143. size?: number;
  42144. width?: number;
  42145. height?: number;
  42146. sideOrientation?: number;
  42147. frontUVs?: Vector4;
  42148. backUVs?: Vector4;
  42149. updatable?: boolean;
  42150. sourcePlane?: Plane;
  42151. }, scene?: Nullable<Scene>): Mesh;
  42152. }
  42153. }
  42154. declare module BABYLON {
  42155. /**
  42156. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  42157. */
  42158. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  42159. private static _AnyMouseID;
  42160. /**
  42161. * Abstract mesh the behavior is set on
  42162. */
  42163. attachedNode: AbstractMesh;
  42164. private _dragPlane;
  42165. private _scene;
  42166. private _pointerObserver;
  42167. private _beforeRenderObserver;
  42168. private static _planeScene;
  42169. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  42170. /**
  42171. * 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)
  42172. */
  42173. maxDragAngle: number;
  42174. /**
  42175. * @hidden
  42176. */
  42177. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  42178. /**
  42179. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  42180. */
  42181. currentDraggingPointerID: number;
  42182. /**
  42183. * The last position where the pointer hit the drag plane in world space
  42184. */
  42185. lastDragPosition: Vector3;
  42186. /**
  42187. * If the behavior is currently in a dragging state
  42188. */
  42189. dragging: boolean;
  42190. /**
  42191. * 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)
  42192. */
  42193. dragDeltaRatio: number;
  42194. /**
  42195. * If the drag plane orientation should be updated during the dragging (Default: true)
  42196. */
  42197. updateDragPlane: boolean;
  42198. private _debugMode;
  42199. private _moving;
  42200. /**
  42201. * Fires each time the attached mesh is dragged with the pointer
  42202. * * delta between last drag position and current drag position in world space
  42203. * * dragDistance along the drag axis
  42204. * * dragPlaneNormal normal of the current drag plane used during the drag
  42205. * * dragPlanePoint in world space where the drag intersects the drag plane
  42206. */
  42207. onDragObservable: Observable<{
  42208. delta: Vector3;
  42209. dragPlanePoint: Vector3;
  42210. dragPlaneNormal: Vector3;
  42211. dragDistance: number;
  42212. pointerId: number;
  42213. }>;
  42214. /**
  42215. * Fires each time a drag begins (eg. mouse down on mesh)
  42216. */
  42217. onDragStartObservable: Observable<{
  42218. dragPlanePoint: Vector3;
  42219. pointerId: number;
  42220. }>;
  42221. /**
  42222. * Fires each time a drag ends (eg. mouse release after drag)
  42223. */
  42224. onDragEndObservable: Observable<{
  42225. dragPlanePoint: Vector3;
  42226. pointerId: number;
  42227. }>;
  42228. /**
  42229. * If the attached mesh should be moved when dragged
  42230. */
  42231. moveAttached: boolean;
  42232. /**
  42233. * If the drag behavior will react to drag events (Default: true)
  42234. */
  42235. enabled: boolean;
  42236. /**
  42237. * If pointer events should start and release the drag (Default: true)
  42238. */
  42239. startAndReleaseDragOnPointerEvents: boolean;
  42240. /**
  42241. * If camera controls should be detached during the drag
  42242. */
  42243. detachCameraControls: boolean;
  42244. /**
  42245. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  42246. */
  42247. useObjectOrientationForDragging: boolean;
  42248. private _options;
  42249. /**
  42250. * Gets the options used by the behavior
  42251. */
  42252. get options(): {
  42253. dragAxis?: Vector3;
  42254. dragPlaneNormal?: Vector3;
  42255. };
  42256. /**
  42257. * Sets the options used by the behavior
  42258. */
  42259. set options(options: {
  42260. dragAxis?: Vector3;
  42261. dragPlaneNormal?: Vector3;
  42262. });
  42263. /**
  42264. * Creates a pointer drag behavior that can be attached to a mesh
  42265. * @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)
  42266. */
  42267. constructor(options?: {
  42268. dragAxis?: Vector3;
  42269. dragPlaneNormal?: Vector3;
  42270. });
  42271. /**
  42272. * Predicate to determine if it is valid to move the object to a new position when it is moved
  42273. */
  42274. validateDrag: (targetPosition: Vector3) => boolean;
  42275. /**
  42276. * The name of the behavior
  42277. */
  42278. get name(): string;
  42279. /**
  42280. * Initializes the behavior
  42281. */
  42282. init(): void;
  42283. private _tmpVector;
  42284. private _alternatePickedPoint;
  42285. private _worldDragAxis;
  42286. private _targetPosition;
  42287. private _attachedElement;
  42288. /**
  42289. * Attaches the drag behavior the passed in mesh
  42290. * @param ownerNode The mesh that will be dragged around once attached
  42291. * @param predicate Predicate to use for pick filtering
  42292. */
  42293. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  42294. /**
  42295. * Force relase the drag action by code.
  42296. */
  42297. releaseDrag(): void;
  42298. private _startDragRay;
  42299. private _lastPointerRay;
  42300. /**
  42301. * Simulates the start of a pointer drag event on the behavior
  42302. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  42303. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  42304. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  42305. */
  42306. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  42307. private _startDrag;
  42308. private _dragDelta;
  42309. private _moveDrag;
  42310. private _pickWithRayOnDragPlane;
  42311. private _pointA;
  42312. private _pointB;
  42313. private _pointC;
  42314. private _lineA;
  42315. private _lineB;
  42316. private _localAxis;
  42317. private _lookAt;
  42318. private _updateDragPlanePosition;
  42319. /**
  42320. * Detaches the behavior from the mesh
  42321. */
  42322. detach(): void;
  42323. }
  42324. }
  42325. declare module BABYLON {
  42326. /**
  42327. * A behavior that when attached to a mesh will allow the mesh to be scaled
  42328. */
  42329. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  42330. private _dragBehaviorA;
  42331. private _dragBehaviorB;
  42332. private _startDistance;
  42333. private _initialScale;
  42334. private _targetScale;
  42335. private _ownerNode;
  42336. private _sceneRenderObserver;
  42337. /**
  42338. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  42339. */
  42340. constructor();
  42341. /**
  42342. * The name of the behavior
  42343. */
  42344. get name(): string;
  42345. /**
  42346. * Initializes the behavior
  42347. */
  42348. init(): void;
  42349. private _getCurrentDistance;
  42350. /**
  42351. * Attaches the scale behavior the passed in mesh
  42352. * @param ownerNode The mesh that will be scaled around once attached
  42353. */
  42354. attach(ownerNode: Mesh): void;
  42355. /**
  42356. * Detaches the behavior from the mesh
  42357. */
  42358. detach(): void;
  42359. }
  42360. }
  42361. declare module BABYLON {
  42362. /**
  42363. * 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
  42364. */
  42365. export class SixDofDragBehavior implements Behavior<Mesh> {
  42366. private static _virtualScene;
  42367. private _ownerNode;
  42368. private _sceneRenderObserver;
  42369. private _scene;
  42370. private _targetPosition;
  42371. private _virtualOriginMesh;
  42372. private _virtualDragMesh;
  42373. private _pointerObserver;
  42374. private _moving;
  42375. private _startingOrientation;
  42376. private _attachedElement;
  42377. /**
  42378. * 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)
  42379. */
  42380. private zDragFactor;
  42381. /**
  42382. * If the object should rotate to face the drag origin
  42383. */
  42384. rotateDraggedObject: boolean;
  42385. /**
  42386. * If the behavior is currently in a dragging state
  42387. */
  42388. dragging: boolean;
  42389. /**
  42390. * 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)
  42391. */
  42392. dragDeltaRatio: number;
  42393. /**
  42394. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  42395. */
  42396. currentDraggingPointerID: number;
  42397. /**
  42398. * If camera controls should be detached during the drag
  42399. */
  42400. detachCameraControls: boolean;
  42401. /**
  42402. * Fires each time a drag starts
  42403. */
  42404. onDragStartObservable: Observable<{}>;
  42405. /**
  42406. * Fires each time a drag ends (eg. mouse release after drag)
  42407. */
  42408. onDragEndObservable: Observable<{}>;
  42409. /**
  42410. * 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
  42411. */
  42412. constructor();
  42413. /**
  42414. * The name of the behavior
  42415. */
  42416. get name(): string;
  42417. /**
  42418. * Initializes the behavior
  42419. */
  42420. init(): void;
  42421. /**
  42422. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  42423. */
  42424. private get _pointerCamera();
  42425. /**
  42426. * Attaches the scale behavior the passed in mesh
  42427. * @param ownerNode The mesh that will be scaled around once attached
  42428. */
  42429. attach(ownerNode: Mesh): void;
  42430. /**
  42431. * Detaches the behavior from the mesh
  42432. */
  42433. detach(): void;
  42434. }
  42435. }
  42436. declare module BABYLON {
  42437. /**
  42438. * Class used to apply inverse kinematics to bones
  42439. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  42440. */
  42441. export class BoneIKController {
  42442. private static _tmpVecs;
  42443. private static _tmpQuat;
  42444. private static _tmpMats;
  42445. /**
  42446. * Gets or sets the target mesh
  42447. */
  42448. targetMesh: AbstractMesh;
  42449. /** Gets or sets the mesh used as pole */
  42450. poleTargetMesh: AbstractMesh;
  42451. /**
  42452. * Gets or sets the bone used as pole
  42453. */
  42454. poleTargetBone: Nullable<Bone>;
  42455. /**
  42456. * Gets or sets the target position
  42457. */
  42458. targetPosition: Vector3;
  42459. /**
  42460. * Gets or sets the pole target position
  42461. */
  42462. poleTargetPosition: Vector3;
  42463. /**
  42464. * Gets or sets the pole target local offset
  42465. */
  42466. poleTargetLocalOffset: Vector3;
  42467. /**
  42468. * Gets or sets the pole angle
  42469. */
  42470. poleAngle: number;
  42471. /**
  42472. * Gets or sets the mesh associated with the controller
  42473. */
  42474. mesh: AbstractMesh;
  42475. /**
  42476. * 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)
  42477. */
  42478. slerpAmount: number;
  42479. private _bone1Quat;
  42480. private _bone1Mat;
  42481. private _bone2Ang;
  42482. private _bone1;
  42483. private _bone2;
  42484. private _bone1Length;
  42485. private _bone2Length;
  42486. private _maxAngle;
  42487. private _maxReach;
  42488. private _rightHandedSystem;
  42489. private _bendAxis;
  42490. private _slerping;
  42491. private _adjustRoll;
  42492. /**
  42493. * Gets or sets maximum allowed angle
  42494. */
  42495. get maxAngle(): number;
  42496. set maxAngle(value: number);
  42497. /**
  42498. * Creates a new BoneIKController
  42499. * @param mesh defines the mesh to control
  42500. * @param bone defines the bone to control
  42501. * @param options defines options to set up the controller
  42502. */
  42503. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  42504. targetMesh?: AbstractMesh;
  42505. poleTargetMesh?: AbstractMesh;
  42506. poleTargetBone?: Bone;
  42507. poleTargetLocalOffset?: Vector3;
  42508. poleAngle?: number;
  42509. bendAxis?: Vector3;
  42510. maxAngle?: number;
  42511. slerpAmount?: number;
  42512. });
  42513. private _setMaxAngle;
  42514. /**
  42515. * Force the controller to update the bones
  42516. */
  42517. update(): void;
  42518. }
  42519. }
  42520. declare module BABYLON {
  42521. /**
  42522. * Class used to make a bone look toward a point in space
  42523. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  42524. */
  42525. export class BoneLookController {
  42526. private static _tmpVecs;
  42527. private static _tmpQuat;
  42528. private static _tmpMats;
  42529. /**
  42530. * The target Vector3 that the bone will look at
  42531. */
  42532. target: Vector3;
  42533. /**
  42534. * The mesh that the bone is attached to
  42535. */
  42536. mesh: AbstractMesh;
  42537. /**
  42538. * The bone that will be looking to the target
  42539. */
  42540. bone: Bone;
  42541. /**
  42542. * The up axis of the coordinate system that is used when the bone is rotated
  42543. */
  42544. upAxis: Vector3;
  42545. /**
  42546. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  42547. */
  42548. upAxisSpace: Space;
  42549. /**
  42550. * Used to make an adjustment to the yaw of the bone
  42551. */
  42552. adjustYaw: number;
  42553. /**
  42554. * Used to make an adjustment to the pitch of the bone
  42555. */
  42556. adjustPitch: number;
  42557. /**
  42558. * Used to make an adjustment to the roll of the bone
  42559. */
  42560. adjustRoll: number;
  42561. /**
  42562. * 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)
  42563. */
  42564. slerpAmount: number;
  42565. private _minYaw;
  42566. private _maxYaw;
  42567. private _minPitch;
  42568. private _maxPitch;
  42569. private _minYawSin;
  42570. private _minYawCos;
  42571. private _maxYawSin;
  42572. private _maxYawCos;
  42573. private _midYawConstraint;
  42574. private _minPitchTan;
  42575. private _maxPitchTan;
  42576. private _boneQuat;
  42577. private _slerping;
  42578. private _transformYawPitch;
  42579. private _transformYawPitchInv;
  42580. private _firstFrameSkipped;
  42581. private _yawRange;
  42582. private _fowardAxis;
  42583. /**
  42584. * Gets or sets the minimum yaw angle that the bone can look to
  42585. */
  42586. get minYaw(): number;
  42587. set minYaw(value: number);
  42588. /**
  42589. * Gets or sets the maximum yaw angle that the bone can look to
  42590. */
  42591. get maxYaw(): number;
  42592. set maxYaw(value: number);
  42593. /**
  42594. * Gets or sets the minimum pitch angle that the bone can look to
  42595. */
  42596. get minPitch(): number;
  42597. set minPitch(value: number);
  42598. /**
  42599. * Gets or sets the maximum pitch angle that the bone can look to
  42600. */
  42601. get maxPitch(): number;
  42602. set maxPitch(value: number);
  42603. /**
  42604. * Create a BoneLookController
  42605. * @param mesh the mesh that the bone belongs to
  42606. * @param bone the bone that will be looking to the target
  42607. * @param target the target Vector3 to look at
  42608. * @param options optional settings:
  42609. * * maxYaw: the maximum angle the bone will yaw to
  42610. * * minYaw: the minimum angle the bone will yaw to
  42611. * * maxPitch: the maximum angle the bone will pitch to
  42612. * * minPitch: the minimum angle the bone will yaw to
  42613. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  42614. * * upAxis: the up axis of the coordinate system
  42615. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  42616. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  42617. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  42618. * * adjustYaw: used to make an adjustment to the yaw of the bone
  42619. * * adjustPitch: used to make an adjustment to the pitch of the bone
  42620. * * adjustRoll: used to make an adjustment to the roll of the bone
  42621. **/
  42622. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  42623. maxYaw?: number;
  42624. minYaw?: number;
  42625. maxPitch?: number;
  42626. minPitch?: number;
  42627. slerpAmount?: number;
  42628. upAxis?: Vector3;
  42629. upAxisSpace?: Space;
  42630. yawAxis?: Vector3;
  42631. pitchAxis?: Vector3;
  42632. adjustYaw?: number;
  42633. adjustPitch?: number;
  42634. adjustRoll?: number;
  42635. });
  42636. /**
  42637. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  42638. */
  42639. update(): void;
  42640. private _getAngleDiff;
  42641. private _getAngleBetween;
  42642. private _isAngleBetween;
  42643. }
  42644. }
  42645. declare module BABYLON {
  42646. /**
  42647. * Manage the gamepad inputs to control an arc rotate camera.
  42648. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42649. */
  42650. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  42651. /**
  42652. * Defines the camera the input is attached to.
  42653. */
  42654. camera: ArcRotateCamera;
  42655. /**
  42656. * Defines the gamepad the input is gathering event from.
  42657. */
  42658. gamepad: Nullable<Gamepad>;
  42659. /**
  42660. * Defines the gamepad rotation sensiblity.
  42661. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42662. */
  42663. gamepadRotationSensibility: number;
  42664. /**
  42665. * Defines the gamepad move sensiblity.
  42666. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42667. */
  42668. gamepadMoveSensibility: number;
  42669. private _yAxisScale;
  42670. /**
  42671. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  42672. */
  42673. get invertYAxis(): boolean;
  42674. set invertYAxis(value: boolean);
  42675. private _onGamepadConnectedObserver;
  42676. private _onGamepadDisconnectedObserver;
  42677. /**
  42678. * Attach the input controls to a specific dom element to get the input from.
  42679. * @param element Defines the element the controls should be listened from
  42680. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42681. */
  42682. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42683. /**
  42684. * Detach the current controls from the specified dom element.
  42685. * @param element Defines the element to stop listening the inputs from
  42686. */
  42687. detachControl(element: Nullable<HTMLElement>): void;
  42688. /**
  42689. * Update the current camera state depending on the inputs that have been used this frame.
  42690. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42691. */
  42692. checkInputs(): void;
  42693. /**
  42694. * Gets the class name of the current intput.
  42695. * @returns the class name
  42696. */
  42697. getClassName(): string;
  42698. /**
  42699. * Get the friendly name associated with the input class.
  42700. * @returns the input friendly name
  42701. */
  42702. getSimpleName(): string;
  42703. }
  42704. }
  42705. declare module BABYLON {
  42706. interface ArcRotateCameraInputsManager {
  42707. /**
  42708. * Add orientation input support to the input manager.
  42709. * @returns the current input manager
  42710. */
  42711. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  42712. }
  42713. /**
  42714. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  42715. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42716. */
  42717. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  42718. /**
  42719. * Defines the camera the input is attached to.
  42720. */
  42721. camera: ArcRotateCamera;
  42722. /**
  42723. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  42724. */
  42725. alphaCorrection: number;
  42726. /**
  42727. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  42728. */
  42729. gammaCorrection: number;
  42730. private _alpha;
  42731. private _gamma;
  42732. private _dirty;
  42733. private _deviceOrientationHandler;
  42734. /**
  42735. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  42736. */
  42737. constructor();
  42738. /**
  42739. * Attach the input controls to a specific dom element to get the input from.
  42740. * @param element Defines the element the controls should be listened from
  42741. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42742. */
  42743. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42744. /** @hidden */
  42745. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  42746. /**
  42747. * Update the current camera state depending on the inputs that have been used this frame.
  42748. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42749. */
  42750. checkInputs(): void;
  42751. /**
  42752. * Detach the current controls from the specified dom element.
  42753. * @param element Defines the element to stop listening the inputs from
  42754. */
  42755. detachControl(element: Nullable<HTMLElement>): void;
  42756. /**
  42757. * Gets the class name of the current intput.
  42758. * @returns the class name
  42759. */
  42760. getClassName(): string;
  42761. /**
  42762. * Get the friendly name associated with the input class.
  42763. * @returns the input friendly name
  42764. */
  42765. getSimpleName(): string;
  42766. }
  42767. }
  42768. declare module BABYLON {
  42769. /**
  42770. * Listen to mouse events to control the camera.
  42771. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42772. */
  42773. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  42774. /**
  42775. * Defines the camera the input is attached to.
  42776. */
  42777. camera: FlyCamera;
  42778. /**
  42779. * Defines if touch is enabled. (Default is true.)
  42780. */
  42781. touchEnabled: boolean;
  42782. /**
  42783. * Defines the buttons associated with the input to handle camera rotation.
  42784. */
  42785. buttons: number[];
  42786. /**
  42787. * Assign buttons for Yaw control.
  42788. */
  42789. buttonsYaw: number[];
  42790. /**
  42791. * Assign buttons for Pitch control.
  42792. */
  42793. buttonsPitch: number[];
  42794. /**
  42795. * Assign buttons for Roll control.
  42796. */
  42797. buttonsRoll: number[];
  42798. /**
  42799. * Detect if any button is being pressed while mouse is moved.
  42800. * -1 = Mouse locked.
  42801. * 0 = Left button.
  42802. * 1 = Middle Button.
  42803. * 2 = Right Button.
  42804. */
  42805. activeButton: number;
  42806. /**
  42807. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  42808. * Higher values reduce its sensitivity.
  42809. */
  42810. angularSensibility: number;
  42811. private _mousemoveCallback;
  42812. private _observer;
  42813. private _rollObserver;
  42814. private previousPosition;
  42815. private noPreventDefault;
  42816. private element;
  42817. /**
  42818. * Listen to mouse events to control the camera.
  42819. * @param touchEnabled Define if touch is enabled. (Default is true.)
  42820. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42821. */
  42822. constructor(touchEnabled?: boolean);
  42823. /**
  42824. * Attach the mouse control to the HTML DOM element.
  42825. * @param element Defines the element that listens to the input events.
  42826. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  42827. */
  42828. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42829. /**
  42830. * Detach the current controls from the specified dom element.
  42831. * @param element Defines the element to stop listening the inputs from
  42832. */
  42833. detachControl(element: Nullable<HTMLElement>): void;
  42834. /**
  42835. * Gets the class name of the current input.
  42836. * @returns the class name.
  42837. */
  42838. getClassName(): string;
  42839. /**
  42840. * Get the friendly name associated with the input class.
  42841. * @returns the input's friendly name.
  42842. */
  42843. getSimpleName(): string;
  42844. private _pointerInput;
  42845. private _onMouseMove;
  42846. /**
  42847. * Rotate camera by mouse offset.
  42848. */
  42849. private rotateCamera;
  42850. }
  42851. }
  42852. declare module BABYLON {
  42853. /**
  42854. * Default Inputs manager for the FlyCamera.
  42855. * It groups all the default supported inputs for ease of use.
  42856. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42857. */
  42858. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  42859. /**
  42860. * Instantiates a new FlyCameraInputsManager.
  42861. * @param camera Defines the camera the inputs belong to.
  42862. */
  42863. constructor(camera: FlyCamera);
  42864. /**
  42865. * Add keyboard input support to the input manager.
  42866. * @returns the new FlyCameraKeyboardMoveInput().
  42867. */
  42868. addKeyboard(): FlyCameraInputsManager;
  42869. /**
  42870. * Add mouse input support to the input manager.
  42871. * @param touchEnabled Enable touch screen support.
  42872. * @returns the new FlyCameraMouseInput().
  42873. */
  42874. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  42875. }
  42876. }
  42877. declare module BABYLON {
  42878. /**
  42879. * This is a flying camera, designed for 3D movement and rotation in all directions,
  42880. * such as in a 3D Space Shooter or a Flight Simulator.
  42881. */
  42882. export class FlyCamera extends TargetCamera {
  42883. /**
  42884. * Define the collision ellipsoid of the camera.
  42885. * This is helpful for simulating a camera body, like a player's body.
  42886. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  42887. */
  42888. ellipsoid: Vector3;
  42889. /**
  42890. * Define an offset for the position of the ellipsoid around the camera.
  42891. * This can be helpful if the camera is attached away from the player's body center,
  42892. * such as at its head.
  42893. */
  42894. ellipsoidOffset: Vector3;
  42895. /**
  42896. * Enable or disable collisions of the camera with the rest of the scene objects.
  42897. */
  42898. checkCollisions: boolean;
  42899. /**
  42900. * Enable or disable gravity on the camera.
  42901. */
  42902. applyGravity: boolean;
  42903. /**
  42904. * Define the current direction the camera is moving to.
  42905. */
  42906. cameraDirection: Vector3;
  42907. /**
  42908. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  42909. * This overrides and empties cameraRotation.
  42910. */
  42911. rotationQuaternion: Quaternion;
  42912. /**
  42913. * Track Roll to maintain the wanted Rolling when looking around.
  42914. */
  42915. _trackRoll: number;
  42916. /**
  42917. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  42918. */
  42919. rollCorrect: number;
  42920. /**
  42921. * Mimic a banked turn, Rolling the camera when Yawing.
  42922. * It's recommended to use rollCorrect = 10 for faster banking correction.
  42923. */
  42924. bankedTurn: boolean;
  42925. /**
  42926. * Limit in radians for how much Roll banking will add. (Default: 90°)
  42927. */
  42928. bankedTurnLimit: number;
  42929. /**
  42930. * Value of 0 disables the banked Roll.
  42931. * Value of 1 is equal to the Yaw angle in radians.
  42932. */
  42933. bankedTurnMultiplier: number;
  42934. /**
  42935. * The inputs manager loads all the input sources, such as keyboard and mouse.
  42936. */
  42937. inputs: FlyCameraInputsManager;
  42938. /**
  42939. * Gets the input sensibility for mouse input.
  42940. * Higher values reduce sensitivity.
  42941. */
  42942. get angularSensibility(): number;
  42943. /**
  42944. * Sets the input sensibility for a mouse input.
  42945. * Higher values reduce sensitivity.
  42946. */
  42947. set angularSensibility(value: number);
  42948. /**
  42949. * Get the keys for camera movement forward.
  42950. */
  42951. get keysForward(): number[];
  42952. /**
  42953. * Set the keys for camera movement forward.
  42954. */
  42955. set keysForward(value: number[]);
  42956. /**
  42957. * Get the keys for camera movement backward.
  42958. */
  42959. get keysBackward(): number[];
  42960. set keysBackward(value: number[]);
  42961. /**
  42962. * Get the keys for camera movement up.
  42963. */
  42964. get keysUp(): number[];
  42965. /**
  42966. * Set the keys for camera movement up.
  42967. */
  42968. set keysUp(value: number[]);
  42969. /**
  42970. * Get the keys for camera movement down.
  42971. */
  42972. get keysDown(): number[];
  42973. /**
  42974. * Set the keys for camera movement down.
  42975. */
  42976. set keysDown(value: number[]);
  42977. /**
  42978. * Get the keys for camera movement left.
  42979. */
  42980. get keysLeft(): number[];
  42981. /**
  42982. * Set the keys for camera movement left.
  42983. */
  42984. set keysLeft(value: number[]);
  42985. /**
  42986. * Set the keys for camera movement right.
  42987. */
  42988. get keysRight(): number[];
  42989. /**
  42990. * Set the keys for camera movement right.
  42991. */
  42992. set keysRight(value: number[]);
  42993. /**
  42994. * Event raised when the camera collides with a mesh in the scene.
  42995. */
  42996. onCollide: (collidedMesh: AbstractMesh) => void;
  42997. private _collider;
  42998. private _needMoveForGravity;
  42999. private _oldPosition;
  43000. private _diffPosition;
  43001. private _newPosition;
  43002. /** @hidden */
  43003. _localDirection: Vector3;
  43004. /** @hidden */
  43005. _transformedDirection: Vector3;
  43006. /**
  43007. * Instantiates a FlyCamera.
  43008. * This is a flying camera, designed for 3D movement and rotation in all directions,
  43009. * such as in a 3D Space Shooter or a Flight Simulator.
  43010. * @param name Define the name of the camera in the scene.
  43011. * @param position Define the starting position of the camera in the scene.
  43012. * @param scene Define the scene the camera belongs to.
  43013. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  43014. */
  43015. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  43016. /**
  43017. * Attach a control to the HTML DOM element.
  43018. * @param element Defines the element that listens to the input events.
  43019. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  43020. */
  43021. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43022. /**
  43023. * Detach a control from the HTML DOM element.
  43024. * The camera will stop reacting to that input.
  43025. * @param element Defines the element that listens to the input events.
  43026. */
  43027. detachControl(element: HTMLElement): void;
  43028. private _collisionMask;
  43029. /**
  43030. * Get the mask that the camera ignores in collision events.
  43031. */
  43032. get collisionMask(): number;
  43033. /**
  43034. * Set the mask that the camera ignores in collision events.
  43035. */
  43036. set collisionMask(mask: number);
  43037. /** @hidden */
  43038. _collideWithWorld(displacement: Vector3): void;
  43039. /** @hidden */
  43040. private _onCollisionPositionChange;
  43041. /** @hidden */
  43042. _checkInputs(): void;
  43043. /** @hidden */
  43044. _decideIfNeedsToMove(): boolean;
  43045. /** @hidden */
  43046. _updatePosition(): void;
  43047. /**
  43048. * Restore the Roll to its target value at the rate specified.
  43049. * @param rate - Higher means slower restoring.
  43050. * @hidden
  43051. */
  43052. restoreRoll(rate: number): void;
  43053. /**
  43054. * Destroy the camera and release the current resources held by it.
  43055. */
  43056. dispose(): void;
  43057. /**
  43058. * Get the current object class name.
  43059. * @returns the class name.
  43060. */
  43061. getClassName(): string;
  43062. }
  43063. }
  43064. declare module BABYLON {
  43065. /**
  43066. * Listen to keyboard events to control the camera.
  43067. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43068. */
  43069. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  43070. /**
  43071. * Defines the camera the input is attached to.
  43072. */
  43073. camera: FlyCamera;
  43074. /**
  43075. * The list of keyboard keys used to control the forward move of the camera.
  43076. */
  43077. keysForward: number[];
  43078. /**
  43079. * The list of keyboard keys used to control the backward move of the camera.
  43080. */
  43081. keysBackward: number[];
  43082. /**
  43083. * The list of keyboard keys used to control the forward move of the camera.
  43084. */
  43085. keysUp: number[];
  43086. /**
  43087. * The list of keyboard keys used to control the backward move of the camera.
  43088. */
  43089. keysDown: number[];
  43090. /**
  43091. * The list of keyboard keys used to control the right strafe move of the camera.
  43092. */
  43093. keysRight: number[];
  43094. /**
  43095. * The list of keyboard keys used to control the left strafe move of the camera.
  43096. */
  43097. keysLeft: number[];
  43098. private _keys;
  43099. private _onCanvasBlurObserver;
  43100. private _onKeyboardObserver;
  43101. private _engine;
  43102. private _scene;
  43103. /**
  43104. * Attach the input controls to a specific dom element to get the input from.
  43105. * @param element Defines the element the controls should be listened from
  43106. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43107. */
  43108. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43109. /**
  43110. * Detach the current controls from the specified dom element.
  43111. * @param element Defines the element to stop listening the inputs from
  43112. */
  43113. detachControl(element: Nullable<HTMLElement>): void;
  43114. /**
  43115. * Gets the class name of the current intput.
  43116. * @returns the class name
  43117. */
  43118. getClassName(): string;
  43119. /** @hidden */
  43120. _onLostFocus(e: FocusEvent): void;
  43121. /**
  43122. * Get the friendly name associated with the input class.
  43123. * @returns the input friendly name
  43124. */
  43125. getSimpleName(): string;
  43126. /**
  43127. * Update the current camera state depending on the inputs that have been used this frame.
  43128. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43129. */
  43130. checkInputs(): void;
  43131. }
  43132. }
  43133. declare module BABYLON {
  43134. /**
  43135. * Manage the mouse wheel inputs to control a follow camera.
  43136. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43137. */
  43138. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  43139. /**
  43140. * Defines the camera the input is attached to.
  43141. */
  43142. camera: FollowCamera;
  43143. /**
  43144. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  43145. */
  43146. axisControlRadius: boolean;
  43147. /**
  43148. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  43149. */
  43150. axisControlHeight: boolean;
  43151. /**
  43152. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  43153. */
  43154. axisControlRotation: boolean;
  43155. /**
  43156. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  43157. * relation to mouseWheel events.
  43158. */
  43159. wheelPrecision: number;
  43160. /**
  43161. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  43162. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  43163. */
  43164. wheelDeltaPercentage: number;
  43165. private _wheel;
  43166. private _observer;
  43167. /**
  43168. * Attach the input controls to a specific dom element to get the input from.
  43169. * @param element Defines the element the controls should be listened from
  43170. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43171. */
  43172. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43173. /**
  43174. * Detach the current controls from the specified dom element.
  43175. * @param element Defines the element to stop listening the inputs from
  43176. */
  43177. detachControl(element: Nullable<HTMLElement>): void;
  43178. /**
  43179. * Gets the class name of the current intput.
  43180. * @returns the class name
  43181. */
  43182. getClassName(): string;
  43183. /**
  43184. * Get the friendly name associated with the input class.
  43185. * @returns the input friendly name
  43186. */
  43187. getSimpleName(): string;
  43188. }
  43189. }
  43190. declare module BABYLON {
  43191. /**
  43192. * Manage the pointers inputs to control an follow camera.
  43193. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43194. */
  43195. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  43196. /**
  43197. * Defines the camera the input is attached to.
  43198. */
  43199. camera: FollowCamera;
  43200. /**
  43201. * Gets the class name of the current input.
  43202. * @returns the class name
  43203. */
  43204. getClassName(): string;
  43205. /**
  43206. * Defines the pointer angular sensibility along the X axis or how fast is
  43207. * the camera rotating.
  43208. * A negative number will reverse the axis direction.
  43209. */
  43210. angularSensibilityX: number;
  43211. /**
  43212. * Defines the pointer angular sensibility along the Y axis or how fast is
  43213. * the camera rotating.
  43214. * A negative number will reverse the axis direction.
  43215. */
  43216. angularSensibilityY: number;
  43217. /**
  43218. * Defines the pointer pinch precision or how fast is the camera zooming.
  43219. * A negative number will reverse the axis direction.
  43220. */
  43221. pinchPrecision: number;
  43222. /**
  43223. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  43224. * from 0.
  43225. * It defines the percentage of current camera.radius to use as delta when
  43226. * pinch zoom is used.
  43227. */
  43228. pinchDeltaPercentage: number;
  43229. /**
  43230. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  43231. */
  43232. axisXControlRadius: boolean;
  43233. /**
  43234. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  43235. */
  43236. axisXControlHeight: boolean;
  43237. /**
  43238. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  43239. */
  43240. axisXControlRotation: boolean;
  43241. /**
  43242. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  43243. */
  43244. axisYControlRadius: boolean;
  43245. /**
  43246. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  43247. */
  43248. axisYControlHeight: boolean;
  43249. /**
  43250. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  43251. */
  43252. axisYControlRotation: boolean;
  43253. /**
  43254. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  43255. */
  43256. axisPinchControlRadius: boolean;
  43257. /**
  43258. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  43259. */
  43260. axisPinchControlHeight: boolean;
  43261. /**
  43262. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  43263. */
  43264. axisPinchControlRotation: boolean;
  43265. /**
  43266. * Log error messages if basic misconfiguration has occurred.
  43267. */
  43268. warningEnable: boolean;
  43269. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  43270. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  43271. private _warningCounter;
  43272. private _warning;
  43273. }
  43274. }
  43275. declare module BABYLON {
  43276. /**
  43277. * Default Inputs manager for the FollowCamera.
  43278. * It groups all the default supported inputs for ease of use.
  43279. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43280. */
  43281. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  43282. /**
  43283. * Instantiates a new FollowCameraInputsManager.
  43284. * @param camera Defines the camera the inputs belong to
  43285. */
  43286. constructor(camera: FollowCamera);
  43287. /**
  43288. * Add keyboard input support to the input manager.
  43289. * @returns the current input manager
  43290. */
  43291. addKeyboard(): FollowCameraInputsManager;
  43292. /**
  43293. * Add mouse wheel input support to the input manager.
  43294. * @returns the current input manager
  43295. */
  43296. addMouseWheel(): FollowCameraInputsManager;
  43297. /**
  43298. * Add pointers input support to the input manager.
  43299. * @returns the current input manager
  43300. */
  43301. addPointers(): FollowCameraInputsManager;
  43302. /**
  43303. * Add orientation input support to the input manager.
  43304. * @returns the current input manager
  43305. */
  43306. addVRDeviceOrientation(): FollowCameraInputsManager;
  43307. }
  43308. }
  43309. declare module BABYLON {
  43310. /**
  43311. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  43312. * an arc rotate version arcFollowCamera are available.
  43313. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  43314. */
  43315. export class FollowCamera extends TargetCamera {
  43316. /**
  43317. * Distance the follow camera should follow an object at
  43318. */
  43319. radius: number;
  43320. /**
  43321. * Minimum allowed distance of the camera to the axis of rotation
  43322. * (The camera can not get closer).
  43323. * This can help limiting how the Camera is able to move in the scene.
  43324. */
  43325. lowerRadiusLimit: Nullable<number>;
  43326. /**
  43327. * Maximum allowed distance of the camera to the axis of rotation
  43328. * (The camera can not get further).
  43329. * This can help limiting how the Camera is able to move in the scene.
  43330. */
  43331. upperRadiusLimit: Nullable<number>;
  43332. /**
  43333. * Define a rotation offset between the camera and the object it follows
  43334. */
  43335. rotationOffset: number;
  43336. /**
  43337. * Minimum allowed angle to camera position relative to target object.
  43338. * This can help limiting how the Camera is able to move in the scene.
  43339. */
  43340. lowerRotationOffsetLimit: Nullable<number>;
  43341. /**
  43342. * Maximum allowed angle to camera position relative to target object.
  43343. * This can help limiting how the Camera is able to move in the scene.
  43344. */
  43345. upperRotationOffsetLimit: Nullable<number>;
  43346. /**
  43347. * Define a height offset between the camera and the object it follows.
  43348. * It can help following an object from the top (like a car chaing a plane)
  43349. */
  43350. heightOffset: number;
  43351. /**
  43352. * Minimum allowed height of camera position relative to target object.
  43353. * This can help limiting how the Camera is able to move in the scene.
  43354. */
  43355. lowerHeightOffsetLimit: Nullable<number>;
  43356. /**
  43357. * Maximum allowed height of camera position relative to target object.
  43358. * This can help limiting how the Camera is able to move in the scene.
  43359. */
  43360. upperHeightOffsetLimit: Nullable<number>;
  43361. /**
  43362. * Define how fast the camera can accelerate to follow it s target.
  43363. */
  43364. cameraAcceleration: number;
  43365. /**
  43366. * Define the speed limit of the camera following an object.
  43367. */
  43368. maxCameraSpeed: number;
  43369. /**
  43370. * Define the target of the camera.
  43371. */
  43372. lockedTarget: Nullable<AbstractMesh>;
  43373. /**
  43374. * Defines the input associated with the camera.
  43375. */
  43376. inputs: FollowCameraInputsManager;
  43377. /**
  43378. * Instantiates the follow camera.
  43379. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  43380. * @param name Define the name of the camera in the scene
  43381. * @param position Define the position of the camera
  43382. * @param scene Define the scene the camera belong to
  43383. * @param lockedTarget Define the target of the camera
  43384. */
  43385. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  43386. private _follow;
  43387. /**
  43388. * Attached controls to the current camera.
  43389. * @param element Defines the element the controls should be listened from
  43390. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43391. */
  43392. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43393. /**
  43394. * Detach the current controls from the camera.
  43395. * The camera will stop reacting to inputs.
  43396. * @param element Defines the element to stop listening the inputs from
  43397. */
  43398. detachControl(element: HTMLElement): void;
  43399. /** @hidden */
  43400. _checkInputs(): void;
  43401. private _checkLimits;
  43402. /**
  43403. * Gets the camera class name.
  43404. * @returns the class name
  43405. */
  43406. getClassName(): string;
  43407. }
  43408. /**
  43409. * Arc Rotate version of the follow camera.
  43410. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  43411. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  43412. */
  43413. export class ArcFollowCamera extends TargetCamera {
  43414. /** The longitudinal angle of the camera */
  43415. alpha: number;
  43416. /** The latitudinal angle of the camera */
  43417. beta: number;
  43418. /** The radius of the camera from its target */
  43419. radius: number;
  43420. /** Define the camera target (the messh it should follow) */
  43421. target: Nullable<AbstractMesh>;
  43422. private _cartesianCoordinates;
  43423. /**
  43424. * Instantiates a new ArcFollowCamera
  43425. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  43426. * @param name Define the name of the camera
  43427. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  43428. * @param beta Define the rotation angle of the camera around the elevation axis
  43429. * @param radius Define the radius of the camera from its target point
  43430. * @param target Define the target of the camera
  43431. * @param scene Define the scene the camera belongs to
  43432. */
  43433. constructor(name: string,
  43434. /** The longitudinal angle of the camera */
  43435. alpha: number,
  43436. /** The latitudinal angle of the camera */
  43437. beta: number,
  43438. /** The radius of the camera from its target */
  43439. radius: number,
  43440. /** Define the camera target (the messh it should follow) */
  43441. target: Nullable<AbstractMesh>, scene: Scene);
  43442. private _follow;
  43443. /** @hidden */
  43444. _checkInputs(): void;
  43445. /**
  43446. * Returns the class name of the object.
  43447. * It is mostly used internally for serialization purposes.
  43448. */
  43449. getClassName(): string;
  43450. }
  43451. }
  43452. declare module BABYLON {
  43453. /**
  43454. * Manage the keyboard inputs to control the movement of a follow camera.
  43455. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43456. */
  43457. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  43458. /**
  43459. * Defines the camera the input is attached to.
  43460. */
  43461. camera: FollowCamera;
  43462. /**
  43463. * Defines the list of key codes associated with the up action (increase heightOffset)
  43464. */
  43465. keysHeightOffsetIncr: number[];
  43466. /**
  43467. * Defines the list of key codes associated with the down action (decrease heightOffset)
  43468. */
  43469. keysHeightOffsetDecr: number[];
  43470. /**
  43471. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  43472. */
  43473. keysHeightOffsetModifierAlt: boolean;
  43474. /**
  43475. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  43476. */
  43477. keysHeightOffsetModifierCtrl: boolean;
  43478. /**
  43479. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  43480. */
  43481. keysHeightOffsetModifierShift: boolean;
  43482. /**
  43483. * Defines the list of key codes associated with the left action (increase rotationOffset)
  43484. */
  43485. keysRotationOffsetIncr: number[];
  43486. /**
  43487. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  43488. */
  43489. keysRotationOffsetDecr: number[];
  43490. /**
  43491. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  43492. */
  43493. keysRotationOffsetModifierAlt: boolean;
  43494. /**
  43495. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  43496. */
  43497. keysRotationOffsetModifierCtrl: boolean;
  43498. /**
  43499. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  43500. */
  43501. keysRotationOffsetModifierShift: boolean;
  43502. /**
  43503. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  43504. */
  43505. keysRadiusIncr: number[];
  43506. /**
  43507. * Defines the list of key codes associated with the zoom-out action (increase radius)
  43508. */
  43509. keysRadiusDecr: number[];
  43510. /**
  43511. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  43512. */
  43513. keysRadiusModifierAlt: boolean;
  43514. /**
  43515. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  43516. */
  43517. keysRadiusModifierCtrl: boolean;
  43518. /**
  43519. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  43520. */
  43521. keysRadiusModifierShift: boolean;
  43522. /**
  43523. * Defines the rate of change of heightOffset.
  43524. */
  43525. heightSensibility: number;
  43526. /**
  43527. * Defines the rate of change of rotationOffset.
  43528. */
  43529. rotationSensibility: number;
  43530. /**
  43531. * Defines the rate of change of radius.
  43532. */
  43533. radiusSensibility: number;
  43534. private _keys;
  43535. private _ctrlPressed;
  43536. private _altPressed;
  43537. private _shiftPressed;
  43538. private _onCanvasBlurObserver;
  43539. private _onKeyboardObserver;
  43540. private _engine;
  43541. private _scene;
  43542. /**
  43543. * Attach the input controls to a specific dom element to get the input from.
  43544. * @param element Defines the element the controls should be listened from
  43545. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43546. */
  43547. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43548. /**
  43549. * Detach the current controls from the specified dom element.
  43550. * @param element Defines the element to stop listening the inputs from
  43551. */
  43552. detachControl(element: Nullable<HTMLElement>): void;
  43553. /**
  43554. * Update the current camera state depending on the inputs that have been used this frame.
  43555. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43556. */
  43557. checkInputs(): void;
  43558. /**
  43559. * Gets the class name of the current input.
  43560. * @returns the class name
  43561. */
  43562. getClassName(): string;
  43563. /**
  43564. * Get the friendly name associated with the input class.
  43565. * @returns the input friendly name
  43566. */
  43567. getSimpleName(): string;
  43568. /**
  43569. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  43570. * allow modification of the heightOffset value.
  43571. */
  43572. private _modifierHeightOffset;
  43573. /**
  43574. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  43575. * allow modification of the rotationOffset value.
  43576. */
  43577. private _modifierRotationOffset;
  43578. /**
  43579. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  43580. * allow modification of the radius value.
  43581. */
  43582. private _modifierRadius;
  43583. }
  43584. }
  43585. declare module BABYLON {
  43586. interface FreeCameraInputsManager {
  43587. /**
  43588. * @hidden
  43589. */
  43590. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  43591. /**
  43592. * Add orientation input support to the input manager.
  43593. * @returns the current input manager
  43594. */
  43595. addDeviceOrientation(): FreeCameraInputsManager;
  43596. }
  43597. /**
  43598. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  43599. * Screen rotation is taken into account.
  43600. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43601. */
  43602. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  43603. private _camera;
  43604. private _screenOrientationAngle;
  43605. private _constantTranform;
  43606. private _screenQuaternion;
  43607. private _alpha;
  43608. private _beta;
  43609. private _gamma;
  43610. /**
  43611. * Can be used to detect if a device orientation sensor is available on a device
  43612. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  43613. * @returns a promise that will resolve on orientation change
  43614. */
  43615. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  43616. /**
  43617. * @hidden
  43618. */
  43619. _onDeviceOrientationChangedObservable: Observable<void>;
  43620. /**
  43621. * Instantiates a new input
  43622. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43623. */
  43624. constructor();
  43625. /**
  43626. * Define the camera controlled by the input.
  43627. */
  43628. get camera(): FreeCamera;
  43629. set camera(camera: FreeCamera);
  43630. /**
  43631. * Attach the input controls to a specific dom element to get the input from.
  43632. * @param element Defines the element the controls should be listened from
  43633. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43634. */
  43635. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43636. private _orientationChanged;
  43637. private _deviceOrientation;
  43638. /**
  43639. * Detach the current controls from the specified dom element.
  43640. * @param element Defines the element to stop listening the inputs from
  43641. */
  43642. detachControl(element: Nullable<HTMLElement>): void;
  43643. /**
  43644. * Update the current camera state depending on the inputs that have been used this frame.
  43645. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43646. */
  43647. checkInputs(): void;
  43648. /**
  43649. * Gets the class name of the current intput.
  43650. * @returns the class name
  43651. */
  43652. getClassName(): string;
  43653. /**
  43654. * Get the friendly name associated with the input class.
  43655. * @returns the input friendly name
  43656. */
  43657. getSimpleName(): string;
  43658. }
  43659. }
  43660. declare module BABYLON {
  43661. /**
  43662. * Manage the gamepad inputs to control a free camera.
  43663. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43664. */
  43665. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  43666. /**
  43667. * Define the camera the input is attached to.
  43668. */
  43669. camera: FreeCamera;
  43670. /**
  43671. * Define the Gamepad controlling the input
  43672. */
  43673. gamepad: Nullable<Gamepad>;
  43674. /**
  43675. * Defines the gamepad rotation sensiblity.
  43676. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  43677. */
  43678. gamepadAngularSensibility: number;
  43679. /**
  43680. * Defines the gamepad move sensiblity.
  43681. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  43682. */
  43683. gamepadMoveSensibility: number;
  43684. private _yAxisScale;
  43685. /**
  43686. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  43687. */
  43688. get invertYAxis(): boolean;
  43689. set invertYAxis(value: boolean);
  43690. private _onGamepadConnectedObserver;
  43691. private _onGamepadDisconnectedObserver;
  43692. private _cameraTransform;
  43693. private _deltaTransform;
  43694. private _vector3;
  43695. private _vector2;
  43696. /**
  43697. * Attach the input controls to a specific dom element to get the input from.
  43698. * @param element Defines the element the controls should be listened from
  43699. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43700. */
  43701. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43702. /**
  43703. * Detach the current controls from the specified dom element.
  43704. * @param element Defines the element to stop listening the inputs from
  43705. */
  43706. detachControl(element: Nullable<HTMLElement>): void;
  43707. /**
  43708. * Update the current camera state depending on the inputs that have been used this frame.
  43709. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43710. */
  43711. checkInputs(): void;
  43712. /**
  43713. * Gets the class name of the current intput.
  43714. * @returns the class name
  43715. */
  43716. getClassName(): string;
  43717. /**
  43718. * Get the friendly name associated with the input class.
  43719. * @returns the input friendly name
  43720. */
  43721. getSimpleName(): string;
  43722. }
  43723. }
  43724. declare module BABYLON {
  43725. /**
  43726. * Defines the potential axis of a Joystick
  43727. */
  43728. export enum JoystickAxis {
  43729. /** X axis */
  43730. X = 0,
  43731. /** Y axis */
  43732. Y = 1,
  43733. /** Z axis */
  43734. Z = 2
  43735. }
  43736. /**
  43737. * Class used to define virtual joystick (used in touch mode)
  43738. */
  43739. export class VirtualJoystick {
  43740. /**
  43741. * Gets or sets a boolean indicating that left and right values must be inverted
  43742. */
  43743. reverseLeftRight: boolean;
  43744. /**
  43745. * Gets or sets a boolean indicating that up and down values must be inverted
  43746. */
  43747. reverseUpDown: boolean;
  43748. /**
  43749. * Gets the offset value for the position (ie. the change of the position value)
  43750. */
  43751. deltaPosition: Vector3;
  43752. /**
  43753. * Gets a boolean indicating if the virtual joystick was pressed
  43754. */
  43755. pressed: boolean;
  43756. /**
  43757. * Canvas the virtual joystick will render onto, default z-index of this is 5
  43758. */
  43759. static Canvas: Nullable<HTMLCanvasElement>;
  43760. private static _globalJoystickIndex;
  43761. private static vjCanvasContext;
  43762. private static vjCanvasWidth;
  43763. private static vjCanvasHeight;
  43764. private static halfWidth;
  43765. private _action;
  43766. private _axisTargetedByLeftAndRight;
  43767. private _axisTargetedByUpAndDown;
  43768. private _joystickSensibility;
  43769. private _inversedSensibility;
  43770. private _joystickPointerID;
  43771. private _joystickColor;
  43772. private _joystickPointerPos;
  43773. private _joystickPreviousPointerPos;
  43774. private _joystickPointerStartPos;
  43775. private _deltaJoystickVector;
  43776. private _leftJoystick;
  43777. private _touches;
  43778. private _onPointerDownHandlerRef;
  43779. private _onPointerMoveHandlerRef;
  43780. private _onPointerUpHandlerRef;
  43781. private _onResize;
  43782. /**
  43783. * Creates a new virtual joystick
  43784. * @param leftJoystick defines that the joystick is for left hand (false by default)
  43785. */
  43786. constructor(leftJoystick?: boolean);
  43787. /**
  43788. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  43789. * @param newJoystickSensibility defines the new sensibility
  43790. */
  43791. setJoystickSensibility(newJoystickSensibility: number): void;
  43792. private _onPointerDown;
  43793. private _onPointerMove;
  43794. private _onPointerUp;
  43795. /**
  43796. * Change the color of the virtual joystick
  43797. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  43798. */
  43799. setJoystickColor(newColor: string): void;
  43800. /**
  43801. * Defines a callback to call when the joystick is touched
  43802. * @param action defines the callback
  43803. */
  43804. setActionOnTouch(action: () => any): void;
  43805. /**
  43806. * Defines which axis you'd like to control for left & right
  43807. * @param axis defines the axis to use
  43808. */
  43809. setAxisForLeftRight(axis: JoystickAxis): void;
  43810. /**
  43811. * Defines which axis you'd like to control for up & down
  43812. * @param axis defines the axis to use
  43813. */
  43814. setAxisForUpDown(axis: JoystickAxis): void;
  43815. private _drawVirtualJoystick;
  43816. /**
  43817. * Release internal HTML canvas
  43818. */
  43819. releaseCanvas(): void;
  43820. }
  43821. }
  43822. declare module BABYLON {
  43823. interface FreeCameraInputsManager {
  43824. /**
  43825. * Add virtual joystick input support to the input manager.
  43826. * @returns the current input manager
  43827. */
  43828. addVirtualJoystick(): FreeCameraInputsManager;
  43829. }
  43830. /**
  43831. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  43832. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43833. */
  43834. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  43835. /**
  43836. * Defines the camera the input is attached to.
  43837. */
  43838. camera: FreeCamera;
  43839. private _leftjoystick;
  43840. private _rightjoystick;
  43841. /**
  43842. * Gets the left stick of the virtual joystick.
  43843. * @returns The virtual Joystick
  43844. */
  43845. getLeftJoystick(): VirtualJoystick;
  43846. /**
  43847. * Gets the right stick of the virtual joystick.
  43848. * @returns The virtual Joystick
  43849. */
  43850. getRightJoystick(): VirtualJoystick;
  43851. /**
  43852. * Update the current camera state depending on the inputs that have been used this frame.
  43853. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43854. */
  43855. checkInputs(): void;
  43856. /**
  43857. * Attach the input controls to a specific dom element to get the input from.
  43858. * @param element Defines the element the controls should be listened from
  43859. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43860. */
  43861. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43862. /**
  43863. * Detach the current controls from the specified dom element.
  43864. * @param element Defines the element to stop listening the inputs from
  43865. */
  43866. detachControl(element: Nullable<HTMLElement>): void;
  43867. /**
  43868. * Gets the class name of the current intput.
  43869. * @returns the class name
  43870. */
  43871. getClassName(): string;
  43872. /**
  43873. * Get the friendly name associated with the input class.
  43874. * @returns the input friendly name
  43875. */
  43876. getSimpleName(): string;
  43877. }
  43878. }
  43879. declare module BABYLON {
  43880. /**
  43881. * This represents a FPS type of camera controlled by touch.
  43882. * This is like a universal camera minus the Gamepad controls.
  43883. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43884. */
  43885. export class TouchCamera extends FreeCamera {
  43886. /**
  43887. * Defines the touch sensibility for rotation.
  43888. * The higher the faster.
  43889. */
  43890. get touchAngularSensibility(): number;
  43891. set touchAngularSensibility(value: number);
  43892. /**
  43893. * Defines the touch sensibility for move.
  43894. * The higher the faster.
  43895. */
  43896. get touchMoveSensibility(): number;
  43897. set touchMoveSensibility(value: number);
  43898. /**
  43899. * Instantiates a new touch camera.
  43900. * This represents a FPS type of camera controlled by touch.
  43901. * This is like a universal camera minus the Gamepad controls.
  43902. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43903. * @param name Define the name of the camera in the scene
  43904. * @param position Define the start position of the camera in the scene
  43905. * @param scene Define the scene the camera belongs to
  43906. */
  43907. constructor(name: string, position: Vector3, scene: Scene);
  43908. /**
  43909. * Gets the current object class name.
  43910. * @return the class name
  43911. */
  43912. getClassName(): string;
  43913. /** @hidden */
  43914. _setupInputs(): void;
  43915. }
  43916. }
  43917. declare module BABYLON {
  43918. /**
  43919. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  43920. * being tilted forward or back and left or right.
  43921. */
  43922. export class DeviceOrientationCamera extends FreeCamera {
  43923. private _initialQuaternion;
  43924. private _quaternionCache;
  43925. private _tmpDragQuaternion;
  43926. private _disablePointerInputWhenUsingDeviceOrientation;
  43927. /**
  43928. * Creates a new device orientation camera
  43929. * @param name The name of the camera
  43930. * @param position The start position camera
  43931. * @param scene The scene the camera belongs to
  43932. */
  43933. constructor(name: string, position: Vector3, scene: Scene);
  43934. /**
  43935. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  43936. */
  43937. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  43938. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  43939. private _dragFactor;
  43940. /**
  43941. * Enabled turning on the y axis when the orientation sensor is active
  43942. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  43943. */
  43944. enableHorizontalDragging(dragFactor?: number): void;
  43945. /**
  43946. * Gets the current instance class name ("DeviceOrientationCamera").
  43947. * This helps avoiding instanceof at run time.
  43948. * @returns the class name
  43949. */
  43950. getClassName(): string;
  43951. /**
  43952. * @hidden
  43953. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  43954. */
  43955. _checkInputs(): void;
  43956. /**
  43957. * Reset the camera to its default orientation on the specified axis only.
  43958. * @param axis The axis to reset
  43959. */
  43960. resetToCurrentRotation(axis?: Axis): void;
  43961. }
  43962. }
  43963. declare module BABYLON {
  43964. /**
  43965. * Defines supported buttons for XBox360 compatible gamepads
  43966. */
  43967. export enum Xbox360Button {
  43968. /** A */
  43969. A = 0,
  43970. /** B */
  43971. B = 1,
  43972. /** X */
  43973. X = 2,
  43974. /** Y */
  43975. Y = 3,
  43976. /** Left button */
  43977. LB = 4,
  43978. /** Right button */
  43979. RB = 5,
  43980. /** Back */
  43981. Back = 8,
  43982. /** Start */
  43983. Start = 9,
  43984. /** Left stick */
  43985. LeftStick = 10,
  43986. /** Right stick */
  43987. RightStick = 11
  43988. }
  43989. /** Defines values for XBox360 DPad */
  43990. export enum Xbox360Dpad {
  43991. /** Up */
  43992. Up = 12,
  43993. /** Down */
  43994. Down = 13,
  43995. /** Left */
  43996. Left = 14,
  43997. /** Right */
  43998. Right = 15
  43999. }
  44000. /**
  44001. * Defines a XBox360 gamepad
  44002. */
  44003. export class Xbox360Pad extends Gamepad {
  44004. private _leftTrigger;
  44005. private _rightTrigger;
  44006. private _onlefttriggerchanged;
  44007. private _onrighttriggerchanged;
  44008. private _onbuttondown;
  44009. private _onbuttonup;
  44010. private _ondpaddown;
  44011. private _ondpadup;
  44012. /** Observable raised when a button is pressed */
  44013. onButtonDownObservable: Observable<Xbox360Button>;
  44014. /** Observable raised when a button is released */
  44015. onButtonUpObservable: Observable<Xbox360Button>;
  44016. /** Observable raised when a pad is pressed */
  44017. onPadDownObservable: Observable<Xbox360Dpad>;
  44018. /** Observable raised when a pad is released */
  44019. onPadUpObservable: Observable<Xbox360Dpad>;
  44020. private _buttonA;
  44021. private _buttonB;
  44022. private _buttonX;
  44023. private _buttonY;
  44024. private _buttonBack;
  44025. private _buttonStart;
  44026. private _buttonLB;
  44027. private _buttonRB;
  44028. private _buttonLeftStick;
  44029. private _buttonRightStick;
  44030. private _dPadUp;
  44031. private _dPadDown;
  44032. private _dPadLeft;
  44033. private _dPadRight;
  44034. private _isXboxOnePad;
  44035. /**
  44036. * Creates a new XBox360 gamepad object
  44037. * @param id defines the id of this gamepad
  44038. * @param index defines its index
  44039. * @param gamepad defines the internal HTML gamepad object
  44040. * @param xboxOne defines if it is a XBox One gamepad
  44041. */
  44042. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  44043. /**
  44044. * Defines the callback to call when left trigger is pressed
  44045. * @param callback defines the callback to use
  44046. */
  44047. onlefttriggerchanged(callback: (value: number) => void): void;
  44048. /**
  44049. * Defines the callback to call when right trigger is pressed
  44050. * @param callback defines the callback to use
  44051. */
  44052. onrighttriggerchanged(callback: (value: number) => void): void;
  44053. /**
  44054. * Gets the left trigger value
  44055. */
  44056. get leftTrigger(): number;
  44057. /**
  44058. * Sets the left trigger value
  44059. */
  44060. set leftTrigger(newValue: number);
  44061. /**
  44062. * Gets the right trigger value
  44063. */
  44064. get rightTrigger(): number;
  44065. /**
  44066. * Sets the right trigger value
  44067. */
  44068. set rightTrigger(newValue: number);
  44069. /**
  44070. * Defines the callback to call when a button is pressed
  44071. * @param callback defines the callback to use
  44072. */
  44073. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  44074. /**
  44075. * Defines the callback to call when a button is released
  44076. * @param callback defines the callback to use
  44077. */
  44078. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  44079. /**
  44080. * Defines the callback to call when a pad is pressed
  44081. * @param callback defines the callback to use
  44082. */
  44083. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  44084. /**
  44085. * Defines the callback to call when a pad is released
  44086. * @param callback defines the callback to use
  44087. */
  44088. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  44089. private _setButtonValue;
  44090. private _setDPadValue;
  44091. /**
  44092. * Gets the value of the `A` button
  44093. */
  44094. get buttonA(): number;
  44095. /**
  44096. * Sets the value of the `A` button
  44097. */
  44098. set buttonA(value: number);
  44099. /**
  44100. * Gets the value of the `B` button
  44101. */
  44102. get buttonB(): number;
  44103. /**
  44104. * Sets the value of the `B` button
  44105. */
  44106. set buttonB(value: number);
  44107. /**
  44108. * Gets the value of the `X` button
  44109. */
  44110. get buttonX(): number;
  44111. /**
  44112. * Sets the value of the `X` button
  44113. */
  44114. set buttonX(value: number);
  44115. /**
  44116. * Gets the value of the `Y` button
  44117. */
  44118. get buttonY(): number;
  44119. /**
  44120. * Sets the value of the `Y` button
  44121. */
  44122. set buttonY(value: number);
  44123. /**
  44124. * Gets the value of the `Start` button
  44125. */
  44126. get buttonStart(): number;
  44127. /**
  44128. * Sets the value of the `Start` button
  44129. */
  44130. set buttonStart(value: number);
  44131. /**
  44132. * Gets the value of the `Back` button
  44133. */
  44134. get buttonBack(): number;
  44135. /**
  44136. * Sets the value of the `Back` button
  44137. */
  44138. set buttonBack(value: number);
  44139. /**
  44140. * Gets the value of the `Left` button
  44141. */
  44142. get buttonLB(): number;
  44143. /**
  44144. * Sets the value of the `Left` button
  44145. */
  44146. set buttonLB(value: number);
  44147. /**
  44148. * Gets the value of the `Right` button
  44149. */
  44150. get buttonRB(): number;
  44151. /**
  44152. * Sets the value of the `Right` button
  44153. */
  44154. set buttonRB(value: number);
  44155. /**
  44156. * Gets the value of the Left joystick
  44157. */
  44158. get buttonLeftStick(): number;
  44159. /**
  44160. * Sets the value of the Left joystick
  44161. */
  44162. set buttonLeftStick(value: number);
  44163. /**
  44164. * Gets the value of the Right joystick
  44165. */
  44166. get buttonRightStick(): number;
  44167. /**
  44168. * Sets the value of the Right joystick
  44169. */
  44170. set buttonRightStick(value: number);
  44171. /**
  44172. * Gets the value of D-pad up
  44173. */
  44174. get dPadUp(): number;
  44175. /**
  44176. * Sets the value of D-pad up
  44177. */
  44178. set dPadUp(value: number);
  44179. /**
  44180. * Gets the value of D-pad down
  44181. */
  44182. get dPadDown(): number;
  44183. /**
  44184. * Sets the value of D-pad down
  44185. */
  44186. set dPadDown(value: number);
  44187. /**
  44188. * Gets the value of D-pad left
  44189. */
  44190. get dPadLeft(): number;
  44191. /**
  44192. * Sets the value of D-pad left
  44193. */
  44194. set dPadLeft(value: number);
  44195. /**
  44196. * Gets the value of D-pad right
  44197. */
  44198. get dPadRight(): number;
  44199. /**
  44200. * Sets the value of D-pad right
  44201. */
  44202. set dPadRight(value: number);
  44203. /**
  44204. * Force the gamepad to synchronize with device values
  44205. */
  44206. update(): void;
  44207. /**
  44208. * Disposes the gamepad
  44209. */
  44210. dispose(): void;
  44211. }
  44212. }
  44213. declare module BABYLON {
  44214. /**
  44215. * Defines supported buttons for DualShock compatible gamepads
  44216. */
  44217. export enum DualShockButton {
  44218. /** Cross */
  44219. Cross = 0,
  44220. /** Circle */
  44221. Circle = 1,
  44222. /** Square */
  44223. Square = 2,
  44224. /** Triangle */
  44225. Triangle = 3,
  44226. /** L1 */
  44227. L1 = 4,
  44228. /** R1 */
  44229. R1 = 5,
  44230. /** Share */
  44231. Share = 8,
  44232. /** Options */
  44233. Options = 9,
  44234. /** Left stick */
  44235. LeftStick = 10,
  44236. /** Right stick */
  44237. RightStick = 11
  44238. }
  44239. /** Defines values for DualShock DPad */
  44240. export enum DualShockDpad {
  44241. /** Up */
  44242. Up = 12,
  44243. /** Down */
  44244. Down = 13,
  44245. /** Left */
  44246. Left = 14,
  44247. /** Right */
  44248. Right = 15
  44249. }
  44250. /**
  44251. * Defines a DualShock gamepad
  44252. */
  44253. export class DualShockPad extends Gamepad {
  44254. private _leftTrigger;
  44255. private _rightTrigger;
  44256. private _onlefttriggerchanged;
  44257. private _onrighttriggerchanged;
  44258. private _onbuttondown;
  44259. private _onbuttonup;
  44260. private _ondpaddown;
  44261. private _ondpadup;
  44262. /** Observable raised when a button is pressed */
  44263. onButtonDownObservable: Observable<DualShockButton>;
  44264. /** Observable raised when a button is released */
  44265. onButtonUpObservable: Observable<DualShockButton>;
  44266. /** Observable raised when a pad is pressed */
  44267. onPadDownObservable: Observable<DualShockDpad>;
  44268. /** Observable raised when a pad is released */
  44269. onPadUpObservable: Observable<DualShockDpad>;
  44270. private _buttonCross;
  44271. private _buttonCircle;
  44272. private _buttonSquare;
  44273. private _buttonTriangle;
  44274. private _buttonShare;
  44275. private _buttonOptions;
  44276. private _buttonL1;
  44277. private _buttonR1;
  44278. private _buttonLeftStick;
  44279. private _buttonRightStick;
  44280. private _dPadUp;
  44281. private _dPadDown;
  44282. private _dPadLeft;
  44283. private _dPadRight;
  44284. /**
  44285. * Creates a new DualShock gamepad object
  44286. * @param id defines the id of this gamepad
  44287. * @param index defines its index
  44288. * @param gamepad defines the internal HTML gamepad object
  44289. */
  44290. constructor(id: string, index: number, gamepad: any);
  44291. /**
  44292. * Defines the callback to call when left trigger is pressed
  44293. * @param callback defines the callback to use
  44294. */
  44295. onlefttriggerchanged(callback: (value: number) => void): void;
  44296. /**
  44297. * Defines the callback to call when right trigger is pressed
  44298. * @param callback defines the callback to use
  44299. */
  44300. onrighttriggerchanged(callback: (value: number) => void): void;
  44301. /**
  44302. * Gets the left trigger value
  44303. */
  44304. get leftTrigger(): number;
  44305. /**
  44306. * Sets the left trigger value
  44307. */
  44308. set leftTrigger(newValue: number);
  44309. /**
  44310. * Gets the right trigger value
  44311. */
  44312. get rightTrigger(): number;
  44313. /**
  44314. * Sets the right trigger value
  44315. */
  44316. set rightTrigger(newValue: number);
  44317. /**
  44318. * Defines the callback to call when a button is pressed
  44319. * @param callback defines the callback to use
  44320. */
  44321. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  44322. /**
  44323. * Defines the callback to call when a button is released
  44324. * @param callback defines the callback to use
  44325. */
  44326. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  44327. /**
  44328. * Defines the callback to call when a pad is pressed
  44329. * @param callback defines the callback to use
  44330. */
  44331. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  44332. /**
  44333. * Defines the callback to call when a pad is released
  44334. * @param callback defines the callback to use
  44335. */
  44336. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  44337. private _setButtonValue;
  44338. private _setDPadValue;
  44339. /**
  44340. * Gets the value of the `Cross` button
  44341. */
  44342. get buttonCross(): number;
  44343. /**
  44344. * Sets the value of the `Cross` button
  44345. */
  44346. set buttonCross(value: number);
  44347. /**
  44348. * Gets the value of the `Circle` button
  44349. */
  44350. get buttonCircle(): number;
  44351. /**
  44352. * Sets the value of the `Circle` button
  44353. */
  44354. set buttonCircle(value: number);
  44355. /**
  44356. * Gets the value of the `Square` button
  44357. */
  44358. get buttonSquare(): number;
  44359. /**
  44360. * Sets the value of the `Square` button
  44361. */
  44362. set buttonSquare(value: number);
  44363. /**
  44364. * Gets the value of the `Triangle` button
  44365. */
  44366. get buttonTriangle(): number;
  44367. /**
  44368. * Sets the value of the `Triangle` button
  44369. */
  44370. set buttonTriangle(value: number);
  44371. /**
  44372. * Gets the value of the `Options` button
  44373. */
  44374. get buttonOptions(): number;
  44375. /**
  44376. * Sets the value of the `Options` button
  44377. */
  44378. set buttonOptions(value: number);
  44379. /**
  44380. * Gets the value of the `Share` button
  44381. */
  44382. get buttonShare(): number;
  44383. /**
  44384. * Sets the value of the `Share` button
  44385. */
  44386. set buttonShare(value: number);
  44387. /**
  44388. * Gets the value of the `L1` button
  44389. */
  44390. get buttonL1(): number;
  44391. /**
  44392. * Sets the value of the `L1` button
  44393. */
  44394. set buttonL1(value: number);
  44395. /**
  44396. * Gets the value of the `R1` button
  44397. */
  44398. get buttonR1(): number;
  44399. /**
  44400. * Sets the value of the `R1` button
  44401. */
  44402. set buttonR1(value: number);
  44403. /**
  44404. * Gets the value of the Left joystick
  44405. */
  44406. get buttonLeftStick(): number;
  44407. /**
  44408. * Sets the value of the Left joystick
  44409. */
  44410. set buttonLeftStick(value: number);
  44411. /**
  44412. * Gets the value of the Right joystick
  44413. */
  44414. get buttonRightStick(): number;
  44415. /**
  44416. * Sets the value of the Right joystick
  44417. */
  44418. set buttonRightStick(value: number);
  44419. /**
  44420. * Gets the value of D-pad up
  44421. */
  44422. get dPadUp(): number;
  44423. /**
  44424. * Sets the value of D-pad up
  44425. */
  44426. set dPadUp(value: number);
  44427. /**
  44428. * Gets the value of D-pad down
  44429. */
  44430. get dPadDown(): number;
  44431. /**
  44432. * Sets the value of D-pad down
  44433. */
  44434. set dPadDown(value: number);
  44435. /**
  44436. * Gets the value of D-pad left
  44437. */
  44438. get dPadLeft(): number;
  44439. /**
  44440. * Sets the value of D-pad left
  44441. */
  44442. set dPadLeft(value: number);
  44443. /**
  44444. * Gets the value of D-pad right
  44445. */
  44446. get dPadRight(): number;
  44447. /**
  44448. * Sets the value of D-pad right
  44449. */
  44450. set dPadRight(value: number);
  44451. /**
  44452. * Force the gamepad to synchronize with device values
  44453. */
  44454. update(): void;
  44455. /**
  44456. * Disposes the gamepad
  44457. */
  44458. dispose(): void;
  44459. }
  44460. }
  44461. declare module BABYLON {
  44462. /**
  44463. * Manager for handling gamepads
  44464. */
  44465. export class GamepadManager {
  44466. private _scene?;
  44467. private _babylonGamepads;
  44468. private _oneGamepadConnected;
  44469. /** @hidden */
  44470. _isMonitoring: boolean;
  44471. private _gamepadEventSupported;
  44472. private _gamepadSupport?;
  44473. /**
  44474. * observable to be triggered when the gamepad controller has been connected
  44475. */
  44476. onGamepadConnectedObservable: Observable<Gamepad>;
  44477. /**
  44478. * observable to be triggered when the gamepad controller has been disconnected
  44479. */
  44480. onGamepadDisconnectedObservable: Observable<Gamepad>;
  44481. private _onGamepadConnectedEvent;
  44482. private _onGamepadDisconnectedEvent;
  44483. /**
  44484. * Initializes the gamepad manager
  44485. * @param _scene BabylonJS scene
  44486. */
  44487. constructor(_scene?: Scene | undefined);
  44488. /**
  44489. * The gamepads in the game pad manager
  44490. */
  44491. get gamepads(): Gamepad[];
  44492. /**
  44493. * Get the gamepad controllers based on type
  44494. * @param type The type of gamepad controller
  44495. * @returns Nullable gamepad
  44496. */
  44497. getGamepadByType(type?: number): Nullable<Gamepad>;
  44498. /**
  44499. * Disposes the gamepad manager
  44500. */
  44501. dispose(): void;
  44502. private _addNewGamepad;
  44503. private _startMonitoringGamepads;
  44504. private _stopMonitoringGamepads;
  44505. /** @hidden */
  44506. _checkGamepadsStatus(): void;
  44507. private _updateGamepadObjects;
  44508. }
  44509. }
  44510. declare module BABYLON {
  44511. interface Scene {
  44512. /** @hidden */
  44513. _gamepadManager: Nullable<GamepadManager>;
  44514. /**
  44515. * Gets the gamepad manager associated with the scene
  44516. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  44517. */
  44518. gamepadManager: GamepadManager;
  44519. }
  44520. /**
  44521. * Interface representing a free camera inputs manager
  44522. */
  44523. interface FreeCameraInputsManager {
  44524. /**
  44525. * Adds gamepad input support to the FreeCameraInputsManager.
  44526. * @returns the FreeCameraInputsManager
  44527. */
  44528. addGamepad(): FreeCameraInputsManager;
  44529. }
  44530. /**
  44531. * Interface representing an arc rotate camera inputs manager
  44532. */
  44533. interface ArcRotateCameraInputsManager {
  44534. /**
  44535. * Adds gamepad input support to the ArcRotateCamera InputManager.
  44536. * @returns the camera inputs manager
  44537. */
  44538. addGamepad(): ArcRotateCameraInputsManager;
  44539. }
  44540. /**
  44541. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  44542. */
  44543. export class GamepadSystemSceneComponent implements ISceneComponent {
  44544. /**
  44545. * The component name helpfull to identify the component in the list of scene components.
  44546. */
  44547. readonly name: string;
  44548. /**
  44549. * The scene the component belongs to.
  44550. */
  44551. scene: Scene;
  44552. /**
  44553. * Creates a new instance of the component for the given scene
  44554. * @param scene Defines the scene to register the component in
  44555. */
  44556. constructor(scene: Scene);
  44557. /**
  44558. * Registers the component in a given scene
  44559. */
  44560. register(): void;
  44561. /**
  44562. * Rebuilds the elements related to this component in case of
  44563. * context lost for instance.
  44564. */
  44565. rebuild(): void;
  44566. /**
  44567. * Disposes the component and the associated ressources
  44568. */
  44569. dispose(): void;
  44570. private _beforeCameraUpdate;
  44571. }
  44572. }
  44573. declare module BABYLON {
  44574. /**
  44575. * 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,
  44576. * which still works and will still be found in many Playgrounds.
  44577. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44578. */
  44579. export class UniversalCamera extends TouchCamera {
  44580. /**
  44581. * Defines the gamepad rotation sensiblity.
  44582. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  44583. */
  44584. get gamepadAngularSensibility(): number;
  44585. set gamepadAngularSensibility(value: number);
  44586. /**
  44587. * Defines the gamepad move sensiblity.
  44588. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  44589. */
  44590. get gamepadMoveSensibility(): number;
  44591. set gamepadMoveSensibility(value: number);
  44592. /**
  44593. * 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,
  44594. * which still works and will still be found in many Playgrounds.
  44595. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44596. * @param name Define the name of the camera in the scene
  44597. * @param position Define the start position of the camera in the scene
  44598. * @param scene Define the scene the camera belongs to
  44599. */
  44600. constructor(name: string, position: Vector3, scene: Scene);
  44601. /**
  44602. * Gets the current object class name.
  44603. * @return the class name
  44604. */
  44605. getClassName(): string;
  44606. }
  44607. }
  44608. declare module BABYLON {
  44609. /**
  44610. * This represents a FPS type of camera. This is only here for back compat purpose.
  44611. * Please use the UniversalCamera instead as both are identical.
  44612. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44613. */
  44614. export class GamepadCamera extends UniversalCamera {
  44615. /**
  44616. * Instantiates a new Gamepad Camera
  44617. * This represents a FPS type of camera. This is only here for back compat purpose.
  44618. * Please use the UniversalCamera instead as both are identical.
  44619. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44620. * @param name Define the name of the camera in the scene
  44621. * @param position Define the start position of the camera in the scene
  44622. * @param scene Define the scene the camera belongs to
  44623. */
  44624. constructor(name: string, position: Vector3, scene: Scene);
  44625. /**
  44626. * Gets the current object class name.
  44627. * @return the class name
  44628. */
  44629. getClassName(): string;
  44630. }
  44631. }
  44632. declare module BABYLON {
  44633. /** @hidden */
  44634. export var passPixelShader: {
  44635. name: string;
  44636. shader: string;
  44637. };
  44638. }
  44639. declare module BABYLON {
  44640. /** @hidden */
  44641. export var passCubePixelShader: {
  44642. name: string;
  44643. shader: string;
  44644. };
  44645. }
  44646. declare module BABYLON {
  44647. /**
  44648. * PassPostProcess which produces an output the same as it's input
  44649. */
  44650. export class PassPostProcess extends PostProcess {
  44651. /**
  44652. * Creates the PassPostProcess
  44653. * @param name The name of the effect.
  44654. * @param options The required width/height ratio to downsize to before computing the render pass.
  44655. * @param camera The camera to apply the render pass to.
  44656. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  44657. * @param engine The engine which the post process will be applied. (default: current engine)
  44658. * @param reusable If the post process can be reused on the same frame. (default: false)
  44659. * @param textureType The type of texture to be used when performing the post processing.
  44660. * @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)
  44661. */
  44662. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  44663. }
  44664. /**
  44665. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  44666. */
  44667. export class PassCubePostProcess extends PostProcess {
  44668. private _face;
  44669. /**
  44670. * Gets or sets the cube face to display.
  44671. * * 0 is +X
  44672. * * 1 is -X
  44673. * * 2 is +Y
  44674. * * 3 is -Y
  44675. * * 4 is +Z
  44676. * * 5 is -Z
  44677. */
  44678. get face(): number;
  44679. set face(value: number);
  44680. /**
  44681. * Creates the PassCubePostProcess
  44682. * @param name The name of the effect.
  44683. * @param options The required width/height ratio to downsize to before computing the render pass.
  44684. * @param camera The camera to apply the render pass to.
  44685. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  44686. * @param engine The engine which the post process will be applied. (default: current engine)
  44687. * @param reusable If the post process can be reused on the same frame. (default: false)
  44688. * @param textureType The type of texture to be used when performing the post processing.
  44689. * @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)
  44690. */
  44691. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  44692. }
  44693. }
  44694. declare module BABYLON {
  44695. /** @hidden */
  44696. export var anaglyphPixelShader: {
  44697. name: string;
  44698. shader: string;
  44699. };
  44700. }
  44701. declare module BABYLON {
  44702. /**
  44703. * Postprocess used to generate anaglyphic rendering
  44704. */
  44705. export class AnaglyphPostProcess extends PostProcess {
  44706. private _passedProcess;
  44707. /**
  44708. * Creates a new AnaglyphPostProcess
  44709. * @param name defines postprocess name
  44710. * @param options defines creation options or target ratio scale
  44711. * @param rigCameras defines cameras using this postprocess
  44712. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  44713. * @param engine defines hosting engine
  44714. * @param reusable defines if the postprocess will be reused multiple times per frame
  44715. */
  44716. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  44717. }
  44718. }
  44719. declare module BABYLON {
  44720. /**
  44721. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  44722. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  44723. */
  44724. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  44725. /**
  44726. * Creates a new AnaglyphArcRotateCamera
  44727. * @param name defines camera name
  44728. * @param alpha defines alpha angle (in radians)
  44729. * @param beta defines beta angle (in radians)
  44730. * @param radius defines radius
  44731. * @param target defines camera target
  44732. * @param interaxialDistance defines distance between each color axis
  44733. * @param scene defines the hosting scene
  44734. */
  44735. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  44736. /**
  44737. * Gets camera class name
  44738. * @returns AnaglyphArcRotateCamera
  44739. */
  44740. getClassName(): string;
  44741. }
  44742. }
  44743. declare module BABYLON {
  44744. /**
  44745. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  44746. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  44747. */
  44748. export class AnaglyphFreeCamera extends FreeCamera {
  44749. /**
  44750. * Creates a new AnaglyphFreeCamera
  44751. * @param name defines camera name
  44752. * @param position defines initial position
  44753. * @param interaxialDistance defines distance between each color axis
  44754. * @param scene defines the hosting scene
  44755. */
  44756. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  44757. /**
  44758. * Gets camera class name
  44759. * @returns AnaglyphFreeCamera
  44760. */
  44761. getClassName(): string;
  44762. }
  44763. }
  44764. declare module BABYLON {
  44765. /**
  44766. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  44767. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  44768. */
  44769. export class AnaglyphGamepadCamera extends GamepadCamera {
  44770. /**
  44771. * Creates a new AnaglyphGamepadCamera
  44772. * @param name defines camera name
  44773. * @param position defines initial position
  44774. * @param interaxialDistance defines distance between each color axis
  44775. * @param scene defines the hosting scene
  44776. */
  44777. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  44778. /**
  44779. * Gets camera class name
  44780. * @returns AnaglyphGamepadCamera
  44781. */
  44782. getClassName(): string;
  44783. }
  44784. }
  44785. declare module BABYLON {
  44786. /**
  44787. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  44788. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  44789. */
  44790. export class AnaglyphUniversalCamera extends UniversalCamera {
  44791. /**
  44792. * Creates a new AnaglyphUniversalCamera
  44793. * @param name defines camera name
  44794. * @param position defines initial position
  44795. * @param interaxialDistance defines distance between each color axis
  44796. * @param scene defines the hosting scene
  44797. */
  44798. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  44799. /**
  44800. * Gets camera class name
  44801. * @returns AnaglyphUniversalCamera
  44802. */
  44803. getClassName(): string;
  44804. }
  44805. }
  44806. declare module BABYLON {
  44807. /**
  44808. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  44809. * @see http://doc.babylonjs.com/features/cameras
  44810. */
  44811. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  44812. /**
  44813. * Creates a new StereoscopicArcRotateCamera
  44814. * @param name defines camera name
  44815. * @param alpha defines alpha angle (in radians)
  44816. * @param beta defines beta angle (in radians)
  44817. * @param radius defines radius
  44818. * @param target defines camera target
  44819. * @param interaxialDistance defines distance between each color axis
  44820. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  44821. * @param scene defines the hosting scene
  44822. */
  44823. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  44824. /**
  44825. * Gets camera class name
  44826. * @returns StereoscopicArcRotateCamera
  44827. */
  44828. getClassName(): string;
  44829. }
  44830. }
  44831. declare module BABYLON {
  44832. /**
  44833. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  44834. * @see http://doc.babylonjs.com/features/cameras
  44835. */
  44836. export class StereoscopicFreeCamera extends FreeCamera {
  44837. /**
  44838. * Creates a new StereoscopicFreeCamera
  44839. * @param name defines camera name
  44840. * @param position defines initial position
  44841. * @param interaxialDistance defines distance between each color axis
  44842. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  44843. * @param scene defines the hosting scene
  44844. */
  44845. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  44846. /**
  44847. * Gets camera class name
  44848. * @returns StereoscopicFreeCamera
  44849. */
  44850. getClassName(): string;
  44851. }
  44852. }
  44853. declare module BABYLON {
  44854. /**
  44855. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  44856. * @see http://doc.babylonjs.com/features/cameras
  44857. */
  44858. export class StereoscopicGamepadCamera extends GamepadCamera {
  44859. /**
  44860. * Creates a new StereoscopicGamepadCamera
  44861. * @param name defines camera name
  44862. * @param position defines initial position
  44863. * @param interaxialDistance defines distance between each color axis
  44864. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  44865. * @param scene defines the hosting scene
  44866. */
  44867. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  44868. /**
  44869. * Gets camera class name
  44870. * @returns StereoscopicGamepadCamera
  44871. */
  44872. getClassName(): string;
  44873. }
  44874. }
  44875. declare module BABYLON {
  44876. /**
  44877. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  44878. * @see http://doc.babylonjs.com/features/cameras
  44879. */
  44880. export class StereoscopicUniversalCamera extends UniversalCamera {
  44881. /**
  44882. * Creates a new StereoscopicUniversalCamera
  44883. * @param name defines camera name
  44884. * @param position defines initial position
  44885. * @param interaxialDistance defines distance between each color axis
  44886. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  44887. * @param scene defines the hosting scene
  44888. */
  44889. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  44890. /**
  44891. * Gets camera class name
  44892. * @returns StereoscopicUniversalCamera
  44893. */
  44894. getClassName(): string;
  44895. }
  44896. }
  44897. declare module BABYLON {
  44898. /**
  44899. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  44900. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  44901. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  44902. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  44903. */
  44904. export class VirtualJoysticksCamera extends FreeCamera {
  44905. /**
  44906. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  44907. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  44908. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  44909. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  44910. * @param name Define the name of the camera in the scene
  44911. * @param position Define the start position of the camera in the scene
  44912. * @param scene Define the scene the camera belongs to
  44913. */
  44914. constructor(name: string, position: Vector3, scene: Scene);
  44915. /**
  44916. * Gets the current object class name.
  44917. * @return the class name
  44918. */
  44919. getClassName(): string;
  44920. }
  44921. }
  44922. declare module BABYLON {
  44923. /**
  44924. * This represents all the required metrics to create a VR camera.
  44925. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  44926. */
  44927. export class VRCameraMetrics {
  44928. /**
  44929. * Define the horizontal resolution off the screen.
  44930. */
  44931. hResolution: number;
  44932. /**
  44933. * Define the vertical resolution off the screen.
  44934. */
  44935. vResolution: number;
  44936. /**
  44937. * Define the horizontal screen size.
  44938. */
  44939. hScreenSize: number;
  44940. /**
  44941. * Define the vertical screen size.
  44942. */
  44943. vScreenSize: number;
  44944. /**
  44945. * Define the vertical screen center position.
  44946. */
  44947. vScreenCenter: number;
  44948. /**
  44949. * Define the distance of the eyes to the screen.
  44950. */
  44951. eyeToScreenDistance: number;
  44952. /**
  44953. * Define the distance between both lenses
  44954. */
  44955. lensSeparationDistance: number;
  44956. /**
  44957. * Define the distance between both viewer's eyes.
  44958. */
  44959. interpupillaryDistance: number;
  44960. /**
  44961. * Define the distortion factor of the VR postprocess.
  44962. * Please, touch with care.
  44963. */
  44964. distortionK: number[];
  44965. /**
  44966. * Define the chromatic aberration correction factors for the VR post process.
  44967. */
  44968. chromaAbCorrection: number[];
  44969. /**
  44970. * Define the scale factor of the post process.
  44971. * The smaller the better but the slower.
  44972. */
  44973. postProcessScaleFactor: number;
  44974. /**
  44975. * Define an offset for the lens center.
  44976. */
  44977. lensCenterOffset: number;
  44978. /**
  44979. * Define if the current vr camera should compensate the distortion of the lense or not.
  44980. */
  44981. compensateDistortion: boolean;
  44982. /**
  44983. * Defines if multiview should be enabled when rendering (Default: false)
  44984. */
  44985. multiviewEnabled: boolean;
  44986. /**
  44987. * Gets the rendering aspect ratio based on the provided resolutions.
  44988. */
  44989. get aspectRatio(): number;
  44990. /**
  44991. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  44992. */
  44993. get aspectRatioFov(): number;
  44994. /**
  44995. * @hidden
  44996. */
  44997. get leftHMatrix(): Matrix;
  44998. /**
  44999. * @hidden
  45000. */
  45001. get rightHMatrix(): Matrix;
  45002. /**
  45003. * @hidden
  45004. */
  45005. get leftPreViewMatrix(): Matrix;
  45006. /**
  45007. * @hidden
  45008. */
  45009. get rightPreViewMatrix(): Matrix;
  45010. /**
  45011. * Get the default VRMetrics based on the most generic setup.
  45012. * @returns the default vr metrics
  45013. */
  45014. static GetDefault(): VRCameraMetrics;
  45015. }
  45016. }
  45017. declare module BABYLON {
  45018. /** @hidden */
  45019. export var vrDistortionCorrectionPixelShader: {
  45020. name: string;
  45021. shader: string;
  45022. };
  45023. }
  45024. declare module BABYLON {
  45025. /**
  45026. * VRDistortionCorrectionPostProcess used for mobile VR
  45027. */
  45028. export class VRDistortionCorrectionPostProcess extends PostProcess {
  45029. private _isRightEye;
  45030. private _distortionFactors;
  45031. private _postProcessScaleFactor;
  45032. private _lensCenterOffset;
  45033. private _scaleIn;
  45034. private _scaleFactor;
  45035. private _lensCenter;
  45036. /**
  45037. * Initializes the VRDistortionCorrectionPostProcess
  45038. * @param name The name of the effect.
  45039. * @param camera The camera to apply the render pass to.
  45040. * @param isRightEye If this is for the right eye distortion
  45041. * @param vrMetrics All the required metrics for the VR camera
  45042. */
  45043. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  45044. }
  45045. }
  45046. declare module BABYLON {
  45047. /**
  45048. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  45049. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  45050. */
  45051. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  45052. /**
  45053. * Creates a new VRDeviceOrientationArcRotateCamera
  45054. * @param name defines camera name
  45055. * @param alpha defines the camera rotation along the logitudinal axis
  45056. * @param beta defines the camera rotation along the latitudinal axis
  45057. * @param radius defines the camera distance from its target
  45058. * @param target defines the camera target
  45059. * @param scene defines the scene the camera belongs to
  45060. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  45061. * @param vrCameraMetrics defines the vr metrics associated to the camera
  45062. */
  45063. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  45064. /**
  45065. * Gets camera class name
  45066. * @returns VRDeviceOrientationArcRotateCamera
  45067. */
  45068. getClassName(): string;
  45069. }
  45070. }
  45071. declare module BABYLON {
  45072. /**
  45073. * Camera used to simulate VR rendering (based on FreeCamera)
  45074. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  45075. */
  45076. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  45077. /**
  45078. * Creates a new VRDeviceOrientationFreeCamera
  45079. * @param name defines camera name
  45080. * @param position defines the start position of the camera
  45081. * @param scene defines the scene the camera belongs to
  45082. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  45083. * @param vrCameraMetrics defines the vr metrics associated to the camera
  45084. */
  45085. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  45086. /**
  45087. * Gets camera class name
  45088. * @returns VRDeviceOrientationFreeCamera
  45089. */
  45090. getClassName(): string;
  45091. }
  45092. }
  45093. declare module BABYLON {
  45094. /**
  45095. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  45096. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  45097. */
  45098. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  45099. /**
  45100. * Creates a new VRDeviceOrientationGamepadCamera
  45101. * @param name defines camera name
  45102. * @param position defines the start position of the camera
  45103. * @param scene defines the scene the camera belongs to
  45104. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  45105. * @param vrCameraMetrics defines the vr metrics associated to the camera
  45106. */
  45107. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  45108. /**
  45109. * Gets camera class name
  45110. * @returns VRDeviceOrientationGamepadCamera
  45111. */
  45112. getClassName(): string;
  45113. }
  45114. }
  45115. declare module BABYLON {
  45116. /** @hidden */
  45117. export var imageProcessingPixelShader: {
  45118. name: string;
  45119. shader: string;
  45120. };
  45121. }
  45122. declare module BABYLON {
  45123. /**
  45124. * ImageProcessingPostProcess
  45125. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  45126. */
  45127. export class ImageProcessingPostProcess extends PostProcess {
  45128. /**
  45129. * Default configuration related to image processing available in the PBR Material.
  45130. */
  45131. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45132. /**
  45133. * Gets the image processing configuration used either in this material.
  45134. */
  45135. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  45136. /**
  45137. * Sets the Default image processing configuration used either in the this material.
  45138. *
  45139. * If sets to null, the scene one is in use.
  45140. */
  45141. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  45142. /**
  45143. * Keep track of the image processing observer to allow dispose and replace.
  45144. */
  45145. private _imageProcessingObserver;
  45146. /**
  45147. * Attaches a new image processing configuration to the PBR Material.
  45148. * @param configuration
  45149. */
  45150. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  45151. /**
  45152. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  45153. */
  45154. get colorCurves(): Nullable<ColorCurves>;
  45155. /**
  45156. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  45157. */
  45158. set colorCurves(value: Nullable<ColorCurves>);
  45159. /**
  45160. * Gets wether the color curves effect is enabled.
  45161. */
  45162. get colorCurvesEnabled(): boolean;
  45163. /**
  45164. * Sets wether the color curves effect is enabled.
  45165. */
  45166. set colorCurvesEnabled(value: boolean);
  45167. /**
  45168. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  45169. */
  45170. get colorGradingTexture(): Nullable<BaseTexture>;
  45171. /**
  45172. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  45173. */
  45174. set colorGradingTexture(value: Nullable<BaseTexture>);
  45175. /**
  45176. * Gets wether the color grading effect is enabled.
  45177. */
  45178. get colorGradingEnabled(): boolean;
  45179. /**
  45180. * Gets wether the color grading effect is enabled.
  45181. */
  45182. set colorGradingEnabled(value: boolean);
  45183. /**
  45184. * Gets exposure used in the effect.
  45185. */
  45186. get exposure(): number;
  45187. /**
  45188. * Sets exposure used in the effect.
  45189. */
  45190. set exposure(value: number);
  45191. /**
  45192. * Gets wether tonemapping is enabled or not.
  45193. */
  45194. get toneMappingEnabled(): boolean;
  45195. /**
  45196. * Sets wether tonemapping is enabled or not
  45197. */
  45198. set toneMappingEnabled(value: boolean);
  45199. /**
  45200. * Gets the type of tone mapping effect.
  45201. */
  45202. get toneMappingType(): number;
  45203. /**
  45204. * Sets the type of tone mapping effect.
  45205. */
  45206. set toneMappingType(value: number);
  45207. /**
  45208. * Gets contrast used in the effect.
  45209. */
  45210. get contrast(): number;
  45211. /**
  45212. * Sets contrast used in the effect.
  45213. */
  45214. set contrast(value: number);
  45215. /**
  45216. * Gets Vignette stretch size.
  45217. */
  45218. get vignetteStretch(): number;
  45219. /**
  45220. * Sets Vignette stretch size.
  45221. */
  45222. set vignetteStretch(value: number);
  45223. /**
  45224. * Gets Vignette centre X Offset.
  45225. */
  45226. get vignetteCentreX(): number;
  45227. /**
  45228. * Sets Vignette centre X Offset.
  45229. */
  45230. set vignetteCentreX(value: number);
  45231. /**
  45232. * Gets Vignette centre Y Offset.
  45233. */
  45234. get vignetteCentreY(): number;
  45235. /**
  45236. * Sets Vignette centre Y Offset.
  45237. */
  45238. set vignetteCentreY(value: number);
  45239. /**
  45240. * Gets Vignette weight or intensity of the vignette effect.
  45241. */
  45242. get vignetteWeight(): number;
  45243. /**
  45244. * Sets Vignette weight or intensity of the vignette effect.
  45245. */
  45246. set vignetteWeight(value: number);
  45247. /**
  45248. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  45249. * if vignetteEnabled is set to true.
  45250. */
  45251. get vignetteColor(): Color4;
  45252. /**
  45253. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  45254. * if vignetteEnabled is set to true.
  45255. */
  45256. set vignetteColor(value: Color4);
  45257. /**
  45258. * Gets Camera field of view used by the Vignette effect.
  45259. */
  45260. get vignetteCameraFov(): number;
  45261. /**
  45262. * Sets Camera field of view used by the Vignette effect.
  45263. */
  45264. set vignetteCameraFov(value: number);
  45265. /**
  45266. * Gets the vignette blend mode allowing different kind of effect.
  45267. */
  45268. get vignetteBlendMode(): number;
  45269. /**
  45270. * Sets the vignette blend mode allowing different kind of effect.
  45271. */
  45272. set vignetteBlendMode(value: number);
  45273. /**
  45274. * Gets wether the vignette effect is enabled.
  45275. */
  45276. get vignetteEnabled(): boolean;
  45277. /**
  45278. * Sets wether the vignette effect is enabled.
  45279. */
  45280. set vignetteEnabled(value: boolean);
  45281. private _fromLinearSpace;
  45282. /**
  45283. * Gets wether the input of the processing is in Gamma or Linear Space.
  45284. */
  45285. get fromLinearSpace(): boolean;
  45286. /**
  45287. * Sets wether the input of the processing is in Gamma or Linear Space.
  45288. */
  45289. set fromLinearSpace(value: boolean);
  45290. /**
  45291. * Defines cache preventing GC.
  45292. */
  45293. private _defines;
  45294. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  45295. /**
  45296. * "ImageProcessingPostProcess"
  45297. * @returns "ImageProcessingPostProcess"
  45298. */
  45299. getClassName(): string;
  45300. protected _updateParameters(): void;
  45301. dispose(camera?: Camera): void;
  45302. }
  45303. }
  45304. declare module BABYLON {
  45305. /**
  45306. * Class containing static functions to help procedurally build meshes
  45307. */
  45308. export class GroundBuilder {
  45309. /**
  45310. * Creates a ground mesh
  45311. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  45312. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  45313. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45314. * @param name defines the name of the mesh
  45315. * @param options defines the options used to create the mesh
  45316. * @param scene defines the hosting scene
  45317. * @returns the ground mesh
  45318. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  45319. */
  45320. static CreateGround(name: string, options: {
  45321. width?: number;
  45322. height?: number;
  45323. subdivisions?: number;
  45324. subdivisionsX?: number;
  45325. subdivisionsY?: number;
  45326. updatable?: boolean;
  45327. }, scene: any): Mesh;
  45328. /**
  45329. * Creates a tiled ground mesh
  45330. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  45331. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  45332. * * 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
  45333. * * 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
  45334. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45335. * @param name defines the name of the mesh
  45336. * @param options defines the options used to create the mesh
  45337. * @param scene defines the hosting scene
  45338. * @returns the tiled ground mesh
  45339. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  45340. */
  45341. static CreateTiledGround(name: string, options: {
  45342. xmin: number;
  45343. zmin: number;
  45344. xmax: number;
  45345. zmax: number;
  45346. subdivisions?: {
  45347. w: number;
  45348. h: number;
  45349. };
  45350. precision?: {
  45351. w: number;
  45352. h: number;
  45353. };
  45354. updatable?: boolean;
  45355. }, scene?: Nullable<Scene>): Mesh;
  45356. /**
  45357. * Creates a ground mesh from a height map
  45358. * * The parameter `url` sets the URL of the height map image resource.
  45359. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  45360. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  45361. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  45362. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  45363. * * 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.
  45364. * * 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).
  45365. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  45366. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45367. * @param name defines the name of the mesh
  45368. * @param url defines the url to the height map
  45369. * @param options defines the options used to create the mesh
  45370. * @param scene defines the hosting scene
  45371. * @returns the ground mesh
  45372. * @see https://doc.babylonjs.com/babylon101/height_map
  45373. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  45374. */
  45375. static CreateGroundFromHeightMap(name: string, url: string, options: {
  45376. width?: number;
  45377. height?: number;
  45378. subdivisions?: number;
  45379. minHeight?: number;
  45380. maxHeight?: number;
  45381. colorFilter?: Color3;
  45382. alphaFilter?: number;
  45383. updatable?: boolean;
  45384. onReady?: (mesh: GroundMesh) => void;
  45385. }, scene?: Nullable<Scene>): GroundMesh;
  45386. }
  45387. }
  45388. declare module BABYLON {
  45389. /**
  45390. * Class containing static functions to help procedurally build meshes
  45391. */
  45392. export class TorusBuilder {
  45393. /**
  45394. * Creates a torus mesh
  45395. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  45396. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  45397. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  45398. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45399. * * 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
  45400. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45401. * @param name defines the name of the mesh
  45402. * @param options defines the options used to create the mesh
  45403. * @param scene defines the hosting scene
  45404. * @returns the torus mesh
  45405. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  45406. */
  45407. static CreateTorus(name: string, options: {
  45408. diameter?: number;
  45409. thickness?: number;
  45410. tessellation?: number;
  45411. updatable?: boolean;
  45412. sideOrientation?: number;
  45413. frontUVs?: Vector4;
  45414. backUVs?: Vector4;
  45415. }, scene: any): Mesh;
  45416. }
  45417. }
  45418. declare module BABYLON {
  45419. /**
  45420. * Class containing static functions to help procedurally build meshes
  45421. */
  45422. export class CylinderBuilder {
  45423. /**
  45424. * Creates a cylinder or a cone mesh
  45425. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  45426. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  45427. * * 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.
  45428. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  45429. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  45430. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  45431. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  45432. * * 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).
  45433. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  45434. * * 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).
  45435. * * 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
  45436. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  45437. * * 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
  45438. * * 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.
  45439. * * If `enclose` is false, a ring surface is one element.
  45440. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  45441. * * 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
  45442. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45443. * * 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
  45444. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45445. * @param name defines the name of the mesh
  45446. * @param options defines the options used to create the mesh
  45447. * @param scene defines the hosting scene
  45448. * @returns the cylinder mesh
  45449. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  45450. */
  45451. static CreateCylinder(name: string, options: {
  45452. height?: number;
  45453. diameterTop?: number;
  45454. diameterBottom?: number;
  45455. diameter?: number;
  45456. tessellation?: number;
  45457. subdivisions?: number;
  45458. arc?: number;
  45459. faceColors?: Color4[];
  45460. faceUV?: Vector4[];
  45461. updatable?: boolean;
  45462. hasRings?: boolean;
  45463. enclose?: boolean;
  45464. cap?: number;
  45465. sideOrientation?: number;
  45466. frontUVs?: Vector4;
  45467. backUVs?: Vector4;
  45468. }, scene: any): Mesh;
  45469. }
  45470. }
  45471. declare module BABYLON {
  45472. /**
  45473. * States of the webXR experience
  45474. */
  45475. export enum WebXRState {
  45476. /**
  45477. * Transitioning to being in XR mode
  45478. */
  45479. ENTERING_XR = 0,
  45480. /**
  45481. * Transitioning to non XR mode
  45482. */
  45483. EXITING_XR = 1,
  45484. /**
  45485. * In XR mode and presenting
  45486. */
  45487. IN_XR = 2,
  45488. /**
  45489. * Not entered XR mode
  45490. */
  45491. NOT_IN_XR = 3
  45492. }
  45493. /**
  45494. * Abstraction of the XR render target
  45495. */
  45496. export interface WebXRRenderTarget extends IDisposable {
  45497. /**
  45498. * xrpresent context of the canvas which can be used to display/mirror xr content
  45499. */
  45500. canvasContext: WebGLRenderingContext;
  45501. /**
  45502. * xr layer for the canvas
  45503. */
  45504. xrLayer: Nullable<XRWebGLLayer>;
  45505. /**
  45506. * Initializes the xr layer for the session
  45507. * @param xrSession xr session
  45508. * @returns a promise that will resolve once the XR Layer has been created
  45509. */
  45510. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  45511. }
  45512. }
  45513. declare module BABYLON {
  45514. /**
  45515. * COnfiguration object for WebXR output canvas
  45516. */
  45517. export class WebXRManagedOutputCanvasOptions {
  45518. /**
  45519. * An optional canvas in case you wish to create it yourself and provide it here.
  45520. * If not provided, a new canvas will be created
  45521. */
  45522. canvasElement?: HTMLCanvasElement;
  45523. /**
  45524. * Options for this XR Layer output
  45525. */
  45526. canvasOptions?: XRWebGLLayerOptions;
  45527. /**
  45528. * CSS styling for a newly created canvas (if not provided)
  45529. */
  45530. newCanvasCssStyle?: string;
  45531. /**
  45532. * Get the default values of the configuration object
  45533. * @returns default values of this configuration object
  45534. */
  45535. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  45536. }
  45537. /**
  45538. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  45539. */
  45540. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  45541. private _options;
  45542. private _canvas;
  45543. private _engine;
  45544. /**
  45545. * Rendering context of the canvas which can be used to display/mirror xr content
  45546. */
  45547. canvasContext: WebGLRenderingContext;
  45548. /**
  45549. * xr layer for the canvas
  45550. */
  45551. xrLayer: Nullable<XRWebGLLayer>;
  45552. /**
  45553. * Initializes the canvas to be added/removed upon entering/exiting xr
  45554. * @param _xrSessionManager The XR Session manager
  45555. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  45556. */
  45557. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  45558. /**
  45559. * Disposes of the object
  45560. */
  45561. dispose(): void;
  45562. /**
  45563. * Initializes the xr layer for the session
  45564. * @param xrSession xr session
  45565. * @returns a promise that will resolve once the XR Layer has been created
  45566. */
  45567. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  45568. private _addCanvas;
  45569. private _removeCanvas;
  45570. private _setManagedOutputCanvas;
  45571. }
  45572. }
  45573. declare module BABYLON {
  45574. /**
  45575. * Manages an XRSession to work with Babylon's engine
  45576. * @see https://doc.babylonjs.com/how_to/webxr
  45577. */
  45578. export class WebXRSessionManager implements IDisposable {
  45579. /** The scene which the session should be created for */
  45580. scene: Scene;
  45581. private _referenceSpace;
  45582. private _rttProvider;
  45583. private _sessionEnded;
  45584. private _xrNavigator;
  45585. private baseLayer;
  45586. /**
  45587. * The base reference space from which the session started. good if you want to reset your
  45588. * reference space
  45589. */
  45590. baseReferenceSpace: XRReferenceSpace;
  45591. /**
  45592. * Current XR frame
  45593. */
  45594. currentFrame: Nullable<XRFrame>;
  45595. /** WebXR timestamp updated every frame */
  45596. currentTimestamp: number;
  45597. /**
  45598. * Used just in case of a failure to initialize an immersive session.
  45599. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  45600. */
  45601. defaultHeightCompensation: number;
  45602. /**
  45603. * Fires every time a new xrFrame arrives which can be used to update the camera
  45604. */
  45605. onXRFrameObservable: Observable<XRFrame>;
  45606. /**
  45607. * Fires when the reference space changed
  45608. */
  45609. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  45610. /**
  45611. * Fires when the xr session is ended either by the device or manually done
  45612. */
  45613. onXRSessionEnded: Observable<any>;
  45614. /**
  45615. * Fires when the xr session is ended either by the device or manually done
  45616. */
  45617. onXRSessionInit: Observable<XRSession>;
  45618. /**
  45619. * Underlying xr session
  45620. */
  45621. session: XRSession;
  45622. /**
  45623. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  45624. * or get the offset the player is currently at.
  45625. */
  45626. viewerReferenceSpace: XRReferenceSpace;
  45627. /**
  45628. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  45629. * @param scene The scene which the session should be created for
  45630. */
  45631. constructor(
  45632. /** The scene which the session should be created for */
  45633. scene: Scene);
  45634. /**
  45635. * The current reference space used in this session. This reference space can constantly change!
  45636. * It is mainly used to offset the camera's position.
  45637. */
  45638. get referenceSpace(): XRReferenceSpace;
  45639. /**
  45640. * Set a new reference space and triggers the observable
  45641. */
  45642. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  45643. /**
  45644. * Disposes of the session manager
  45645. */
  45646. dispose(): void;
  45647. /**
  45648. * Stops the xrSession and restores the render loop
  45649. * @returns Promise which resolves after it exits XR
  45650. */
  45651. exitXRAsync(): Promise<void>;
  45652. /**
  45653. * Gets the correct render target texture to be rendered this frame for this eye
  45654. * @param eye the eye for which to get the render target
  45655. * @returns the render target for the specified eye
  45656. */
  45657. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  45658. /**
  45659. * Creates a WebXRRenderTarget object for the XR session
  45660. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  45661. * @param options optional options to provide when creating a new render target
  45662. * @returns a WebXR render target to which the session can render
  45663. */
  45664. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  45665. /**
  45666. * Initializes the manager
  45667. * After initialization enterXR can be called to start an XR session
  45668. * @returns Promise which resolves after it is initialized
  45669. */
  45670. initializeAsync(): Promise<void>;
  45671. /**
  45672. * Initializes an xr session
  45673. * @param xrSessionMode mode to initialize
  45674. * @param xrSessionInit defines optional and required values to pass to the session builder
  45675. * @returns a promise which will resolve once the session has been initialized
  45676. */
  45677. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  45678. /**
  45679. * Checks if a session would be supported for the creation options specified
  45680. * @param sessionMode session mode to check if supported eg. immersive-vr
  45681. * @returns A Promise that resolves to true if supported and false if not
  45682. */
  45683. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  45684. /**
  45685. * Resets the reference space to the one started the session
  45686. */
  45687. resetReferenceSpace(): void;
  45688. /**
  45689. * Starts rendering to the xr layer
  45690. */
  45691. runXRRenderLoop(): void;
  45692. /**
  45693. * Sets the reference space on the xr session
  45694. * @param referenceSpaceType space to set
  45695. * @returns a promise that will resolve once the reference space has been set
  45696. */
  45697. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  45698. /**
  45699. * Updates the render state of the session
  45700. * @param state state to set
  45701. * @returns a promise that resolves once the render state has been updated
  45702. */
  45703. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  45704. /**
  45705. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  45706. * @param sessionMode defines the session to test
  45707. * @returns a promise with boolean as final value
  45708. */
  45709. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  45710. private _createRenderTargetTexture;
  45711. }
  45712. }
  45713. declare module BABYLON {
  45714. /**
  45715. * WebXR Camera which holds the views for the xrSession
  45716. * @see https://doc.babylonjs.com/how_to/webxr_camera
  45717. */
  45718. export class WebXRCamera extends FreeCamera {
  45719. private _xrSessionManager;
  45720. private _firstFrame;
  45721. private _referenceQuaternion;
  45722. private _referencedPosition;
  45723. private _xrInvPositionCache;
  45724. private _xrInvQuaternionCache;
  45725. /**
  45726. * Should position compensation execute on first frame.
  45727. * This is used when copying the position from a native (non XR) camera
  45728. */
  45729. compensateOnFirstFrame: boolean;
  45730. /**
  45731. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  45732. * @param name the name of the camera
  45733. * @param scene the scene to add the camera to
  45734. * @param _xrSessionManager a constructed xr session manager
  45735. */
  45736. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  45737. /**
  45738. * Return the user's height, unrelated to the current ground.
  45739. * This will be the y position of this camera, when ground level is 0.
  45740. */
  45741. get realWorldHeight(): number;
  45742. /** @hidden */
  45743. _updateForDualEyeDebugging(): void;
  45744. /**
  45745. * Sets this camera's transformation based on a non-vr camera
  45746. * @param otherCamera the non-vr camera to copy the transformation from
  45747. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  45748. */
  45749. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  45750. /**
  45751. * Gets the current instance class name ("WebXRCamera").
  45752. * @returns the class name
  45753. */
  45754. getClassName(): string;
  45755. /**
  45756. * Overriding the _getViewMatrix function, as it is computed by WebXR
  45757. */
  45758. _getViewMatrix(): Matrix;
  45759. private _updateFromXRSession;
  45760. private _updateNumberOfRigCameras;
  45761. private _updateReferenceSpace;
  45762. private _updateReferenceSpaceOffset;
  45763. }
  45764. }
  45765. declare module BABYLON {
  45766. /**
  45767. * Defining the interface required for a (webxr) feature
  45768. */
  45769. export interface IWebXRFeature extends IDisposable {
  45770. /**
  45771. * Is this feature attached
  45772. */
  45773. attached: boolean;
  45774. /**
  45775. * Should auto-attach be disabled?
  45776. */
  45777. disableAutoAttach: boolean;
  45778. /**
  45779. * Attach the feature to the session
  45780. * Will usually be called by the features manager
  45781. *
  45782. * @param force should attachment be forced (even when already attached)
  45783. * @returns true if successful.
  45784. */
  45785. attach(force?: boolean): boolean;
  45786. /**
  45787. * Detach the feature from the session
  45788. * Will usually be called by the features manager
  45789. *
  45790. * @returns true if successful.
  45791. */
  45792. detach(): boolean;
  45793. }
  45794. /**
  45795. * A list of the currently available features without referencing them
  45796. */
  45797. export class WebXRFeatureName {
  45798. /**
  45799. * The name of the anchor system feature
  45800. */
  45801. static ANCHOR_SYSTEM: string;
  45802. /**
  45803. * The name of the background remover feature
  45804. */
  45805. static BACKGROUND_REMOVER: string;
  45806. /**
  45807. * The name of the hit test feature
  45808. */
  45809. static HIT_TEST: string;
  45810. /**
  45811. * physics impostors for xr controllers feature
  45812. */
  45813. static PHYSICS_CONTROLLERS: string;
  45814. /**
  45815. * The name of the plane detection feature
  45816. */
  45817. static PLANE_DETECTION: string;
  45818. /**
  45819. * The name of the pointer selection feature
  45820. */
  45821. static POINTER_SELECTION: string;
  45822. /**
  45823. * The name of the teleportation feature
  45824. */
  45825. static TELEPORTATION: string;
  45826. }
  45827. /**
  45828. * Defining the constructor of a feature. Used to register the modules.
  45829. */
  45830. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  45831. /**
  45832. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  45833. * It is mainly used in AR sessions.
  45834. *
  45835. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  45836. */
  45837. export class WebXRFeaturesManager implements IDisposable {
  45838. private _xrSessionManager;
  45839. private static readonly _AvailableFeatures;
  45840. private _features;
  45841. /**
  45842. * constructs a new features manages.
  45843. *
  45844. * @param _xrSessionManager an instance of WebXRSessionManager
  45845. */
  45846. constructor(_xrSessionManager: WebXRSessionManager);
  45847. /**
  45848. * Used to register a module. After calling this function a developer can use this feature in the scene.
  45849. * Mainly used internally.
  45850. *
  45851. * @param featureName the name of the feature to register
  45852. * @param constructorFunction the function used to construct the module
  45853. * @param version the (babylon) version of the module
  45854. * @param stable is that a stable version of this module
  45855. */
  45856. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  45857. /**
  45858. * Returns a constructor of a specific feature.
  45859. *
  45860. * @param featureName the name of the feature to construct
  45861. * @param version the version of the feature to load
  45862. * @param xrSessionManager the xrSessionManager. Used to construct the module
  45863. * @param options optional options provided to the module.
  45864. * @returns a function that, when called, will return a new instance of this feature
  45865. */
  45866. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  45867. /**
  45868. * Can be used to return the list of features currently registered
  45869. *
  45870. * @returns an Array of available features
  45871. */
  45872. static GetAvailableFeatures(): string[];
  45873. /**
  45874. * Gets the versions available for a specific feature
  45875. * @param featureName the name of the feature
  45876. * @returns an array with the available versions
  45877. */
  45878. static GetAvailableVersions(featureName: string): string[];
  45879. /**
  45880. * Return the latest unstable version of this feature
  45881. * @param featureName the name of the feature to search
  45882. * @returns the version number. if not found will return -1
  45883. */
  45884. static GetLatestVersionOfFeature(featureName: string): number;
  45885. /**
  45886. * Return the latest stable version of this feature
  45887. * @param featureName the name of the feature to search
  45888. * @returns the version number. if not found will return -1
  45889. */
  45890. static GetStableVersionOfFeature(featureName: string): number;
  45891. /**
  45892. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  45893. * Can be used during a session to start a feature
  45894. * @param featureName the name of feature to attach
  45895. */
  45896. attachFeature(featureName: string): void;
  45897. /**
  45898. * Can be used inside a session or when the session ends to detach a specific feature
  45899. * @param featureName the name of the feature to detach
  45900. */
  45901. detachFeature(featureName: string): void;
  45902. /**
  45903. * Used to disable an already-enabled feature
  45904. * The feature will be disposed and will be recreated once enabled.
  45905. * @param featureName the feature to disable
  45906. * @returns true if disable was successful
  45907. */
  45908. disableFeature(featureName: string | {
  45909. Name: string;
  45910. }): boolean;
  45911. /**
  45912. * dispose this features manager
  45913. */
  45914. dispose(): void;
  45915. /**
  45916. * Enable a feature using its name and a version. This will enable it in the scene, and will be responsible to attach it when the session starts.
  45917. * If used twice, the old version will be disposed and a new one will be constructed. This way you can re-enable with different configuration.
  45918. *
  45919. * @param featureName the name of the feature to load or the class of the feature
  45920. * @param version optional version to load. if not provided the latest version will be enabled
  45921. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  45922. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  45923. * @returns a new constructed feature or throws an error if feature not found.
  45924. */
  45925. enableFeature(featureName: string | {
  45926. Name: string;
  45927. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  45928. /**
  45929. * get the implementation of an enabled feature.
  45930. * @param featureName the name of the feature to load
  45931. * @returns the feature class, if found
  45932. */
  45933. getEnabledFeature(featureName: string): IWebXRFeature;
  45934. /**
  45935. * Get the list of enabled features
  45936. * @returns an array of enabled features
  45937. */
  45938. getEnabledFeatures(): string[];
  45939. }
  45940. }
  45941. declare module BABYLON {
  45942. /**
  45943. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  45944. * @see https://doc.babylonjs.com/how_to/webxr
  45945. */
  45946. export class WebXRExperienceHelper implements IDisposable {
  45947. private scene;
  45948. private _nonVRCamera;
  45949. private _originalSceneAutoClear;
  45950. private _supported;
  45951. /**
  45952. * Camera used to render xr content
  45953. */
  45954. camera: WebXRCamera;
  45955. /** A features manager for this xr session */
  45956. featuresManager: WebXRFeaturesManager;
  45957. /**
  45958. * Observers registered here will be triggered after the camera's initial transformation is set
  45959. * This can be used to set a different ground level or an extra rotation.
  45960. *
  45961. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  45962. * to the position set after this observable is done executing.
  45963. */
  45964. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  45965. /**
  45966. * Fires when the state of the experience helper has changed
  45967. */
  45968. onStateChangedObservable: Observable<WebXRState>;
  45969. /** Session manager used to keep track of xr session */
  45970. sessionManager: WebXRSessionManager;
  45971. /**
  45972. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  45973. */
  45974. state: WebXRState;
  45975. /**
  45976. * Creates a WebXRExperienceHelper
  45977. * @param scene The scene the helper should be created in
  45978. */
  45979. private constructor();
  45980. /**
  45981. * Creates the experience helper
  45982. * @param scene the scene to attach the experience helper to
  45983. * @returns a promise for the experience helper
  45984. */
  45985. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  45986. /**
  45987. * Disposes of the experience helper
  45988. */
  45989. dispose(): void;
  45990. /**
  45991. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  45992. * @param sessionMode options for the XR session
  45993. * @param referenceSpaceType frame of reference of the XR session
  45994. * @param renderTarget the output canvas that will be used to enter XR mode
  45995. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  45996. * @returns promise that resolves after xr mode has entered
  45997. */
  45998. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  45999. /**
  46000. * Exits XR mode and returns the scene to its original state
  46001. * @returns promise that resolves after xr mode has exited
  46002. */
  46003. exitXRAsync(): Promise<void>;
  46004. private _nonXRToXRCamera;
  46005. private _setState;
  46006. }
  46007. }
  46008. declare module BABYLON {
  46009. /**
  46010. * X-Y values for axes in WebXR
  46011. */
  46012. export interface IWebXRMotionControllerAxesValue {
  46013. /**
  46014. * The value of the x axis
  46015. */
  46016. x: number;
  46017. /**
  46018. * The value of the y-axis
  46019. */
  46020. y: number;
  46021. }
  46022. /**
  46023. * changed / previous values for the values of this component
  46024. */
  46025. export interface IWebXRMotionControllerComponentChangesValues<T> {
  46026. /**
  46027. * current (this frame) value
  46028. */
  46029. current: T;
  46030. /**
  46031. * previous (last change) value
  46032. */
  46033. previous: T;
  46034. }
  46035. /**
  46036. * Represents changes in the component between current frame and last values recorded
  46037. */
  46038. export interface IWebXRMotionControllerComponentChanges {
  46039. /**
  46040. * will be populated with previous and current values if axes changed
  46041. */
  46042. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  46043. /**
  46044. * will be populated with previous and current values if pressed changed
  46045. */
  46046. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  46047. /**
  46048. * will be populated with previous and current values if touched changed
  46049. */
  46050. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  46051. /**
  46052. * will be populated with previous and current values if value changed
  46053. */
  46054. value?: IWebXRMotionControllerComponentChangesValues<number>;
  46055. }
  46056. /**
  46057. * This class represents a single component (for example button or thumbstick) of a motion controller
  46058. */
  46059. export class WebXRControllerComponent implements IDisposable {
  46060. /**
  46061. * the id of this component
  46062. */
  46063. id: string;
  46064. /**
  46065. * the type of the component
  46066. */
  46067. type: MotionControllerComponentType;
  46068. private _buttonIndex;
  46069. private _axesIndices;
  46070. private _axes;
  46071. private _changes;
  46072. private _currentValue;
  46073. private _hasChanges;
  46074. private _pressed;
  46075. private _touched;
  46076. /**
  46077. * button component type
  46078. */
  46079. static BUTTON_TYPE: MotionControllerComponentType;
  46080. /**
  46081. * squeeze component type
  46082. */
  46083. static SQUEEZE_TYPE: MotionControllerComponentType;
  46084. /**
  46085. * Thumbstick component type
  46086. */
  46087. static THUMBSTICK_TYPE: MotionControllerComponentType;
  46088. /**
  46089. * Touchpad component type
  46090. */
  46091. static TOUCHPAD_TYPE: MotionControllerComponentType;
  46092. /**
  46093. * trigger component type
  46094. */
  46095. static TRIGGER_TYPE: MotionControllerComponentType;
  46096. /**
  46097. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  46098. * the axes data changes
  46099. */
  46100. onAxisValueChangedObservable: Observable<{
  46101. x: number;
  46102. y: number;
  46103. }>;
  46104. /**
  46105. * Observers registered here will be triggered when the state of a button changes
  46106. * State change is either pressed / touched / value
  46107. */
  46108. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  46109. /**
  46110. * Creates a new component for a motion controller.
  46111. * It is created by the motion controller itself
  46112. *
  46113. * @param id the id of this component
  46114. * @param type the type of the component
  46115. * @param _buttonIndex index in the buttons array of the gamepad
  46116. * @param _axesIndices indices of the values in the axes array of the gamepad
  46117. */
  46118. constructor(
  46119. /**
  46120. * the id of this component
  46121. */
  46122. id: string,
  46123. /**
  46124. * the type of the component
  46125. */
  46126. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  46127. /**
  46128. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  46129. */
  46130. get axes(): IWebXRMotionControllerAxesValue;
  46131. /**
  46132. * Get the changes. Elements will be populated only if they changed with their previous and current value
  46133. */
  46134. get changes(): IWebXRMotionControllerComponentChanges;
  46135. /**
  46136. * Return whether or not the component changed the last frame
  46137. */
  46138. get hasChanges(): boolean;
  46139. /**
  46140. * is the button currently pressed
  46141. */
  46142. get pressed(): boolean;
  46143. /**
  46144. * is the button currently touched
  46145. */
  46146. get touched(): boolean;
  46147. /**
  46148. * Get the current value of this component
  46149. */
  46150. get value(): number;
  46151. /**
  46152. * Dispose this component
  46153. */
  46154. dispose(): void;
  46155. /**
  46156. * Are there axes correlating to this component
  46157. * @return true is axes data is available
  46158. */
  46159. isAxes(): boolean;
  46160. /**
  46161. * Is this component a button (hence - pressable)
  46162. * @returns true if can be pressed
  46163. */
  46164. isButton(): boolean;
  46165. /**
  46166. * update this component using the gamepad object it is in. Called on every frame
  46167. * @param nativeController the native gamepad controller object
  46168. */
  46169. update(nativeController: IMinimalMotionControllerObject): void;
  46170. }
  46171. }
  46172. declare module BABYLON {
  46173. /**
  46174. * Class used to represent data loading progression
  46175. */
  46176. export class SceneLoaderProgressEvent {
  46177. /** defines if data length to load can be evaluated */
  46178. readonly lengthComputable: boolean;
  46179. /** defines the loaded data length */
  46180. readonly loaded: number;
  46181. /** defines the data length to load */
  46182. readonly total: number;
  46183. /**
  46184. * Create a new progress event
  46185. * @param lengthComputable defines if data length to load can be evaluated
  46186. * @param loaded defines the loaded data length
  46187. * @param total defines the data length to load
  46188. */
  46189. constructor(
  46190. /** defines if data length to load can be evaluated */
  46191. lengthComputable: boolean,
  46192. /** defines the loaded data length */
  46193. loaded: number,
  46194. /** defines the data length to load */
  46195. total: number);
  46196. /**
  46197. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  46198. * @param event defines the source event
  46199. * @returns a new SceneLoaderProgressEvent
  46200. */
  46201. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  46202. }
  46203. /**
  46204. * Interface used by SceneLoader plugins to define supported file extensions
  46205. */
  46206. export interface ISceneLoaderPluginExtensions {
  46207. /**
  46208. * Defines the list of supported extensions
  46209. */
  46210. [extension: string]: {
  46211. isBinary: boolean;
  46212. };
  46213. }
  46214. /**
  46215. * Interface used by SceneLoader plugin factory
  46216. */
  46217. export interface ISceneLoaderPluginFactory {
  46218. /**
  46219. * Defines the name of the factory
  46220. */
  46221. name: string;
  46222. /**
  46223. * Function called to create a new plugin
  46224. * @return the new plugin
  46225. */
  46226. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  46227. /**
  46228. * The callback that returns true if the data can be directly loaded.
  46229. * @param data string containing the file data
  46230. * @returns if the data can be loaded directly
  46231. */
  46232. canDirectLoad?(data: string): boolean;
  46233. }
  46234. /**
  46235. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  46236. */
  46237. export interface ISceneLoaderPluginBase {
  46238. /**
  46239. * The friendly name of this plugin.
  46240. */
  46241. name: string;
  46242. /**
  46243. * The file extensions supported by this plugin.
  46244. */
  46245. extensions: string | ISceneLoaderPluginExtensions;
  46246. /**
  46247. * The callback called when loading from a url.
  46248. * @param scene scene loading this url
  46249. * @param url url to load
  46250. * @param onSuccess callback called when the file successfully loads
  46251. * @param onProgress callback called while file is loading (if the server supports this mode)
  46252. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  46253. * @param onError callback called when the file fails to load
  46254. * @returns a file request object
  46255. */
  46256. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  46257. /**
  46258. * The callback called when loading from a file object.
  46259. * @param scene scene loading this file
  46260. * @param file defines the file to load
  46261. * @param onSuccess defines the callback to call when data is loaded
  46262. * @param onProgress defines the callback to call during loading process
  46263. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  46264. * @param onError defines the callback to call when an error occurs
  46265. * @returns a file request object
  46266. */
  46267. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  46268. /**
  46269. * The callback that returns true if the data can be directly loaded.
  46270. * @param data string containing the file data
  46271. * @returns if the data can be loaded directly
  46272. */
  46273. canDirectLoad?(data: string): boolean;
  46274. /**
  46275. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  46276. * @param scene scene loading this data
  46277. * @param data string containing the data
  46278. * @returns data to pass to the plugin
  46279. */
  46280. directLoad?(scene: Scene, data: string): any;
  46281. /**
  46282. * The callback that allows custom handling of the root url based on the response url.
  46283. * @param rootUrl the original root url
  46284. * @param responseURL the response url if available
  46285. * @returns the new root url
  46286. */
  46287. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  46288. }
  46289. /**
  46290. * Interface used to define a SceneLoader plugin
  46291. */
  46292. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  46293. /**
  46294. * Import meshes into a scene.
  46295. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46296. * @param scene The scene to import into
  46297. * @param data The data to import
  46298. * @param rootUrl The root url for scene and resources
  46299. * @param meshes The meshes array to import into
  46300. * @param particleSystems The particle systems array to import into
  46301. * @param skeletons The skeletons array to import into
  46302. * @param onError The callback when import fails
  46303. * @returns True if successful or false otherwise
  46304. */
  46305. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  46306. /**
  46307. * Load into a scene.
  46308. * @param scene The scene to load into
  46309. * @param data The data to import
  46310. * @param rootUrl The root url for scene and resources
  46311. * @param onError The callback when import fails
  46312. * @returns True if successful or false otherwise
  46313. */
  46314. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  46315. /**
  46316. * Load into an asset container.
  46317. * @param scene The scene to load into
  46318. * @param data The data to import
  46319. * @param rootUrl The root url for scene and resources
  46320. * @param onError The callback when import fails
  46321. * @returns The loaded asset container
  46322. */
  46323. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  46324. }
  46325. /**
  46326. * Interface used to define an async SceneLoader plugin
  46327. */
  46328. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  46329. /**
  46330. * Import meshes into a scene.
  46331. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46332. * @param scene The scene to import into
  46333. * @param data The data to import
  46334. * @param rootUrl The root url for scene and resources
  46335. * @param onProgress The callback when the load progresses
  46336. * @param fileName Defines the name of the file to load
  46337. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  46338. */
  46339. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  46340. meshes: AbstractMesh[];
  46341. particleSystems: IParticleSystem[];
  46342. skeletons: Skeleton[];
  46343. animationGroups: AnimationGroup[];
  46344. }>;
  46345. /**
  46346. * Load into a scene.
  46347. * @param scene The scene to load into
  46348. * @param data The data to import
  46349. * @param rootUrl The root url for scene and resources
  46350. * @param onProgress The callback when the load progresses
  46351. * @param fileName Defines the name of the file to load
  46352. * @returns Nothing
  46353. */
  46354. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  46355. /**
  46356. * Load into an asset container.
  46357. * @param scene The scene to load into
  46358. * @param data The data to import
  46359. * @param rootUrl The root url for scene and resources
  46360. * @param onProgress The callback when the load progresses
  46361. * @param fileName Defines the name of the file to load
  46362. * @returns The loaded asset container
  46363. */
  46364. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  46365. }
  46366. /**
  46367. * Mode that determines how to handle old animation groups before loading new ones.
  46368. */
  46369. export enum SceneLoaderAnimationGroupLoadingMode {
  46370. /**
  46371. * Reset all old animations to initial state then dispose them.
  46372. */
  46373. Clean = 0,
  46374. /**
  46375. * Stop all old animations.
  46376. */
  46377. Stop = 1,
  46378. /**
  46379. * Restart old animations from first frame.
  46380. */
  46381. Sync = 2,
  46382. /**
  46383. * Old animations remains untouched.
  46384. */
  46385. NoSync = 3
  46386. }
  46387. /**
  46388. * Class used to load scene from various file formats using registered plugins
  46389. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  46390. */
  46391. export class SceneLoader {
  46392. /**
  46393. * No logging while loading
  46394. */
  46395. static readonly NO_LOGGING: number;
  46396. /**
  46397. * Minimal logging while loading
  46398. */
  46399. static readonly MINIMAL_LOGGING: number;
  46400. /**
  46401. * Summary logging while loading
  46402. */
  46403. static readonly SUMMARY_LOGGING: number;
  46404. /**
  46405. * Detailled logging while loading
  46406. */
  46407. static readonly DETAILED_LOGGING: number;
  46408. /**
  46409. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  46410. */
  46411. static get ForceFullSceneLoadingForIncremental(): boolean;
  46412. static set ForceFullSceneLoadingForIncremental(value: boolean);
  46413. /**
  46414. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  46415. */
  46416. static get ShowLoadingScreen(): boolean;
  46417. static set ShowLoadingScreen(value: boolean);
  46418. /**
  46419. * Defines the current logging level (while loading the scene)
  46420. * @ignorenaming
  46421. */
  46422. static get loggingLevel(): number;
  46423. static set loggingLevel(value: number);
  46424. /**
  46425. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  46426. */
  46427. static get CleanBoneMatrixWeights(): boolean;
  46428. static set CleanBoneMatrixWeights(value: boolean);
  46429. /**
  46430. * Event raised when a plugin is used to load a scene
  46431. */
  46432. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  46433. private static _registeredPlugins;
  46434. private static _getDefaultPlugin;
  46435. private static _getPluginForExtension;
  46436. private static _getPluginForDirectLoad;
  46437. private static _getPluginForFilename;
  46438. private static _getDirectLoad;
  46439. private static _loadData;
  46440. private static _getFileInfo;
  46441. /**
  46442. * Gets a plugin that can load the given extension
  46443. * @param extension defines the extension to load
  46444. * @returns a plugin or null if none works
  46445. */
  46446. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  46447. /**
  46448. * Gets a boolean indicating that the given extension can be loaded
  46449. * @param extension defines the extension to load
  46450. * @returns true if the extension is supported
  46451. */
  46452. static IsPluginForExtensionAvailable(extension: string): boolean;
  46453. /**
  46454. * Adds a new plugin to the list of registered plugins
  46455. * @param plugin defines the plugin to add
  46456. */
  46457. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  46458. /**
  46459. * Import meshes into a scene
  46460. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46461. * @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)
  46462. * @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)
  46463. * @param scene the instance of BABYLON.Scene to append to
  46464. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  46465. * @param onProgress a callback with a progress event for each file being loaded
  46466. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46467. * @param pluginExtension the extension used to determine the plugin
  46468. * @returns The loaded plugin
  46469. */
  46470. 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>;
  46471. /**
  46472. * Import meshes into a scene
  46473. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46474. * @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)
  46475. * @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)
  46476. * @param scene the instance of BABYLON.Scene to append to
  46477. * @param onProgress a callback with a progress event for each file being loaded
  46478. * @param pluginExtension the extension used to determine the plugin
  46479. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  46480. */
  46481. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  46482. meshes: AbstractMesh[];
  46483. particleSystems: IParticleSystem[];
  46484. skeletons: Skeleton[];
  46485. animationGroups: AnimationGroup[];
  46486. }>;
  46487. /**
  46488. * Load a scene
  46489. * @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)
  46490. * @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)
  46491. * @param engine is the instance of BABYLON.Engine to use to create the scene
  46492. * @param onSuccess a callback with the scene when import succeeds
  46493. * @param onProgress a callback with a progress event for each file being loaded
  46494. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46495. * @param pluginExtension the extension used to determine the plugin
  46496. * @returns The loaded plugin
  46497. */
  46498. 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>;
  46499. /**
  46500. * Load a scene
  46501. * @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)
  46502. * @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)
  46503. * @param engine is the instance of BABYLON.Engine to use to create the scene
  46504. * @param onProgress a callback with a progress event for each file being loaded
  46505. * @param pluginExtension the extension used to determine the plugin
  46506. * @returns The loaded scene
  46507. */
  46508. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  46509. /**
  46510. * Append a scene
  46511. * @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)
  46512. * @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)
  46513. * @param scene is the instance of BABYLON.Scene to append to
  46514. * @param onSuccess a callback with the scene when import succeeds
  46515. * @param onProgress a callback with a progress event for each file being loaded
  46516. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46517. * @param pluginExtension the extension used to determine the plugin
  46518. * @returns The loaded plugin
  46519. */
  46520. 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>;
  46521. /**
  46522. * Append a scene
  46523. * @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)
  46524. * @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)
  46525. * @param scene is the instance of BABYLON.Scene to append to
  46526. * @param onProgress a callback with a progress event for each file being loaded
  46527. * @param pluginExtension the extension used to determine the plugin
  46528. * @returns The given scene
  46529. */
  46530. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  46531. /**
  46532. * Load a scene into an asset container
  46533. * @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)
  46534. * @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)
  46535. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  46536. * @param onSuccess a callback with the scene when import succeeds
  46537. * @param onProgress a callback with a progress event for each file being loaded
  46538. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46539. * @param pluginExtension the extension used to determine the plugin
  46540. * @returns The loaded plugin
  46541. */
  46542. 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>;
  46543. /**
  46544. * Load a scene into an asset container
  46545. * @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)
  46546. * @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)
  46547. * @param scene is the instance of Scene to append to
  46548. * @param onProgress a callback with a progress event for each file being loaded
  46549. * @param pluginExtension the extension used to determine the plugin
  46550. * @returns The loaded asset container
  46551. */
  46552. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  46553. /**
  46554. * Import animations from a file into a scene
  46555. * @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)
  46556. * @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)
  46557. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  46558. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  46559. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  46560. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  46561. * @param onSuccess a callback with the scene when import succeeds
  46562. * @param onProgress a callback with a progress event for each file being loaded
  46563. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46564. */
  46565. static ImportAnimations(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): void;
  46566. /**
  46567. * Import animations from a file into a scene
  46568. * @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)
  46569. * @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)
  46570. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  46571. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  46572. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  46573. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  46574. * @param onSuccess a callback with the scene when import succeeds
  46575. * @param onProgress a callback with a progress event for each file being loaded
  46576. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46577. * @returns the updated scene with imported animations
  46578. */
  46579. static ImportAnimationsAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): Promise<Scene>;
  46580. }
  46581. }
  46582. declare module BABYLON {
  46583. /**
  46584. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  46585. */
  46586. export type MotionControllerHandedness = "none" | "left" | "right";
  46587. /**
  46588. * The type of components available in motion controllers.
  46589. * This is not the name of the component.
  46590. */
  46591. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  46592. /**
  46593. * The state of a controller component
  46594. */
  46595. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  46596. /**
  46597. * The schema of motion controller layout.
  46598. * No object will be initialized using this interface
  46599. * This is used just to define the profile.
  46600. */
  46601. export interface IMotionControllerLayout {
  46602. /**
  46603. * Path to load the assets. Usually relative to the base path
  46604. */
  46605. assetPath: string;
  46606. /**
  46607. * Available components (unsorted)
  46608. */
  46609. components: {
  46610. /**
  46611. * A map of component Ids
  46612. */
  46613. [componentId: string]: {
  46614. /**
  46615. * The type of input the component outputs
  46616. */
  46617. type: MotionControllerComponentType;
  46618. /**
  46619. * The indices of this component in the gamepad object
  46620. */
  46621. gamepadIndices: {
  46622. /**
  46623. * Index of button
  46624. */
  46625. button?: number;
  46626. /**
  46627. * If available, index of x-axis
  46628. */
  46629. xAxis?: number;
  46630. /**
  46631. * If available, index of y-axis
  46632. */
  46633. yAxis?: number;
  46634. };
  46635. /**
  46636. * The mesh's root node name
  46637. */
  46638. rootNodeName: string;
  46639. /**
  46640. * Animation definitions for this model
  46641. */
  46642. visualResponses: {
  46643. [stateKey: string]: {
  46644. /**
  46645. * What property will be animated
  46646. */
  46647. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  46648. /**
  46649. * What states influence this visual response
  46650. */
  46651. states: MotionControllerComponentStateType[];
  46652. /**
  46653. * Type of animation - movement or visibility
  46654. */
  46655. valueNodeProperty: "transform" | "visibility";
  46656. /**
  46657. * Base node name to move. Its position will be calculated according to the min and max nodes
  46658. */
  46659. valueNodeName?: string;
  46660. /**
  46661. * Minimum movement node
  46662. */
  46663. minNodeName?: string;
  46664. /**
  46665. * Max movement node
  46666. */
  46667. maxNodeName?: string;
  46668. };
  46669. };
  46670. /**
  46671. * If touch enabled, what is the name of node to display user feedback
  46672. */
  46673. touchPointNodeName?: string;
  46674. };
  46675. };
  46676. /**
  46677. * Is it xr standard mapping or not
  46678. */
  46679. gamepadMapping: "" | "xr-standard";
  46680. /**
  46681. * Base root node of this entire model
  46682. */
  46683. rootNodeName: string;
  46684. /**
  46685. * Defines the main button component id
  46686. */
  46687. selectComponentId: string;
  46688. }
  46689. /**
  46690. * A definition for the layout map in the input profile
  46691. */
  46692. export interface IMotionControllerLayoutMap {
  46693. /**
  46694. * Layouts with handedness type as a key
  46695. */
  46696. [handedness: string]: IMotionControllerLayout;
  46697. }
  46698. /**
  46699. * The XR Input profile schema
  46700. * Profiles can be found here:
  46701. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  46702. */
  46703. export interface IMotionControllerProfile {
  46704. /**
  46705. * fallback profiles for this profileId
  46706. */
  46707. fallbackProfileIds: string[];
  46708. /**
  46709. * The layout map, with handedness as key
  46710. */
  46711. layouts: IMotionControllerLayoutMap;
  46712. /**
  46713. * The id of this profile
  46714. * correlates to the profile(s) in the xrInput.profiles array
  46715. */
  46716. profileId: string;
  46717. }
  46718. /**
  46719. * A helper-interface for the 3 meshes needed for controller button animation
  46720. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  46721. */
  46722. export interface IMotionControllerButtonMeshMap {
  46723. /**
  46724. * the mesh that defines the pressed value mesh position.
  46725. * This is used to find the max-position of this button
  46726. */
  46727. pressedMesh: AbstractMesh;
  46728. /**
  46729. * the mesh that defines the unpressed value mesh position.
  46730. * This is used to find the min (or initial) position of this button
  46731. */
  46732. unpressedMesh: AbstractMesh;
  46733. /**
  46734. * The mesh that will be changed when value changes
  46735. */
  46736. valueMesh: AbstractMesh;
  46737. }
  46738. /**
  46739. * A helper-interface for the 3 meshes needed for controller axis animation.
  46740. * This will be expanded when touchpad animations are fully supported
  46741. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  46742. */
  46743. export interface IMotionControllerMeshMap {
  46744. /**
  46745. * the mesh that defines the maximum value mesh position.
  46746. */
  46747. maxMesh?: AbstractMesh;
  46748. /**
  46749. * the mesh that defines the minimum value mesh position.
  46750. */
  46751. minMesh?: AbstractMesh;
  46752. /**
  46753. * The mesh that will be changed when axis value changes
  46754. */
  46755. valueMesh: AbstractMesh;
  46756. }
  46757. /**
  46758. * The elements needed for change-detection of the gamepad objects in motion controllers
  46759. */
  46760. export interface IMinimalMotionControllerObject {
  46761. /**
  46762. * Available axes of this controller
  46763. */
  46764. axes: number[];
  46765. /**
  46766. * An array of available buttons
  46767. */
  46768. buttons: Array<{
  46769. /**
  46770. * Value of the button/trigger
  46771. */
  46772. value: number;
  46773. /**
  46774. * If the button/trigger is currently touched
  46775. */
  46776. touched: boolean;
  46777. /**
  46778. * If the button/trigger is currently pressed
  46779. */
  46780. pressed: boolean;
  46781. }>;
  46782. /**
  46783. * EXPERIMENTAL haptic support.
  46784. */
  46785. hapticActuators?: Array<{
  46786. pulse: (value: number, duration: number) => Promise<boolean>;
  46787. }>;
  46788. }
  46789. /**
  46790. * An Abstract Motion controller
  46791. * This class receives an xrInput and a profile layout and uses those to initialize the components
  46792. * Each component has an observable to check for changes in value and state
  46793. */
  46794. export abstract class WebXRAbstractMotionController implements IDisposable {
  46795. protected scene: Scene;
  46796. protected layout: IMotionControllerLayout;
  46797. /**
  46798. * The gamepad object correlating to this controller
  46799. */
  46800. gamepadObject: IMinimalMotionControllerObject;
  46801. /**
  46802. * handedness (left/right/none) of this controller
  46803. */
  46804. handedness: MotionControllerHandedness;
  46805. private _initComponent;
  46806. private _modelReady;
  46807. /**
  46808. * A map of components (WebXRControllerComponent) in this motion controller
  46809. * Components have a ComponentType and can also have both button and axis definitions
  46810. */
  46811. readonly components: {
  46812. [id: string]: WebXRControllerComponent;
  46813. };
  46814. /**
  46815. * Disable the model's animation. Can be set at any time.
  46816. */
  46817. disableAnimation: boolean;
  46818. /**
  46819. * Observers registered here will be triggered when the model of this controller is done loading
  46820. */
  46821. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  46822. /**
  46823. * The profile id of this motion controller
  46824. */
  46825. abstract profileId: string;
  46826. /**
  46827. * The root mesh of the model. It is null if the model was not yet initialized
  46828. */
  46829. rootMesh: Nullable<AbstractMesh>;
  46830. /**
  46831. * constructs a new abstract motion controller
  46832. * @param scene the scene to which the model of the controller will be added
  46833. * @param layout The profile layout to load
  46834. * @param gamepadObject The gamepad object correlating to this controller
  46835. * @param handedness handedness (left/right/none) of this controller
  46836. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  46837. */
  46838. constructor(scene: Scene, layout: IMotionControllerLayout,
  46839. /**
  46840. * The gamepad object correlating to this controller
  46841. */
  46842. gamepadObject: IMinimalMotionControllerObject,
  46843. /**
  46844. * handedness (left/right/none) of this controller
  46845. */
  46846. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  46847. /**
  46848. * Dispose this controller, the model mesh and all its components
  46849. */
  46850. dispose(): void;
  46851. /**
  46852. * Returns all components of specific type
  46853. * @param type the type to search for
  46854. * @return an array of components with this type
  46855. */
  46856. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  46857. /**
  46858. * get a component based an its component id as defined in layout.components
  46859. * @param id the id of the component
  46860. * @returns the component correlates to the id or undefined if not found
  46861. */
  46862. getComponent(id: string): WebXRControllerComponent;
  46863. /**
  46864. * Get the list of components available in this motion controller
  46865. * @returns an array of strings correlating to available components
  46866. */
  46867. getComponentIds(): string[];
  46868. /**
  46869. * Get the first component of specific type
  46870. * @param type type of component to find
  46871. * @return a controller component or null if not found
  46872. */
  46873. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  46874. /**
  46875. * Get the main (Select) component of this controller as defined in the layout
  46876. * @returns the main component of this controller
  46877. */
  46878. getMainComponent(): WebXRControllerComponent;
  46879. /**
  46880. * Loads the model correlating to this controller
  46881. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  46882. * @returns A promise fulfilled with the result of the model loading
  46883. */
  46884. loadModel(): Promise<boolean>;
  46885. /**
  46886. * Update this model using the current XRFrame
  46887. * @param xrFrame the current xr frame to use and update the model
  46888. */
  46889. updateFromXRFrame(xrFrame: XRFrame): void;
  46890. /**
  46891. * Backwards compatibility due to a deeply-integrated typo
  46892. */
  46893. get handness(): XREye;
  46894. /**
  46895. * Pulse (vibrate) this controller
  46896. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  46897. * Consecutive calls to this function will cancel the last pulse call
  46898. *
  46899. * @param value the strength of the pulse in 0.0...1.0 range
  46900. * @param duration Duration of the pulse in milliseconds
  46901. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  46902. * @returns a promise that will send true when the pulse has ended and false if the device doesn't support pulse or an error accrued
  46903. */
  46904. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  46905. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  46906. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  46907. /**
  46908. * Moves the axis on the controller mesh based on its current state
  46909. * @param axis the index of the axis
  46910. * @param axisValue the value of the axis which determines the meshes new position
  46911. * @hidden
  46912. */
  46913. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  46914. /**
  46915. * Update the model itself with the current frame data
  46916. * @param xrFrame the frame to use for updating the model mesh
  46917. */
  46918. protected updateModel(xrFrame: XRFrame): void;
  46919. /**
  46920. * Get the filename and path for this controller's model
  46921. * @returns a map of filename and path
  46922. */
  46923. protected abstract _getFilenameAndPath(): {
  46924. filename: string;
  46925. path: string;
  46926. };
  46927. /**
  46928. * This function is called before the mesh is loaded. It checks for loading constraints.
  46929. * For example, this function can check if the GLB loader is available
  46930. * If this function returns false, the generic controller will be loaded instead
  46931. * @returns Is the client ready to load the mesh
  46932. */
  46933. protected abstract _getModelLoadingConstraints(): boolean;
  46934. /**
  46935. * This function will be called after the model was successfully loaded and can be used
  46936. * for mesh transformations before it is available for the user
  46937. * @param meshes the loaded meshes
  46938. */
  46939. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  46940. /**
  46941. * Set the root mesh for this controller. Important for the WebXR controller class
  46942. * @param meshes the loaded meshes
  46943. */
  46944. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  46945. /**
  46946. * A function executed each frame that updates the mesh (if needed)
  46947. * @param xrFrame the current xrFrame
  46948. */
  46949. protected abstract _updateModel(xrFrame: XRFrame): void;
  46950. private _getGenericFilenameAndPath;
  46951. private _getGenericParentMesh;
  46952. }
  46953. }
  46954. declare module BABYLON {
  46955. /**
  46956. * A generic trigger-only motion controller for WebXR
  46957. */
  46958. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  46959. /**
  46960. * Static version of the profile id of this controller
  46961. */
  46962. static ProfileId: string;
  46963. profileId: string;
  46964. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  46965. protected _getFilenameAndPath(): {
  46966. filename: string;
  46967. path: string;
  46968. };
  46969. protected _getModelLoadingConstraints(): boolean;
  46970. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  46971. protected _setRootMesh(meshes: AbstractMesh[]): void;
  46972. protected _updateModel(): void;
  46973. }
  46974. }
  46975. declare module BABYLON {
  46976. /**
  46977. * Class containing static functions to help procedurally build meshes
  46978. */
  46979. export class SphereBuilder {
  46980. /**
  46981. * Creates a sphere mesh
  46982. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  46983. * * 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`)
  46984. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  46985. * * 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
  46986. * * 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)
  46987. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46988. * * 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
  46989. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46990. * @param name defines the name of the mesh
  46991. * @param options defines the options used to create the mesh
  46992. * @param scene defines the hosting scene
  46993. * @returns the sphere mesh
  46994. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  46995. */
  46996. static CreateSphere(name: string, options: {
  46997. segments?: number;
  46998. diameter?: number;
  46999. diameterX?: number;
  47000. diameterY?: number;
  47001. diameterZ?: number;
  47002. arc?: number;
  47003. slice?: number;
  47004. sideOrientation?: number;
  47005. frontUVs?: Vector4;
  47006. backUVs?: Vector4;
  47007. updatable?: boolean;
  47008. }, scene?: Nullable<Scene>): Mesh;
  47009. }
  47010. }
  47011. declare module BABYLON {
  47012. /**
  47013. * A profiled motion controller has its profile loaded from an online repository.
  47014. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  47015. */
  47016. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  47017. private _repositoryUrl;
  47018. private _buttonMeshMapping;
  47019. private _touchDots;
  47020. /**
  47021. * The profile ID of this controller. Will be populated when the controller initializes.
  47022. */
  47023. profileId: string;
  47024. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  47025. dispose(): void;
  47026. protected _getFilenameAndPath(): {
  47027. filename: string;
  47028. path: string;
  47029. };
  47030. protected _getModelLoadingConstraints(): boolean;
  47031. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  47032. protected _setRootMesh(meshes: AbstractMesh[]): void;
  47033. protected _updateModel(_xrFrame: XRFrame): void;
  47034. }
  47035. }
  47036. declare module BABYLON {
  47037. /**
  47038. * A construction function type to create a new controller based on an xrInput object
  47039. */
  47040. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  47041. /**
  47042. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  47043. *
  47044. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  47045. * it should be replaced with auto-loaded controllers.
  47046. *
  47047. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  47048. */
  47049. export class WebXRMotionControllerManager {
  47050. private static _AvailableControllers;
  47051. private static _Fallbacks;
  47052. private static _ProfileLoadingPromises;
  47053. private static _ProfilesList;
  47054. /**
  47055. * The base URL of the online controller repository. Can be changed at any time.
  47056. */
  47057. static BaseRepositoryUrl: string;
  47058. /**
  47059. * Which repository gets priority - local or online
  47060. */
  47061. static PrioritizeOnlineRepository: boolean;
  47062. /**
  47063. * Use the online repository, or use only locally-defined controllers
  47064. */
  47065. static UseOnlineRepository: boolean;
  47066. /**
  47067. * Clear the cache used for profile loading and reload when requested again
  47068. */
  47069. static ClearProfilesCache(): void;
  47070. /**
  47071. * Register the default fallbacks.
  47072. * This function is called automatically when this file is imported.
  47073. */
  47074. static DefaultFallbacks(): void;
  47075. /**
  47076. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  47077. * @param profileId the profile to which a fallback needs to be found
  47078. * @return an array with corresponding fallback profiles
  47079. */
  47080. static FindFallbackWithProfileId(profileId: string): string[];
  47081. /**
  47082. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  47083. * The order of search:
  47084. *
  47085. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  47086. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  47087. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  47088. * 4) return the generic trigger controller if none were found
  47089. *
  47090. * @param xrInput the xrInput to which a new controller is initialized
  47091. * @param scene the scene to which the model will be added
  47092. * @param forceProfile force a certain profile for this controller
  47093. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  47094. */
  47095. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  47096. /**
  47097. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  47098. *
  47099. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  47100. *
  47101. * @param type the profile type to register
  47102. * @param constructFunction the function to be called when loading this profile
  47103. */
  47104. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  47105. /**
  47106. * Register a fallback to a specific profile.
  47107. * @param profileId the profileId that will receive the fallbacks
  47108. * @param fallbacks A list of fallback profiles
  47109. */
  47110. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  47111. /**
  47112. * Will update the list of profiles available in the repository
  47113. * @return a promise that resolves to a map of profiles available online
  47114. */
  47115. static UpdateProfilesList(): Promise<{
  47116. [profile: string]: string;
  47117. }>;
  47118. private static _LoadProfileFromRepository;
  47119. private static _LoadProfilesFromAvailableControllers;
  47120. }
  47121. }
  47122. declare module BABYLON {
  47123. /**
  47124. * Configuration options for the WebXR controller creation
  47125. */
  47126. export interface IWebXRControllerOptions {
  47127. /**
  47128. * Should the controller mesh be animated when a user interacts with it
  47129. * The pressed buttons / thumbstick and touchpad animations will be disabled
  47130. */
  47131. disableMotionControllerAnimation?: boolean;
  47132. /**
  47133. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  47134. */
  47135. doNotLoadControllerMesh?: boolean;
  47136. /**
  47137. * Force a specific controller type for this controller.
  47138. * This can be used when creating your own profile or when testing different controllers
  47139. */
  47140. forceControllerProfile?: string;
  47141. /**
  47142. * Defines a rendering group ID for meshes that will be loaded.
  47143. * This is for the default controllers only.
  47144. */
  47145. renderingGroupId?: number;
  47146. }
  47147. /**
  47148. * Represents an XR controller
  47149. */
  47150. export class WebXRInputSource {
  47151. private _scene;
  47152. /** The underlying input source for the controller */
  47153. inputSource: XRInputSource;
  47154. private _options;
  47155. private _tmpVector;
  47156. private _uniqueId;
  47157. /**
  47158. * 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
  47159. */
  47160. grip?: AbstractMesh;
  47161. /**
  47162. * If available, this is the gamepad object related to this controller.
  47163. * Using this object it is possible to get click events and trackpad changes of the
  47164. * webxr controller that is currently being used.
  47165. */
  47166. motionController?: WebXRAbstractMotionController;
  47167. /**
  47168. * Event that fires when the controller is removed/disposed.
  47169. * The object provided as event data is this controller, after associated assets were disposed.
  47170. * uniqueId is still available.
  47171. */
  47172. onDisposeObservable: Observable<WebXRInputSource>;
  47173. /**
  47174. * Will be triggered when the mesh associated with the motion controller is done loading.
  47175. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  47176. * A shortened version of controller -> motion controller -> on mesh loaded.
  47177. */
  47178. onMeshLoadedObservable: Observable<AbstractMesh>;
  47179. /**
  47180. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  47181. */
  47182. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  47183. /**
  47184. * Pointer which can be used to select objects or attach a visible laser to
  47185. */
  47186. pointer: AbstractMesh;
  47187. /**
  47188. * Creates the controller
  47189. * @see https://doc.babylonjs.com/how_to/webxr
  47190. * @param _scene the scene which the controller should be associated to
  47191. * @param inputSource the underlying input source for the controller
  47192. * @param _options options for this controller creation
  47193. */
  47194. constructor(_scene: Scene,
  47195. /** The underlying input source for the controller */
  47196. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  47197. /**
  47198. * Get this controllers unique id
  47199. */
  47200. get uniqueId(): string;
  47201. /**
  47202. * Disposes of the object
  47203. */
  47204. dispose(): void;
  47205. /**
  47206. * Gets a world space ray coming from the pointer or grip
  47207. * @param result the resulting ray
  47208. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  47209. */
  47210. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  47211. /**
  47212. * Updates the controller pose based on the given XRFrame
  47213. * @param xrFrame xr frame to update the pose with
  47214. * @param referenceSpace reference space to use
  47215. */
  47216. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  47217. }
  47218. }
  47219. declare module BABYLON {
  47220. /**
  47221. * The schema for initialization options of the XR Input class
  47222. */
  47223. export interface IWebXRInputOptions {
  47224. /**
  47225. * If set to true no model will be automatically loaded
  47226. */
  47227. doNotLoadControllerMeshes?: boolean;
  47228. /**
  47229. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  47230. * If not found, the xr input profile data will be used.
  47231. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  47232. */
  47233. forceInputProfile?: string;
  47234. /**
  47235. * Do not send a request to the controller repository to load the profile.
  47236. *
  47237. * Instead, use the controllers available in babylon itself.
  47238. */
  47239. disableOnlineControllerRepository?: boolean;
  47240. /**
  47241. * A custom URL for the controllers repository
  47242. */
  47243. customControllersRepositoryURL?: string;
  47244. /**
  47245. * Should the controller model's components not move according to the user input
  47246. */
  47247. disableControllerAnimation?: boolean;
  47248. /**
  47249. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  47250. */
  47251. controllerOptions?: IWebXRControllerOptions;
  47252. }
  47253. /**
  47254. * XR input used to track XR inputs such as controllers/rays
  47255. */
  47256. export class WebXRInput implements IDisposable {
  47257. /**
  47258. * the xr session manager for this session
  47259. */
  47260. xrSessionManager: WebXRSessionManager;
  47261. /**
  47262. * the WebXR camera for this session. Mainly used for teleportation
  47263. */
  47264. xrCamera: WebXRCamera;
  47265. private readonly options;
  47266. /**
  47267. * XR controllers being tracked
  47268. */
  47269. controllers: Array<WebXRInputSource>;
  47270. private _frameObserver;
  47271. private _sessionEndedObserver;
  47272. private _sessionInitObserver;
  47273. /**
  47274. * Event when a controller has been connected/added
  47275. */
  47276. onControllerAddedObservable: Observable<WebXRInputSource>;
  47277. /**
  47278. * Event when a controller has been removed/disconnected
  47279. */
  47280. onControllerRemovedObservable: Observable<WebXRInputSource>;
  47281. /**
  47282. * Initializes the WebXRInput
  47283. * @param xrSessionManager the xr session manager for this session
  47284. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  47285. * @param options = initialization options for this xr input
  47286. */
  47287. constructor(
  47288. /**
  47289. * the xr session manager for this session
  47290. */
  47291. xrSessionManager: WebXRSessionManager,
  47292. /**
  47293. * the WebXR camera for this session. Mainly used for teleportation
  47294. */
  47295. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  47296. private _onInputSourcesChange;
  47297. private _addAndRemoveControllers;
  47298. /**
  47299. * Disposes of the object
  47300. */
  47301. dispose(): void;
  47302. }
  47303. }
  47304. declare module BABYLON {
  47305. /**
  47306. * This is the base class for all WebXR features.
  47307. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  47308. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  47309. */
  47310. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  47311. protected _xrSessionManager: WebXRSessionManager;
  47312. private _attached;
  47313. private _removeOnDetach;
  47314. /**
  47315. * Should auto-attach be disabled?
  47316. */
  47317. disableAutoAttach: boolean;
  47318. /**
  47319. * Construct a new (abstract) WebXR feature
  47320. * @param _xrSessionManager the xr session manager for this feature
  47321. */
  47322. constructor(_xrSessionManager: WebXRSessionManager);
  47323. /**
  47324. * Is this feature attached
  47325. */
  47326. get attached(): boolean;
  47327. /**
  47328. * attach this feature
  47329. *
  47330. * @param force should attachment be forced (even when already attached)
  47331. * @returns true if successful, false is failed or already attached
  47332. */
  47333. attach(force?: boolean): boolean;
  47334. /**
  47335. * detach this feature.
  47336. *
  47337. * @returns true if successful, false if failed or already detached
  47338. */
  47339. detach(): boolean;
  47340. /**
  47341. * Dispose this feature and all of the resources attached
  47342. */
  47343. dispose(): void;
  47344. /**
  47345. * This is used to register callbacks that will automatically be removed when detach is called.
  47346. * @param observable the observable to which the observer will be attached
  47347. * @param callback the callback to register
  47348. */
  47349. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  47350. /**
  47351. * Code in this function will be executed on each xrFrame received from the browser.
  47352. * This function will not execute after the feature is detached.
  47353. * @param _xrFrame the current frame
  47354. */
  47355. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  47356. }
  47357. }
  47358. declare module BABYLON {
  47359. /**
  47360. * Renders a layer on top of an existing scene
  47361. */
  47362. export class UtilityLayerRenderer implements IDisposable {
  47363. /** the original scene that will be rendered on top of */
  47364. originalScene: Scene;
  47365. private _pointerCaptures;
  47366. private _lastPointerEvents;
  47367. private static _DefaultUtilityLayer;
  47368. private static _DefaultKeepDepthUtilityLayer;
  47369. private _sharedGizmoLight;
  47370. private _renderCamera;
  47371. /**
  47372. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  47373. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  47374. * @returns the camera that is used when rendering the utility layer
  47375. */
  47376. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  47377. /**
  47378. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  47379. * @param cam the camera that should be used when rendering the utility layer
  47380. */
  47381. setRenderCamera(cam: Nullable<Camera>): void;
  47382. /**
  47383. * @hidden
  47384. * Light which used by gizmos to get light shading
  47385. */
  47386. _getSharedGizmoLight(): HemisphericLight;
  47387. /**
  47388. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  47389. */
  47390. pickUtilitySceneFirst: boolean;
  47391. /**
  47392. * 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)
  47393. */
  47394. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  47395. /**
  47396. * 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)
  47397. */
  47398. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  47399. /**
  47400. * The scene that is rendered on top of the original scene
  47401. */
  47402. utilityLayerScene: Scene;
  47403. /**
  47404. * If the utility layer should automatically be rendered on top of existing scene
  47405. */
  47406. shouldRender: boolean;
  47407. /**
  47408. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  47409. */
  47410. onlyCheckPointerDownEvents: boolean;
  47411. /**
  47412. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  47413. */
  47414. processAllEvents: boolean;
  47415. /**
  47416. * Observable raised when the pointer move from the utility layer scene to the main scene
  47417. */
  47418. onPointerOutObservable: Observable<number>;
  47419. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  47420. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  47421. private _afterRenderObserver;
  47422. private _sceneDisposeObserver;
  47423. private _originalPointerObserver;
  47424. /**
  47425. * Instantiates a UtilityLayerRenderer
  47426. * @param originalScene the original scene that will be rendered on top of
  47427. * @param handleEvents boolean indicating if the utility layer should handle events
  47428. */
  47429. constructor(
  47430. /** the original scene that will be rendered on top of */
  47431. originalScene: Scene, handleEvents?: boolean);
  47432. private _notifyObservers;
  47433. /**
  47434. * Renders the utility layers scene on top of the original scene
  47435. */
  47436. render(): void;
  47437. /**
  47438. * Disposes of the renderer
  47439. */
  47440. dispose(): void;
  47441. private _updateCamera;
  47442. }
  47443. }
  47444. declare module BABYLON {
  47445. /**
  47446. * Options interface for the pointer selection module
  47447. */
  47448. export interface IWebXRControllerPointerSelectionOptions {
  47449. /**
  47450. * if provided, this scene will be used to render meshes.
  47451. */
  47452. customUtilityLayerScene?: Scene;
  47453. /**
  47454. * Disable the pointer up event when the xr controller in screen and gaze mode is disposed (meaning - when the user removed the finger from the screen)
  47455. * If not disabled, the last picked point will be used to execute a pointer up event
  47456. * If disabled, pointer up event will be triggered right after the pointer down event.
  47457. * Used in screen and gaze target ray mode only
  47458. */
  47459. disablePointerUpOnTouchOut: boolean;
  47460. /**
  47461. * For gaze mode (time to select instead of press)
  47462. */
  47463. forceGazeMode: boolean;
  47464. /**
  47465. * Factor to be applied to the pointer-moved function in the gaze mode. How sensitive should the gaze mode be when checking if the pointer moved
  47466. * to start a new countdown to the pointer down event.
  47467. * Defaults to 1.
  47468. */
  47469. gazeModePointerMovedFactor?: number;
  47470. /**
  47471. * Different button type to use instead of the main component
  47472. */
  47473. overrideButtonId?: string;
  47474. /**
  47475. * use this rendering group id for the meshes (optional)
  47476. */
  47477. renderingGroupId?: number;
  47478. /**
  47479. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  47480. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  47481. * 3000 means 3 seconds between pointing at something and selecting it
  47482. */
  47483. timeToSelect?: number;
  47484. /**
  47485. * Should meshes created here be added to a utility layer or the main scene
  47486. */
  47487. useUtilityLayer?: boolean;
  47488. /**
  47489. * the xr input to use with this pointer selection
  47490. */
  47491. xrInput: WebXRInput;
  47492. }
  47493. /**
  47494. * A module that will enable pointer selection for motion controllers of XR Input Sources
  47495. */
  47496. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  47497. private readonly _options;
  47498. private static _idCounter;
  47499. private _attachController;
  47500. private _controllers;
  47501. private _scene;
  47502. private _tmpVectorForPickCompare;
  47503. /**
  47504. * The module's name
  47505. */
  47506. static readonly Name: string;
  47507. /**
  47508. * The (Babylon) version of this module.
  47509. * This is an integer representing the implementation version.
  47510. * This number does not correspond to the WebXR specs version
  47511. */
  47512. static readonly Version: number;
  47513. /**
  47514. * Disable lighting on the laser pointer (so it will always be visible)
  47515. */
  47516. disablePointerLighting: boolean;
  47517. /**
  47518. * Disable lighting on the selection mesh (so it will always be visible)
  47519. */
  47520. disableSelectionMeshLighting: boolean;
  47521. /**
  47522. * Should the laser pointer be displayed
  47523. */
  47524. displayLaserPointer: boolean;
  47525. /**
  47526. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  47527. */
  47528. displaySelectionMesh: boolean;
  47529. /**
  47530. * This color will be set to the laser pointer when selection is triggered
  47531. */
  47532. laserPointerPickedColor: Color3;
  47533. /**
  47534. * Default color of the laser pointer
  47535. */
  47536. lasterPointerDefaultColor: Color3;
  47537. /**
  47538. * default color of the selection ring
  47539. */
  47540. selectionMeshDefaultColor: Color3;
  47541. /**
  47542. * This color will be applied to the selection ring when selection is triggered
  47543. */
  47544. selectionMeshPickedColor: Color3;
  47545. /**
  47546. * Optional filter to be used for ray selection. This predicate shares behavior with
  47547. * scene.pointerMovePredicate which takes priority if it is also assigned.
  47548. */
  47549. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  47550. /**
  47551. * constructs a new background remover module
  47552. * @param _xrSessionManager the session manager for this module
  47553. * @param _options read-only options to be used in this module
  47554. */
  47555. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  47556. /**
  47557. * attach this feature
  47558. * Will usually be called by the features manager
  47559. *
  47560. * @returns true if successful.
  47561. */
  47562. attach(): boolean;
  47563. /**
  47564. * detach this feature.
  47565. * Will usually be called by the features manager
  47566. *
  47567. * @returns true if successful.
  47568. */
  47569. detach(): boolean;
  47570. /**
  47571. * Will get the mesh under a specific pointer.
  47572. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  47573. * @param controllerId the controllerId to check
  47574. * @returns The mesh under pointer or null if no mesh is under the pointer
  47575. */
  47576. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  47577. /**
  47578. * Get the xr controller that correlates to the pointer id in the pointer event
  47579. *
  47580. * @param id the pointer id to search for
  47581. * @returns the controller that correlates to this id or null if not found
  47582. */
  47583. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  47584. protected _onXRFrame(_xrFrame: XRFrame): void;
  47585. private _attachGazeMode;
  47586. private _attachScreenRayMode;
  47587. private _attachTrackedPointerRayMode;
  47588. private _convertNormalToDirectionOfRay;
  47589. private _detachController;
  47590. private _generateNewMeshPair;
  47591. private _pickingMoved;
  47592. private _updatePointerDistance;
  47593. }
  47594. }
  47595. declare module BABYLON {
  47596. /**
  47597. * Button which can be used to enter a different mode of XR
  47598. */
  47599. export class WebXREnterExitUIButton {
  47600. /** button element */
  47601. element: HTMLElement;
  47602. /** XR initialization options for the button */
  47603. sessionMode: XRSessionMode;
  47604. /** Reference space type */
  47605. referenceSpaceType: XRReferenceSpaceType;
  47606. /**
  47607. * Creates a WebXREnterExitUIButton
  47608. * @param element button element
  47609. * @param sessionMode XR initialization session mode
  47610. * @param referenceSpaceType the type of reference space to be used
  47611. */
  47612. constructor(
  47613. /** button element */
  47614. element: HTMLElement,
  47615. /** XR initialization options for the button */
  47616. sessionMode: XRSessionMode,
  47617. /** Reference space type */
  47618. referenceSpaceType: XRReferenceSpaceType);
  47619. /**
  47620. * Extendable function which can be used to update the button's visuals when the state changes
  47621. * @param activeButton the current active button in the UI
  47622. */
  47623. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  47624. }
  47625. /**
  47626. * Options to create the webXR UI
  47627. */
  47628. export class WebXREnterExitUIOptions {
  47629. /**
  47630. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  47631. */
  47632. customButtons?: Array<WebXREnterExitUIButton>;
  47633. /**
  47634. * A reference space type to use when creating the default button.
  47635. * Default is local-floor
  47636. */
  47637. referenceSpaceType?: XRReferenceSpaceType;
  47638. /**
  47639. * Context to enter xr with
  47640. */
  47641. renderTarget?: Nullable<WebXRRenderTarget>;
  47642. /**
  47643. * A session mode to use when creating the default button.
  47644. * Default is immersive-vr
  47645. */
  47646. sessionMode?: XRSessionMode;
  47647. /**
  47648. * A list of optional features to init the session with
  47649. */
  47650. optionalFeatures?: string[];
  47651. }
  47652. /**
  47653. * UI to allow the user to enter/exit XR mode
  47654. */
  47655. export class WebXREnterExitUI implements IDisposable {
  47656. private scene;
  47657. /** version of the options passed to this UI */
  47658. options: WebXREnterExitUIOptions;
  47659. private _activeButton;
  47660. private _buttons;
  47661. private _overlay;
  47662. /**
  47663. * Fired every time the active button is changed.
  47664. *
  47665. * When xr is entered via a button that launches xr that button will be the callback parameter
  47666. *
  47667. * When exiting xr the callback parameter will be null)
  47668. */
  47669. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  47670. /**
  47671. *
  47672. * @param scene babylon scene object to use
  47673. * @param options (read-only) version of the options passed to this UI
  47674. */
  47675. private constructor();
  47676. /**
  47677. * Creates UI to allow the user to enter/exit XR mode
  47678. * @param scene the scene to add the ui to
  47679. * @param helper the xr experience helper to enter/exit xr with
  47680. * @param options options to configure the UI
  47681. * @returns the created ui
  47682. */
  47683. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  47684. /**
  47685. * Disposes of the XR UI component
  47686. */
  47687. dispose(): void;
  47688. private _updateButtons;
  47689. }
  47690. }
  47691. declare module BABYLON {
  47692. /**
  47693. * Class containing static functions to help procedurally build meshes
  47694. */
  47695. export class LinesBuilder {
  47696. /**
  47697. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  47698. * * 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
  47699. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  47700. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  47701. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  47702. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  47703. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  47704. * * 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
  47705. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  47706. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47707. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  47708. * @param name defines the name of the new line system
  47709. * @param options defines the options used to create the line system
  47710. * @param scene defines the hosting scene
  47711. * @returns a new line system mesh
  47712. */
  47713. static CreateLineSystem(name: string, options: {
  47714. lines: Vector3[][];
  47715. updatable?: boolean;
  47716. instance?: Nullable<LinesMesh>;
  47717. colors?: Nullable<Color4[][]>;
  47718. useVertexAlpha?: boolean;
  47719. }, scene: Nullable<Scene>): LinesMesh;
  47720. /**
  47721. * Creates a line mesh
  47722. * 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
  47723. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  47724. * * The parameter `points` is an array successive Vector3
  47725. * * 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
  47726. * * The optional parameter `colors` is an array of successive Color4, one per line point
  47727. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  47728. * * When updating an instance, remember that only point positions can change, not the number of points
  47729. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47730. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  47731. * @param name defines the name of the new line system
  47732. * @param options defines the options used to create the line system
  47733. * @param scene defines the hosting scene
  47734. * @returns a new line mesh
  47735. */
  47736. static CreateLines(name: string, options: {
  47737. points: Vector3[];
  47738. updatable?: boolean;
  47739. instance?: Nullable<LinesMesh>;
  47740. colors?: Color4[];
  47741. useVertexAlpha?: boolean;
  47742. }, scene?: Nullable<Scene>): LinesMesh;
  47743. /**
  47744. * Creates a dashed line mesh
  47745. * * 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
  47746. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  47747. * * The parameter `points` is an array successive Vector3
  47748. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  47749. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  47750. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  47751. * * 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
  47752. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  47753. * * When updating an instance, remember that only point positions can change, not the number of points
  47754. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47755. * @param name defines the name of the mesh
  47756. * @param options defines the options used to create the mesh
  47757. * @param scene defines the hosting scene
  47758. * @returns the dashed line mesh
  47759. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  47760. */
  47761. static CreateDashedLines(name: string, options: {
  47762. points: Vector3[];
  47763. dashSize?: number;
  47764. gapSize?: number;
  47765. dashNb?: number;
  47766. updatable?: boolean;
  47767. instance?: LinesMesh;
  47768. useVertexAlpha?: boolean;
  47769. }, scene?: Nullable<Scene>): LinesMesh;
  47770. }
  47771. }
  47772. declare module BABYLON {
  47773. /**
  47774. * The options container for the teleportation module
  47775. */
  47776. export interface IWebXRTeleportationOptions {
  47777. /**
  47778. * if provided, this scene will be used to render meshes.
  47779. */
  47780. customUtilityLayerScene?: Scene;
  47781. /**
  47782. * Values to configure the default target mesh
  47783. */
  47784. defaultTargetMeshOptions?: {
  47785. /**
  47786. * Fill color of the teleportation area
  47787. */
  47788. teleportationFillColor?: string;
  47789. /**
  47790. * Border color for the teleportation area
  47791. */
  47792. teleportationBorderColor?: string;
  47793. /**
  47794. * Disable the mesh's animation sequence
  47795. */
  47796. disableAnimation?: boolean;
  47797. /**
  47798. * Disable lighting on the material or the ring and arrow
  47799. */
  47800. disableLighting?: boolean;
  47801. /**
  47802. * Override the default material of the torus and arrow
  47803. */
  47804. torusArrowMaterial?: Material;
  47805. };
  47806. /**
  47807. * A list of meshes to use as floor meshes.
  47808. * Meshes can be added and removed after initializing the feature using the
  47809. * addFloorMesh and removeFloorMesh functions
  47810. * If empty, rotation will still work
  47811. */
  47812. floorMeshes?: AbstractMesh[];
  47813. /**
  47814. * use this rendering group id for the meshes (optional)
  47815. */
  47816. renderingGroupId?: number;
  47817. /**
  47818. * Should teleportation move only to snap points
  47819. */
  47820. snapPointsOnly?: boolean;
  47821. /**
  47822. * An array of points to which the teleportation will snap to.
  47823. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  47824. */
  47825. snapPositions?: Vector3[];
  47826. /**
  47827. * How close should the teleportation ray be in order to snap to position.
  47828. * Default to 0.8 units (meters)
  47829. */
  47830. snapToPositionRadius?: number;
  47831. /**
  47832. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  47833. * If you want to support rotation, make sure your mesh has a direction indicator.
  47834. *
  47835. * When left untouched, the default mesh will be initialized.
  47836. */
  47837. teleportationTargetMesh?: AbstractMesh;
  47838. /**
  47839. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  47840. */
  47841. timeToTeleport?: number;
  47842. /**
  47843. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  47844. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  47845. */
  47846. useMainComponentOnly?: boolean;
  47847. /**
  47848. * Should meshes created here be added to a utility layer or the main scene
  47849. */
  47850. useUtilityLayer?: boolean;
  47851. /**
  47852. * Babylon XR Input class for controller
  47853. */
  47854. xrInput: WebXRInput;
  47855. }
  47856. /**
  47857. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  47858. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  47859. * the input of the attached controllers.
  47860. */
  47861. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  47862. private _options;
  47863. private _controllers;
  47864. private _currentTeleportationControllerId;
  47865. private _floorMeshes;
  47866. private _quadraticBezierCurve;
  47867. private _selectionFeature;
  47868. private _snapToPositions;
  47869. private _snappedToPoint;
  47870. private _teleportationRingMaterial?;
  47871. private _tmpRay;
  47872. private _tmpVector;
  47873. /**
  47874. * The module's name
  47875. */
  47876. static readonly Name: string;
  47877. /**
  47878. * The (Babylon) version of this module.
  47879. * This is an integer representing the implementation version.
  47880. * This number does not correspond to the webxr specs version
  47881. */
  47882. static readonly Version: number;
  47883. /**
  47884. * Is movement backwards enabled
  47885. */
  47886. backwardsMovementEnabled: boolean;
  47887. /**
  47888. * Distance to travel when moving backwards
  47889. */
  47890. backwardsTeleportationDistance: number;
  47891. /**
  47892. * The distance from the user to the inspection point in the direction of the controller
  47893. * A higher number will allow the user to move further
  47894. * defaults to 5 (meters, in xr units)
  47895. */
  47896. parabolicCheckRadius: number;
  47897. /**
  47898. * Should the module support parabolic ray on top of direct ray
  47899. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  47900. * Very helpful when moving between floors / different heights
  47901. */
  47902. parabolicRayEnabled: boolean;
  47903. /**
  47904. * How much rotation should be applied when rotating right and left
  47905. */
  47906. rotationAngle: number;
  47907. /**
  47908. * Is rotation enabled when moving forward?
  47909. * Disabling this feature will prevent the user from deciding the direction when teleporting
  47910. */
  47911. rotationEnabled: boolean;
  47912. /**
  47913. * constructs a new anchor system
  47914. * @param _xrSessionManager an instance of WebXRSessionManager
  47915. * @param _options configuration object for this feature
  47916. */
  47917. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  47918. /**
  47919. * Get the snapPointsOnly flag
  47920. */
  47921. get snapPointsOnly(): boolean;
  47922. /**
  47923. * Sets the snapPointsOnly flag
  47924. * @param snapToPoints should teleportation be exclusively to snap points
  47925. */
  47926. set snapPointsOnly(snapToPoints: boolean);
  47927. /**
  47928. * Add a new mesh to the floor meshes array
  47929. * @param mesh the mesh to use as floor mesh
  47930. */
  47931. addFloorMesh(mesh: AbstractMesh): void;
  47932. /**
  47933. * Add a new snap-to point to fix teleportation to this position
  47934. * @param newSnapPoint The new Snap-To point
  47935. */
  47936. addSnapPoint(newSnapPoint: Vector3): void;
  47937. attach(): boolean;
  47938. detach(): boolean;
  47939. dispose(): void;
  47940. /**
  47941. * Remove a mesh from the floor meshes array
  47942. * @param mesh the mesh to remove
  47943. */
  47944. removeFloorMesh(mesh: AbstractMesh): void;
  47945. /**
  47946. * Remove a mesh from the floor meshes array using its name
  47947. * @param name the mesh name to remove
  47948. */
  47949. removeFloorMeshByName(name: string): void;
  47950. /**
  47951. * This function will iterate through the array, searching for this point or equal to it. It will then remove it from the snap-to array
  47952. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  47953. * @returns was the point found and removed or not
  47954. */
  47955. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  47956. /**
  47957. * This function sets a selection feature that will be disabled when
  47958. * the forward ray is shown and will be reattached when hidden.
  47959. * This is used to remove the selection rays when moving.
  47960. * @param selectionFeature the feature to disable when forward movement is enabled
  47961. */
  47962. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  47963. protected _onXRFrame(_xrFrame: XRFrame): void;
  47964. private _attachController;
  47965. private _createDefaultTargetMesh;
  47966. private _detachController;
  47967. private _findClosestSnapPointWithRadius;
  47968. private _setTargetMeshPosition;
  47969. private _setTargetMeshVisibility;
  47970. private _showParabolicPath;
  47971. private _teleportForward;
  47972. }
  47973. }
  47974. declare module BABYLON {
  47975. /**
  47976. * Options for the default xr helper
  47977. */
  47978. export class WebXRDefaultExperienceOptions {
  47979. /**
  47980. * Enable or disable default UI to enter XR
  47981. */
  47982. disableDefaultUI?: boolean;
  47983. /**
  47984. * Should teleportation not initialize. defaults to false.
  47985. */
  47986. disableTeleportation?: boolean;
  47987. /**
  47988. * Floor meshes that will be used for teleport
  47989. */
  47990. floorMeshes?: Array<AbstractMesh>;
  47991. /**
  47992. * If set to true, the first frame will not be used to reset position
  47993. * The first frame is mainly used when copying transformation from the old camera
  47994. * Mainly used in AR
  47995. */
  47996. ignoreNativeCameraTransformation?: boolean;
  47997. /**
  47998. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  47999. */
  48000. inputOptions?: IWebXRInputOptions;
  48001. /**
  48002. * optional configuration for the output canvas
  48003. */
  48004. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  48005. /**
  48006. * optional UI options. This can be used among other to change session mode and reference space type
  48007. */
  48008. uiOptions?: WebXREnterExitUIOptions;
  48009. /**
  48010. * When loading teleportation and pointer select, use stable versions instead of latest.
  48011. */
  48012. useStablePlugins?: boolean;
  48013. /**
  48014. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  48015. */
  48016. renderingGroupId?: number;
  48017. /**
  48018. * A list of optional features to init the session with
  48019. * If set to true, all features we support will be added
  48020. */
  48021. optionalFeatures?: boolean | string[];
  48022. }
  48023. /**
  48024. * Default experience which provides a similar setup to the previous webVRExperience
  48025. */
  48026. export class WebXRDefaultExperience {
  48027. /**
  48028. * Base experience
  48029. */
  48030. baseExperience: WebXRExperienceHelper;
  48031. /**
  48032. * Enables ui for entering/exiting xr
  48033. */
  48034. enterExitUI: WebXREnterExitUI;
  48035. /**
  48036. * Input experience extension
  48037. */
  48038. input: WebXRInput;
  48039. /**
  48040. * Enables laser pointer and selection
  48041. */
  48042. pointerSelection: WebXRControllerPointerSelection;
  48043. /**
  48044. * Default target xr should render to
  48045. */
  48046. renderTarget: WebXRRenderTarget;
  48047. /**
  48048. * Enables teleportation
  48049. */
  48050. teleportation: WebXRMotionControllerTeleportation;
  48051. private constructor();
  48052. /**
  48053. * Creates the default xr experience
  48054. * @param scene scene
  48055. * @param options options for basic configuration
  48056. * @returns resulting WebXRDefaultExperience
  48057. */
  48058. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  48059. /**
  48060. * DIsposes of the experience helper
  48061. */
  48062. dispose(): void;
  48063. }
  48064. }
  48065. declare module BABYLON {
  48066. /**
  48067. * Options to modify the vr teleportation behavior.
  48068. */
  48069. export interface VRTeleportationOptions {
  48070. /**
  48071. * The name of the mesh which should be used as the teleportation floor. (default: null)
  48072. */
  48073. floorMeshName?: string;
  48074. /**
  48075. * A list of meshes to be used as the teleportation floor. (default: empty)
  48076. */
  48077. floorMeshes?: Mesh[];
  48078. /**
  48079. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  48080. */
  48081. teleportationMode?: number;
  48082. /**
  48083. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  48084. */
  48085. teleportationTime?: number;
  48086. /**
  48087. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  48088. */
  48089. teleportationSpeed?: number;
  48090. /**
  48091. * The easing function used in the animation or null for Linear. (default CircleEase)
  48092. */
  48093. easingFunction?: EasingFunction;
  48094. }
  48095. /**
  48096. * Options to modify the vr experience helper's behavior.
  48097. */
  48098. export interface VRExperienceHelperOptions extends WebVROptions {
  48099. /**
  48100. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  48101. */
  48102. createDeviceOrientationCamera?: boolean;
  48103. /**
  48104. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  48105. */
  48106. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  48107. /**
  48108. * Uses the main button on the controller to toggle the laser casted. (default: true)
  48109. */
  48110. laserToggle?: boolean;
  48111. /**
  48112. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  48113. */
  48114. floorMeshes?: Mesh[];
  48115. /**
  48116. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  48117. */
  48118. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  48119. /**
  48120. * Defines if WebXR should be used instead of WebVR (if available)
  48121. */
  48122. useXR?: boolean;
  48123. }
  48124. /**
  48125. * Event containing information after VR has been entered
  48126. */
  48127. export class OnAfterEnteringVRObservableEvent {
  48128. /**
  48129. * If entering vr was successful
  48130. */
  48131. success: boolean;
  48132. }
  48133. /**
  48134. * Helps to quickly add VR support to an existing scene.
  48135. * See http://doc.babylonjs.com/how_to/webvr_helper
  48136. */
  48137. export class VRExperienceHelper {
  48138. /** Options to modify the vr experience helper's behavior. */
  48139. webVROptions: VRExperienceHelperOptions;
  48140. private _scene;
  48141. private _position;
  48142. private _btnVR;
  48143. private _btnVRDisplayed;
  48144. private _webVRsupported;
  48145. private _webVRready;
  48146. private _webVRrequesting;
  48147. private _webVRpresenting;
  48148. private _hasEnteredVR;
  48149. private _fullscreenVRpresenting;
  48150. private _inputElement;
  48151. private _webVRCamera;
  48152. private _vrDeviceOrientationCamera;
  48153. private _deviceOrientationCamera;
  48154. private _existingCamera;
  48155. private _onKeyDown;
  48156. private _onVrDisplayPresentChange;
  48157. private _onVRDisplayChanged;
  48158. private _onVRRequestPresentStart;
  48159. private _onVRRequestPresentComplete;
  48160. /**
  48161. * 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)
  48162. */
  48163. enableGazeEvenWhenNoPointerLock: boolean;
  48164. /**
  48165. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  48166. */
  48167. exitVROnDoubleTap: boolean;
  48168. /**
  48169. * Observable raised right before entering VR.
  48170. */
  48171. onEnteringVRObservable: Observable<VRExperienceHelper>;
  48172. /**
  48173. * Observable raised when entering VR has completed.
  48174. */
  48175. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  48176. /**
  48177. * Observable raised when exiting VR.
  48178. */
  48179. onExitingVRObservable: Observable<VRExperienceHelper>;
  48180. /**
  48181. * Observable raised when controller mesh is loaded.
  48182. */
  48183. onControllerMeshLoadedObservable: Observable<WebVRController>;
  48184. /** Return this.onEnteringVRObservable
  48185. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  48186. */
  48187. get onEnteringVR(): Observable<VRExperienceHelper>;
  48188. /** Return this.onExitingVRObservable
  48189. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  48190. */
  48191. get onExitingVR(): Observable<VRExperienceHelper>;
  48192. /** Return this.onControllerMeshLoadedObservable
  48193. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  48194. */
  48195. get onControllerMeshLoaded(): Observable<WebVRController>;
  48196. private _rayLength;
  48197. private _useCustomVRButton;
  48198. private _teleportationRequested;
  48199. private _teleportActive;
  48200. private _floorMeshName;
  48201. private _floorMeshesCollection;
  48202. private _teleportationMode;
  48203. private _teleportationTime;
  48204. private _teleportationSpeed;
  48205. private _teleportationEasing;
  48206. private _rotationAllowed;
  48207. private _teleportBackwardsVector;
  48208. private _teleportationTarget;
  48209. private _isDefaultTeleportationTarget;
  48210. private _postProcessMove;
  48211. private _teleportationFillColor;
  48212. private _teleportationBorderColor;
  48213. private _rotationAngle;
  48214. private _haloCenter;
  48215. private _cameraGazer;
  48216. private _padSensibilityUp;
  48217. private _padSensibilityDown;
  48218. private _leftController;
  48219. private _rightController;
  48220. private _gazeColor;
  48221. private _laserColor;
  48222. private _pickedLaserColor;
  48223. private _pickedGazeColor;
  48224. /**
  48225. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  48226. */
  48227. onNewMeshSelected: Observable<AbstractMesh>;
  48228. /**
  48229. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  48230. * This observable will provide the mesh and the controller used to select the mesh
  48231. */
  48232. onMeshSelectedWithController: Observable<{
  48233. mesh: AbstractMesh;
  48234. controller: WebVRController;
  48235. }>;
  48236. /**
  48237. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  48238. */
  48239. onNewMeshPicked: Observable<PickingInfo>;
  48240. private _circleEase;
  48241. /**
  48242. * Observable raised before camera teleportation
  48243. */
  48244. onBeforeCameraTeleport: Observable<Vector3>;
  48245. /**
  48246. * Observable raised after camera teleportation
  48247. */
  48248. onAfterCameraTeleport: Observable<Vector3>;
  48249. /**
  48250. * Observable raised when current selected mesh gets unselected
  48251. */
  48252. onSelectedMeshUnselected: Observable<AbstractMesh>;
  48253. private _raySelectionPredicate;
  48254. /**
  48255. * To be optionaly changed by user to define custom ray selection
  48256. */
  48257. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  48258. /**
  48259. * To be optionaly changed by user to define custom selection logic (after ray selection)
  48260. */
  48261. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  48262. /**
  48263. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  48264. */
  48265. teleportationEnabled: boolean;
  48266. private _defaultHeight;
  48267. private _teleportationInitialized;
  48268. private _interactionsEnabled;
  48269. private _interactionsRequested;
  48270. private _displayGaze;
  48271. private _displayLaserPointer;
  48272. /**
  48273. * The mesh used to display where the user is going to teleport.
  48274. */
  48275. get teleportationTarget(): Mesh;
  48276. /**
  48277. * Sets the mesh to be used to display where the user is going to teleport.
  48278. */
  48279. set teleportationTarget(value: Mesh);
  48280. /**
  48281. * 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
  48282. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  48283. * See http://doc.babylonjs.com/resources/baking_transformations
  48284. */
  48285. get gazeTrackerMesh(): Mesh;
  48286. set gazeTrackerMesh(value: Mesh);
  48287. /**
  48288. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  48289. */
  48290. updateGazeTrackerScale: boolean;
  48291. /**
  48292. * If the gaze trackers color should be updated when selecting meshes
  48293. */
  48294. updateGazeTrackerColor: boolean;
  48295. /**
  48296. * If the controller laser color should be updated when selecting meshes
  48297. */
  48298. updateControllerLaserColor: boolean;
  48299. /**
  48300. * The gaze tracking mesh corresponding to the left controller
  48301. */
  48302. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  48303. /**
  48304. * The gaze tracking mesh corresponding to the right controller
  48305. */
  48306. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  48307. /**
  48308. * If the ray of the gaze should be displayed.
  48309. */
  48310. get displayGaze(): boolean;
  48311. /**
  48312. * Sets if the ray of the gaze should be displayed.
  48313. */
  48314. set displayGaze(value: boolean);
  48315. /**
  48316. * If the ray of the LaserPointer should be displayed.
  48317. */
  48318. get displayLaserPointer(): boolean;
  48319. /**
  48320. * Sets if the ray of the LaserPointer should be displayed.
  48321. */
  48322. set displayLaserPointer(value: boolean);
  48323. /**
  48324. * The deviceOrientationCamera used as the camera when not in VR.
  48325. */
  48326. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  48327. /**
  48328. * Based on the current WebVR support, returns the current VR camera used.
  48329. */
  48330. get currentVRCamera(): Nullable<Camera>;
  48331. /**
  48332. * The webVRCamera which is used when in VR.
  48333. */
  48334. get webVRCamera(): WebVRFreeCamera;
  48335. /**
  48336. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  48337. */
  48338. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  48339. /**
  48340. * The html button that is used to trigger entering into VR.
  48341. */
  48342. get vrButton(): Nullable<HTMLButtonElement>;
  48343. private get _teleportationRequestInitiated();
  48344. /**
  48345. * Defines whether or not Pointer lock should be requested when switching to
  48346. * full screen.
  48347. */
  48348. requestPointerLockOnFullScreen: boolean;
  48349. /**
  48350. * If asking to force XR, this will be populated with the default xr experience
  48351. */
  48352. xr: WebXRDefaultExperience;
  48353. /**
  48354. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  48355. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  48356. */
  48357. xrTestDone: boolean;
  48358. /**
  48359. * Instantiates a VRExperienceHelper.
  48360. * Helps to quickly add VR support to an existing scene.
  48361. * @param scene The scene the VRExperienceHelper belongs to.
  48362. * @param webVROptions Options to modify the vr experience helper's behavior.
  48363. */
  48364. constructor(scene: Scene,
  48365. /** Options to modify the vr experience helper's behavior. */
  48366. webVROptions?: VRExperienceHelperOptions);
  48367. private completeVRInit;
  48368. private _onDefaultMeshLoaded;
  48369. private _onResize;
  48370. private _onFullscreenChange;
  48371. /**
  48372. * Gets a value indicating if we are currently in VR mode.
  48373. */
  48374. get isInVRMode(): boolean;
  48375. private onVrDisplayPresentChange;
  48376. private onVRDisplayChanged;
  48377. private moveButtonToBottomRight;
  48378. private displayVRButton;
  48379. private updateButtonVisibility;
  48380. private _cachedAngularSensibility;
  48381. /**
  48382. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  48383. * Otherwise, will use the fullscreen API.
  48384. */
  48385. enterVR(): void;
  48386. /**
  48387. * Attempt to exit VR, or fullscreen.
  48388. */
  48389. exitVR(): void;
  48390. /**
  48391. * The position of the vr experience helper.
  48392. */
  48393. get position(): Vector3;
  48394. /**
  48395. * Sets the position of the vr experience helper.
  48396. */
  48397. set position(value: Vector3);
  48398. /**
  48399. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  48400. */
  48401. enableInteractions(): void;
  48402. private get _noControllerIsActive();
  48403. private beforeRender;
  48404. private _isTeleportationFloor;
  48405. /**
  48406. * Adds a floor mesh to be used for teleportation.
  48407. * @param floorMesh the mesh to be used for teleportation.
  48408. */
  48409. addFloorMesh(floorMesh: Mesh): void;
  48410. /**
  48411. * Removes a floor mesh from being used for teleportation.
  48412. * @param floorMesh the mesh to be removed.
  48413. */
  48414. removeFloorMesh(floorMesh: Mesh): void;
  48415. /**
  48416. * Enables interactions and teleportation using the VR controllers and gaze.
  48417. * @param vrTeleportationOptions options to modify teleportation behavior.
  48418. */
  48419. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  48420. private _onNewGamepadConnected;
  48421. private _tryEnableInteractionOnController;
  48422. private _onNewGamepadDisconnected;
  48423. private _enableInteractionOnController;
  48424. private _checkTeleportWithRay;
  48425. private _checkRotate;
  48426. private _checkTeleportBackwards;
  48427. private _enableTeleportationOnController;
  48428. private _createTeleportationCircles;
  48429. private _displayTeleportationTarget;
  48430. private _hideTeleportationTarget;
  48431. private _rotateCamera;
  48432. private _moveTeleportationSelectorTo;
  48433. private _workingVector;
  48434. private _workingQuaternion;
  48435. private _workingMatrix;
  48436. /**
  48437. * Time Constant Teleportation Mode
  48438. */
  48439. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  48440. /**
  48441. * Speed Constant Teleportation Mode
  48442. */
  48443. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  48444. /**
  48445. * Teleports the users feet to the desired location
  48446. * @param location The location where the user's feet should be placed
  48447. */
  48448. teleportCamera(location: Vector3): void;
  48449. private _convertNormalToDirectionOfRay;
  48450. private _castRayAndSelectObject;
  48451. private _notifySelectedMeshUnselected;
  48452. /**
  48453. * Permanently set new colors for the laser pointer
  48454. * @param color the new laser color
  48455. * @param pickedColor the new laser color when picked mesh detected
  48456. */
  48457. setLaserColor(color: Color3, pickedColor?: Color3): void;
  48458. /**
  48459. * Set lighting enabled / disabled on the laser pointer of both controllers
  48460. * @param enabled should the lighting be enabled on the laser pointer
  48461. */
  48462. setLaserLightingState(enabled?: boolean): void;
  48463. /**
  48464. * Permanently set new colors for the gaze pointer
  48465. * @param color the new gaze color
  48466. * @param pickedColor the new gaze color when picked mesh detected
  48467. */
  48468. setGazeColor(color: Color3, pickedColor?: Color3): void;
  48469. /**
  48470. * Sets the color of the laser ray from the vr controllers.
  48471. * @param color new color for the ray.
  48472. */
  48473. changeLaserColor(color: Color3): void;
  48474. /**
  48475. * Sets the color of the ray from the vr headsets gaze.
  48476. * @param color new color for the ray.
  48477. */
  48478. changeGazeColor(color: Color3): void;
  48479. /**
  48480. * Exits VR and disposes of the vr experience helper
  48481. */
  48482. dispose(): void;
  48483. /**
  48484. * Gets the name of the VRExperienceHelper class
  48485. * @returns "VRExperienceHelper"
  48486. */
  48487. getClassName(): string;
  48488. }
  48489. }
  48490. declare module BABYLON {
  48491. /**
  48492. * Contains an array of blocks representing the octree
  48493. */
  48494. export interface IOctreeContainer<T> {
  48495. /**
  48496. * Blocks within the octree
  48497. */
  48498. blocks: Array<OctreeBlock<T>>;
  48499. }
  48500. /**
  48501. * Class used to store a cell in an octree
  48502. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  48503. */
  48504. export class OctreeBlock<T> {
  48505. /**
  48506. * Gets the content of the current block
  48507. */
  48508. entries: T[];
  48509. /**
  48510. * Gets the list of block children
  48511. */
  48512. blocks: Array<OctreeBlock<T>>;
  48513. private _depth;
  48514. private _maxDepth;
  48515. private _capacity;
  48516. private _minPoint;
  48517. private _maxPoint;
  48518. private _boundingVectors;
  48519. private _creationFunc;
  48520. /**
  48521. * Creates a new block
  48522. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  48523. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  48524. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  48525. * @param depth defines the current depth of this block in the octree
  48526. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  48527. * @param creationFunc defines a callback to call when an element is added to the block
  48528. */
  48529. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  48530. /**
  48531. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  48532. */
  48533. get capacity(): number;
  48534. /**
  48535. * Gets the minimum vector (in world space) of the block's bounding box
  48536. */
  48537. get minPoint(): Vector3;
  48538. /**
  48539. * Gets the maximum vector (in world space) of the block's bounding box
  48540. */
  48541. get maxPoint(): Vector3;
  48542. /**
  48543. * Add a new element to this block
  48544. * @param entry defines the element to add
  48545. */
  48546. addEntry(entry: T): void;
  48547. /**
  48548. * Remove an element from this block
  48549. * @param entry defines the element to remove
  48550. */
  48551. removeEntry(entry: T): void;
  48552. /**
  48553. * Add an array of elements to this block
  48554. * @param entries defines the array of elements to add
  48555. */
  48556. addEntries(entries: T[]): void;
  48557. /**
  48558. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  48559. * @param frustumPlanes defines the frustum planes to test
  48560. * @param selection defines the array to store current content if selection is positive
  48561. * @param allowDuplicate defines if the selection array can contains duplicated entries
  48562. */
  48563. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  48564. /**
  48565. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  48566. * @param sphereCenter defines the bounding sphere center
  48567. * @param sphereRadius defines the bounding sphere radius
  48568. * @param selection defines the array to store current content if selection is positive
  48569. * @param allowDuplicate defines if the selection array can contains duplicated entries
  48570. */
  48571. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  48572. /**
  48573. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  48574. * @param ray defines the ray to test with
  48575. * @param selection defines the array to store current content if selection is positive
  48576. */
  48577. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  48578. /**
  48579. * Subdivide the content into child blocks (this block will then be empty)
  48580. */
  48581. createInnerBlocks(): void;
  48582. /**
  48583. * @hidden
  48584. */
  48585. 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;
  48586. }
  48587. }
  48588. declare module BABYLON {
  48589. /**
  48590. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  48591. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  48592. */
  48593. export class Octree<T> {
  48594. /** 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.) */
  48595. maxDepth: number;
  48596. /**
  48597. * Blocks within the octree containing objects
  48598. */
  48599. blocks: Array<OctreeBlock<T>>;
  48600. /**
  48601. * Content stored in the octree
  48602. */
  48603. dynamicContent: T[];
  48604. private _maxBlockCapacity;
  48605. private _selectionContent;
  48606. private _creationFunc;
  48607. /**
  48608. * Creates a octree
  48609. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  48610. * @param creationFunc function to be used to instatiate the octree
  48611. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  48612. * @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.)
  48613. */
  48614. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  48615. /** 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.) */
  48616. maxDepth?: number);
  48617. /**
  48618. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  48619. * @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);
  48620. * @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);
  48621. * @param entries meshes to be added to the octree blocks
  48622. */
  48623. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  48624. /**
  48625. * Adds a mesh to the octree
  48626. * @param entry Mesh to add to the octree
  48627. */
  48628. addMesh(entry: T): void;
  48629. /**
  48630. * Remove an element from the octree
  48631. * @param entry defines the element to remove
  48632. */
  48633. removeMesh(entry: T): void;
  48634. /**
  48635. * Selects an array of meshes within the frustum
  48636. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  48637. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  48638. * @returns array of meshes within the frustum
  48639. */
  48640. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  48641. /**
  48642. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  48643. * @param sphereCenter defines the bounding sphere center
  48644. * @param sphereRadius defines the bounding sphere radius
  48645. * @param allowDuplicate defines if the selection array can contains duplicated entries
  48646. * @returns an array of objects that intersect the sphere
  48647. */
  48648. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  48649. /**
  48650. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  48651. * @param ray defines the ray to test with
  48652. * @returns array of intersected objects
  48653. */
  48654. intersectsRay(ray: Ray): SmartArray<T>;
  48655. /**
  48656. * Adds a mesh into the octree block if it intersects the block
  48657. */
  48658. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  48659. /**
  48660. * Adds a submesh into the octree block if it intersects the block
  48661. */
  48662. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  48663. }
  48664. }
  48665. declare module BABYLON {
  48666. interface Scene {
  48667. /**
  48668. * @hidden
  48669. * Backing Filed
  48670. */
  48671. _selectionOctree: Octree<AbstractMesh>;
  48672. /**
  48673. * Gets the octree used to boost mesh selection (picking)
  48674. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  48675. */
  48676. selectionOctree: Octree<AbstractMesh>;
  48677. /**
  48678. * Creates or updates the octree used to boost selection (picking)
  48679. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  48680. * @param maxCapacity defines the maximum capacity per leaf
  48681. * @param maxDepth defines the maximum depth of the octree
  48682. * @returns an octree of AbstractMesh
  48683. */
  48684. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  48685. }
  48686. interface AbstractMesh {
  48687. /**
  48688. * @hidden
  48689. * Backing Field
  48690. */
  48691. _submeshesOctree: Octree<SubMesh>;
  48692. /**
  48693. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  48694. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  48695. * @param maxCapacity defines the maximum size of each block (64 by default)
  48696. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  48697. * @returns the new octree
  48698. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  48699. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  48700. */
  48701. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  48702. }
  48703. /**
  48704. * Defines the octree scene component responsible to manage any octrees
  48705. * in a given scene.
  48706. */
  48707. export class OctreeSceneComponent {
  48708. /**
  48709. * The component name help to identify the component in the list of scene components.
  48710. */
  48711. readonly name: string;
  48712. /**
  48713. * The scene the component belongs to.
  48714. */
  48715. scene: Scene;
  48716. /**
  48717. * Indicates if the meshes have been checked to make sure they are isEnabled()
  48718. */
  48719. readonly checksIsEnabled: boolean;
  48720. /**
  48721. * Creates a new instance of the component for the given scene
  48722. * @param scene Defines the scene to register the component in
  48723. */
  48724. constructor(scene: Scene);
  48725. /**
  48726. * Registers the component in a given scene
  48727. */
  48728. register(): void;
  48729. /**
  48730. * Return the list of active meshes
  48731. * @returns the list of active meshes
  48732. */
  48733. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  48734. /**
  48735. * Return the list of active sub meshes
  48736. * @param mesh The mesh to get the candidates sub meshes from
  48737. * @returns the list of active sub meshes
  48738. */
  48739. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  48740. private _tempRay;
  48741. /**
  48742. * Return the list of sub meshes intersecting with a given local ray
  48743. * @param mesh defines the mesh to find the submesh for
  48744. * @param localRay defines the ray in local space
  48745. * @returns the list of intersecting sub meshes
  48746. */
  48747. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  48748. /**
  48749. * Return the list of sub meshes colliding with a collider
  48750. * @param mesh defines the mesh to find the submesh for
  48751. * @param collider defines the collider to evaluate the collision against
  48752. * @returns the list of colliding sub meshes
  48753. */
  48754. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  48755. /**
  48756. * Rebuilds the elements related to this component in case of
  48757. * context lost for instance.
  48758. */
  48759. rebuild(): void;
  48760. /**
  48761. * Disposes the component and the associated ressources.
  48762. */
  48763. dispose(): void;
  48764. }
  48765. }
  48766. declare module BABYLON {
  48767. /**
  48768. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  48769. */
  48770. export class Gizmo implements IDisposable {
  48771. /** The utility layer the gizmo will be added to */
  48772. gizmoLayer: UtilityLayerRenderer;
  48773. /**
  48774. * The root mesh of the gizmo
  48775. */
  48776. _rootMesh: Mesh;
  48777. private _attachedMesh;
  48778. /**
  48779. * Ratio for the scale of the gizmo (Default: 1)
  48780. */
  48781. scaleRatio: number;
  48782. /**
  48783. * If a custom mesh has been set (Default: false)
  48784. */
  48785. protected _customMeshSet: boolean;
  48786. /**
  48787. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  48788. * * When set, interactions will be enabled
  48789. */
  48790. get attachedMesh(): Nullable<AbstractMesh>;
  48791. set attachedMesh(value: Nullable<AbstractMesh>);
  48792. /**
  48793. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  48794. * @param mesh The mesh to replace the default mesh of the gizmo
  48795. */
  48796. setCustomMesh(mesh: Mesh): void;
  48797. /**
  48798. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  48799. */
  48800. updateGizmoRotationToMatchAttachedMesh: boolean;
  48801. /**
  48802. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  48803. */
  48804. updateGizmoPositionToMatchAttachedMesh: boolean;
  48805. /**
  48806. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  48807. */
  48808. updateScale: boolean;
  48809. protected _interactionsEnabled: boolean;
  48810. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48811. private _beforeRenderObserver;
  48812. private _tempVector;
  48813. /**
  48814. * Creates a gizmo
  48815. * @param gizmoLayer The utility layer the gizmo will be added to
  48816. */
  48817. constructor(
  48818. /** The utility layer the gizmo will be added to */
  48819. gizmoLayer?: UtilityLayerRenderer);
  48820. /**
  48821. * Updates the gizmo to match the attached mesh's position/rotation
  48822. */
  48823. protected _update(): void;
  48824. /**
  48825. * Disposes of the gizmo
  48826. */
  48827. dispose(): void;
  48828. }
  48829. }
  48830. declare module BABYLON {
  48831. /**
  48832. * Single plane drag gizmo
  48833. */
  48834. export class PlaneDragGizmo extends Gizmo {
  48835. /**
  48836. * Drag behavior responsible for the gizmos dragging interactions
  48837. */
  48838. dragBehavior: PointerDragBehavior;
  48839. private _pointerObserver;
  48840. /**
  48841. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48842. */
  48843. snapDistance: number;
  48844. /**
  48845. * Event that fires each time the gizmo snaps to a new location.
  48846. * * snapDistance is the the change in distance
  48847. */
  48848. onSnapObservable: Observable<{
  48849. snapDistance: number;
  48850. }>;
  48851. private _plane;
  48852. private _coloredMaterial;
  48853. private _hoverMaterial;
  48854. private _isEnabled;
  48855. private _parent;
  48856. /** @hidden */
  48857. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  48858. /** @hidden */
  48859. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  48860. /**
  48861. * Creates a PlaneDragGizmo
  48862. * @param gizmoLayer The utility layer the gizmo will be added to
  48863. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  48864. * @param color The color of the gizmo
  48865. */
  48866. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  48867. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48868. /**
  48869. * If the gizmo is enabled
  48870. */
  48871. set isEnabled(value: boolean);
  48872. get isEnabled(): boolean;
  48873. /**
  48874. * Disposes of the gizmo
  48875. */
  48876. dispose(): void;
  48877. }
  48878. }
  48879. declare module BABYLON {
  48880. /**
  48881. * Gizmo that enables dragging a mesh along 3 axis
  48882. */
  48883. export class PositionGizmo extends Gizmo {
  48884. /**
  48885. * Internal gizmo used for interactions on the x axis
  48886. */
  48887. xGizmo: AxisDragGizmo;
  48888. /**
  48889. * Internal gizmo used for interactions on the y axis
  48890. */
  48891. yGizmo: AxisDragGizmo;
  48892. /**
  48893. * Internal gizmo used for interactions on the z axis
  48894. */
  48895. zGizmo: AxisDragGizmo;
  48896. /**
  48897. * Internal gizmo used for interactions on the yz plane
  48898. */
  48899. xPlaneGizmo: PlaneDragGizmo;
  48900. /**
  48901. * Internal gizmo used for interactions on the xz plane
  48902. */
  48903. yPlaneGizmo: PlaneDragGizmo;
  48904. /**
  48905. * Internal gizmo used for interactions on the xy plane
  48906. */
  48907. zPlaneGizmo: PlaneDragGizmo;
  48908. /**
  48909. * private variables
  48910. */
  48911. private _meshAttached;
  48912. private _updateGizmoRotationToMatchAttachedMesh;
  48913. private _snapDistance;
  48914. private _scaleRatio;
  48915. /** Fires an event when any of it's sub gizmos are dragged */
  48916. onDragStartObservable: Observable<unknown>;
  48917. /** Fires an event when any of it's sub gizmos are released from dragging */
  48918. onDragEndObservable: Observable<unknown>;
  48919. /**
  48920. * If set to true, planar drag is enabled
  48921. */
  48922. private _planarGizmoEnabled;
  48923. get attachedMesh(): Nullable<AbstractMesh>;
  48924. set attachedMesh(mesh: Nullable<AbstractMesh>);
  48925. /**
  48926. * Creates a PositionGizmo
  48927. * @param gizmoLayer The utility layer the gizmo will be added to
  48928. */
  48929. constructor(gizmoLayer?: UtilityLayerRenderer);
  48930. /**
  48931. * If the planar drag gizmo is enabled
  48932. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  48933. */
  48934. set planarGizmoEnabled(value: boolean);
  48935. get planarGizmoEnabled(): boolean;
  48936. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  48937. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  48938. /**
  48939. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48940. */
  48941. set snapDistance(value: number);
  48942. get snapDistance(): number;
  48943. /**
  48944. * Ratio for the scale of the gizmo (Default: 1)
  48945. */
  48946. set scaleRatio(value: number);
  48947. get scaleRatio(): number;
  48948. /**
  48949. * Disposes of the gizmo
  48950. */
  48951. dispose(): void;
  48952. /**
  48953. * CustomMeshes are not supported by this gizmo
  48954. * @param mesh The mesh to replace the default mesh of the gizmo
  48955. */
  48956. setCustomMesh(mesh: Mesh): void;
  48957. }
  48958. }
  48959. declare module BABYLON {
  48960. /**
  48961. * Single axis drag gizmo
  48962. */
  48963. export class AxisDragGizmo extends Gizmo {
  48964. /**
  48965. * Drag behavior responsible for the gizmos dragging interactions
  48966. */
  48967. dragBehavior: PointerDragBehavior;
  48968. private _pointerObserver;
  48969. /**
  48970. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48971. */
  48972. snapDistance: number;
  48973. /**
  48974. * Event that fires each time the gizmo snaps to a new location.
  48975. * * snapDistance is the the change in distance
  48976. */
  48977. onSnapObservable: Observable<{
  48978. snapDistance: number;
  48979. }>;
  48980. private _isEnabled;
  48981. private _parent;
  48982. private _arrow;
  48983. private _coloredMaterial;
  48984. private _hoverMaterial;
  48985. /** @hidden */
  48986. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  48987. /** @hidden */
  48988. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  48989. /**
  48990. * Creates an AxisDragGizmo
  48991. * @param gizmoLayer The utility layer the gizmo will be added to
  48992. * @param dragAxis The axis which the gizmo will be able to drag on
  48993. * @param color The color of the gizmo
  48994. */
  48995. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  48996. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48997. /**
  48998. * If the gizmo is enabled
  48999. */
  49000. set isEnabled(value: boolean);
  49001. get isEnabled(): boolean;
  49002. /**
  49003. * Disposes of the gizmo
  49004. */
  49005. dispose(): void;
  49006. }
  49007. }
  49008. declare module BABYLON.Debug {
  49009. /**
  49010. * The Axes viewer will show 3 axes in a specific point in space
  49011. */
  49012. export class AxesViewer {
  49013. private _xAxis;
  49014. private _yAxis;
  49015. private _zAxis;
  49016. private _scaleLinesFactor;
  49017. private _instanced;
  49018. /**
  49019. * Gets the hosting scene
  49020. */
  49021. scene: Scene;
  49022. /**
  49023. * Gets or sets a number used to scale line length
  49024. */
  49025. scaleLines: number;
  49026. /** Gets the node hierarchy used to render x-axis */
  49027. get xAxis(): TransformNode;
  49028. /** Gets the node hierarchy used to render y-axis */
  49029. get yAxis(): TransformNode;
  49030. /** Gets the node hierarchy used to render z-axis */
  49031. get zAxis(): TransformNode;
  49032. /**
  49033. * Creates a new AxesViewer
  49034. * @param scene defines the hosting scene
  49035. * @param scaleLines defines a number used to scale line length (1 by default)
  49036. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  49037. * @param xAxis defines the node hierarchy used to render the x-axis
  49038. * @param yAxis defines the node hierarchy used to render the y-axis
  49039. * @param zAxis defines the node hierarchy used to render the z-axis
  49040. */
  49041. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  49042. /**
  49043. * Force the viewer to update
  49044. * @param position defines the position of the viewer
  49045. * @param xaxis defines the x axis of the viewer
  49046. * @param yaxis defines the y axis of the viewer
  49047. * @param zaxis defines the z axis of the viewer
  49048. */
  49049. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  49050. /**
  49051. * Creates an instance of this axes viewer.
  49052. * @returns a new axes viewer with instanced meshes
  49053. */
  49054. createInstance(): AxesViewer;
  49055. /** Releases resources */
  49056. dispose(): void;
  49057. private static _SetRenderingGroupId;
  49058. }
  49059. }
  49060. declare module BABYLON.Debug {
  49061. /**
  49062. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  49063. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  49064. */
  49065. export class BoneAxesViewer extends AxesViewer {
  49066. /**
  49067. * Gets or sets the target mesh where to display the axes viewer
  49068. */
  49069. mesh: Nullable<Mesh>;
  49070. /**
  49071. * Gets or sets the target bone where to display the axes viewer
  49072. */
  49073. bone: Nullable<Bone>;
  49074. /** Gets current position */
  49075. pos: Vector3;
  49076. /** Gets direction of X axis */
  49077. xaxis: Vector3;
  49078. /** Gets direction of Y axis */
  49079. yaxis: Vector3;
  49080. /** Gets direction of Z axis */
  49081. zaxis: Vector3;
  49082. /**
  49083. * Creates a new BoneAxesViewer
  49084. * @param scene defines the hosting scene
  49085. * @param bone defines the target bone
  49086. * @param mesh defines the target mesh
  49087. * @param scaleLines defines a scaling factor for line length (1 by default)
  49088. */
  49089. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  49090. /**
  49091. * Force the viewer to update
  49092. */
  49093. update(): void;
  49094. /** Releases resources */
  49095. dispose(): void;
  49096. }
  49097. }
  49098. declare module BABYLON {
  49099. /**
  49100. * Interface used to define scene explorer extensibility option
  49101. */
  49102. export interface IExplorerExtensibilityOption {
  49103. /**
  49104. * Define the option label
  49105. */
  49106. label: string;
  49107. /**
  49108. * Defines the action to execute on click
  49109. */
  49110. action: (entity: any) => void;
  49111. }
  49112. /**
  49113. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  49114. */
  49115. export interface IExplorerExtensibilityGroup {
  49116. /**
  49117. * Defines a predicate to test if a given type mut be extended
  49118. */
  49119. predicate: (entity: any) => boolean;
  49120. /**
  49121. * Gets the list of options added to a type
  49122. */
  49123. entries: IExplorerExtensibilityOption[];
  49124. }
  49125. /**
  49126. * Interface used to define the options to use to create the Inspector
  49127. */
  49128. export interface IInspectorOptions {
  49129. /**
  49130. * Display in overlay mode (default: false)
  49131. */
  49132. overlay?: boolean;
  49133. /**
  49134. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  49135. */
  49136. globalRoot?: HTMLElement;
  49137. /**
  49138. * Display the Scene explorer
  49139. */
  49140. showExplorer?: boolean;
  49141. /**
  49142. * Display the property inspector
  49143. */
  49144. showInspector?: boolean;
  49145. /**
  49146. * Display in embed mode (both panes on the right)
  49147. */
  49148. embedMode?: boolean;
  49149. /**
  49150. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  49151. */
  49152. handleResize?: boolean;
  49153. /**
  49154. * Allow the panes to popup (default: true)
  49155. */
  49156. enablePopup?: boolean;
  49157. /**
  49158. * Allow the panes to be closed by users (default: true)
  49159. */
  49160. enableClose?: boolean;
  49161. /**
  49162. * Optional list of extensibility entries
  49163. */
  49164. explorerExtensibility?: IExplorerExtensibilityGroup[];
  49165. /**
  49166. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  49167. */
  49168. inspectorURL?: string;
  49169. /**
  49170. * Optional initial tab (default to DebugLayerTab.Properties)
  49171. */
  49172. initialTab?: DebugLayerTab;
  49173. }
  49174. interface Scene {
  49175. /**
  49176. * @hidden
  49177. * Backing field
  49178. */
  49179. _debugLayer: DebugLayer;
  49180. /**
  49181. * Gets the debug layer (aka Inspector) associated with the scene
  49182. * @see http://doc.babylonjs.com/features/playground_debuglayer
  49183. */
  49184. debugLayer: DebugLayer;
  49185. }
  49186. /**
  49187. * Enum of inspector action tab
  49188. */
  49189. export enum DebugLayerTab {
  49190. /**
  49191. * Properties tag (default)
  49192. */
  49193. Properties = 0,
  49194. /**
  49195. * Debug tab
  49196. */
  49197. Debug = 1,
  49198. /**
  49199. * Statistics tab
  49200. */
  49201. Statistics = 2,
  49202. /**
  49203. * Tools tab
  49204. */
  49205. Tools = 3,
  49206. /**
  49207. * Settings tab
  49208. */
  49209. Settings = 4
  49210. }
  49211. /**
  49212. * The debug layer (aka Inspector) is the go to tool in order to better understand
  49213. * what is happening in your scene
  49214. * @see http://doc.babylonjs.com/features/playground_debuglayer
  49215. */
  49216. export class DebugLayer {
  49217. /**
  49218. * Define the url to get the inspector script from.
  49219. * By default it uses the babylonjs CDN.
  49220. * @ignoreNaming
  49221. */
  49222. static InspectorURL: string;
  49223. private _scene;
  49224. private BJSINSPECTOR;
  49225. private _onPropertyChangedObservable?;
  49226. /**
  49227. * Observable triggered when a property is changed through the inspector.
  49228. */
  49229. get onPropertyChangedObservable(): any;
  49230. /**
  49231. * Instantiates a new debug layer.
  49232. * The debug layer (aka Inspector) is the go to tool in order to better understand
  49233. * what is happening in your scene
  49234. * @see http://doc.babylonjs.com/features/playground_debuglayer
  49235. * @param scene Defines the scene to inspect
  49236. */
  49237. constructor(scene: Scene);
  49238. /** Creates the inspector window. */
  49239. private _createInspector;
  49240. /**
  49241. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  49242. * @param entity defines the entity to select
  49243. * @param lineContainerTitle defines the specific block to highlight
  49244. */
  49245. select(entity: any, lineContainerTitle?: string): void;
  49246. /** Get the inspector from bundle or global */
  49247. private _getGlobalInspector;
  49248. /**
  49249. * Get if the inspector is visible or not.
  49250. * @returns true if visible otherwise, false
  49251. */
  49252. isVisible(): boolean;
  49253. /**
  49254. * Hide the inspector and close its window.
  49255. */
  49256. hide(): void;
  49257. /**
  49258. * Update the scene in the inspector
  49259. */
  49260. setAsActiveScene(): void;
  49261. /**
  49262. * Launch the debugLayer.
  49263. * @param config Define the configuration of the inspector
  49264. * @return a promise fulfilled when the debug layer is visible
  49265. */
  49266. show(config?: IInspectorOptions): Promise<DebugLayer>;
  49267. }
  49268. }
  49269. declare module BABYLON {
  49270. /**
  49271. * Class containing static functions to help procedurally build meshes
  49272. */
  49273. export class BoxBuilder {
  49274. /**
  49275. * Creates a box mesh
  49276. * * The parameter `size` sets the size (float) of each box side (default 1)
  49277. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  49278. * * 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)
  49279. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  49280. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49281. * * 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
  49282. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49283. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  49284. * @param name defines the name of the mesh
  49285. * @param options defines the options used to create the mesh
  49286. * @param scene defines the hosting scene
  49287. * @returns the box mesh
  49288. */
  49289. static CreateBox(name: string, options: {
  49290. size?: number;
  49291. width?: number;
  49292. height?: number;
  49293. depth?: number;
  49294. faceUV?: Vector4[];
  49295. faceColors?: Color4[];
  49296. sideOrientation?: number;
  49297. frontUVs?: Vector4;
  49298. backUVs?: Vector4;
  49299. wrap?: boolean;
  49300. topBaseAt?: number;
  49301. bottomBaseAt?: number;
  49302. updatable?: boolean;
  49303. }, scene?: Nullable<Scene>): Mesh;
  49304. }
  49305. }
  49306. declare module BABYLON.Debug {
  49307. /**
  49308. * Used to show the physics impostor around the specific mesh
  49309. */
  49310. export class PhysicsViewer {
  49311. /** @hidden */
  49312. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  49313. /** @hidden */
  49314. protected _meshes: Array<Nullable<AbstractMesh>>;
  49315. /** @hidden */
  49316. protected _scene: Nullable<Scene>;
  49317. /** @hidden */
  49318. protected _numMeshes: number;
  49319. /** @hidden */
  49320. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  49321. private _renderFunction;
  49322. private _utilityLayer;
  49323. private _debugBoxMesh;
  49324. private _debugSphereMesh;
  49325. private _debugCylinderMesh;
  49326. private _debugMaterial;
  49327. private _debugMeshMeshes;
  49328. /**
  49329. * Creates a new PhysicsViewer
  49330. * @param scene defines the hosting scene
  49331. */
  49332. constructor(scene: Scene);
  49333. /** @hidden */
  49334. protected _updateDebugMeshes(): void;
  49335. /**
  49336. * Renders a specified physic impostor
  49337. * @param impostor defines the impostor to render
  49338. * @param targetMesh defines the mesh represented by the impostor
  49339. * @returns the new debug mesh used to render the impostor
  49340. */
  49341. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  49342. /**
  49343. * Hides a specified physic impostor
  49344. * @param impostor defines the impostor to hide
  49345. */
  49346. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  49347. private _getDebugMaterial;
  49348. private _getDebugBoxMesh;
  49349. private _getDebugSphereMesh;
  49350. private _getDebugCylinderMesh;
  49351. private _getDebugMeshMesh;
  49352. private _getDebugMesh;
  49353. /** Releases all resources */
  49354. dispose(): void;
  49355. }
  49356. }
  49357. declare module BABYLON {
  49358. /**
  49359. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  49360. * in order to better appreciate the issue one might have.
  49361. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  49362. */
  49363. export class RayHelper {
  49364. /**
  49365. * Defines the ray we are currently tryin to visualize.
  49366. */
  49367. ray: Nullable<Ray>;
  49368. private _renderPoints;
  49369. private _renderLine;
  49370. private _renderFunction;
  49371. private _scene;
  49372. private _updateToMeshFunction;
  49373. private _attachedToMesh;
  49374. private _meshSpaceDirection;
  49375. private _meshSpaceOrigin;
  49376. /**
  49377. * Helper function to create a colored helper in a scene in one line.
  49378. * @param ray Defines the ray we are currently tryin to visualize
  49379. * @param scene Defines the scene the ray is used in
  49380. * @param color Defines the color we want to see the ray in
  49381. * @returns The newly created ray helper.
  49382. */
  49383. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  49384. /**
  49385. * Instantiate a new ray helper.
  49386. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  49387. * in order to better appreciate the issue one might have.
  49388. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  49389. * @param ray Defines the ray we are currently tryin to visualize
  49390. */
  49391. constructor(ray: Ray);
  49392. /**
  49393. * Shows the ray we are willing to debug.
  49394. * @param scene Defines the scene the ray needs to be rendered in
  49395. * @param color Defines the color the ray needs to be rendered in
  49396. */
  49397. show(scene: Scene, color?: Color3): void;
  49398. /**
  49399. * Hides the ray we are debugging.
  49400. */
  49401. hide(): void;
  49402. private _render;
  49403. /**
  49404. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  49405. * @param mesh Defines the mesh we want the helper attached to
  49406. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  49407. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  49408. * @param length Defines the length of the ray
  49409. */
  49410. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  49411. /**
  49412. * Detach the ray helper from the mesh it has previously been attached to.
  49413. */
  49414. detachFromMesh(): void;
  49415. private _updateToMesh;
  49416. /**
  49417. * Dispose the helper and release its associated resources.
  49418. */
  49419. dispose(): void;
  49420. }
  49421. }
  49422. declare module BABYLON.Debug {
  49423. /**
  49424. * Class used to render a debug view of a given skeleton
  49425. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  49426. */
  49427. export class SkeletonViewer {
  49428. /** defines the skeleton to render */
  49429. skeleton: Skeleton;
  49430. /** defines the mesh attached to the skeleton */
  49431. mesh: AbstractMesh;
  49432. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  49433. autoUpdateBonesMatrices: boolean;
  49434. /** defines the rendering group id to use with the viewer */
  49435. renderingGroupId: number;
  49436. /** Gets or sets the color used to render the skeleton */
  49437. color: Color3;
  49438. private _scene;
  49439. private _debugLines;
  49440. private _debugMesh;
  49441. private _isEnabled;
  49442. private _renderFunction;
  49443. private _utilityLayer;
  49444. /**
  49445. * Returns the mesh used to render the bones
  49446. */
  49447. get debugMesh(): Nullable<LinesMesh>;
  49448. /**
  49449. * Creates a new SkeletonViewer
  49450. * @param skeleton defines the skeleton to render
  49451. * @param mesh defines the mesh attached to the skeleton
  49452. * @param scene defines the hosting scene
  49453. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  49454. * @param renderingGroupId defines the rendering group id to use with the viewer
  49455. */
  49456. constructor(
  49457. /** defines the skeleton to render */
  49458. skeleton: Skeleton,
  49459. /** defines the mesh attached to the skeleton */
  49460. mesh: AbstractMesh, scene: Scene,
  49461. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  49462. autoUpdateBonesMatrices?: boolean,
  49463. /** defines the rendering group id to use with the viewer */
  49464. renderingGroupId?: number);
  49465. /** Gets or sets a boolean indicating if the viewer is enabled */
  49466. set isEnabled(value: boolean);
  49467. get isEnabled(): boolean;
  49468. private _getBonePosition;
  49469. private _getLinesForBonesWithLength;
  49470. private _getLinesForBonesNoLength;
  49471. /** Update the viewer to sync with current skeleton state */
  49472. update(): void;
  49473. /** Release associated resources */
  49474. dispose(): void;
  49475. }
  49476. }
  49477. declare module BABYLON {
  49478. /**
  49479. * Enum for Device Types
  49480. */
  49481. export enum DeviceType {
  49482. /** Generic */
  49483. Generic = 0,
  49484. /** Keyboard */
  49485. Keyboard = 1,
  49486. /** Mouse */
  49487. Mouse = 2,
  49488. /** Touch Pointers */
  49489. Touch = 3,
  49490. /** PS4 Dual Shock */
  49491. DualShock = 4,
  49492. /** Xbox */
  49493. Xbox = 5,
  49494. /** Switch Controller */
  49495. Switch = 6
  49496. }
  49497. /**
  49498. * Enum for All Pointers (Touch/Mouse)
  49499. */
  49500. export enum PointerInput {
  49501. /** Horizontal Axis */
  49502. Horizontal = 0,
  49503. /** Vertical Axis */
  49504. Vertical = 1,
  49505. /** Left Click or Touch */
  49506. LeftClick = 2,
  49507. /** Middle Click */
  49508. MiddleClick = 3,
  49509. /** Right Click */
  49510. RightClick = 4,
  49511. /** Browser Back */
  49512. BrowserBack = 5,
  49513. /** Browser Forward */
  49514. BrowserForward = 6
  49515. }
  49516. /**
  49517. * Enum for Dual Shock Gamepad
  49518. */
  49519. export enum DualShockInput {
  49520. /** Cross */
  49521. Cross = 0,
  49522. /** Circle */
  49523. Circle = 1,
  49524. /** Square */
  49525. Square = 2,
  49526. /** Triangle */
  49527. Triangle = 3,
  49528. /** L1 */
  49529. L1 = 4,
  49530. /** R1 */
  49531. R1 = 5,
  49532. /** L2 */
  49533. L2 = 6,
  49534. /** R2 */
  49535. R2 = 7,
  49536. /** Share */
  49537. Share = 8,
  49538. /** Options */
  49539. Options = 9,
  49540. /** L3 */
  49541. L3 = 10,
  49542. /** R3 */
  49543. R3 = 11,
  49544. /** DPadUp */
  49545. DPadUp = 12,
  49546. /** DPadDown */
  49547. DPadDown = 13,
  49548. /** DPadLeft */
  49549. DPadLeft = 14,
  49550. /** DRight */
  49551. DPadRight = 15,
  49552. /** Home */
  49553. Home = 16,
  49554. /** TouchPad */
  49555. TouchPad = 17,
  49556. /** LStickXAxis */
  49557. LStickXAxis = 18,
  49558. /** LStickYAxis */
  49559. LStickYAxis = 19,
  49560. /** RStickXAxis */
  49561. RStickXAxis = 20,
  49562. /** RStickYAxis */
  49563. RStickYAxis = 21
  49564. }
  49565. /**
  49566. * Enum for Xbox Gamepad
  49567. */
  49568. export enum XboxInput {
  49569. /** A */
  49570. A = 0,
  49571. /** B */
  49572. B = 1,
  49573. /** X */
  49574. X = 2,
  49575. /** Y */
  49576. Y = 3,
  49577. /** LB */
  49578. LB = 4,
  49579. /** RB */
  49580. RB = 5,
  49581. /** LT */
  49582. LT = 6,
  49583. /** RT */
  49584. RT = 7,
  49585. /** Back */
  49586. Back = 8,
  49587. /** Start */
  49588. Start = 9,
  49589. /** LS */
  49590. LS = 10,
  49591. /** RS */
  49592. RS = 11,
  49593. /** DPadUp */
  49594. DPadUp = 12,
  49595. /** DPadDown */
  49596. DPadDown = 13,
  49597. /** DPadLeft */
  49598. DPadLeft = 14,
  49599. /** DRight */
  49600. DPadRight = 15,
  49601. /** Home */
  49602. Home = 16,
  49603. /** LStickXAxis */
  49604. LStickXAxis = 17,
  49605. /** LStickYAxis */
  49606. LStickYAxis = 18,
  49607. /** RStickXAxis */
  49608. RStickXAxis = 19,
  49609. /** RStickYAxis */
  49610. RStickYAxis = 20
  49611. }
  49612. /**
  49613. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  49614. */
  49615. export enum SwitchInput {
  49616. /** B */
  49617. B = 0,
  49618. /** A */
  49619. A = 1,
  49620. /** Y */
  49621. Y = 2,
  49622. /** X */
  49623. X = 3,
  49624. /** L */
  49625. L = 4,
  49626. /** R */
  49627. R = 5,
  49628. /** ZL */
  49629. ZL = 6,
  49630. /** ZR */
  49631. ZR = 7,
  49632. /** Minus */
  49633. Minus = 8,
  49634. /** Plus */
  49635. Plus = 9,
  49636. /** LS */
  49637. LS = 10,
  49638. /** RS */
  49639. RS = 11,
  49640. /** DPadUp */
  49641. DPadUp = 12,
  49642. /** DPadDown */
  49643. DPadDown = 13,
  49644. /** DPadLeft */
  49645. DPadLeft = 14,
  49646. /** DRight */
  49647. DPadRight = 15,
  49648. /** Home */
  49649. Home = 16,
  49650. /** Capture */
  49651. Capture = 17,
  49652. /** LStickXAxis */
  49653. LStickXAxis = 18,
  49654. /** LStickYAxis */
  49655. LStickYAxis = 19,
  49656. /** RStickXAxis */
  49657. RStickXAxis = 20,
  49658. /** RStickYAxis */
  49659. RStickYAxis = 21
  49660. }
  49661. }
  49662. declare module BABYLON {
  49663. /**
  49664. * This class will take all inputs from Keyboard, Pointer, and
  49665. * any Gamepads and provide a polling system that all devices
  49666. * will use. This class assumes that there will only be one
  49667. * pointer device and one keyboard.
  49668. */
  49669. export class DeviceInputSystem implements IDisposable {
  49670. /**
  49671. * Callback to be triggered when a device is connected
  49672. */
  49673. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  49674. /**
  49675. * Callback to be triggered when a device is disconnected
  49676. */
  49677. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  49678. /**
  49679. * Callback to be triggered when event driven input is updated
  49680. */
  49681. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  49682. private _inputs;
  49683. private _gamepads;
  49684. private _keyboardActive;
  49685. private _pointerActive;
  49686. private _elementToAttachTo;
  49687. private _keyboardDownEvent;
  49688. private _keyboardUpEvent;
  49689. private _pointerMoveEvent;
  49690. private _pointerDownEvent;
  49691. private _pointerUpEvent;
  49692. private _gamepadConnectedEvent;
  49693. private _gamepadDisconnectedEvent;
  49694. private static _MAX_KEYCODES;
  49695. private static _MAX_POINTER_INPUTS;
  49696. /**
  49697. * Default Constructor
  49698. * @param engine - engine to pull input element from
  49699. */
  49700. constructor(engine: Engine);
  49701. /**
  49702. * Checks for current device input value, given an id and input index
  49703. * @param deviceName Id of connected device
  49704. * @param inputIndex Index of device input
  49705. * @returns Current value of input
  49706. */
  49707. /**
  49708. * Checks for current device input value, given an id and input index
  49709. * @param deviceType Enum specifiying device type
  49710. * @param deviceSlot "Slot" or index that device is referenced in
  49711. * @param inputIndex Id of input to be checked
  49712. * @returns Current value of input
  49713. */
  49714. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  49715. /**
  49716. * Dispose of all the eventlisteners
  49717. */
  49718. dispose(): void;
  49719. /**
  49720. * Add device and inputs to device array
  49721. * @param deviceType Enum specifiying device type
  49722. * @param deviceSlot "Slot" or index that device is referenced in
  49723. * @param numberOfInputs Number of input entries to create for given device
  49724. */
  49725. private _registerDevice;
  49726. /**
  49727. * Given a specific device name, remove that device from the device map
  49728. * @param deviceType Enum specifiying device type
  49729. * @param deviceSlot "Slot" or index that device is referenced in
  49730. */
  49731. private _unregisterDevice;
  49732. /**
  49733. * Handle all actions that come from keyboard interaction
  49734. */
  49735. private _handleKeyActions;
  49736. /**
  49737. * Handle all actions that come from pointer interaction
  49738. */
  49739. private _handlePointerActions;
  49740. /**
  49741. * Handle all actions that come from gamepad interaction
  49742. */
  49743. private _handleGamepadActions;
  49744. /**
  49745. * Update all non-event based devices with each frame
  49746. * @param deviceType Enum specifiying device type
  49747. * @param deviceSlot "Slot" or index that device is referenced in
  49748. * @param inputIndex Id of input to be checked
  49749. */
  49750. private _updateDevice;
  49751. /**
  49752. * Gets DeviceType from the device name
  49753. * @param deviceName Name of Device from DeviceInputSystem
  49754. * @returns DeviceType enum value
  49755. */
  49756. private _getGamepadDeviceType;
  49757. }
  49758. }
  49759. declare module BABYLON {
  49760. /**
  49761. * Type to handle enforcement of inputs
  49762. */
  49763. export type DeviceInput<T extends DeviceType> = T extends DeviceType.Keyboard | DeviceType.Generic ? number : T extends DeviceType.Mouse | DeviceType.Touch ? PointerInput : T extends DeviceType.DualShock ? DualShockInput : T extends DeviceType.Xbox ? XboxInput : T extends DeviceType.Switch ? SwitchInput : never;
  49764. }
  49765. declare module BABYLON {
  49766. /**
  49767. * Class that handles all input for a specific device
  49768. */
  49769. export class DeviceSource<T extends DeviceType> {
  49770. /** Type of device */
  49771. readonly deviceType: DeviceType;
  49772. /** "Slot" or index that device is referenced in */
  49773. readonly deviceSlot: number;
  49774. /**
  49775. * Observable to handle device input changes per device
  49776. */
  49777. readonly onInputChangedObservable: Observable<{
  49778. inputIndex: DeviceInput<T>;
  49779. previousState: Nullable<number>;
  49780. currentState: Nullable<number>;
  49781. }>;
  49782. private readonly _deviceInputSystem;
  49783. /**
  49784. * Default Constructor
  49785. * @param deviceInputSystem Reference to DeviceInputSystem
  49786. * @param deviceType Type of device
  49787. * @param deviceSlot "Slot" or index that device is referenced in
  49788. */
  49789. constructor(deviceInputSystem: DeviceInputSystem,
  49790. /** Type of device */
  49791. deviceType: DeviceType,
  49792. /** "Slot" or index that device is referenced in */
  49793. deviceSlot?: number);
  49794. /**
  49795. * Get input for specific input
  49796. * @param inputIndex index of specific input on device
  49797. * @returns Input value from DeviceInputSystem
  49798. */
  49799. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  49800. }
  49801. /**
  49802. * Class to keep track of devices
  49803. */
  49804. export class DeviceSourceManager implements IDisposable {
  49805. /**
  49806. * Observable to be triggered when before a device is connected
  49807. */
  49808. readonly onBeforeDeviceConnectedObservable: Observable<{
  49809. deviceType: DeviceType;
  49810. deviceSlot: number;
  49811. }>;
  49812. /**
  49813. * Observable to be triggered when before a device is disconnected
  49814. */
  49815. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  49816. deviceType: DeviceType;
  49817. deviceSlot: number;
  49818. }>;
  49819. /**
  49820. * Observable to be triggered when after a device is connected
  49821. */
  49822. readonly onAfterDeviceConnectedObservable: Observable<{
  49823. deviceType: DeviceType;
  49824. deviceSlot: number;
  49825. }>;
  49826. /**
  49827. * Observable to be triggered when after a device is disconnected
  49828. */
  49829. readonly onAfterDeviceDisconnectedObservable: Observable<{
  49830. deviceType: DeviceType;
  49831. deviceSlot: number;
  49832. }>;
  49833. private readonly _devices;
  49834. private readonly _firstDevice;
  49835. private readonly _deviceInputSystem;
  49836. /**
  49837. * Default Constructor
  49838. * @param engine engine to pull input element from
  49839. */
  49840. constructor(engine: Engine);
  49841. /**
  49842. * Gets a DeviceSource, given a type and slot
  49843. * @param deviceType Enum specifying device type
  49844. * @param deviceSlot "Slot" or index that device is referenced in
  49845. * @returns DeviceSource object
  49846. */
  49847. getDeviceSource<T extends DeviceType>(deviceType: DeviceType, deviceSlot?: number): Nullable<DeviceSource<T>>;
  49848. /**
  49849. * Gets an array of DeviceSource objects for a given device type
  49850. * @param deviceType Enum specifying device type
  49851. * @returns Array of DeviceSource objects
  49852. */
  49853. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  49854. /**
  49855. * Dispose of DeviceInputSystem and other parts
  49856. */
  49857. dispose(): void;
  49858. /**
  49859. * Function to add device name to device list
  49860. * @param deviceType Enum specifying device type
  49861. * @param deviceSlot "Slot" or index that device is referenced in
  49862. */
  49863. private _addDevice;
  49864. /**
  49865. * Function to remove device name to device list
  49866. * @param deviceType Enum specifying device type
  49867. * @param deviceSlot "Slot" or index that device is referenced in
  49868. */
  49869. private _removeDevice;
  49870. /**
  49871. * Updates array storing first connected device of each type
  49872. * @param type Type of Device
  49873. */
  49874. private _updateFirstDevices;
  49875. }
  49876. }
  49877. declare module BABYLON {
  49878. /**
  49879. * Options to create the null engine
  49880. */
  49881. export class NullEngineOptions {
  49882. /**
  49883. * Render width (Default: 512)
  49884. */
  49885. renderWidth: number;
  49886. /**
  49887. * Render height (Default: 256)
  49888. */
  49889. renderHeight: number;
  49890. /**
  49891. * Texture size (Default: 512)
  49892. */
  49893. textureSize: number;
  49894. /**
  49895. * If delta time between frames should be constant
  49896. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  49897. */
  49898. deterministicLockstep: boolean;
  49899. /**
  49900. * Maximum about of steps between frames (Default: 4)
  49901. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  49902. */
  49903. lockstepMaxSteps: number;
  49904. }
  49905. /**
  49906. * The null engine class provides support for headless version of babylon.js.
  49907. * This can be used in server side scenario or for testing purposes
  49908. */
  49909. export class NullEngine extends Engine {
  49910. private _options;
  49911. /**
  49912. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  49913. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  49914. * @returns true if engine is in deterministic lock step mode
  49915. */
  49916. isDeterministicLockStep(): boolean;
  49917. /**
  49918. * Gets the max steps when engine is running in deterministic lock step
  49919. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  49920. * @returns the max steps
  49921. */
  49922. getLockstepMaxSteps(): number;
  49923. /**
  49924. * Gets the current hardware scaling level.
  49925. * By default the hardware scaling level is computed from the window device ratio.
  49926. * 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.
  49927. * @returns a number indicating the current hardware scaling level
  49928. */
  49929. getHardwareScalingLevel(): number;
  49930. constructor(options?: NullEngineOptions);
  49931. /**
  49932. * Creates a vertex buffer
  49933. * @param vertices the data for the vertex buffer
  49934. * @returns the new WebGL static buffer
  49935. */
  49936. createVertexBuffer(vertices: FloatArray): DataBuffer;
  49937. /**
  49938. * Creates a new index buffer
  49939. * @param indices defines the content of the index buffer
  49940. * @param updatable defines if the index buffer must be updatable
  49941. * @returns a new webGL buffer
  49942. */
  49943. createIndexBuffer(indices: IndicesArray): DataBuffer;
  49944. /**
  49945. * Clear the current render buffer or the current render target (if any is set up)
  49946. * @param color defines the color to use
  49947. * @param backBuffer defines if the back buffer must be cleared
  49948. * @param depth defines if the depth buffer must be cleared
  49949. * @param stencil defines if the stencil buffer must be cleared
  49950. */
  49951. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  49952. /**
  49953. * Gets the current render width
  49954. * @param useScreen defines if screen size must be used (or the current render target if any)
  49955. * @returns a number defining the current render width
  49956. */
  49957. getRenderWidth(useScreen?: boolean): number;
  49958. /**
  49959. * Gets the current render height
  49960. * @param useScreen defines if screen size must be used (or the current render target if any)
  49961. * @returns a number defining the current render height
  49962. */
  49963. getRenderHeight(useScreen?: boolean): number;
  49964. /**
  49965. * Set the WebGL's viewport
  49966. * @param viewport defines the viewport element to be used
  49967. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  49968. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  49969. */
  49970. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  49971. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  49972. /**
  49973. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  49974. * @param pipelineContext defines the pipeline context to use
  49975. * @param uniformsNames defines the list of uniform names
  49976. * @returns an array of webGL uniform locations
  49977. */
  49978. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  49979. /**
  49980. * Gets the lsit of active attributes for a given webGL program
  49981. * @param pipelineContext defines the pipeline context to use
  49982. * @param attributesNames defines the list of attribute names to get
  49983. * @returns an array of indices indicating the offset of each attribute
  49984. */
  49985. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  49986. /**
  49987. * Binds an effect to the webGL context
  49988. * @param effect defines the effect to bind
  49989. */
  49990. bindSamplers(effect: Effect): void;
  49991. /**
  49992. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  49993. * @param effect defines the effect to activate
  49994. */
  49995. enableEffect(effect: Effect): void;
  49996. /**
  49997. * Set various states to the webGL context
  49998. * @param culling defines backface culling state
  49999. * @param zOffset defines the value to apply to zOffset (0 by default)
  50000. * @param force defines if states must be applied even if cache is up to date
  50001. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  50002. */
  50003. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  50004. /**
  50005. * Set the value of an uniform to an array of int32
  50006. * @param uniform defines the webGL uniform location where to store the value
  50007. * @param array defines the array of int32 to store
  50008. */
  50009. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  50010. /**
  50011. * Set the value of an uniform to an array of int32 (stored as vec2)
  50012. * @param uniform defines the webGL uniform location where to store the value
  50013. * @param array defines the array of int32 to store
  50014. */
  50015. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  50016. /**
  50017. * Set the value of an uniform to an array of int32 (stored as vec3)
  50018. * @param uniform defines the webGL uniform location where to store the value
  50019. * @param array defines the array of int32 to store
  50020. */
  50021. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  50022. /**
  50023. * Set the value of an uniform to an array of int32 (stored as vec4)
  50024. * @param uniform defines the webGL uniform location where to store the value
  50025. * @param array defines the array of int32 to store
  50026. */
  50027. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  50028. /**
  50029. * Set the value of an uniform to an array of float32
  50030. * @param uniform defines the webGL uniform location where to store the value
  50031. * @param array defines the array of float32 to store
  50032. */
  50033. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  50034. /**
  50035. * Set the value of an uniform to an array of float32 (stored as vec2)
  50036. * @param uniform defines the webGL uniform location where to store the value
  50037. * @param array defines the array of float32 to store
  50038. */
  50039. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  50040. /**
  50041. * Set the value of an uniform to an array of float32 (stored as vec3)
  50042. * @param uniform defines the webGL uniform location where to store the value
  50043. * @param array defines the array of float32 to store
  50044. */
  50045. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  50046. /**
  50047. * Set the value of an uniform to an array of float32 (stored as vec4)
  50048. * @param uniform defines the webGL uniform location where to store the value
  50049. * @param array defines the array of float32 to store
  50050. */
  50051. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  50052. /**
  50053. * Set the value of an uniform to an array of number
  50054. * @param uniform defines the webGL uniform location where to store the value
  50055. * @param array defines the array of number to store
  50056. */
  50057. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  50058. /**
  50059. * Set the value of an uniform to an array of number (stored as vec2)
  50060. * @param uniform defines the webGL uniform location where to store the value
  50061. * @param array defines the array of number to store
  50062. */
  50063. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  50064. /**
  50065. * Set the value of an uniform to an array of number (stored as vec3)
  50066. * @param uniform defines the webGL uniform location where to store the value
  50067. * @param array defines the array of number to store
  50068. */
  50069. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  50070. /**
  50071. * Set the value of an uniform to an array of number (stored as vec4)
  50072. * @param uniform defines the webGL uniform location where to store the value
  50073. * @param array defines the array of number to store
  50074. */
  50075. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  50076. /**
  50077. * Set the value of an uniform to an array of float32 (stored as matrices)
  50078. * @param uniform defines the webGL uniform location where to store the value
  50079. * @param matrices defines the array of float32 to store
  50080. */
  50081. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  50082. /**
  50083. * Set the value of an uniform to a matrix (3x3)
  50084. * @param uniform defines the webGL uniform location where to store the value
  50085. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  50086. */
  50087. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  50088. /**
  50089. * Set the value of an uniform to a matrix (2x2)
  50090. * @param uniform defines the webGL uniform location where to store the value
  50091. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  50092. */
  50093. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  50094. /**
  50095. * Set the value of an uniform to a number (float)
  50096. * @param uniform defines the webGL uniform location where to store the value
  50097. * @param value defines the float number to store
  50098. */
  50099. setFloat(uniform: WebGLUniformLocation, value: number): void;
  50100. /**
  50101. * Set the value of an uniform to a vec2
  50102. * @param uniform defines the webGL uniform location where to store the value
  50103. * @param x defines the 1st component of the value
  50104. * @param y defines the 2nd component of the value
  50105. */
  50106. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  50107. /**
  50108. * Set the value of an uniform to a vec3
  50109. * @param uniform defines the webGL uniform location where to store the value
  50110. * @param x defines the 1st component of the value
  50111. * @param y defines the 2nd component of the value
  50112. * @param z defines the 3rd component of the value
  50113. */
  50114. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  50115. /**
  50116. * Set the value of an uniform to a boolean
  50117. * @param uniform defines the webGL uniform location where to store the value
  50118. * @param bool defines the boolean to store
  50119. */
  50120. setBool(uniform: WebGLUniformLocation, bool: number): void;
  50121. /**
  50122. * Set the value of an uniform to a vec4
  50123. * @param uniform defines the webGL uniform location where to store the value
  50124. * @param x defines the 1st component of the value
  50125. * @param y defines the 2nd component of the value
  50126. * @param z defines the 3rd component of the value
  50127. * @param w defines the 4th component of the value
  50128. */
  50129. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  50130. /**
  50131. * Sets the current alpha mode
  50132. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  50133. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  50134. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  50135. */
  50136. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  50137. /**
  50138. * Bind webGl buffers directly to the webGL context
  50139. * @param vertexBuffers defines the vertex buffer to bind
  50140. * @param indexBuffer defines the index buffer to bind
  50141. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  50142. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  50143. * @param effect defines the effect associated with the vertex buffer
  50144. */
  50145. bindBuffers(vertexBuffers: {
  50146. [key: string]: VertexBuffer;
  50147. }, indexBuffer: DataBuffer, effect: Effect): void;
  50148. /**
  50149. * Force the entire cache to be cleared
  50150. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  50151. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  50152. */
  50153. wipeCaches(bruteForce?: boolean): void;
  50154. /**
  50155. * Send a draw order
  50156. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  50157. * @param indexStart defines the starting index
  50158. * @param indexCount defines the number of index to draw
  50159. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50160. */
  50161. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  50162. /**
  50163. * Draw a list of indexed primitives
  50164. * @param fillMode defines the primitive to use
  50165. * @param indexStart defines the starting index
  50166. * @param indexCount defines the number of index to draw
  50167. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50168. */
  50169. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  50170. /**
  50171. * Draw a list of unindexed primitives
  50172. * @param fillMode defines the primitive to use
  50173. * @param verticesStart defines the index of first vertex to draw
  50174. * @param verticesCount defines the count of vertices to draw
  50175. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50176. */
  50177. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  50178. /** @hidden */
  50179. _createTexture(): WebGLTexture;
  50180. /** @hidden */
  50181. _releaseTexture(texture: InternalTexture): void;
  50182. /**
  50183. * Usually called from Texture.ts.
  50184. * Passed information to create a WebGLTexture
  50185. * @param urlArg defines a value which contains one of the following:
  50186. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  50187. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  50188. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  50189. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  50190. * @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)
  50191. * @param scene needed for loading to the correct scene
  50192. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  50193. * @param onLoad optional callback to be called upon successful completion
  50194. * @param onError optional callback to be called upon failure
  50195. * @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
  50196. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  50197. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  50198. * @param forcedExtension defines the extension to use to pick the right loader
  50199. * @param mimeType defines an optional mime type
  50200. * @returns a InternalTexture for assignment back into BABYLON.Texture
  50201. */
  50202. 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>, mimeType?: string): InternalTexture;
  50203. /**
  50204. * Creates a new render target texture
  50205. * @param size defines the size of the texture
  50206. * @param options defines the options used to create the texture
  50207. * @returns a new render target texture stored in an InternalTexture
  50208. */
  50209. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  50210. /**
  50211. * Update the sampling mode of a given texture
  50212. * @param samplingMode defines the required sampling mode
  50213. * @param texture defines the texture to update
  50214. */
  50215. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  50216. /**
  50217. * Binds the frame buffer to the specified texture.
  50218. * @param texture The texture to render to or null for the default canvas
  50219. * @param faceIndex The face of the texture to render to in case of cube texture
  50220. * @param requiredWidth The width of the target to render to
  50221. * @param requiredHeight The height of the target to render to
  50222. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  50223. * @param lodLevel defines le lod level to bind to the frame buffer
  50224. */
  50225. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  50226. /**
  50227. * Unbind the current render target texture from the webGL context
  50228. * @param texture defines the render target texture to unbind
  50229. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  50230. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  50231. */
  50232. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  50233. /**
  50234. * Creates a dynamic vertex buffer
  50235. * @param vertices the data for the dynamic vertex buffer
  50236. * @returns the new WebGL dynamic buffer
  50237. */
  50238. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  50239. /**
  50240. * Update the content of a dynamic texture
  50241. * @param texture defines the texture to update
  50242. * @param canvas defines the canvas containing the source
  50243. * @param invertY defines if data must be stored with Y axis inverted
  50244. * @param premulAlpha defines if alpha is stored as premultiplied
  50245. * @param format defines the format of the data
  50246. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  50247. */
  50248. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  50249. /**
  50250. * Gets a boolean indicating if all created effects are ready
  50251. * @returns true if all effects are ready
  50252. */
  50253. areAllEffectsReady(): boolean;
  50254. /**
  50255. * @hidden
  50256. * Get the current error code of the webGL context
  50257. * @returns the error code
  50258. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  50259. */
  50260. getError(): number;
  50261. /** @hidden */
  50262. _getUnpackAlignement(): number;
  50263. /** @hidden */
  50264. _unpackFlipY(value: boolean): void;
  50265. /**
  50266. * Update a dynamic index buffer
  50267. * @param indexBuffer defines the target index buffer
  50268. * @param indices defines the data to update
  50269. * @param offset defines the offset in the target index buffer where update should start
  50270. */
  50271. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  50272. /**
  50273. * Updates a dynamic vertex buffer.
  50274. * @param vertexBuffer the vertex buffer to update
  50275. * @param vertices the data used to update the vertex buffer
  50276. * @param byteOffset the byte offset of the data (optional)
  50277. * @param byteLength the byte length of the data (optional)
  50278. */
  50279. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  50280. /** @hidden */
  50281. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  50282. /** @hidden */
  50283. _bindTexture(channel: number, texture: InternalTexture): void;
  50284. protected _deleteBuffer(buffer: WebGLBuffer): void;
  50285. /**
  50286. * 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
  50287. */
  50288. releaseEffects(): void;
  50289. displayLoadingUI(): void;
  50290. hideLoadingUI(): void;
  50291. /** @hidden */
  50292. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50293. /** @hidden */
  50294. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50295. /** @hidden */
  50296. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50297. /** @hidden */
  50298. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  50299. }
  50300. }
  50301. declare module BABYLON {
  50302. /**
  50303. * @hidden
  50304. **/
  50305. export class _TimeToken {
  50306. _startTimeQuery: Nullable<WebGLQuery>;
  50307. _endTimeQuery: Nullable<WebGLQuery>;
  50308. _timeElapsedQuery: Nullable<WebGLQuery>;
  50309. _timeElapsedQueryEnded: boolean;
  50310. }
  50311. }
  50312. declare module BABYLON {
  50313. /** @hidden */
  50314. export class _OcclusionDataStorage {
  50315. /** @hidden */
  50316. occlusionInternalRetryCounter: number;
  50317. /** @hidden */
  50318. isOcclusionQueryInProgress: boolean;
  50319. /** @hidden */
  50320. isOccluded: boolean;
  50321. /** @hidden */
  50322. occlusionRetryCount: number;
  50323. /** @hidden */
  50324. occlusionType: number;
  50325. /** @hidden */
  50326. occlusionQueryAlgorithmType: number;
  50327. }
  50328. interface Engine {
  50329. /**
  50330. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  50331. * @return the new query
  50332. */
  50333. createQuery(): WebGLQuery;
  50334. /**
  50335. * Delete and release a webGL query
  50336. * @param query defines the query to delete
  50337. * @return the current engine
  50338. */
  50339. deleteQuery(query: WebGLQuery): Engine;
  50340. /**
  50341. * Check if a given query has resolved and got its value
  50342. * @param query defines the query to check
  50343. * @returns true if the query got its value
  50344. */
  50345. isQueryResultAvailable(query: WebGLQuery): boolean;
  50346. /**
  50347. * Gets the value of a given query
  50348. * @param query defines the query to check
  50349. * @returns the value of the query
  50350. */
  50351. getQueryResult(query: WebGLQuery): number;
  50352. /**
  50353. * Initiates an occlusion query
  50354. * @param algorithmType defines the algorithm to use
  50355. * @param query defines the query to use
  50356. * @returns the current engine
  50357. * @see http://doc.babylonjs.com/features/occlusionquery
  50358. */
  50359. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  50360. /**
  50361. * Ends an occlusion query
  50362. * @see http://doc.babylonjs.com/features/occlusionquery
  50363. * @param algorithmType defines the algorithm to use
  50364. * @returns the current engine
  50365. */
  50366. endOcclusionQuery(algorithmType: number): Engine;
  50367. /**
  50368. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  50369. * Please note that only one query can be issued at a time
  50370. * @returns a time token used to track the time span
  50371. */
  50372. startTimeQuery(): Nullable<_TimeToken>;
  50373. /**
  50374. * Ends a time query
  50375. * @param token defines the token used to measure the time span
  50376. * @returns the time spent (in ns)
  50377. */
  50378. endTimeQuery(token: _TimeToken): int;
  50379. /** @hidden */
  50380. _currentNonTimestampToken: Nullable<_TimeToken>;
  50381. /** @hidden */
  50382. _createTimeQuery(): WebGLQuery;
  50383. /** @hidden */
  50384. _deleteTimeQuery(query: WebGLQuery): void;
  50385. /** @hidden */
  50386. _getGlAlgorithmType(algorithmType: number): number;
  50387. /** @hidden */
  50388. _getTimeQueryResult(query: WebGLQuery): any;
  50389. /** @hidden */
  50390. _getTimeQueryAvailability(query: WebGLQuery): any;
  50391. }
  50392. interface AbstractMesh {
  50393. /**
  50394. * Backing filed
  50395. * @hidden
  50396. */
  50397. __occlusionDataStorage: _OcclusionDataStorage;
  50398. /**
  50399. * Access property
  50400. * @hidden
  50401. */
  50402. _occlusionDataStorage: _OcclusionDataStorage;
  50403. /**
  50404. * 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.
  50405. * The default value is -1 which means don't break the query and wait till the result
  50406. * @see http://doc.babylonjs.com/features/occlusionquery
  50407. */
  50408. occlusionRetryCount: number;
  50409. /**
  50410. * 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:
  50411. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  50412. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  50413. * * 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.
  50414. * @see http://doc.babylonjs.com/features/occlusionquery
  50415. */
  50416. occlusionType: number;
  50417. /**
  50418. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  50419. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  50420. * * 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.
  50421. * @see http://doc.babylonjs.com/features/occlusionquery
  50422. */
  50423. occlusionQueryAlgorithmType: number;
  50424. /**
  50425. * 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
  50426. * @see http://doc.babylonjs.com/features/occlusionquery
  50427. */
  50428. isOccluded: boolean;
  50429. /**
  50430. * Flag to check the progress status of the query
  50431. * @see http://doc.babylonjs.com/features/occlusionquery
  50432. */
  50433. isOcclusionQueryInProgress: boolean;
  50434. }
  50435. }
  50436. declare module BABYLON {
  50437. /** @hidden */
  50438. export var _forceTransformFeedbackToBundle: boolean;
  50439. interface Engine {
  50440. /**
  50441. * Creates a webGL transform feedback object
  50442. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  50443. * @returns the webGL transform feedback object
  50444. */
  50445. createTransformFeedback(): WebGLTransformFeedback;
  50446. /**
  50447. * Delete a webGL transform feedback object
  50448. * @param value defines the webGL transform feedback object to delete
  50449. */
  50450. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  50451. /**
  50452. * Bind a webGL transform feedback object to the webgl context
  50453. * @param value defines the webGL transform feedback object to bind
  50454. */
  50455. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  50456. /**
  50457. * Begins a transform feedback operation
  50458. * @param usePoints defines if points or triangles must be used
  50459. */
  50460. beginTransformFeedback(usePoints: boolean): void;
  50461. /**
  50462. * Ends a transform feedback operation
  50463. */
  50464. endTransformFeedback(): void;
  50465. /**
  50466. * Specify the varyings to use with transform feedback
  50467. * @param program defines the associated webGL program
  50468. * @param value defines the list of strings representing the varying names
  50469. */
  50470. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  50471. /**
  50472. * Bind a webGL buffer for a transform feedback operation
  50473. * @param value defines the webGL buffer to bind
  50474. */
  50475. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  50476. }
  50477. }
  50478. declare module BABYLON {
  50479. /**
  50480. * Creation options of the multi render target texture.
  50481. */
  50482. export interface IMultiRenderTargetOptions {
  50483. /**
  50484. * Define if the texture needs to create mip maps after render.
  50485. */
  50486. generateMipMaps?: boolean;
  50487. /**
  50488. * Define the types of all the draw buffers we want to create
  50489. */
  50490. types?: number[];
  50491. /**
  50492. * Define the sampling modes of all the draw buffers we want to create
  50493. */
  50494. samplingModes?: number[];
  50495. /**
  50496. * Define if a depth buffer is required
  50497. */
  50498. generateDepthBuffer?: boolean;
  50499. /**
  50500. * Define if a stencil buffer is required
  50501. */
  50502. generateStencilBuffer?: boolean;
  50503. /**
  50504. * Define if a depth texture is required instead of a depth buffer
  50505. */
  50506. generateDepthTexture?: boolean;
  50507. /**
  50508. * Define the number of desired draw buffers
  50509. */
  50510. textureCount?: number;
  50511. /**
  50512. * Define if aspect ratio should be adapted to the texture or stay the scene one
  50513. */
  50514. doNotChangeAspectRatio?: boolean;
  50515. /**
  50516. * Define the default type of the buffers we are creating
  50517. */
  50518. defaultType?: number;
  50519. }
  50520. /**
  50521. * A multi render target, like a render target provides the ability to render to a texture.
  50522. * Unlike the render target, it can render to several draw buffers in one draw.
  50523. * This is specially interesting in deferred rendering or for any effects requiring more than
  50524. * just one color from a single pass.
  50525. */
  50526. export class MultiRenderTarget extends RenderTargetTexture {
  50527. private _internalTextures;
  50528. private _textures;
  50529. private _multiRenderTargetOptions;
  50530. /**
  50531. * Get if draw buffers are currently supported by the used hardware and browser.
  50532. */
  50533. get isSupported(): boolean;
  50534. /**
  50535. * Get the list of textures generated by the multi render target.
  50536. */
  50537. get textures(): Texture[];
  50538. /**
  50539. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  50540. */
  50541. get depthTexture(): Texture;
  50542. /**
  50543. * Set the wrapping mode on U of all the textures we are rendering to.
  50544. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  50545. */
  50546. set wrapU(wrap: number);
  50547. /**
  50548. * Set the wrapping mode on V of all the textures we are rendering to.
  50549. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  50550. */
  50551. set wrapV(wrap: number);
  50552. /**
  50553. * Instantiate a new multi render target texture.
  50554. * A multi render target, like a render target provides the ability to render to a texture.
  50555. * Unlike the render target, it can render to several draw buffers in one draw.
  50556. * This is specially interesting in deferred rendering or for any effects requiring more than
  50557. * just one color from a single pass.
  50558. * @param name Define the name of the texture
  50559. * @param size Define the size of the buffers to render to
  50560. * @param count Define the number of target we are rendering into
  50561. * @param scene Define the scene the texture belongs to
  50562. * @param options Define the options used to create the multi render target
  50563. */
  50564. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  50565. /** @hidden */
  50566. _rebuild(): void;
  50567. private _createInternalTextures;
  50568. private _createTextures;
  50569. /**
  50570. * Define the number of samples used if MSAA is enabled.
  50571. */
  50572. get samples(): number;
  50573. set samples(value: number);
  50574. /**
  50575. * Resize all the textures in the multi render target.
  50576. * Be carrefull as it will recreate all the data in the new texture.
  50577. * @param size Define the new size
  50578. */
  50579. resize(size: any): void;
  50580. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  50581. /**
  50582. * Dispose the render targets and their associated resources
  50583. */
  50584. dispose(): void;
  50585. /**
  50586. * Release all the underlying texture used as draw buffers.
  50587. */
  50588. releaseInternalTextures(): void;
  50589. }
  50590. }
  50591. declare module BABYLON {
  50592. interface ThinEngine {
  50593. /**
  50594. * Unbind a list of render target textures from the webGL context
  50595. * This is used only when drawBuffer extension or webGL2 are active
  50596. * @param textures defines the render target textures to unbind
  50597. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  50598. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  50599. */
  50600. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  50601. /**
  50602. * Create a multi render target texture
  50603. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  50604. * @param size defines the size of the texture
  50605. * @param options defines the creation options
  50606. * @returns the cube texture as an InternalTexture
  50607. */
  50608. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  50609. /**
  50610. * Update the sample count for a given multiple render target texture
  50611. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  50612. * @param textures defines the textures to update
  50613. * @param samples defines the sample count to set
  50614. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  50615. */
  50616. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  50617. }
  50618. }
  50619. declare module BABYLON {
  50620. /**
  50621. * Class used to define an additional view for the engine
  50622. * @see https://doc.babylonjs.com/how_to/multi_canvases
  50623. */
  50624. export class EngineView {
  50625. /** Defines the canvas where to render the view */
  50626. target: HTMLCanvasElement;
  50627. /** Defines an optional camera used to render the view (will use active camera else) */
  50628. camera?: Camera;
  50629. }
  50630. interface Engine {
  50631. /**
  50632. * Gets or sets the HTML element to use for attaching events
  50633. */
  50634. inputElement: Nullable<HTMLElement>;
  50635. /**
  50636. * Gets the current engine view
  50637. * @see https://doc.babylonjs.com/how_to/multi_canvases
  50638. */
  50639. activeView: Nullable<EngineView>;
  50640. /** Gets or sets the list of views */
  50641. views: EngineView[];
  50642. /**
  50643. * Register a new child canvas
  50644. * @param canvas defines the canvas to register
  50645. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  50646. * @returns the associated view
  50647. */
  50648. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  50649. /**
  50650. * Remove a registered child canvas
  50651. * @param canvas defines the canvas to remove
  50652. * @returns the current engine
  50653. */
  50654. unRegisterView(canvas: HTMLCanvasElement): Engine;
  50655. }
  50656. }
  50657. declare module BABYLON {
  50658. interface Engine {
  50659. /** @hidden */
  50660. _excludedCompressedTextures: string[];
  50661. /** @hidden */
  50662. _textureFormatInUse: string;
  50663. /**
  50664. * Gets the list of texture formats supported
  50665. */
  50666. readonly texturesSupported: Array<string>;
  50667. /**
  50668. * Gets the texture format in use
  50669. */
  50670. readonly textureFormatInUse: Nullable<string>;
  50671. /**
  50672. * Set the compressed texture extensions or file names to skip.
  50673. *
  50674. * @param skippedFiles defines the list of those texture files you want to skip
  50675. * Example: [".dds", ".env", "myfile.png"]
  50676. */
  50677. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  50678. /**
  50679. * Set the compressed texture format to use, based on the formats you have, and the formats
  50680. * supported by the hardware / browser.
  50681. *
  50682. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  50683. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  50684. * to API arguments needed to compressed textures. This puts the burden on the container
  50685. * generator to house the arcane code for determining these for current & future formats.
  50686. *
  50687. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  50688. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  50689. *
  50690. * Note: The result of this call is not taken into account when a texture is base64.
  50691. *
  50692. * @param formatsAvailable defines the list of those format families you have created
  50693. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  50694. *
  50695. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  50696. * @returns The extension selected.
  50697. */
  50698. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  50699. }
  50700. }
  50701. declare module BABYLON {
  50702. /**
  50703. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  50704. */
  50705. export interface CubeMapInfo {
  50706. /**
  50707. * The pixel array for the front face.
  50708. * This is stored in format, left to right, up to down format.
  50709. */
  50710. front: Nullable<ArrayBufferView>;
  50711. /**
  50712. * The pixel array for the back face.
  50713. * This is stored in format, left to right, up to down format.
  50714. */
  50715. back: Nullable<ArrayBufferView>;
  50716. /**
  50717. * The pixel array for the left face.
  50718. * This is stored in format, left to right, up to down format.
  50719. */
  50720. left: Nullable<ArrayBufferView>;
  50721. /**
  50722. * The pixel array for the right face.
  50723. * This is stored in format, left to right, up to down format.
  50724. */
  50725. right: Nullable<ArrayBufferView>;
  50726. /**
  50727. * The pixel array for the up face.
  50728. * This is stored in format, left to right, up to down format.
  50729. */
  50730. up: Nullable<ArrayBufferView>;
  50731. /**
  50732. * The pixel array for the down face.
  50733. * This is stored in format, left to right, up to down format.
  50734. */
  50735. down: Nullable<ArrayBufferView>;
  50736. /**
  50737. * The size of the cubemap stored.
  50738. *
  50739. * Each faces will be size * size pixels.
  50740. */
  50741. size: number;
  50742. /**
  50743. * The format of the texture.
  50744. *
  50745. * RGBA, RGB.
  50746. */
  50747. format: number;
  50748. /**
  50749. * The type of the texture data.
  50750. *
  50751. * UNSIGNED_INT, FLOAT.
  50752. */
  50753. type: number;
  50754. /**
  50755. * Specifies whether the texture is in gamma space.
  50756. */
  50757. gammaSpace: boolean;
  50758. }
  50759. /**
  50760. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  50761. */
  50762. export class PanoramaToCubeMapTools {
  50763. private static FACE_LEFT;
  50764. private static FACE_RIGHT;
  50765. private static FACE_FRONT;
  50766. private static FACE_BACK;
  50767. private static FACE_DOWN;
  50768. private static FACE_UP;
  50769. /**
  50770. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  50771. *
  50772. * @param float32Array The source data.
  50773. * @param inputWidth The width of the input panorama.
  50774. * @param inputHeight The height of the input panorama.
  50775. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  50776. * @return The cubemap data
  50777. */
  50778. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  50779. private static CreateCubemapTexture;
  50780. private static CalcProjectionSpherical;
  50781. }
  50782. }
  50783. declare module BABYLON {
  50784. /**
  50785. * Helper class dealing with the extraction of spherical polynomial dataArray
  50786. * from a cube map.
  50787. */
  50788. export class CubeMapToSphericalPolynomialTools {
  50789. private static FileFaces;
  50790. /**
  50791. * Converts a texture to the according Spherical Polynomial data.
  50792. * This extracts the first 3 orders only as they are the only one used in the lighting.
  50793. *
  50794. * @param texture The texture to extract the information from.
  50795. * @return The Spherical Polynomial data.
  50796. */
  50797. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  50798. /**
  50799. * Converts a cubemap to the according Spherical Polynomial data.
  50800. * This extracts the first 3 orders only as they are the only one used in the lighting.
  50801. *
  50802. * @param cubeInfo The Cube map to extract the information from.
  50803. * @return The Spherical Polynomial data.
  50804. */
  50805. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  50806. }
  50807. }
  50808. declare module BABYLON {
  50809. interface BaseTexture {
  50810. /**
  50811. * Get the polynomial representation of the texture data.
  50812. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  50813. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  50814. */
  50815. sphericalPolynomial: Nullable<SphericalPolynomial>;
  50816. }
  50817. }
  50818. declare module BABYLON {
  50819. /** @hidden */
  50820. export var rgbdEncodePixelShader: {
  50821. name: string;
  50822. shader: string;
  50823. };
  50824. }
  50825. declare module BABYLON {
  50826. /** @hidden */
  50827. export var rgbdDecodePixelShader: {
  50828. name: string;
  50829. shader: string;
  50830. };
  50831. }
  50832. declare module BABYLON {
  50833. /**
  50834. * Raw texture data and descriptor sufficient for WebGL texture upload
  50835. */
  50836. export interface EnvironmentTextureInfo {
  50837. /**
  50838. * Version of the environment map
  50839. */
  50840. version: number;
  50841. /**
  50842. * Width of image
  50843. */
  50844. width: number;
  50845. /**
  50846. * Irradiance information stored in the file.
  50847. */
  50848. irradiance: any;
  50849. /**
  50850. * Specular information stored in the file.
  50851. */
  50852. specular: any;
  50853. }
  50854. /**
  50855. * Defines One Image in the file. It requires only the position in the file
  50856. * as well as the length.
  50857. */
  50858. interface BufferImageData {
  50859. /**
  50860. * Length of the image data.
  50861. */
  50862. length: number;
  50863. /**
  50864. * Position of the data from the null terminator delimiting the end of the JSON.
  50865. */
  50866. position: number;
  50867. }
  50868. /**
  50869. * Defines the specular data enclosed in the file.
  50870. * This corresponds to the version 1 of the data.
  50871. */
  50872. export interface EnvironmentTextureSpecularInfoV1 {
  50873. /**
  50874. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  50875. */
  50876. specularDataPosition?: number;
  50877. /**
  50878. * This contains all the images data needed to reconstruct the cubemap.
  50879. */
  50880. mipmaps: Array<BufferImageData>;
  50881. /**
  50882. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  50883. */
  50884. lodGenerationScale: number;
  50885. }
  50886. /**
  50887. * Sets of helpers addressing the serialization and deserialization of environment texture
  50888. * stored in a BabylonJS env file.
  50889. * Those files are usually stored as .env files.
  50890. */
  50891. export class EnvironmentTextureTools {
  50892. /**
  50893. * Magic number identifying the env file.
  50894. */
  50895. private static _MagicBytes;
  50896. /**
  50897. * Gets the environment info from an env file.
  50898. * @param data The array buffer containing the .env bytes.
  50899. * @returns the environment file info (the json header) if successfully parsed.
  50900. */
  50901. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  50902. /**
  50903. * Creates an environment texture from a loaded cube texture.
  50904. * @param texture defines the cube texture to convert in env file
  50905. * @return a promise containing the environment data if succesfull.
  50906. */
  50907. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  50908. /**
  50909. * Creates a JSON representation of the spherical data.
  50910. * @param texture defines the texture containing the polynomials
  50911. * @return the JSON representation of the spherical info
  50912. */
  50913. private static _CreateEnvTextureIrradiance;
  50914. /**
  50915. * Creates the ArrayBufferViews used for initializing environment texture image data.
  50916. * @param data the image data
  50917. * @param info parameters that determine what views will be created for accessing the underlying buffer
  50918. * @return the views described by info providing access to the underlying buffer
  50919. */
  50920. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  50921. /**
  50922. * Uploads the texture info contained in the env file to the GPU.
  50923. * @param texture defines the internal texture to upload to
  50924. * @param data defines the data to load
  50925. * @param info defines the texture info retrieved through the GetEnvInfo method
  50926. * @returns a promise
  50927. */
  50928. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  50929. private static _OnImageReadyAsync;
  50930. /**
  50931. * Uploads the levels of image data to the GPU.
  50932. * @param texture defines the internal texture to upload to
  50933. * @param imageData defines the array buffer views of image data [mipmap][face]
  50934. * @returns a promise
  50935. */
  50936. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  50937. /**
  50938. * Uploads spherical polynomials information to the texture.
  50939. * @param texture defines the texture we are trying to upload the information to
  50940. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  50941. */
  50942. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  50943. /** @hidden */
  50944. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  50945. }
  50946. }
  50947. declare module BABYLON {
  50948. /** @hidden */
  50949. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  50950. private _genericAttributeLocation;
  50951. private _varyingLocationCount;
  50952. private _varyingLocationMap;
  50953. private _replacements;
  50954. private _textureCount;
  50955. private _uniforms;
  50956. lineProcessor(line: string): string;
  50957. attributeProcessor(attribute: string): string;
  50958. varyingProcessor(varying: string, isFragment: boolean): string;
  50959. uniformProcessor(uniform: string): string;
  50960. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  50961. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  50962. }
  50963. }
  50964. declare module BABYLON {
  50965. /**
  50966. * Container for accessors for natively-stored mesh data buffers.
  50967. */
  50968. class NativeDataBuffer extends DataBuffer {
  50969. /**
  50970. * Accessor value used to identify/retrieve a natively-stored index buffer.
  50971. */
  50972. nativeIndexBuffer?: any;
  50973. /**
  50974. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  50975. */
  50976. nativeVertexBuffer?: any;
  50977. }
  50978. /** @hidden */
  50979. class NativeTexture extends InternalTexture {
  50980. getInternalTexture(): InternalTexture;
  50981. getViewCount(): number;
  50982. }
  50983. /** @hidden */
  50984. export class NativeEngine extends Engine {
  50985. private readonly _native;
  50986. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  50987. private readonly INVALID_HANDLE;
  50988. getHardwareScalingLevel(): number;
  50989. constructor();
  50990. dispose(): void;
  50991. /**
  50992. * Can be used to override the current requestAnimationFrame requester.
  50993. * @hidden
  50994. */
  50995. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  50996. /**
  50997. * Override default engine behavior.
  50998. * @param color
  50999. * @param backBuffer
  51000. * @param depth
  51001. * @param stencil
  51002. */
  51003. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  51004. /**
  51005. * Gets host document
  51006. * @returns the host document object
  51007. */
  51008. getHostDocument(): Nullable<Document>;
  51009. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  51010. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  51011. createVertexBuffer(data: DataArray): NativeDataBuffer;
  51012. recordVertexArrayObject(vertexBuffers: {
  51013. [key: string]: VertexBuffer;
  51014. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  51015. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  51016. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  51017. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  51018. /**
  51019. * Draw a list of indexed primitives
  51020. * @param fillMode defines the primitive to use
  51021. * @param indexStart defines the starting index
  51022. * @param indexCount defines the number of index to draw
  51023. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51024. */
  51025. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  51026. /**
  51027. * Draw a list of unindexed primitives
  51028. * @param fillMode defines the primitive to use
  51029. * @param verticesStart defines the index of first vertex to draw
  51030. * @param verticesCount defines the count of vertices to draw
  51031. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51032. */
  51033. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  51034. createPipelineContext(): IPipelineContext;
  51035. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  51036. /** @hidden */
  51037. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  51038. /** @hidden */
  51039. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  51040. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  51041. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  51042. protected _setProgram(program: WebGLProgram): void;
  51043. _releaseEffect(effect: Effect): void;
  51044. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  51045. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  51046. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  51047. bindSamplers(effect: Effect): void;
  51048. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  51049. getRenderWidth(useScreen?: boolean): number;
  51050. getRenderHeight(useScreen?: boolean): number;
  51051. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  51052. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  51053. /**
  51054. * Set the z offset to apply to current rendering
  51055. * @param value defines the offset to apply
  51056. */
  51057. setZOffset(value: number): void;
  51058. /**
  51059. * Gets the current value of the zOffset
  51060. * @returns the current zOffset state
  51061. */
  51062. getZOffset(): number;
  51063. /**
  51064. * Enable or disable depth buffering
  51065. * @param enable defines the state to set
  51066. */
  51067. setDepthBuffer(enable: boolean): void;
  51068. /**
  51069. * Gets a boolean indicating if depth writing is enabled
  51070. * @returns the current depth writing state
  51071. */
  51072. getDepthWrite(): boolean;
  51073. /**
  51074. * Enable or disable depth writing
  51075. * @param enable defines the state to set
  51076. */
  51077. setDepthWrite(enable: boolean): void;
  51078. /**
  51079. * Enable or disable color writing
  51080. * @param enable defines the state to set
  51081. */
  51082. setColorWrite(enable: boolean): void;
  51083. /**
  51084. * Gets a boolean indicating if color writing is enabled
  51085. * @returns the current color writing state
  51086. */
  51087. getColorWrite(): boolean;
  51088. /**
  51089. * Sets alpha constants used by some alpha blending modes
  51090. * @param r defines the red component
  51091. * @param g defines the green component
  51092. * @param b defines the blue component
  51093. * @param a defines the alpha component
  51094. */
  51095. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  51096. /**
  51097. * Sets the current alpha mode
  51098. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  51099. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  51100. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  51101. */
  51102. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  51103. /**
  51104. * Gets the current alpha mode
  51105. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  51106. * @returns the current alpha mode
  51107. */
  51108. getAlphaMode(): number;
  51109. setInt(uniform: WebGLUniformLocation, int: number): void;
  51110. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  51111. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  51112. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  51113. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  51114. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  51115. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  51116. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  51117. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  51118. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  51119. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  51120. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  51121. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  51122. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  51123. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  51124. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  51125. setFloat(uniform: WebGLUniformLocation, value: number): void;
  51126. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  51127. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  51128. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  51129. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  51130. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  51131. wipeCaches(bruteForce?: boolean): void;
  51132. _createTexture(): WebGLTexture;
  51133. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  51134. /**
  51135. * Usually called from Texture.ts.
  51136. * Passed information to create a WebGLTexture
  51137. * @param url defines a value which contains one of the following:
  51138. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  51139. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  51140. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  51141. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  51142. * @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)
  51143. * @param scene needed for loading to the correct scene
  51144. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  51145. * @param onLoad optional callback to be called upon successful completion
  51146. * @param onError optional callback to be called upon failure
  51147. * @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
  51148. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  51149. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  51150. * @param forcedExtension defines the extension to use to pick the right loader
  51151. * @param mimeType defines an optional mime type
  51152. * @returns a InternalTexture for assignment back into BABYLON.Texture
  51153. */
  51154. createTexture(url: 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>, mimeType?: string): InternalTexture;
  51155. /**
  51156. * Creates a cube texture
  51157. * @param rootUrl defines the url where the files to load is located
  51158. * @param scene defines the current scene
  51159. * @param files defines the list of files to load (1 per face)
  51160. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  51161. * @param onLoad defines an optional callback raised when the texture is loaded
  51162. * @param onError defines an optional callback raised if there is an issue to load the texture
  51163. * @param format defines the format of the data
  51164. * @param forcedExtension defines the extension to use to pick the right loader
  51165. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  51166. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  51167. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  51168. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  51169. * @returns the cube texture as an InternalTexture
  51170. */
  51171. 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;
  51172. private _getSamplingFilter;
  51173. private static _GetNativeTextureFormat;
  51174. createRenderTargetTexture(size: number | {
  51175. width: number;
  51176. height: number;
  51177. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  51178. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  51179. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  51180. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  51181. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  51182. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  51183. /**
  51184. * Updates a dynamic vertex buffer.
  51185. * @param vertexBuffer the vertex buffer to update
  51186. * @param data the data used to update the vertex buffer
  51187. * @param byteOffset the byte offset of the data (optional)
  51188. * @param byteLength the byte length of the data (optional)
  51189. */
  51190. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  51191. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  51192. private _updateAnisotropicLevel;
  51193. private _getAddressMode;
  51194. /** @hidden */
  51195. _bindTexture(channel: number, texture: InternalTexture): void;
  51196. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  51197. releaseEffects(): void;
  51198. /** @hidden */
  51199. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51200. /** @hidden */
  51201. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51202. /** @hidden */
  51203. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51204. /** @hidden */
  51205. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  51206. }
  51207. }
  51208. declare module BABYLON {
  51209. /**
  51210. * Gather the list of clipboard event types as constants.
  51211. */
  51212. export class ClipboardEventTypes {
  51213. /**
  51214. * The clipboard event is fired when a copy command is active (pressed).
  51215. */
  51216. static readonly COPY: number;
  51217. /**
  51218. * The clipboard event is fired when a cut command is active (pressed).
  51219. */
  51220. static readonly CUT: number;
  51221. /**
  51222. * The clipboard event is fired when a paste command is active (pressed).
  51223. */
  51224. static readonly PASTE: number;
  51225. }
  51226. /**
  51227. * This class is used to store clipboard related info for the onClipboardObservable event.
  51228. */
  51229. export class ClipboardInfo {
  51230. /**
  51231. * Defines the type of event (BABYLON.ClipboardEventTypes)
  51232. */
  51233. type: number;
  51234. /**
  51235. * Defines the related dom event
  51236. */
  51237. event: ClipboardEvent;
  51238. /**
  51239. *Creates an instance of ClipboardInfo.
  51240. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  51241. * @param event Defines the related dom event
  51242. */
  51243. constructor(
  51244. /**
  51245. * Defines the type of event (BABYLON.ClipboardEventTypes)
  51246. */
  51247. type: number,
  51248. /**
  51249. * Defines the related dom event
  51250. */
  51251. event: ClipboardEvent);
  51252. /**
  51253. * Get the clipboard event's type from the keycode.
  51254. * @param keyCode Defines the keyCode for the current keyboard event.
  51255. * @return {number}
  51256. */
  51257. static GetTypeFromCharacter(keyCode: number): number;
  51258. }
  51259. }
  51260. declare module BABYLON {
  51261. /**
  51262. * Google Daydream controller
  51263. */
  51264. export class DaydreamController extends WebVRController {
  51265. /**
  51266. * Base Url for the controller model.
  51267. */
  51268. static MODEL_BASE_URL: string;
  51269. /**
  51270. * File name for the controller model.
  51271. */
  51272. static MODEL_FILENAME: string;
  51273. /**
  51274. * Gamepad Id prefix used to identify Daydream Controller.
  51275. */
  51276. static readonly GAMEPAD_ID_PREFIX: string;
  51277. /**
  51278. * Creates a new DaydreamController from a gamepad
  51279. * @param vrGamepad the gamepad that the controller should be created from
  51280. */
  51281. constructor(vrGamepad: any);
  51282. /**
  51283. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51284. * @param scene scene in which to add meshes
  51285. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51286. */
  51287. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51288. /**
  51289. * Called once for each button that changed state since the last frame
  51290. * @param buttonIdx Which button index changed
  51291. * @param state New state of the button
  51292. * @param changes Which properties on the state changed since last frame
  51293. */
  51294. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51295. }
  51296. }
  51297. declare module BABYLON {
  51298. /**
  51299. * Gear VR Controller
  51300. */
  51301. export class GearVRController extends WebVRController {
  51302. /**
  51303. * Base Url for the controller model.
  51304. */
  51305. static MODEL_BASE_URL: string;
  51306. /**
  51307. * File name for the controller model.
  51308. */
  51309. static MODEL_FILENAME: string;
  51310. /**
  51311. * Gamepad Id prefix used to identify this controller.
  51312. */
  51313. static readonly GAMEPAD_ID_PREFIX: string;
  51314. private readonly _buttonIndexToObservableNameMap;
  51315. /**
  51316. * Creates a new GearVRController from a gamepad
  51317. * @param vrGamepad the gamepad that the controller should be created from
  51318. */
  51319. constructor(vrGamepad: any);
  51320. /**
  51321. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51322. * @param scene scene in which to add meshes
  51323. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51324. */
  51325. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51326. /**
  51327. * Called once for each button that changed state since the last frame
  51328. * @param buttonIdx Which button index changed
  51329. * @param state New state of the button
  51330. * @param changes Which properties on the state changed since last frame
  51331. */
  51332. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51333. }
  51334. }
  51335. declare module BABYLON {
  51336. /**
  51337. * Generic Controller
  51338. */
  51339. export class GenericController extends WebVRController {
  51340. /**
  51341. * Base Url for the controller model.
  51342. */
  51343. static readonly MODEL_BASE_URL: string;
  51344. /**
  51345. * File name for the controller model.
  51346. */
  51347. static readonly MODEL_FILENAME: string;
  51348. /**
  51349. * Creates a new GenericController from a gamepad
  51350. * @param vrGamepad the gamepad that the controller should be created from
  51351. */
  51352. constructor(vrGamepad: any);
  51353. /**
  51354. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51355. * @param scene scene in which to add meshes
  51356. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51357. */
  51358. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51359. /**
  51360. * Called once for each button that changed state since the last frame
  51361. * @param buttonIdx Which button index changed
  51362. * @param state New state of the button
  51363. * @param changes Which properties on the state changed since last frame
  51364. */
  51365. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51366. }
  51367. }
  51368. declare module BABYLON {
  51369. /**
  51370. * Oculus Touch Controller
  51371. */
  51372. export class OculusTouchController extends WebVRController {
  51373. /**
  51374. * Base Url for the controller model.
  51375. */
  51376. static MODEL_BASE_URL: string;
  51377. /**
  51378. * File name for the left controller model.
  51379. */
  51380. static MODEL_LEFT_FILENAME: string;
  51381. /**
  51382. * File name for the right controller model.
  51383. */
  51384. static MODEL_RIGHT_FILENAME: string;
  51385. /**
  51386. * Base Url for the Quest controller model.
  51387. */
  51388. static QUEST_MODEL_BASE_URL: string;
  51389. /**
  51390. * @hidden
  51391. * If the controllers are running on a device that needs the updated Quest controller models
  51392. */
  51393. static _IsQuest: boolean;
  51394. /**
  51395. * Fired when the secondary trigger on this controller is modified
  51396. */
  51397. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  51398. /**
  51399. * Fired when the thumb rest on this controller is modified
  51400. */
  51401. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  51402. /**
  51403. * Creates a new OculusTouchController from a gamepad
  51404. * @param vrGamepad the gamepad that the controller should be created from
  51405. */
  51406. constructor(vrGamepad: any);
  51407. /**
  51408. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51409. * @param scene scene in which to add meshes
  51410. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51411. */
  51412. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51413. /**
  51414. * Fired when the A button on this controller is modified
  51415. */
  51416. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51417. /**
  51418. * Fired when the B button on this controller is modified
  51419. */
  51420. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51421. /**
  51422. * Fired when the X button on this controller is modified
  51423. */
  51424. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51425. /**
  51426. * Fired when the Y button on this controller is modified
  51427. */
  51428. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51429. /**
  51430. * Called once for each button that changed state since the last frame
  51431. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  51432. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  51433. * 2) secondary trigger (same)
  51434. * 3) A (right) X (left), touch, pressed = value
  51435. * 4) B / Y
  51436. * 5) thumb rest
  51437. * @param buttonIdx Which button index changed
  51438. * @param state New state of the button
  51439. * @param changes Which properties on the state changed since last frame
  51440. */
  51441. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51442. }
  51443. }
  51444. declare module BABYLON {
  51445. /**
  51446. * Vive Controller
  51447. */
  51448. export class ViveController extends WebVRController {
  51449. /**
  51450. * Base Url for the controller model.
  51451. */
  51452. static MODEL_BASE_URL: string;
  51453. /**
  51454. * File name for the controller model.
  51455. */
  51456. static MODEL_FILENAME: string;
  51457. /**
  51458. * Creates a new ViveController from a gamepad
  51459. * @param vrGamepad the gamepad that the controller should be created from
  51460. */
  51461. constructor(vrGamepad: any);
  51462. /**
  51463. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51464. * @param scene scene in which to add meshes
  51465. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51466. */
  51467. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51468. /**
  51469. * Fired when the left button on this controller is modified
  51470. */
  51471. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51472. /**
  51473. * Fired when the right button on this controller is modified
  51474. */
  51475. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51476. /**
  51477. * Fired when the menu button on this controller is modified
  51478. */
  51479. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51480. /**
  51481. * Called once for each button that changed state since the last frame
  51482. * Vive mapping:
  51483. * 0: touchpad
  51484. * 1: trigger
  51485. * 2: left AND right buttons
  51486. * 3: menu button
  51487. * @param buttonIdx Which button index changed
  51488. * @param state New state of the button
  51489. * @param changes Which properties on the state changed since last frame
  51490. */
  51491. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51492. }
  51493. }
  51494. declare module BABYLON {
  51495. /**
  51496. * Defines the WindowsMotionController object that the state of the windows motion controller
  51497. */
  51498. export class WindowsMotionController extends WebVRController {
  51499. /**
  51500. * The base url used to load the left and right controller models
  51501. */
  51502. static MODEL_BASE_URL: string;
  51503. /**
  51504. * The name of the left controller model file
  51505. */
  51506. static MODEL_LEFT_FILENAME: string;
  51507. /**
  51508. * The name of the right controller model file
  51509. */
  51510. static MODEL_RIGHT_FILENAME: string;
  51511. /**
  51512. * The controller name prefix for this controller type
  51513. */
  51514. static readonly GAMEPAD_ID_PREFIX: string;
  51515. /**
  51516. * The controller id pattern for this controller type
  51517. */
  51518. private static readonly GAMEPAD_ID_PATTERN;
  51519. private _loadedMeshInfo;
  51520. protected readonly _mapping: {
  51521. buttons: string[];
  51522. buttonMeshNames: {
  51523. trigger: string;
  51524. menu: string;
  51525. grip: string;
  51526. thumbstick: string;
  51527. trackpad: string;
  51528. };
  51529. buttonObservableNames: {
  51530. trigger: string;
  51531. menu: string;
  51532. grip: string;
  51533. thumbstick: string;
  51534. trackpad: string;
  51535. };
  51536. axisMeshNames: string[];
  51537. pointingPoseMeshName: string;
  51538. };
  51539. /**
  51540. * Fired when the trackpad on this controller is clicked
  51541. */
  51542. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  51543. /**
  51544. * Fired when the trackpad on this controller is modified
  51545. */
  51546. onTrackpadValuesChangedObservable: Observable<StickValues>;
  51547. /**
  51548. * The current x and y values of this controller's trackpad
  51549. */
  51550. trackpad: StickValues;
  51551. /**
  51552. * Creates a new WindowsMotionController from a gamepad
  51553. * @param vrGamepad the gamepad that the controller should be created from
  51554. */
  51555. constructor(vrGamepad: any);
  51556. /**
  51557. * Fired when the trigger on this controller is modified
  51558. */
  51559. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51560. /**
  51561. * Fired when the menu button on this controller is modified
  51562. */
  51563. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51564. /**
  51565. * Fired when the grip button on this controller is modified
  51566. */
  51567. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51568. /**
  51569. * Fired when the thumbstick button on this controller is modified
  51570. */
  51571. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51572. /**
  51573. * Fired when the touchpad button on this controller is modified
  51574. */
  51575. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51576. /**
  51577. * Fired when the touchpad values on this controller are modified
  51578. */
  51579. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  51580. protected _updateTrackpad(): void;
  51581. /**
  51582. * Called once per frame by the engine.
  51583. */
  51584. update(): void;
  51585. /**
  51586. * Called once for each button that changed state since the last frame
  51587. * @param buttonIdx Which button index changed
  51588. * @param state New state of the button
  51589. * @param changes Which properties on the state changed since last frame
  51590. */
  51591. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51592. /**
  51593. * Moves the buttons on the controller mesh based on their current state
  51594. * @param buttonName the name of the button to move
  51595. * @param buttonValue the value of the button which determines the buttons new position
  51596. */
  51597. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  51598. /**
  51599. * Moves the axis on the controller mesh based on its current state
  51600. * @param axis the index of the axis
  51601. * @param axisValue the value of the axis which determines the meshes new position
  51602. * @hidden
  51603. */
  51604. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  51605. /**
  51606. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51607. * @param scene scene in which to add meshes
  51608. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51609. */
  51610. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  51611. /**
  51612. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  51613. * can be transformed by button presses and axes values, based on this._mapping.
  51614. *
  51615. * @param scene scene in which the meshes exist
  51616. * @param meshes list of meshes that make up the controller model to process
  51617. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  51618. */
  51619. private processModel;
  51620. private createMeshInfo;
  51621. /**
  51622. * Gets the ray of the controller in the direction the controller is pointing
  51623. * @param length the length the resulting ray should be
  51624. * @returns a ray in the direction the controller is pointing
  51625. */
  51626. getForwardRay(length?: number): Ray;
  51627. /**
  51628. * Disposes of the controller
  51629. */
  51630. dispose(): void;
  51631. }
  51632. /**
  51633. * This class represents a new windows motion controller in XR.
  51634. */
  51635. export class XRWindowsMotionController extends WindowsMotionController {
  51636. /**
  51637. * Changing the original WIndowsMotionController mapping to fir the new mapping
  51638. */
  51639. protected readonly _mapping: {
  51640. buttons: string[];
  51641. buttonMeshNames: {
  51642. trigger: string;
  51643. menu: string;
  51644. grip: string;
  51645. thumbstick: string;
  51646. trackpad: string;
  51647. };
  51648. buttonObservableNames: {
  51649. trigger: string;
  51650. menu: string;
  51651. grip: string;
  51652. thumbstick: string;
  51653. trackpad: string;
  51654. };
  51655. axisMeshNames: string[];
  51656. pointingPoseMeshName: string;
  51657. };
  51658. /**
  51659. * Construct a new XR-Based windows motion controller
  51660. *
  51661. * @param gamepadInfo the gamepad object from the browser
  51662. */
  51663. constructor(gamepadInfo: any);
  51664. /**
  51665. * holds the thumbstick values (X,Y)
  51666. */
  51667. thumbstickValues: StickValues;
  51668. /**
  51669. * Fired when the thumbstick on this controller is clicked
  51670. */
  51671. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  51672. /**
  51673. * Fired when the thumbstick on this controller is modified
  51674. */
  51675. onThumbstickValuesChangedObservable: Observable<StickValues>;
  51676. /**
  51677. * Fired when the touchpad button on this controller is modified
  51678. */
  51679. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  51680. /**
  51681. * Fired when the touchpad values on this controller are modified
  51682. */
  51683. onTrackpadValuesChangedObservable: Observable<StickValues>;
  51684. /**
  51685. * Fired when the thumbstick button on this controller is modified
  51686. * here to prevent breaking changes
  51687. */
  51688. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51689. /**
  51690. * updating the thumbstick(!) and not the trackpad.
  51691. * This is named this way due to the difference between WebVR and XR and to avoid
  51692. * changing the parent class.
  51693. */
  51694. protected _updateTrackpad(): void;
  51695. /**
  51696. * Disposes the class with joy
  51697. */
  51698. dispose(): void;
  51699. }
  51700. }
  51701. declare module BABYLON {
  51702. /**
  51703. * Class containing static functions to help procedurally build meshes
  51704. */
  51705. export class PolyhedronBuilder {
  51706. /**
  51707. * Creates a polyhedron mesh
  51708. * * 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
  51709. * * The parameter `size` (positive float, default 1) sets the polygon size
  51710. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  51711. * * 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`
  51712. * * 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
  51713. * * 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)`)
  51714. * * 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
  51715. * * 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
  51716. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51717. * * 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
  51718. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51719. * @param name defines the name of the mesh
  51720. * @param options defines the options used to create the mesh
  51721. * @param scene defines the hosting scene
  51722. * @returns the polyhedron mesh
  51723. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  51724. */
  51725. static CreatePolyhedron(name: string, options: {
  51726. type?: number;
  51727. size?: number;
  51728. sizeX?: number;
  51729. sizeY?: number;
  51730. sizeZ?: number;
  51731. custom?: any;
  51732. faceUV?: Vector4[];
  51733. faceColors?: Color4[];
  51734. flat?: boolean;
  51735. updatable?: boolean;
  51736. sideOrientation?: number;
  51737. frontUVs?: Vector4;
  51738. backUVs?: Vector4;
  51739. }, scene?: Nullable<Scene>): Mesh;
  51740. }
  51741. }
  51742. declare module BABYLON {
  51743. /**
  51744. * Gizmo that enables scaling a mesh along 3 axis
  51745. */
  51746. export class ScaleGizmo extends Gizmo {
  51747. /**
  51748. * Internal gizmo used for interactions on the x axis
  51749. */
  51750. xGizmo: AxisScaleGizmo;
  51751. /**
  51752. * Internal gizmo used for interactions on the y axis
  51753. */
  51754. yGizmo: AxisScaleGizmo;
  51755. /**
  51756. * Internal gizmo used for interactions on the z axis
  51757. */
  51758. zGizmo: AxisScaleGizmo;
  51759. /**
  51760. * Internal gizmo used to scale all axis equally
  51761. */
  51762. uniformScaleGizmo: AxisScaleGizmo;
  51763. private _meshAttached;
  51764. private _updateGizmoRotationToMatchAttachedMesh;
  51765. private _snapDistance;
  51766. private _scaleRatio;
  51767. private _uniformScalingMesh;
  51768. private _octahedron;
  51769. private _sensitivity;
  51770. /** Fires an event when any of it's sub gizmos are dragged */
  51771. onDragStartObservable: Observable<unknown>;
  51772. /** Fires an event when any of it's sub gizmos are released from dragging */
  51773. onDragEndObservable: Observable<unknown>;
  51774. get attachedMesh(): Nullable<AbstractMesh>;
  51775. set attachedMesh(mesh: Nullable<AbstractMesh>);
  51776. /**
  51777. * Creates a ScaleGizmo
  51778. * @param gizmoLayer The utility layer the gizmo will be added to
  51779. */
  51780. constructor(gizmoLayer?: UtilityLayerRenderer);
  51781. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  51782. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  51783. /**
  51784. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51785. */
  51786. set snapDistance(value: number);
  51787. get snapDistance(): number;
  51788. /**
  51789. * Ratio for the scale of the gizmo (Default: 1)
  51790. */
  51791. set scaleRatio(value: number);
  51792. get scaleRatio(): number;
  51793. /**
  51794. * Sensitivity factor for dragging (Default: 1)
  51795. */
  51796. set sensitivity(value: number);
  51797. get sensitivity(): number;
  51798. /**
  51799. * Disposes of the gizmo
  51800. */
  51801. dispose(): void;
  51802. }
  51803. }
  51804. declare module BABYLON {
  51805. /**
  51806. * Single axis scale gizmo
  51807. */
  51808. export class AxisScaleGizmo extends Gizmo {
  51809. /**
  51810. * Drag behavior responsible for the gizmos dragging interactions
  51811. */
  51812. dragBehavior: PointerDragBehavior;
  51813. private _pointerObserver;
  51814. /**
  51815. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51816. */
  51817. snapDistance: number;
  51818. /**
  51819. * Event that fires each time the gizmo snaps to a new location.
  51820. * * snapDistance is the the change in distance
  51821. */
  51822. onSnapObservable: Observable<{
  51823. snapDistance: number;
  51824. }>;
  51825. /**
  51826. * If the scaling operation should be done on all axis (default: false)
  51827. */
  51828. uniformScaling: boolean;
  51829. /**
  51830. * Custom sensitivity value for the drag strength
  51831. */
  51832. sensitivity: number;
  51833. private _isEnabled;
  51834. private _parent;
  51835. private _arrow;
  51836. private _coloredMaterial;
  51837. private _hoverMaterial;
  51838. /**
  51839. * Creates an AxisScaleGizmo
  51840. * @param gizmoLayer The utility layer the gizmo will be added to
  51841. * @param dragAxis The axis which the gizmo will be able to scale on
  51842. * @param color The color of the gizmo
  51843. */
  51844. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  51845. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  51846. /**
  51847. * If the gizmo is enabled
  51848. */
  51849. set isEnabled(value: boolean);
  51850. get isEnabled(): boolean;
  51851. /**
  51852. * Disposes of the gizmo
  51853. */
  51854. dispose(): void;
  51855. /**
  51856. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  51857. * @param mesh The mesh to replace the default mesh of the gizmo
  51858. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  51859. */
  51860. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  51861. }
  51862. }
  51863. declare module BABYLON {
  51864. /**
  51865. * Bounding box gizmo
  51866. */
  51867. export class BoundingBoxGizmo extends Gizmo {
  51868. private _lineBoundingBox;
  51869. private _rotateSpheresParent;
  51870. private _scaleBoxesParent;
  51871. private _boundingDimensions;
  51872. private _renderObserver;
  51873. private _pointerObserver;
  51874. private _scaleDragSpeed;
  51875. private _tmpQuaternion;
  51876. private _tmpVector;
  51877. private _tmpRotationMatrix;
  51878. /**
  51879. * 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)
  51880. */
  51881. ignoreChildren: boolean;
  51882. /**
  51883. * 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)
  51884. */
  51885. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  51886. /**
  51887. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  51888. */
  51889. rotationSphereSize: number;
  51890. /**
  51891. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  51892. */
  51893. scaleBoxSize: number;
  51894. /**
  51895. * 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)
  51896. */
  51897. fixedDragMeshScreenSize: boolean;
  51898. /**
  51899. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  51900. */
  51901. fixedDragMeshScreenSizeDistanceFactor: number;
  51902. /**
  51903. * Fired when a rotation sphere or scale box is dragged
  51904. */
  51905. onDragStartObservable: Observable<{}>;
  51906. /**
  51907. * Fired when a scale box is dragged
  51908. */
  51909. onScaleBoxDragObservable: Observable<{}>;
  51910. /**
  51911. * Fired when a scale box drag is ended
  51912. */
  51913. onScaleBoxDragEndObservable: Observable<{}>;
  51914. /**
  51915. * Fired when a rotation sphere is dragged
  51916. */
  51917. onRotationSphereDragObservable: Observable<{}>;
  51918. /**
  51919. * Fired when a rotation sphere drag is ended
  51920. */
  51921. onRotationSphereDragEndObservable: Observable<{}>;
  51922. /**
  51923. * 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)
  51924. */
  51925. scalePivot: Nullable<Vector3>;
  51926. /**
  51927. * Mesh used as a pivot to rotate the attached mesh
  51928. */
  51929. private _anchorMesh;
  51930. private _existingMeshScale;
  51931. private _dragMesh;
  51932. private pointerDragBehavior;
  51933. private coloredMaterial;
  51934. private hoverColoredMaterial;
  51935. /**
  51936. * Sets the color of the bounding box gizmo
  51937. * @param color the color to set
  51938. */
  51939. setColor(color: Color3): void;
  51940. /**
  51941. * Creates an BoundingBoxGizmo
  51942. * @param gizmoLayer The utility layer the gizmo will be added to
  51943. * @param color The color of the gizmo
  51944. */
  51945. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  51946. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  51947. private _selectNode;
  51948. /**
  51949. * Updates the bounding box information for the Gizmo
  51950. */
  51951. updateBoundingBox(): void;
  51952. private _updateRotationSpheres;
  51953. private _updateScaleBoxes;
  51954. /**
  51955. * Enables rotation on the specified axis and disables rotation on the others
  51956. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  51957. */
  51958. setEnabledRotationAxis(axis: string): void;
  51959. /**
  51960. * Enables/disables scaling
  51961. * @param enable if scaling should be enabled
  51962. * @param homogeneousScaling defines if scaling should only be homogeneous
  51963. */
  51964. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  51965. private _updateDummy;
  51966. /**
  51967. * Enables a pointer drag behavior on the bounding box of the gizmo
  51968. */
  51969. enableDragBehavior(): void;
  51970. /**
  51971. * Disposes of the gizmo
  51972. */
  51973. dispose(): void;
  51974. /**
  51975. * 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)
  51976. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  51977. * @returns the bounding box mesh with the passed in mesh as a child
  51978. */
  51979. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  51980. /**
  51981. * CustomMeshes are not supported by this gizmo
  51982. * @param mesh The mesh to replace the default mesh of the gizmo
  51983. */
  51984. setCustomMesh(mesh: Mesh): void;
  51985. }
  51986. }
  51987. declare module BABYLON {
  51988. /**
  51989. * Single plane rotation gizmo
  51990. */
  51991. export class PlaneRotationGizmo extends Gizmo {
  51992. /**
  51993. * Drag behavior responsible for the gizmos dragging interactions
  51994. */
  51995. dragBehavior: PointerDragBehavior;
  51996. private _pointerObserver;
  51997. /**
  51998. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  51999. */
  52000. snapDistance: number;
  52001. /**
  52002. * Event that fires each time the gizmo snaps to a new location.
  52003. * * snapDistance is the the change in distance
  52004. */
  52005. onSnapObservable: Observable<{
  52006. snapDistance: number;
  52007. }>;
  52008. private _isEnabled;
  52009. private _parent;
  52010. /**
  52011. * Creates a PlaneRotationGizmo
  52012. * @param gizmoLayer The utility layer the gizmo will be added to
  52013. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  52014. * @param color The color of the gizmo
  52015. * @param tessellation Amount of tessellation to be used when creating rotation circles
  52016. * @param useEulerRotation Use and update Euler angle instead of quaternion
  52017. */
  52018. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  52019. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  52020. /**
  52021. * If the gizmo is enabled
  52022. */
  52023. set isEnabled(value: boolean);
  52024. get isEnabled(): boolean;
  52025. /**
  52026. * Disposes of the gizmo
  52027. */
  52028. dispose(): void;
  52029. }
  52030. }
  52031. declare module BABYLON {
  52032. /**
  52033. * Gizmo that enables rotating a mesh along 3 axis
  52034. */
  52035. export class RotationGizmo extends Gizmo {
  52036. /**
  52037. * Internal gizmo used for interactions on the x axis
  52038. */
  52039. xGizmo: PlaneRotationGizmo;
  52040. /**
  52041. * Internal gizmo used for interactions on the y axis
  52042. */
  52043. yGizmo: PlaneRotationGizmo;
  52044. /**
  52045. * Internal gizmo used for interactions on the z axis
  52046. */
  52047. zGizmo: PlaneRotationGizmo;
  52048. /** Fires an event when any of it's sub gizmos are dragged */
  52049. onDragStartObservable: Observable<unknown>;
  52050. /** Fires an event when any of it's sub gizmos are released from dragging */
  52051. onDragEndObservable: Observable<unknown>;
  52052. private _meshAttached;
  52053. get attachedMesh(): Nullable<AbstractMesh>;
  52054. set attachedMesh(mesh: Nullable<AbstractMesh>);
  52055. /**
  52056. * Creates a RotationGizmo
  52057. * @param gizmoLayer The utility layer the gizmo will be added to
  52058. * @param tessellation Amount of tessellation to be used when creating rotation circles
  52059. * @param useEulerRotation Use and update Euler angle instead of quaternion
  52060. */
  52061. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  52062. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52063. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52064. /**
  52065. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52066. */
  52067. set snapDistance(value: number);
  52068. get snapDistance(): number;
  52069. /**
  52070. * Ratio for the scale of the gizmo (Default: 1)
  52071. */
  52072. set scaleRatio(value: number);
  52073. get scaleRatio(): number;
  52074. /**
  52075. * Disposes of the gizmo
  52076. */
  52077. dispose(): void;
  52078. /**
  52079. * CustomMeshes are not supported by this gizmo
  52080. * @param mesh The mesh to replace the default mesh of the gizmo
  52081. */
  52082. setCustomMesh(mesh: Mesh): void;
  52083. }
  52084. }
  52085. declare module BABYLON {
  52086. /**
  52087. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  52088. */
  52089. export class GizmoManager implements IDisposable {
  52090. private scene;
  52091. /**
  52092. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  52093. */
  52094. gizmos: {
  52095. positionGizmo: Nullable<PositionGizmo>;
  52096. rotationGizmo: Nullable<RotationGizmo>;
  52097. scaleGizmo: Nullable<ScaleGizmo>;
  52098. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  52099. };
  52100. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  52101. clearGizmoOnEmptyPointerEvent: boolean;
  52102. /** Fires an event when the manager is attached to a mesh */
  52103. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  52104. private _gizmosEnabled;
  52105. private _pointerObserver;
  52106. private _attachedMesh;
  52107. private _boundingBoxColor;
  52108. private _defaultUtilityLayer;
  52109. private _defaultKeepDepthUtilityLayer;
  52110. /**
  52111. * When bounding box gizmo is enabled, this can be used to track drag/end events
  52112. */
  52113. boundingBoxDragBehavior: SixDofDragBehavior;
  52114. /**
  52115. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  52116. */
  52117. attachableMeshes: Nullable<Array<AbstractMesh>>;
  52118. /**
  52119. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  52120. */
  52121. usePointerToAttachGizmos: boolean;
  52122. /**
  52123. * Utility layer that the bounding box gizmo belongs to
  52124. */
  52125. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  52126. /**
  52127. * Utility layer that all gizmos besides bounding box belong to
  52128. */
  52129. get utilityLayer(): UtilityLayerRenderer;
  52130. /**
  52131. * Instatiates a gizmo manager
  52132. * @param scene the scene to overlay the gizmos on top of
  52133. */
  52134. constructor(scene: Scene);
  52135. /**
  52136. * Attaches a set of gizmos to the specified mesh
  52137. * @param mesh The mesh the gizmo's should be attached to
  52138. */
  52139. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  52140. /**
  52141. * If the position gizmo is enabled
  52142. */
  52143. set positionGizmoEnabled(value: boolean);
  52144. get positionGizmoEnabled(): boolean;
  52145. /**
  52146. * If the rotation gizmo is enabled
  52147. */
  52148. set rotationGizmoEnabled(value: boolean);
  52149. get rotationGizmoEnabled(): boolean;
  52150. /**
  52151. * If the scale gizmo is enabled
  52152. */
  52153. set scaleGizmoEnabled(value: boolean);
  52154. get scaleGizmoEnabled(): boolean;
  52155. /**
  52156. * If the boundingBox gizmo is enabled
  52157. */
  52158. set boundingBoxGizmoEnabled(value: boolean);
  52159. get boundingBoxGizmoEnabled(): boolean;
  52160. /**
  52161. * Disposes of the gizmo manager
  52162. */
  52163. dispose(): void;
  52164. }
  52165. }
  52166. declare module BABYLON {
  52167. /**
  52168. * A directional light is defined by a direction (what a surprise!).
  52169. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  52170. * 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.
  52171. * Documentation: https://doc.babylonjs.com/babylon101/lights
  52172. */
  52173. export class DirectionalLight extends ShadowLight {
  52174. private _shadowFrustumSize;
  52175. /**
  52176. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  52177. */
  52178. get shadowFrustumSize(): number;
  52179. /**
  52180. * Specifies a fix frustum size for the shadow generation.
  52181. */
  52182. set shadowFrustumSize(value: number);
  52183. private _shadowOrthoScale;
  52184. /**
  52185. * Gets the shadow projection scale against the optimal computed one.
  52186. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  52187. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  52188. */
  52189. get shadowOrthoScale(): number;
  52190. /**
  52191. * Sets the shadow projection scale against the optimal computed one.
  52192. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  52193. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  52194. */
  52195. set shadowOrthoScale(value: number);
  52196. /**
  52197. * Automatically compute the projection matrix to best fit (including all the casters)
  52198. * on each frame.
  52199. */
  52200. autoUpdateExtends: boolean;
  52201. /**
  52202. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  52203. * on each frame. autoUpdateExtends must be set to true for this to work
  52204. */
  52205. autoCalcShadowZBounds: boolean;
  52206. private _orthoLeft;
  52207. private _orthoRight;
  52208. private _orthoTop;
  52209. private _orthoBottom;
  52210. /**
  52211. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  52212. * The directional light is emitted from everywhere in the given direction.
  52213. * It can cast shadows.
  52214. * Documentation : https://doc.babylonjs.com/babylon101/lights
  52215. * @param name The friendly name of the light
  52216. * @param direction The direction of the light
  52217. * @param scene The scene the light belongs to
  52218. */
  52219. constructor(name: string, direction: Vector3, scene: Scene);
  52220. /**
  52221. * Returns the string "DirectionalLight".
  52222. * @return The class name
  52223. */
  52224. getClassName(): string;
  52225. /**
  52226. * Returns the integer 1.
  52227. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  52228. */
  52229. getTypeID(): number;
  52230. /**
  52231. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  52232. * Returns the DirectionalLight Shadow projection matrix.
  52233. */
  52234. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52235. /**
  52236. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  52237. * Returns the DirectionalLight Shadow projection matrix.
  52238. */
  52239. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  52240. /**
  52241. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  52242. * Returns the DirectionalLight Shadow projection matrix.
  52243. */
  52244. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52245. protected _buildUniformLayout(): void;
  52246. /**
  52247. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  52248. * @param effect The effect to update
  52249. * @param lightIndex The index of the light in the effect to update
  52250. * @returns The directional light
  52251. */
  52252. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  52253. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  52254. /**
  52255. * Gets the minZ used for shadow according to both the scene and the light.
  52256. *
  52257. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  52258. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  52259. * @param activeCamera The camera we are returning the min for
  52260. * @returns the depth min z
  52261. */
  52262. getDepthMinZ(activeCamera: Camera): number;
  52263. /**
  52264. * Gets the maxZ used for shadow according to both the scene and the light.
  52265. *
  52266. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  52267. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  52268. * @param activeCamera The camera we are returning the max for
  52269. * @returns the depth max z
  52270. */
  52271. getDepthMaxZ(activeCamera: Camera): number;
  52272. /**
  52273. * Prepares the list of defines specific to the light type.
  52274. * @param defines the list of defines
  52275. * @param lightIndex defines the index of the light for the effect
  52276. */
  52277. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  52278. }
  52279. }
  52280. declare module BABYLON {
  52281. /**
  52282. * Class containing static functions to help procedurally build meshes
  52283. */
  52284. export class HemisphereBuilder {
  52285. /**
  52286. * Creates a hemisphere mesh
  52287. * @param name defines the name of the mesh
  52288. * @param options defines the options used to create the mesh
  52289. * @param scene defines the hosting scene
  52290. * @returns the hemisphere mesh
  52291. */
  52292. static CreateHemisphere(name: string, options: {
  52293. segments?: number;
  52294. diameter?: number;
  52295. sideOrientation?: number;
  52296. }, scene: any): Mesh;
  52297. }
  52298. }
  52299. declare module BABYLON {
  52300. /**
  52301. * A spot light is defined by a position, a direction, an angle, and an exponent.
  52302. * These values define a cone of light starting from the position, emitting toward the direction.
  52303. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  52304. * and the exponent defines the speed of the decay of the light with distance (reach).
  52305. * Documentation: https://doc.babylonjs.com/babylon101/lights
  52306. */
  52307. export class SpotLight extends ShadowLight {
  52308. private _angle;
  52309. private _innerAngle;
  52310. private _cosHalfAngle;
  52311. private _lightAngleScale;
  52312. private _lightAngleOffset;
  52313. /**
  52314. * Gets the cone angle of the spot light in Radians.
  52315. */
  52316. get angle(): number;
  52317. /**
  52318. * Sets the cone angle of the spot light in Radians.
  52319. */
  52320. set angle(value: number);
  52321. /**
  52322. * Only used in gltf falloff mode, this defines the angle where
  52323. * the directional falloff will start before cutting at angle which could be seen
  52324. * as outer angle.
  52325. */
  52326. get innerAngle(): number;
  52327. /**
  52328. * Only used in gltf falloff mode, this defines the angle where
  52329. * the directional falloff will start before cutting at angle which could be seen
  52330. * as outer angle.
  52331. */
  52332. set innerAngle(value: number);
  52333. private _shadowAngleScale;
  52334. /**
  52335. * Allows scaling the angle of the light for shadow generation only.
  52336. */
  52337. get shadowAngleScale(): number;
  52338. /**
  52339. * Allows scaling the angle of the light for shadow generation only.
  52340. */
  52341. set shadowAngleScale(value: number);
  52342. /**
  52343. * The light decay speed with the distance from the emission spot.
  52344. */
  52345. exponent: number;
  52346. private _projectionTextureMatrix;
  52347. /**
  52348. * Allows reading the projecton texture
  52349. */
  52350. get projectionTextureMatrix(): Matrix;
  52351. protected _projectionTextureLightNear: number;
  52352. /**
  52353. * Gets the near clip of the Spotlight for texture projection.
  52354. */
  52355. get projectionTextureLightNear(): number;
  52356. /**
  52357. * Sets the near clip of the Spotlight for texture projection.
  52358. */
  52359. set projectionTextureLightNear(value: number);
  52360. protected _projectionTextureLightFar: number;
  52361. /**
  52362. * Gets the far clip of the Spotlight for texture projection.
  52363. */
  52364. get projectionTextureLightFar(): number;
  52365. /**
  52366. * Sets the far clip of the Spotlight for texture projection.
  52367. */
  52368. set projectionTextureLightFar(value: number);
  52369. protected _projectionTextureUpDirection: Vector3;
  52370. /**
  52371. * Gets the Up vector of the Spotlight for texture projection.
  52372. */
  52373. get projectionTextureUpDirection(): Vector3;
  52374. /**
  52375. * Sets the Up vector of the Spotlight for texture projection.
  52376. */
  52377. set projectionTextureUpDirection(value: Vector3);
  52378. private _projectionTexture;
  52379. /**
  52380. * Gets the projection texture of the light.
  52381. */
  52382. get projectionTexture(): Nullable<BaseTexture>;
  52383. /**
  52384. * Sets the projection texture of the light.
  52385. */
  52386. set projectionTexture(value: Nullable<BaseTexture>);
  52387. private _projectionTextureViewLightDirty;
  52388. private _projectionTextureProjectionLightDirty;
  52389. private _projectionTextureDirty;
  52390. private _projectionTextureViewTargetVector;
  52391. private _projectionTextureViewLightMatrix;
  52392. private _projectionTextureProjectionLightMatrix;
  52393. private _projectionTextureScalingMatrix;
  52394. /**
  52395. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  52396. * It can cast shadows.
  52397. * Documentation : https://doc.babylonjs.com/babylon101/lights
  52398. * @param name The light friendly name
  52399. * @param position The position of the spot light in the scene
  52400. * @param direction The direction of the light in the scene
  52401. * @param angle The cone angle of the light in Radians
  52402. * @param exponent The light decay speed with the distance from the emission spot
  52403. * @param scene The scene the lights belongs to
  52404. */
  52405. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  52406. /**
  52407. * Returns the string "SpotLight".
  52408. * @returns the class name
  52409. */
  52410. getClassName(): string;
  52411. /**
  52412. * Returns the integer 2.
  52413. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  52414. */
  52415. getTypeID(): number;
  52416. /**
  52417. * Overrides the direction setter to recompute the projection texture view light Matrix.
  52418. */
  52419. protected _setDirection(value: Vector3): void;
  52420. /**
  52421. * Overrides the position setter to recompute the projection texture view light Matrix.
  52422. */
  52423. protected _setPosition(value: Vector3): void;
  52424. /**
  52425. * 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.
  52426. * Returns the SpotLight.
  52427. */
  52428. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52429. protected _computeProjectionTextureViewLightMatrix(): void;
  52430. protected _computeProjectionTextureProjectionLightMatrix(): void;
  52431. /**
  52432. * Main function for light texture projection matrix computing.
  52433. */
  52434. protected _computeProjectionTextureMatrix(): void;
  52435. protected _buildUniformLayout(): void;
  52436. private _computeAngleValues;
  52437. /**
  52438. * Sets the passed Effect "effect" with the Light textures.
  52439. * @param effect The effect to update
  52440. * @param lightIndex The index of the light in the effect to update
  52441. * @returns The light
  52442. */
  52443. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  52444. /**
  52445. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  52446. * @param effect The effect to update
  52447. * @param lightIndex The index of the light in the effect to update
  52448. * @returns The spot light
  52449. */
  52450. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  52451. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  52452. /**
  52453. * Disposes the light and the associated resources.
  52454. */
  52455. dispose(): void;
  52456. /**
  52457. * Prepares the list of defines specific to the light type.
  52458. * @param defines the list of defines
  52459. * @param lightIndex defines the index of the light for the effect
  52460. */
  52461. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  52462. }
  52463. }
  52464. declare module BABYLON {
  52465. /**
  52466. * Gizmo that enables viewing a light
  52467. */
  52468. export class LightGizmo extends Gizmo {
  52469. private _lightMesh;
  52470. private _material;
  52471. private _cachedPosition;
  52472. private _cachedForward;
  52473. private _attachedMeshParent;
  52474. /**
  52475. * Creates a LightGizmo
  52476. * @param gizmoLayer The utility layer the gizmo will be added to
  52477. */
  52478. constructor(gizmoLayer?: UtilityLayerRenderer);
  52479. private _light;
  52480. /**
  52481. * The light that the gizmo is attached to
  52482. */
  52483. set light(light: Nullable<Light>);
  52484. get light(): Nullable<Light>;
  52485. /**
  52486. * Gets the material used to render the light gizmo
  52487. */
  52488. get material(): StandardMaterial;
  52489. /**
  52490. * @hidden
  52491. * Updates the gizmo to match the attached mesh's position/rotation
  52492. */
  52493. protected _update(): void;
  52494. private static _Scale;
  52495. /**
  52496. * Creates the lines for a light mesh
  52497. */
  52498. private static _CreateLightLines;
  52499. /**
  52500. * Disposes of the light gizmo
  52501. */
  52502. dispose(): void;
  52503. private static _CreateHemisphericLightMesh;
  52504. private static _CreatePointLightMesh;
  52505. private static _CreateSpotLightMesh;
  52506. private static _CreateDirectionalLightMesh;
  52507. }
  52508. }
  52509. declare module BABYLON {
  52510. /** @hidden */
  52511. export var backgroundFragmentDeclaration: {
  52512. name: string;
  52513. shader: string;
  52514. };
  52515. }
  52516. declare module BABYLON {
  52517. /** @hidden */
  52518. export var backgroundUboDeclaration: {
  52519. name: string;
  52520. shader: string;
  52521. };
  52522. }
  52523. declare module BABYLON {
  52524. /** @hidden */
  52525. export var backgroundPixelShader: {
  52526. name: string;
  52527. shader: string;
  52528. };
  52529. }
  52530. declare module BABYLON {
  52531. /** @hidden */
  52532. export var backgroundVertexDeclaration: {
  52533. name: string;
  52534. shader: string;
  52535. };
  52536. }
  52537. declare module BABYLON {
  52538. /** @hidden */
  52539. export var backgroundVertexShader: {
  52540. name: string;
  52541. shader: string;
  52542. };
  52543. }
  52544. declare module BABYLON {
  52545. /**
  52546. * Background material used to create an efficient environement around your scene.
  52547. */
  52548. export class BackgroundMaterial extends PushMaterial {
  52549. /**
  52550. * Standard reflectance value at parallel view angle.
  52551. */
  52552. static StandardReflectance0: number;
  52553. /**
  52554. * Standard reflectance value at grazing angle.
  52555. */
  52556. static StandardReflectance90: number;
  52557. protected _primaryColor: Color3;
  52558. /**
  52559. * Key light Color (multiply against the environement texture)
  52560. */
  52561. primaryColor: Color3;
  52562. protected __perceptualColor: Nullable<Color3>;
  52563. /**
  52564. * Experimental Internal Use Only.
  52565. *
  52566. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  52567. * This acts as a helper to set the primary color to a more "human friendly" value.
  52568. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  52569. * output color as close as possible from the chosen value.
  52570. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  52571. * part of lighting setup.)
  52572. */
  52573. get _perceptualColor(): Nullable<Color3>;
  52574. set _perceptualColor(value: Nullable<Color3>);
  52575. protected _primaryColorShadowLevel: float;
  52576. /**
  52577. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  52578. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  52579. */
  52580. get primaryColorShadowLevel(): float;
  52581. set primaryColorShadowLevel(value: float);
  52582. protected _primaryColorHighlightLevel: float;
  52583. /**
  52584. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  52585. * The primary color is used at the level chosen to define what the white area would look.
  52586. */
  52587. get primaryColorHighlightLevel(): float;
  52588. set primaryColorHighlightLevel(value: float);
  52589. protected _reflectionTexture: Nullable<BaseTexture>;
  52590. /**
  52591. * Reflection Texture used in the material.
  52592. * Should be author in a specific way for the best result (refer to the documentation).
  52593. */
  52594. reflectionTexture: Nullable<BaseTexture>;
  52595. protected _reflectionBlur: float;
  52596. /**
  52597. * Reflection Texture level of blur.
  52598. *
  52599. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  52600. * texture twice.
  52601. */
  52602. reflectionBlur: float;
  52603. protected _diffuseTexture: Nullable<BaseTexture>;
  52604. /**
  52605. * Diffuse Texture used in the material.
  52606. * Should be author in a specific way for the best result (refer to the documentation).
  52607. */
  52608. diffuseTexture: Nullable<BaseTexture>;
  52609. protected _shadowLights: Nullable<IShadowLight[]>;
  52610. /**
  52611. * Specify the list of lights casting shadow on the material.
  52612. * All scene shadow lights will be included if null.
  52613. */
  52614. shadowLights: Nullable<IShadowLight[]>;
  52615. protected _shadowLevel: float;
  52616. /**
  52617. * Helps adjusting the shadow to a softer level if required.
  52618. * 0 means black shadows and 1 means no shadows.
  52619. */
  52620. shadowLevel: float;
  52621. protected _sceneCenter: Vector3;
  52622. /**
  52623. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  52624. * It is usually zero but might be interesting to modify according to your setup.
  52625. */
  52626. sceneCenter: Vector3;
  52627. protected _opacityFresnel: boolean;
  52628. /**
  52629. * This helps specifying that the material is falling off to the sky box at grazing angle.
  52630. * This helps ensuring a nice transition when the camera goes under the ground.
  52631. */
  52632. opacityFresnel: boolean;
  52633. protected _reflectionFresnel: boolean;
  52634. /**
  52635. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  52636. * This helps adding a mirror texture on the ground.
  52637. */
  52638. reflectionFresnel: boolean;
  52639. protected _reflectionFalloffDistance: number;
  52640. /**
  52641. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  52642. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  52643. */
  52644. reflectionFalloffDistance: number;
  52645. protected _reflectionAmount: number;
  52646. /**
  52647. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  52648. */
  52649. reflectionAmount: number;
  52650. protected _reflectionReflectance0: number;
  52651. /**
  52652. * This specifies the weight of the reflection at grazing angle.
  52653. */
  52654. reflectionReflectance0: number;
  52655. protected _reflectionReflectance90: number;
  52656. /**
  52657. * This specifies the weight of the reflection at a perpendicular point of view.
  52658. */
  52659. reflectionReflectance90: number;
  52660. /**
  52661. * Sets the reflection reflectance fresnel values according to the default standard
  52662. * empirically know to work well :-)
  52663. */
  52664. set reflectionStandardFresnelWeight(value: number);
  52665. protected _useRGBColor: boolean;
  52666. /**
  52667. * Helps to directly use the maps channels instead of their level.
  52668. */
  52669. useRGBColor: boolean;
  52670. protected _enableNoise: boolean;
  52671. /**
  52672. * This helps reducing the banding effect that could occur on the background.
  52673. */
  52674. enableNoise: boolean;
  52675. /**
  52676. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  52677. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  52678. * Recommended to be keep at 1.0 except for special cases.
  52679. */
  52680. get fovMultiplier(): number;
  52681. set fovMultiplier(value: number);
  52682. private _fovMultiplier;
  52683. /**
  52684. * Enable the FOV adjustment feature controlled by fovMultiplier.
  52685. */
  52686. useEquirectangularFOV: boolean;
  52687. private _maxSimultaneousLights;
  52688. /**
  52689. * Number of Simultaneous lights allowed on the material.
  52690. */
  52691. maxSimultaneousLights: int;
  52692. /**
  52693. * Default configuration related to image processing available in the Background Material.
  52694. */
  52695. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  52696. /**
  52697. * Keep track of the image processing observer to allow dispose and replace.
  52698. */
  52699. private _imageProcessingObserver;
  52700. /**
  52701. * Attaches a new image processing configuration to the PBR Material.
  52702. * @param configuration (if null the scene configuration will be use)
  52703. */
  52704. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  52705. /**
  52706. * Gets the image processing configuration used either in this material.
  52707. */
  52708. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  52709. /**
  52710. * Sets the Default image processing configuration used either in the this material.
  52711. *
  52712. * If sets to null, the scene one is in use.
  52713. */
  52714. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  52715. /**
  52716. * Gets wether the color curves effect is enabled.
  52717. */
  52718. get cameraColorCurvesEnabled(): boolean;
  52719. /**
  52720. * Sets wether the color curves effect is enabled.
  52721. */
  52722. set cameraColorCurvesEnabled(value: boolean);
  52723. /**
  52724. * Gets wether the color grading effect is enabled.
  52725. */
  52726. get cameraColorGradingEnabled(): boolean;
  52727. /**
  52728. * Gets wether the color grading effect is enabled.
  52729. */
  52730. set cameraColorGradingEnabled(value: boolean);
  52731. /**
  52732. * Gets wether tonemapping is enabled or not.
  52733. */
  52734. get cameraToneMappingEnabled(): boolean;
  52735. /**
  52736. * Sets wether tonemapping is enabled or not
  52737. */
  52738. set cameraToneMappingEnabled(value: boolean);
  52739. /**
  52740. * The camera exposure used on this material.
  52741. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52742. * This corresponds to a photographic exposure.
  52743. */
  52744. get cameraExposure(): float;
  52745. /**
  52746. * The camera exposure used on this material.
  52747. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52748. * This corresponds to a photographic exposure.
  52749. */
  52750. set cameraExposure(value: float);
  52751. /**
  52752. * Gets The camera contrast used on this material.
  52753. */
  52754. get cameraContrast(): float;
  52755. /**
  52756. * Sets The camera contrast used on this material.
  52757. */
  52758. set cameraContrast(value: float);
  52759. /**
  52760. * Gets the Color Grading 2D Lookup Texture.
  52761. */
  52762. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  52763. /**
  52764. * Sets the Color Grading 2D Lookup Texture.
  52765. */
  52766. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  52767. /**
  52768. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52769. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52770. * 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;
  52771. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52772. */
  52773. get cameraColorCurves(): Nullable<ColorCurves>;
  52774. /**
  52775. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52776. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52777. * 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;
  52778. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52779. */
  52780. set cameraColorCurves(value: Nullable<ColorCurves>);
  52781. /**
  52782. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  52783. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  52784. */
  52785. switchToBGR: boolean;
  52786. private _renderTargets;
  52787. private _reflectionControls;
  52788. private _white;
  52789. private _primaryShadowColor;
  52790. private _primaryHighlightColor;
  52791. /**
  52792. * Instantiates a Background Material in the given scene
  52793. * @param name The friendly name of the material
  52794. * @param scene The scene to add the material to
  52795. */
  52796. constructor(name: string, scene: Scene);
  52797. /**
  52798. * Gets a boolean indicating that current material needs to register RTT
  52799. */
  52800. get hasRenderTargetTextures(): boolean;
  52801. /**
  52802. * The entire material has been created in order to prevent overdraw.
  52803. * @returns false
  52804. */
  52805. needAlphaTesting(): boolean;
  52806. /**
  52807. * The entire material has been created in order to prevent overdraw.
  52808. * @returns true if blending is enable
  52809. */
  52810. needAlphaBlending(): boolean;
  52811. /**
  52812. * Checks wether the material is ready to be rendered for a given mesh.
  52813. * @param mesh The mesh to render
  52814. * @param subMesh The submesh to check against
  52815. * @param useInstances Specify wether or not the material is used with instances
  52816. * @returns true if all the dependencies are ready (Textures, Effects...)
  52817. */
  52818. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  52819. /**
  52820. * Compute the primary color according to the chosen perceptual color.
  52821. */
  52822. private _computePrimaryColorFromPerceptualColor;
  52823. /**
  52824. * Compute the highlights and shadow colors according to their chosen levels.
  52825. */
  52826. private _computePrimaryColors;
  52827. /**
  52828. * Build the uniform buffer used in the material.
  52829. */
  52830. buildUniformLayout(): void;
  52831. /**
  52832. * Unbind the material.
  52833. */
  52834. unbind(): void;
  52835. /**
  52836. * Bind only the world matrix to the material.
  52837. * @param world The world matrix to bind.
  52838. */
  52839. bindOnlyWorldMatrix(world: Matrix): void;
  52840. /**
  52841. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  52842. * @param world The world matrix to bind.
  52843. * @param subMesh The submesh to bind for.
  52844. */
  52845. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  52846. /**
  52847. * Checks to see if a texture is used in the material.
  52848. * @param texture - Base texture to use.
  52849. * @returns - Boolean specifying if a texture is used in the material.
  52850. */
  52851. hasTexture(texture: BaseTexture): boolean;
  52852. /**
  52853. * Dispose the material.
  52854. * @param forceDisposeEffect Force disposal of the associated effect.
  52855. * @param forceDisposeTextures Force disposal of the associated textures.
  52856. */
  52857. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  52858. /**
  52859. * Clones the material.
  52860. * @param name The cloned name.
  52861. * @returns The cloned material.
  52862. */
  52863. clone(name: string): BackgroundMaterial;
  52864. /**
  52865. * Serializes the current material to its JSON representation.
  52866. * @returns The JSON representation.
  52867. */
  52868. serialize(): any;
  52869. /**
  52870. * Gets the class name of the material
  52871. * @returns "BackgroundMaterial"
  52872. */
  52873. getClassName(): string;
  52874. /**
  52875. * Parse a JSON input to create back a background material.
  52876. * @param source The JSON data to parse
  52877. * @param scene The scene to create the parsed material in
  52878. * @param rootUrl The root url of the assets the material depends upon
  52879. * @returns the instantiated BackgroundMaterial.
  52880. */
  52881. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  52882. }
  52883. }
  52884. declare module BABYLON {
  52885. /**
  52886. * Represents the different options available during the creation of
  52887. * a Environment helper.
  52888. *
  52889. * This can control the default ground, skybox and image processing setup of your scene.
  52890. */
  52891. export interface IEnvironmentHelperOptions {
  52892. /**
  52893. * Specifies whether or not to create a ground.
  52894. * True by default.
  52895. */
  52896. createGround: boolean;
  52897. /**
  52898. * Specifies the ground size.
  52899. * 15 by default.
  52900. */
  52901. groundSize: number;
  52902. /**
  52903. * The texture used on the ground for the main color.
  52904. * Comes from the BabylonJS CDN by default.
  52905. *
  52906. * Remarks: Can be either a texture or a url.
  52907. */
  52908. groundTexture: string | BaseTexture;
  52909. /**
  52910. * The color mixed in the ground texture by default.
  52911. * BabylonJS clearColor by default.
  52912. */
  52913. groundColor: Color3;
  52914. /**
  52915. * Specifies the ground opacity.
  52916. * 1 by default.
  52917. */
  52918. groundOpacity: number;
  52919. /**
  52920. * Enables the ground to receive shadows.
  52921. * True by default.
  52922. */
  52923. enableGroundShadow: boolean;
  52924. /**
  52925. * Helps preventing the shadow to be fully black on the ground.
  52926. * 0.5 by default.
  52927. */
  52928. groundShadowLevel: number;
  52929. /**
  52930. * Creates a mirror texture attach to the ground.
  52931. * false by default.
  52932. */
  52933. enableGroundMirror: boolean;
  52934. /**
  52935. * Specifies the ground mirror size ratio.
  52936. * 0.3 by default as the default kernel is 64.
  52937. */
  52938. groundMirrorSizeRatio: number;
  52939. /**
  52940. * Specifies the ground mirror blur kernel size.
  52941. * 64 by default.
  52942. */
  52943. groundMirrorBlurKernel: number;
  52944. /**
  52945. * Specifies the ground mirror visibility amount.
  52946. * 1 by default
  52947. */
  52948. groundMirrorAmount: number;
  52949. /**
  52950. * Specifies the ground mirror reflectance weight.
  52951. * This uses the standard weight of the background material to setup the fresnel effect
  52952. * of the mirror.
  52953. * 1 by default.
  52954. */
  52955. groundMirrorFresnelWeight: number;
  52956. /**
  52957. * Specifies the ground mirror Falloff distance.
  52958. * This can helps reducing the size of the reflection.
  52959. * 0 by Default.
  52960. */
  52961. groundMirrorFallOffDistance: number;
  52962. /**
  52963. * Specifies the ground mirror texture type.
  52964. * Unsigned Int by Default.
  52965. */
  52966. groundMirrorTextureType: number;
  52967. /**
  52968. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  52969. * the shown objects.
  52970. */
  52971. groundYBias: number;
  52972. /**
  52973. * Specifies whether or not to create a skybox.
  52974. * True by default.
  52975. */
  52976. createSkybox: boolean;
  52977. /**
  52978. * Specifies the skybox size.
  52979. * 20 by default.
  52980. */
  52981. skyboxSize: number;
  52982. /**
  52983. * The texture used on the skybox for the main color.
  52984. * Comes from the BabylonJS CDN by default.
  52985. *
  52986. * Remarks: Can be either a texture or a url.
  52987. */
  52988. skyboxTexture: string | BaseTexture;
  52989. /**
  52990. * The color mixed in the skybox texture by default.
  52991. * BabylonJS clearColor by default.
  52992. */
  52993. skyboxColor: Color3;
  52994. /**
  52995. * The background rotation around the Y axis of the scene.
  52996. * This helps aligning the key lights of your scene with the background.
  52997. * 0 by default.
  52998. */
  52999. backgroundYRotation: number;
  53000. /**
  53001. * Compute automatically the size of the elements to best fit with the scene.
  53002. */
  53003. sizeAuto: boolean;
  53004. /**
  53005. * Default position of the rootMesh if autoSize is not true.
  53006. */
  53007. rootPosition: Vector3;
  53008. /**
  53009. * Sets up the image processing in the scene.
  53010. * true by default.
  53011. */
  53012. setupImageProcessing: boolean;
  53013. /**
  53014. * The texture used as your environment texture in the scene.
  53015. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  53016. *
  53017. * Remarks: Can be either a texture or a url.
  53018. */
  53019. environmentTexture: string | BaseTexture;
  53020. /**
  53021. * The value of the exposure to apply to the scene.
  53022. * 0.6 by default if setupImageProcessing is true.
  53023. */
  53024. cameraExposure: number;
  53025. /**
  53026. * The value of the contrast to apply to the scene.
  53027. * 1.6 by default if setupImageProcessing is true.
  53028. */
  53029. cameraContrast: number;
  53030. /**
  53031. * Specifies whether or not tonemapping should be enabled in the scene.
  53032. * true by default if setupImageProcessing is true.
  53033. */
  53034. toneMappingEnabled: boolean;
  53035. }
  53036. /**
  53037. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  53038. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  53039. * It also helps with the default setup of your imageProcessing configuration.
  53040. */
  53041. export class EnvironmentHelper {
  53042. /**
  53043. * Default ground texture URL.
  53044. */
  53045. private static _groundTextureCDNUrl;
  53046. /**
  53047. * Default skybox texture URL.
  53048. */
  53049. private static _skyboxTextureCDNUrl;
  53050. /**
  53051. * Default environment texture URL.
  53052. */
  53053. private static _environmentTextureCDNUrl;
  53054. /**
  53055. * Creates the default options for the helper.
  53056. */
  53057. private static _getDefaultOptions;
  53058. private _rootMesh;
  53059. /**
  53060. * Gets the root mesh created by the helper.
  53061. */
  53062. get rootMesh(): Mesh;
  53063. private _skybox;
  53064. /**
  53065. * Gets the skybox created by the helper.
  53066. */
  53067. get skybox(): Nullable<Mesh>;
  53068. private _skyboxTexture;
  53069. /**
  53070. * Gets the skybox texture created by the helper.
  53071. */
  53072. get skyboxTexture(): Nullable<BaseTexture>;
  53073. private _skyboxMaterial;
  53074. /**
  53075. * Gets the skybox material created by the helper.
  53076. */
  53077. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  53078. private _ground;
  53079. /**
  53080. * Gets the ground mesh created by the helper.
  53081. */
  53082. get ground(): Nullable<Mesh>;
  53083. private _groundTexture;
  53084. /**
  53085. * Gets the ground texture created by the helper.
  53086. */
  53087. get groundTexture(): Nullable<BaseTexture>;
  53088. private _groundMirror;
  53089. /**
  53090. * Gets the ground mirror created by the helper.
  53091. */
  53092. get groundMirror(): Nullable<MirrorTexture>;
  53093. /**
  53094. * Gets the ground mirror render list to helps pushing the meshes
  53095. * you wish in the ground reflection.
  53096. */
  53097. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  53098. private _groundMaterial;
  53099. /**
  53100. * Gets the ground material created by the helper.
  53101. */
  53102. get groundMaterial(): Nullable<BackgroundMaterial>;
  53103. /**
  53104. * Stores the creation options.
  53105. */
  53106. private readonly _scene;
  53107. private _options;
  53108. /**
  53109. * This observable will be notified with any error during the creation of the environment,
  53110. * mainly texture creation errors.
  53111. */
  53112. onErrorObservable: Observable<{
  53113. message?: string;
  53114. exception?: any;
  53115. }>;
  53116. /**
  53117. * constructor
  53118. * @param options Defines the options we want to customize the helper
  53119. * @param scene The scene to add the material to
  53120. */
  53121. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  53122. /**
  53123. * Updates the background according to the new options
  53124. * @param options
  53125. */
  53126. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  53127. /**
  53128. * Sets the primary color of all the available elements.
  53129. * @param color the main color to affect to the ground and the background
  53130. */
  53131. setMainColor(color: Color3): void;
  53132. /**
  53133. * Setup the image processing according to the specified options.
  53134. */
  53135. private _setupImageProcessing;
  53136. /**
  53137. * Setup the environment texture according to the specified options.
  53138. */
  53139. private _setupEnvironmentTexture;
  53140. /**
  53141. * Setup the background according to the specified options.
  53142. */
  53143. private _setupBackground;
  53144. /**
  53145. * Get the scene sizes according to the setup.
  53146. */
  53147. private _getSceneSize;
  53148. /**
  53149. * Setup the ground according to the specified options.
  53150. */
  53151. private _setupGround;
  53152. /**
  53153. * Setup the ground material according to the specified options.
  53154. */
  53155. private _setupGroundMaterial;
  53156. /**
  53157. * Setup the ground diffuse texture according to the specified options.
  53158. */
  53159. private _setupGroundDiffuseTexture;
  53160. /**
  53161. * Setup the ground mirror texture according to the specified options.
  53162. */
  53163. private _setupGroundMirrorTexture;
  53164. /**
  53165. * Setup the ground to receive the mirror texture.
  53166. */
  53167. private _setupMirrorInGroundMaterial;
  53168. /**
  53169. * Setup the skybox according to the specified options.
  53170. */
  53171. private _setupSkybox;
  53172. /**
  53173. * Setup the skybox material according to the specified options.
  53174. */
  53175. private _setupSkyboxMaterial;
  53176. /**
  53177. * Setup the skybox reflection texture according to the specified options.
  53178. */
  53179. private _setupSkyboxReflectionTexture;
  53180. private _errorHandler;
  53181. /**
  53182. * Dispose all the elements created by the Helper.
  53183. */
  53184. dispose(): void;
  53185. }
  53186. }
  53187. declare module BABYLON {
  53188. /**
  53189. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  53190. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  53191. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  53192. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  53193. */
  53194. export class PhotoDome extends TransformNode {
  53195. /**
  53196. * Define the image as a Monoscopic panoramic 360 image.
  53197. */
  53198. static readonly MODE_MONOSCOPIC: number;
  53199. /**
  53200. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  53201. */
  53202. static readonly MODE_TOPBOTTOM: number;
  53203. /**
  53204. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  53205. */
  53206. static readonly MODE_SIDEBYSIDE: number;
  53207. private _useDirectMapping;
  53208. /**
  53209. * The texture being displayed on the sphere
  53210. */
  53211. protected _photoTexture: Texture;
  53212. /**
  53213. * Gets or sets the texture being displayed on the sphere
  53214. */
  53215. get photoTexture(): Texture;
  53216. set photoTexture(value: Texture);
  53217. /**
  53218. * Observable raised when an error occured while loading the 360 image
  53219. */
  53220. onLoadErrorObservable: Observable<string>;
  53221. /**
  53222. * The skybox material
  53223. */
  53224. protected _material: BackgroundMaterial;
  53225. /**
  53226. * The surface used for the skybox
  53227. */
  53228. protected _mesh: Mesh;
  53229. /**
  53230. * Gets the mesh used for the skybox.
  53231. */
  53232. get mesh(): Mesh;
  53233. /**
  53234. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  53235. * Also see the options.resolution property.
  53236. */
  53237. get fovMultiplier(): number;
  53238. set fovMultiplier(value: number);
  53239. private _imageMode;
  53240. /**
  53241. * Gets or set the current video mode for the video. It can be:
  53242. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  53243. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  53244. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  53245. */
  53246. get imageMode(): number;
  53247. set imageMode(value: number);
  53248. /**
  53249. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  53250. * @param name Element's name, child elements will append suffixes for their own names.
  53251. * @param urlsOfPhoto defines the url of the photo to display
  53252. * @param options defines an object containing optional or exposed sub element properties
  53253. * @param onError defines a callback called when an error occured while loading the texture
  53254. */
  53255. constructor(name: string, urlOfPhoto: string, options: {
  53256. resolution?: number;
  53257. size?: number;
  53258. useDirectMapping?: boolean;
  53259. faceForward?: boolean;
  53260. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  53261. private _onBeforeCameraRenderObserver;
  53262. private _changeImageMode;
  53263. /**
  53264. * Releases resources associated with this node.
  53265. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  53266. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  53267. */
  53268. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  53269. }
  53270. }
  53271. declare module BABYLON {
  53272. /**
  53273. * Class used to host RGBD texture specific utilities
  53274. */
  53275. export class RGBDTextureTools {
  53276. /**
  53277. * Expand the RGBD Texture from RGBD to Half Float if possible.
  53278. * @param texture the texture to expand.
  53279. */
  53280. static ExpandRGBDTexture(texture: Texture): void;
  53281. }
  53282. }
  53283. declare module BABYLON {
  53284. /**
  53285. * Class used to host texture specific utilities
  53286. */
  53287. export class BRDFTextureTools {
  53288. /**
  53289. * Prevents texture cache collision
  53290. */
  53291. private static _instanceNumber;
  53292. /**
  53293. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  53294. * @param scene defines the hosting scene
  53295. * @returns the environment BRDF texture
  53296. */
  53297. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  53298. private static _environmentBRDFBase64Texture;
  53299. }
  53300. }
  53301. declare module BABYLON {
  53302. /**
  53303. * @hidden
  53304. */
  53305. export interface IMaterialClearCoatDefines {
  53306. CLEARCOAT: boolean;
  53307. CLEARCOAT_DEFAULTIOR: boolean;
  53308. CLEARCOAT_TEXTURE: boolean;
  53309. CLEARCOAT_TEXTUREDIRECTUV: number;
  53310. CLEARCOAT_BUMP: boolean;
  53311. CLEARCOAT_BUMPDIRECTUV: number;
  53312. CLEARCOAT_TINT: boolean;
  53313. CLEARCOAT_TINT_TEXTURE: boolean;
  53314. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  53315. /** @hidden */
  53316. _areTexturesDirty: boolean;
  53317. }
  53318. /**
  53319. * Define the code related to the clear coat parameters of the pbr material.
  53320. */
  53321. export class PBRClearCoatConfiguration {
  53322. /**
  53323. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  53324. * The default fits with a polyurethane material.
  53325. */
  53326. private static readonly _DefaultIndexOfRefraction;
  53327. private _isEnabled;
  53328. /**
  53329. * Defines if the clear coat is enabled in the material.
  53330. */
  53331. isEnabled: boolean;
  53332. /**
  53333. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  53334. */
  53335. intensity: number;
  53336. /**
  53337. * Defines the clear coat layer roughness.
  53338. */
  53339. roughness: number;
  53340. private _indexOfRefraction;
  53341. /**
  53342. * Defines the index of refraction of the clear coat.
  53343. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  53344. * The default fits with a polyurethane material.
  53345. * Changing the default value is more performance intensive.
  53346. */
  53347. indexOfRefraction: number;
  53348. private _texture;
  53349. /**
  53350. * Stores the clear coat values in a texture.
  53351. */
  53352. texture: Nullable<BaseTexture>;
  53353. private _bumpTexture;
  53354. /**
  53355. * Define the clear coat specific bump texture.
  53356. */
  53357. bumpTexture: Nullable<BaseTexture>;
  53358. private _isTintEnabled;
  53359. /**
  53360. * Defines if the clear coat tint is enabled in the material.
  53361. */
  53362. isTintEnabled: boolean;
  53363. /**
  53364. * Defines the clear coat tint of the material.
  53365. * This is only use if tint is enabled
  53366. */
  53367. tintColor: Color3;
  53368. /**
  53369. * Defines the distance at which the tint color should be found in the
  53370. * clear coat media.
  53371. * This is only use if tint is enabled
  53372. */
  53373. tintColorAtDistance: number;
  53374. /**
  53375. * Defines the clear coat layer thickness.
  53376. * This is only use if tint is enabled
  53377. */
  53378. tintThickness: number;
  53379. private _tintTexture;
  53380. /**
  53381. * Stores the clear tint values in a texture.
  53382. * rgb is tint
  53383. * a is a thickness factor
  53384. */
  53385. tintTexture: Nullable<BaseTexture>;
  53386. /** @hidden */
  53387. private _internalMarkAllSubMeshesAsTexturesDirty;
  53388. /** @hidden */
  53389. _markAllSubMeshesAsTexturesDirty(): void;
  53390. /**
  53391. * Instantiate a new istance of clear coat configuration.
  53392. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  53393. */
  53394. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  53395. /**
  53396. * Gets wehter the submesh is ready to be used or not.
  53397. * @param defines the list of "defines" to update.
  53398. * @param scene defines the scene the material belongs to.
  53399. * @param engine defines the engine the material belongs to.
  53400. * @param disableBumpMap defines wether the material disables bump or not.
  53401. * @returns - boolean indicating that the submesh is ready or not.
  53402. */
  53403. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  53404. /**
  53405. * Checks to see if a texture is used in the material.
  53406. * @param defines the list of "defines" to update.
  53407. * @param scene defines the scene to the material belongs to.
  53408. */
  53409. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  53410. /**
  53411. * Binds the material data.
  53412. * @param uniformBuffer defines the Uniform buffer to fill in.
  53413. * @param scene defines the scene the material belongs to.
  53414. * @param engine defines the engine the material belongs to.
  53415. * @param disableBumpMap defines wether the material disables bump or not.
  53416. * @param isFrozen defines wether the material is frozen or not.
  53417. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  53418. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  53419. */
  53420. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  53421. /**
  53422. * Checks to see if a texture is used in the material.
  53423. * @param texture - Base texture to use.
  53424. * @returns - Boolean specifying if a texture is used in the material.
  53425. */
  53426. hasTexture(texture: BaseTexture): boolean;
  53427. /**
  53428. * Returns an array of the actively used textures.
  53429. * @param activeTextures Array of BaseTextures
  53430. */
  53431. getActiveTextures(activeTextures: BaseTexture[]): void;
  53432. /**
  53433. * Returns the animatable textures.
  53434. * @param animatables Array of animatable textures.
  53435. */
  53436. getAnimatables(animatables: IAnimatable[]): void;
  53437. /**
  53438. * Disposes the resources of the material.
  53439. * @param forceDisposeTextures - Forces the disposal of all textures.
  53440. */
  53441. dispose(forceDisposeTextures?: boolean): void;
  53442. /**
  53443. * Get the current class name of the texture useful for serialization or dynamic coding.
  53444. * @returns "PBRClearCoatConfiguration"
  53445. */
  53446. getClassName(): string;
  53447. /**
  53448. * Add fallbacks to the effect fallbacks list.
  53449. * @param defines defines the Base texture to use.
  53450. * @param fallbacks defines the current fallback list.
  53451. * @param currentRank defines the current fallback rank.
  53452. * @returns the new fallback rank.
  53453. */
  53454. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  53455. /**
  53456. * Add the required uniforms to the current list.
  53457. * @param uniforms defines the current uniform list.
  53458. */
  53459. static AddUniforms(uniforms: string[]): void;
  53460. /**
  53461. * Add the required samplers to the current list.
  53462. * @param samplers defines the current sampler list.
  53463. */
  53464. static AddSamplers(samplers: string[]): void;
  53465. /**
  53466. * Add the required uniforms to the current buffer.
  53467. * @param uniformBuffer defines the current uniform buffer.
  53468. */
  53469. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  53470. /**
  53471. * Makes a duplicate of the current configuration into another one.
  53472. * @param clearCoatConfiguration define the config where to copy the info
  53473. */
  53474. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  53475. /**
  53476. * Serializes this clear coat configuration.
  53477. * @returns - An object with the serialized config.
  53478. */
  53479. serialize(): any;
  53480. /**
  53481. * Parses a anisotropy Configuration from a serialized object.
  53482. * @param source - Serialized object.
  53483. * @param scene Defines the scene we are parsing for
  53484. * @param rootUrl Defines the rootUrl to load from
  53485. */
  53486. parse(source: any, scene: Scene, rootUrl: string): void;
  53487. }
  53488. }
  53489. declare module BABYLON {
  53490. /**
  53491. * @hidden
  53492. */
  53493. export interface IMaterialAnisotropicDefines {
  53494. ANISOTROPIC: boolean;
  53495. ANISOTROPIC_TEXTURE: boolean;
  53496. ANISOTROPIC_TEXTUREDIRECTUV: number;
  53497. MAINUV1: boolean;
  53498. _areTexturesDirty: boolean;
  53499. _needUVs: boolean;
  53500. }
  53501. /**
  53502. * Define the code related to the anisotropic parameters of the pbr material.
  53503. */
  53504. export class PBRAnisotropicConfiguration {
  53505. private _isEnabled;
  53506. /**
  53507. * Defines if the anisotropy is enabled in the material.
  53508. */
  53509. isEnabled: boolean;
  53510. /**
  53511. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  53512. */
  53513. intensity: number;
  53514. /**
  53515. * Defines if the effect is along the tangents, bitangents or in between.
  53516. * By default, the effect is "strectching" the highlights along the tangents.
  53517. */
  53518. direction: Vector2;
  53519. private _texture;
  53520. /**
  53521. * Stores the anisotropy values in a texture.
  53522. * rg is direction (like normal from -1 to 1)
  53523. * b is a intensity
  53524. */
  53525. texture: Nullable<BaseTexture>;
  53526. /** @hidden */
  53527. private _internalMarkAllSubMeshesAsTexturesDirty;
  53528. /** @hidden */
  53529. _markAllSubMeshesAsTexturesDirty(): void;
  53530. /**
  53531. * Instantiate a new istance of anisotropy configuration.
  53532. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  53533. */
  53534. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  53535. /**
  53536. * Specifies that the submesh is ready to be used.
  53537. * @param defines the list of "defines" to update.
  53538. * @param scene defines the scene the material belongs to.
  53539. * @returns - boolean indicating that the submesh is ready or not.
  53540. */
  53541. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  53542. /**
  53543. * Checks to see if a texture is used in the material.
  53544. * @param defines the list of "defines" to update.
  53545. * @param mesh the mesh we are preparing the defines for.
  53546. * @param scene defines the scene the material belongs to.
  53547. */
  53548. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  53549. /**
  53550. * Binds the material data.
  53551. * @param uniformBuffer defines the Uniform buffer to fill in.
  53552. * @param scene defines the scene the material belongs to.
  53553. * @param isFrozen defines wether the material is frozen or not.
  53554. */
  53555. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  53556. /**
  53557. * Checks to see if a texture is used in the material.
  53558. * @param texture - Base texture to use.
  53559. * @returns - Boolean specifying if a texture is used in the material.
  53560. */
  53561. hasTexture(texture: BaseTexture): boolean;
  53562. /**
  53563. * Returns an array of the actively used textures.
  53564. * @param activeTextures Array of BaseTextures
  53565. */
  53566. getActiveTextures(activeTextures: BaseTexture[]): void;
  53567. /**
  53568. * Returns the animatable textures.
  53569. * @param animatables Array of animatable textures.
  53570. */
  53571. getAnimatables(animatables: IAnimatable[]): void;
  53572. /**
  53573. * Disposes the resources of the material.
  53574. * @param forceDisposeTextures - Forces the disposal of all textures.
  53575. */
  53576. dispose(forceDisposeTextures?: boolean): void;
  53577. /**
  53578. * Get the current class name of the texture useful for serialization or dynamic coding.
  53579. * @returns "PBRAnisotropicConfiguration"
  53580. */
  53581. getClassName(): string;
  53582. /**
  53583. * Add fallbacks to the effect fallbacks list.
  53584. * @param defines defines the Base texture to use.
  53585. * @param fallbacks defines the current fallback list.
  53586. * @param currentRank defines the current fallback rank.
  53587. * @returns the new fallback rank.
  53588. */
  53589. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  53590. /**
  53591. * Add the required uniforms to the current list.
  53592. * @param uniforms defines the current uniform list.
  53593. */
  53594. static AddUniforms(uniforms: string[]): void;
  53595. /**
  53596. * Add the required uniforms to the current buffer.
  53597. * @param uniformBuffer defines the current uniform buffer.
  53598. */
  53599. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  53600. /**
  53601. * Add the required samplers to the current list.
  53602. * @param samplers defines the current sampler list.
  53603. */
  53604. static AddSamplers(samplers: string[]): void;
  53605. /**
  53606. * Makes a duplicate of the current configuration into another one.
  53607. * @param anisotropicConfiguration define the config where to copy the info
  53608. */
  53609. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  53610. /**
  53611. * Serializes this anisotropy configuration.
  53612. * @returns - An object with the serialized config.
  53613. */
  53614. serialize(): any;
  53615. /**
  53616. * Parses a anisotropy Configuration from a serialized object.
  53617. * @param source - Serialized object.
  53618. * @param scene Defines the scene we are parsing for
  53619. * @param rootUrl Defines the rootUrl to load from
  53620. */
  53621. parse(source: any, scene: Scene, rootUrl: string): void;
  53622. }
  53623. }
  53624. declare module BABYLON {
  53625. /**
  53626. * @hidden
  53627. */
  53628. export interface IMaterialBRDFDefines {
  53629. BRDF_V_HEIGHT_CORRELATED: boolean;
  53630. MS_BRDF_ENERGY_CONSERVATION: boolean;
  53631. SPHERICAL_HARMONICS: boolean;
  53632. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  53633. /** @hidden */
  53634. _areMiscDirty: boolean;
  53635. }
  53636. /**
  53637. * Define the code related to the BRDF parameters of the pbr material.
  53638. */
  53639. export class PBRBRDFConfiguration {
  53640. /**
  53641. * Default value used for the energy conservation.
  53642. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  53643. */
  53644. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  53645. /**
  53646. * Default value used for the Smith Visibility Height Correlated mode.
  53647. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  53648. */
  53649. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  53650. /**
  53651. * Default value used for the IBL diffuse part.
  53652. * This can help switching back to the polynomials mode globally which is a tiny bit
  53653. * less GPU intensive at the drawback of a lower quality.
  53654. */
  53655. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  53656. /**
  53657. * Default value used for activating energy conservation for the specular workflow.
  53658. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  53659. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  53660. */
  53661. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  53662. private _useEnergyConservation;
  53663. /**
  53664. * Defines if the material uses energy conservation.
  53665. */
  53666. useEnergyConservation: boolean;
  53667. private _useSmithVisibilityHeightCorrelated;
  53668. /**
  53669. * LEGACY Mode set to false
  53670. * Defines if the material uses height smith correlated visibility term.
  53671. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  53672. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  53673. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  53674. * Not relying on height correlated will also disable energy conservation.
  53675. */
  53676. useSmithVisibilityHeightCorrelated: boolean;
  53677. private _useSphericalHarmonics;
  53678. /**
  53679. * LEGACY Mode set to false
  53680. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  53681. * diffuse part of the IBL.
  53682. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  53683. * to the ground truth.
  53684. */
  53685. useSphericalHarmonics: boolean;
  53686. private _useSpecularGlossinessInputEnergyConservation;
  53687. /**
  53688. * Defines if the material uses energy conservation, when the specular workflow is active.
  53689. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  53690. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  53691. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  53692. */
  53693. useSpecularGlossinessInputEnergyConservation: boolean;
  53694. /** @hidden */
  53695. private _internalMarkAllSubMeshesAsMiscDirty;
  53696. /** @hidden */
  53697. _markAllSubMeshesAsMiscDirty(): void;
  53698. /**
  53699. * Instantiate a new istance of clear coat configuration.
  53700. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  53701. */
  53702. constructor(markAllSubMeshesAsMiscDirty: () => void);
  53703. /**
  53704. * Checks to see if a texture is used in the material.
  53705. * @param defines the list of "defines" to update.
  53706. */
  53707. prepareDefines(defines: IMaterialBRDFDefines): void;
  53708. /**
  53709. * Get the current class name of the texture useful for serialization or dynamic coding.
  53710. * @returns "PBRClearCoatConfiguration"
  53711. */
  53712. getClassName(): string;
  53713. /**
  53714. * Makes a duplicate of the current configuration into another one.
  53715. * @param brdfConfiguration define the config where to copy the info
  53716. */
  53717. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  53718. /**
  53719. * Serializes this BRDF configuration.
  53720. * @returns - An object with the serialized config.
  53721. */
  53722. serialize(): any;
  53723. /**
  53724. * Parses a anisotropy Configuration from a serialized object.
  53725. * @param source - Serialized object.
  53726. * @param scene Defines the scene we are parsing for
  53727. * @param rootUrl Defines the rootUrl to load from
  53728. */
  53729. parse(source: any, scene: Scene, rootUrl: string): void;
  53730. }
  53731. }
  53732. declare module BABYLON {
  53733. /**
  53734. * @hidden
  53735. */
  53736. export interface IMaterialSheenDefines {
  53737. SHEEN: boolean;
  53738. SHEEN_TEXTURE: boolean;
  53739. SHEEN_TEXTUREDIRECTUV: number;
  53740. SHEEN_LINKWITHALBEDO: boolean;
  53741. SHEEN_ROUGHNESS: boolean;
  53742. SHEEN_ALBEDOSCALING: boolean;
  53743. /** @hidden */
  53744. _areTexturesDirty: boolean;
  53745. }
  53746. /**
  53747. * Define the code related to the Sheen parameters of the pbr material.
  53748. */
  53749. export class PBRSheenConfiguration {
  53750. private _isEnabled;
  53751. /**
  53752. * Defines if the material uses sheen.
  53753. */
  53754. isEnabled: boolean;
  53755. private _linkSheenWithAlbedo;
  53756. /**
  53757. * Defines if the sheen is linked to the sheen color.
  53758. */
  53759. linkSheenWithAlbedo: boolean;
  53760. /**
  53761. * Defines the sheen intensity.
  53762. */
  53763. intensity: number;
  53764. /**
  53765. * Defines the sheen color.
  53766. */
  53767. color: Color3;
  53768. private _texture;
  53769. /**
  53770. * Stores the sheen tint values in a texture.
  53771. * rgb is tint
  53772. * a is a intensity
  53773. */
  53774. texture: Nullable<BaseTexture>;
  53775. private _roughness;
  53776. /**
  53777. * Defines the sheen roughness.
  53778. * It is not taken into account if linkSheenWithAlbedo is true.
  53779. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  53780. */
  53781. roughness: Nullable<number>;
  53782. private _albedoScaling;
  53783. /**
  53784. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  53785. * It allows the strength of the sheen effect to not depend on the base color of the material,
  53786. * making it easier to setup and tweak the effect
  53787. */
  53788. albedoScaling: boolean;
  53789. /** @hidden */
  53790. private _internalMarkAllSubMeshesAsTexturesDirty;
  53791. /** @hidden */
  53792. _markAllSubMeshesAsTexturesDirty(): void;
  53793. /**
  53794. * Instantiate a new istance of clear coat configuration.
  53795. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  53796. */
  53797. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  53798. /**
  53799. * Specifies that the submesh is ready to be used.
  53800. * @param defines the list of "defines" to update.
  53801. * @param scene defines the scene the material belongs to.
  53802. * @returns - boolean indicating that the submesh is ready or not.
  53803. */
  53804. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  53805. /**
  53806. * Checks to see if a texture is used in the material.
  53807. * @param defines the list of "defines" to update.
  53808. * @param scene defines the scene the material belongs to.
  53809. */
  53810. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  53811. /**
  53812. * Binds the material data.
  53813. * @param uniformBuffer defines the Uniform buffer to fill in.
  53814. * @param scene defines the scene the material belongs to.
  53815. * @param isFrozen defines wether the material is frozen or not.
  53816. */
  53817. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  53818. /**
  53819. * Checks to see if a texture is used in the material.
  53820. * @param texture - Base texture to use.
  53821. * @returns - Boolean specifying if a texture is used in the material.
  53822. */
  53823. hasTexture(texture: BaseTexture): boolean;
  53824. /**
  53825. * Returns an array of the actively used textures.
  53826. * @param activeTextures Array of BaseTextures
  53827. */
  53828. getActiveTextures(activeTextures: BaseTexture[]): void;
  53829. /**
  53830. * Returns the animatable textures.
  53831. * @param animatables Array of animatable textures.
  53832. */
  53833. getAnimatables(animatables: IAnimatable[]): void;
  53834. /**
  53835. * Disposes the resources of the material.
  53836. * @param forceDisposeTextures - Forces the disposal of all textures.
  53837. */
  53838. dispose(forceDisposeTextures?: boolean): void;
  53839. /**
  53840. * Get the current class name of the texture useful for serialization or dynamic coding.
  53841. * @returns "PBRSheenConfiguration"
  53842. */
  53843. getClassName(): string;
  53844. /**
  53845. * Add fallbacks to the effect fallbacks list.
  53846. * @param defines defines the Base texture to use.
  53847. * @param fallbacks defines the current fallback list.
  53848. * @param currentRank defines the current fallback rank.
  53849. * @returns the new fallback rank.
  53850. */
  53851. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  53852. /**
  53853. * Add the required uniforms to the current list.
  53854. * @param uniforms defines the current uniform list.
  53855. */
  53856. static AddUniforms(uniforms: string[]): void;
  53857. /**
  53858. * Add the required uniforms to the current buffer.
  53859. * @param uniformBuffer defines the current uniform buffer.
  53860. */
  53861. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  53862. /**
  53863. * Add the required samplers to the current list.
  53864. * @param samplers defines the current sampler list.
  53865. */
  53866. static AddSamplers(samplers: string[]): void;
  53867. /**
  53868. * Makes a duplicate of the current configuration into another one.
  53869. * @param sheenConfiguration define the config where to copy the info
  53870. */
  53871. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  53872. /**
  53873. * Serializes this BRDF configuration.
  53874. * @returns - An object with the serialized config.
  53875. */
  53876. serialize(): any;
  53877. /**
  53878. * Parses a anisotropy Configuration from a serialized object.
  53879. * @param source - Serialized object.
  53880. * @param scene Defines the scene we are parsing for
  53881. * @param rootUrl Defines the rootUrl to load from
  53882. */
  53883. parse(source: any, scene: Scene, rootUrl: string): void;
  53884. }
  53885. }
  53886. declare module BABYLON {
  53887. /**
  53888. * @hidden
  53889. */
  53890. export interface IMaterialSubSurfaceDefines {
  53891. SUBSURFACE: boolean;
  53892. SS_REFRACTION: boolean;
  53893. SS_TRANSLUCENCY: boolean;
  53894. SS_SCATERRING: boolean;
  53895. SS_THICKNESSANDMASK_TEXTURE: boolean;
  53896. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  53897. SS_REFRACTIONMAP_3D: boolean;
  53898. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  53899. SS_LODINREFRACTIONALPHA: boolean;
  53900. SS_GAMMAREFRACTION: boolean;
  53901. SS_RGBDREFRACTION: boolean;
  53902. SS_LINEARSPECULARREFRACTION: boolean;
  53903. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  53904. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  53905. /** @hidden */
  53906. _areTexturesDirty: boolean;
  53907. }
  53908. /**
  53909. * Define the code related to the sub surface parameters of the pbr material.
  53910. */
  53911. export class PBRSubSurfaceConfiguration {
  53912. private _isRefractionEnabled;
  53913. /**
  53914. * Defines if the refraction is enabled in the material.
  53915. */
  53916. isRefractionEnabled: boolean;
  53917. private _isTranslucencyEnabled;
  53918. /**
  53919. * Defines if the translucency is enabled in the material.
  53920. */
  53921. isTranslucencyEnabled: boolean;
  53922. private _isScatteringEnabled;
  53923. /**
  53924. * Defines the refraction intensity of the material.
  53925. * The refraction when enabled replaces the Diffuse part of the material.
  53926. * The intensity helps transitionning between diffuse and refraction.
  53927. */
  53928. refractionIntensity: number;
  53929. /**
  53930. * Defines the translucency intensity of the material.
  53931. * When translucency has been enabled, this defines how much of the "translucency"
  53932. * is addded to the diffuse part of the material.
  53933. */
  53934. translucencyIntensity: number;
  53935. /**
  53936. * Defines the scattering intensity of the material.
  53937. * When scattering has been enabled, this defines how much of the "scattered light"
  53938. * is addded to the diffuse part of the material.
  53939. */
  53940. scatteringIntensity: number;
  53941. private _thicknessTexture;
  53942. /**
  53943. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  53944. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  53945. * 0 would mean minimumThickness
  53946. * 1 would mean maximumThickness
  53947. * The other channels might be use as a mask to vary the different effects intensity.
  53948. */
  53949. thicknessTexture: Nullable<BaseTexture>;
  53950. private _refractionTexture;
  53951. /**
  53952. * Defines the texture to use for refraction.
  53953. */
  53954. refractionTexture: Nullable<BaseTexture>;
  53955. private _indexOfRefraction;
  53956. /**
  53957. * Index of refraction of the material base layer.
  53958. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  53959. *
  53960. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  53961. *
  53962. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  53963. */
  53964. indexOfRefraction: number;
  53965. private _invertRefractionY;
  53966. /**
  53967. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  53968. */
  53969. invertRefractionY: boolean;
  53970. private _linkRefractionWithTransparency;
  53971. /**
  53972. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  53973. * Materials half opaque for instance using refraction could benefit from this control.
  53974. */
  53975. linkRefractionWithTransparency: boolean;
  53976. /**
  53977. * Defines the minimum thickness stored in the thickness map.
  53978. * If no thickness map is defined, this value will be used to simulate thickness.
  53979. */
  53980. minimumThickness: number;
  53981. /**
  53982. * Defines the maximum thickness stored in the thickness map.
  53983. */
  53984. maximumThickness: number;
  53985. /**
  53986. * Defines the volume tint of the material.
  53987. * This is used for both translucency and scattering.
  53988. */
  53989. tintColor: Color3;
  53990. /**
  53991. * Defines the distance at which the tint color should be found in the media.
  53992. * This is used for refraction only.
  53993. */
  53994. tintColorAtDistance: number;
  53995. /**
  53996. * Defines how far each channel transmit through the media.
  53997. * It is defined as a color to simplify it selection.
  53998. */
  53999. diffusionDistance: Color3;
  54000. private _useMaskFromThicknessTexture;
  54001. /**
  54002. * Stores the intensity of the different subsurface effects in the thickness texture.
  54003. * * the green channel is the translucency intensity.
  54004. * * the blue channel is the scattering intensity.
  54005. * * the alpha channel is the refraction intensity.
  54006. */
  54007. useMaskFromThicknessTexture: boolean;
  54008. /** @hidden */
  54009. private _internalMarkAllSubMeshesAsTexturesDirty;
  54010. /** @hidden */
  54011. _markAllSubMeshesAsTexturesDirty(): void;
  54012. /**
  54013. * Instantiate a new istance of sub surface configuration.
  54014. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  54015. */
  54016. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  54017. /**
  54018. * Gets wehter the submesh is ready to be used or not.
  54019. * @param defines the list of "defines" to update.
  54020. * @param scene defines the scene the material belongs to.
  54021. * @returns - boolean indicating that the submesh is ready or not.
  54022. */
  54023. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  54024. /**
  54025. * Checks to see if a texture is used in the material.
  54026. * @param defines the list of "defines" to update.
  54027. * @param scene defines the scene to the material belongs to.
  54028. */
  54029. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  54030. /**
  54031. * Binds the material data.
  54032. * @param uniformBuffer defines the Uniform buffer to fill in.
  54033. * @param scene defines the scene the material belongs to.
  54034. * @param engine defines the engine the material belongs to.
  54035. * @param isFrozen defines wether the material is frozen or not.
  54036. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  54037. */
  54038. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  54039. /**
  54040. * Unbinds the material from the mesh.
  54041. * @param activeEffect defines the effect that should be unbound from.
  54042. * @returns true if unbound, otherwise false
  54043. */
  54044. unbind(activeEffect: Effect): boolean;
  54045. /**
  54046. * Returns the texture used for refraction or null if none is used.
  54047. * @param scene defines the scene the material belongs to.
  54048. * @returns - Refraction texture if present. If no refraction texture and refraction
  54049. * is linked with transparency, returns environment texture. Otherwise, returns null.
  54050. */
  54051. private _getRefractionTexture;
  54052. /**
  54053. * Returns true if alpha blending should be disabled.
  54054. */
  54055. get disableAlphaBlending(): boolean;
  54056. /**
  54057. * Fills the list of render target textures.
  54058. * @param renderTargets the list of render targets to update
  54059. */
  54060. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  54061. /**
  54062. * Checks to see if a texture is used in the material.
  54063. * @param texture - Base texture to use.
  54064. * @returns - Boolean specifying if a texture is used in the material.
  54065. */
  54066. hasTexture(texture: BaseTexture): boolean;
  54067. /**
  54068. * Gets a boolean indicating that current material needs to register RTT
  54069. * @returns true if this uses a render target otherwise false.
  54070. */
  54071. hasRenderTargetTextures(): boolean;
  54072. /**
  54073. * Returns an array of the actively used textures.
  54074. * @param activeTextures Array of BaseTextures
  54075. */
  54076. getActiveTextures(activeTextures: BaseTexture[]): void;
  54077. /**
  54078. * Returns the animatable textures.
  54079. * @param animatables Array of animatable textures.
  54080. */
  54081. getAnimatables(animatables: IAnimatable[]): void;
  54082. /**
  54083. * Disposes the resources of the material.
  54084. * @param forceDisposeTextures - Forces the disposal of all textures.
  54085. */
  54086. dispose(forceDisposeTextures?: boolean): void;
  54087. /**
  54088. * Get the current class name of the texture useful for serialization or dynamic coding.
  54089. * @returns "PBRSubSurfaceConfiguration"
  54090. */
  54091. getClassName(): string;
  54092. /**
  54093. * Add fallbacks to the effect fallbacks list.
  54094. * @param defines defines the Base texture to use.
  54095. * @param fallbacks defines the current fallback list.
  54096. * @param currentRank defines the current fallback rank.
  54097. * @returns the new fallback rank.
  54098. */
  54099. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  54100. /**
  54101. * Add the required uniforms to the current list.
  54102. * @param uniforms defines the current uniform list.
  54103. */
  54104. static AddUniforms(uniforms: string[]): void;
  54105. /**
  54106. * Add the required samplers to the current list.
  54107. * @param samplers defines the current sampler list.
  54108. */
  54109. static AddSamplers(samplers: string[]): void;
  54110. /**
  54111. * Add the required uniforms to the current buffer.
  54112. * @param uniformBuffer defines the current uniform buffer.
  54113. */
  54114. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  54115. /**
  54116. * Makes a duplicate of the current configuration into another one.
  54117. * @param configuration define the config where to copy the info
  54118. */
  54119. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  54120. /**
  54121. * Serializes this Sub Surface configuration.
  54122. * @returns - An object with the serialized config.
  54123. */
  54124. serialize(): any;
  54125. /**
  54126. * Parses a anisotropy Configuration from a serialized object.
  54127. * @param source - Serialized object.
  54128. * @param scene Defines the scene we are parsing for
  54129. * @param rootUrl Defines the rootUrl to load from
  54130. */
  54131. parse(source: any, scene: Scene, rootUrl: string): void;
  54132. }
  54133. }
  54134. declare module BABYLON {
  54135. /** @hidden */
  54136. export var pbrFragmentDeclaration: {
  54137. name: string;
  54138. shader: string;
  54139. };
  54140. }
  54141. declare module BABYLON {
  54142. /** @hidden */
  54143. export var pbrUboDeclaration: {
  54144. name: string;
  54145. shader: string;
  54146. };
  54147. }
  54148. declare module BABYLON {
  54149. /** @hidden */
  54150. export var pbrFragmentExtraDeclaration: {
  54151. name: string;
  54152. shader: string;
  54153. };
  54154. }
  54155. declare module BABYLON {
  54156. /** @hidden */
  54157. export var pbrFragmentSamplersDeclaration: {
  54158. name: string;
  54159. shader: string;
  54160. };
  54161. }
  54162. declare module BABYLON {
  54163. /** @hidden */
  54164. export var importanceSampling: {
  54165. name: string;
  54166. shader: string;
  54167. };
  54168. }
  54169. declare module BABYLON {
  54170. /** @hidden */
  54171. export var pbrHelperFunctions: {
  54172. name: string;
  54173. shader: string;
  54174. };
  54175. }
  54176. declare module BABYLON {
  54177. /** @hidden */
  54178. export var harmonicsFunctions: {
  54179. name: string;
  54180. shader: string;
  54181. };
  54182. }
  54183. declare module BABYLON {
  54184. /** @hidden */
  54185. export var pbrDirectLightingSetupFunctions: {
  54186. name: string;
  54187. shader: string;
  54188. };
  54189. }
  54190. declare module BABYLON {
  54191. /** @hidden */
  54192. export var pbrDirectLightingFalloffFunctions: {
  54193. name: string;
  54194. shader: string;
  54195. };
  54196. }
  54197. declare module BABYLON {
  54198. /** @hidden */
  54199. export var pbrBRDFFunctions: {
  54200. name: string;
  54201. shader: string;
  54202. };
  54203. }
  54204. declare module BABYLON {
  54205. /** @hidden */
  54206. export var hdrFilteringFunctions: {
  54207. name: string;
  54208. shader: string;
  54209. };
  54210. }
  54211. declare module BABYLON {
  54212. /** @hidden */
  54213. export var pbrDirectLightingFunctions: {
  54214. name: string;
  54215. shader: string;
  54216. };
  54217. }
  54218. declare module BABYLON {
  54219. /** @hidden */
  54220. export var pbrIBLFunctions: {
  54221. name: string;
  54222. shader: string;
  54223. };
  54224. }
  54225. declare module BABYLON {
  54226. /** @hidden */
  54227. export var pbrBlockAlbedoOpacity: {
  54228. name: string;
  54229. shader: string;
  54230. };
  54231. }
  54232. declare module BABYLON {
  54233. /** @hidden */
  54234. export var pbrBlockReflectivity: {
  54235. name: string;
  54236. shader: string;
  54237. };
  54238. }
  54239. declare module BABYLON {
  54240. /** @hidden */
  54241. export var pbrBlockAmbientOcclusion: {
  54242. name: string;
  54243. shader: string;
  54244. };
  54245. }
  54246. declare module BABYLON {
  54247. /** @hidden */
  54248. export var pbrBlockAlphaFresnel: {
  54249. name: string;
  54250. shader: string;
  54251. };
  54252. }
  54253. declare module BABYLON {
  54254. /** @hidden */
  54255. export var pbrBlockAnisotropic: {
  54256. name: string;
  54257. shader: string;
  54258. };
  54259. }
  54260. declare module BABYLON {
  54261. /** @hidden */
  54262. export var pbrBlockReflection: {
  54263. name: string;
  54264. shader: string;
  54265. };
  54266. }
  54267. declare module BABYLON {
  54268. /** @hidden */
  54269. export var pbrBlockSheen: {
  54270. name: string;
  54271. shader: string;
  54272. };
  54273. }
  54274. declare module BABYLON {
  54275. /** @hidden */
  54276. export var pbrBlockClearcoat: {
  54277. name: string;
  54278. shader: string;
  54279. };
  54280. }
  54281. declare module BABYLON {
  54282. /** @hidden */
  54283. export var pbrBlockSubSurface: {
  54284. name: string;
  54285. shader: string;
  54286. };
  54287. }
  54288. declare module BABYLON {
  54289. /** @hidden */
  54290. export var pbrBlockNormalGeometric: {
  54291. name: string;
  54292. shader: string;
  54293. };
  54294. }
  54295. declare module BABYLON {
  54296. /** @hidden */
  54297. export var pbrBlockNormalFinal: {
  54298. name: string;
  54299. shader: string;
  54300. };
  54301. }
  54302. declare module BABYLON {
  54303. /** @hidden */
  54304. export var pbrBlockGeometryInfo: {
  54305. name: string;
  54306. shader: string;
  54307. };
  54308. }
  54309. declare module BABYLON {
  54310. /** @hidden */
  54311. export var pbrBlockReflectance0: {
  54312. name: string;
  54313. shader: string;
  54314. };
  54315. }
  54316. declare module BABYLON {
  54317. /** @hidden */
  54318. export var pbrBlockReflectance: {
  54319. name: string;
  54320. shader: string;
  54321. };
  54322. }
  54323. declare module BABYLON {
  54324. /** @hidden */
  54325. export var pbrBlockDirectLighting: {
  54326. name: string;
  54327. shader: string;
  54328. };
  54329. }
  54330. declare module BABYLON {
  54331. /** @hidden */
  54332. export var pbrBlockFinalLitComponents: {
  54333. name: string;
  54334. shader: string;
  54335. };
  54336. }
  54337. declare module BABYLON {
  54338. /** @hidden */
  54339. export var pbrBlockFinalUnlitComponents: {
  54340. name: string;
  54341. shader: string;
  54342. };
  54343. }
  54344. declare module BABYLON {
  54345. /** @hidden */
  54346. export var pbrBlockFinalColorComposition: {
  54347. name: string;
  54348. shader: string;
  54349. };
  54350. }
  54351. declare module BABYLON {
  54352. /** @hidden */
  54353. export var pbrBlockImageProcessing: {
  54354. name: string;
  54355. shader: string;
  54356. };
  54357. }
  54358. declare module BABYLON {
  54359. /** @hidden */
  54360. export var pbrDebug: {
  54361. name: string;
  54362. shader: string;
  54363. };
  54364. }
  54365. declare module BABYLON {
  54366. /** @hidden */
  54367. export var pbrPixelShader: {
  54368. name: string;
  54369. shader: string;
  54370. };
  54371. }
  54372. declare module BABYLON {
  54373. /** @hidden */
  54374. export var pbrVertexDeclaration: {
  54375. name: string;
  54376. shader: string;
  54377. };
  54378. }
  54379. declare module BABYLON {
  54380. /** @hidden */
  54381. export var pbrVertexShader: {
  54382. name: string;
  54383. shader: string;
  54384. };
  54385. }
  54386. declare module BABYLON {
  54387. /**
  54388. * Manages the defines for the PBR Material.
  54389. * @hidden
  54390. */
  54391. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  54392. PBR: boolean;
  54393. NUM_SAMPLES: string;
  54394. REALTIME_FILTERING: boolean;
  54395. MAINUV1: boolean;
  54396. MAINUV2: boolean;
  54397. UV1: boolean;
  54398. UV2: boolean;
  54399. ALBEDO: boolean;
  54400. GAMMAALBEDO: boolean;
  54401. ALBEDODIRECTUV: number;
  54402. VERTEXCOLOR: boolean;
  54403. AMBIENT: boolean;
  54404. AMBIENTDIRECTUV: number;
  54405. AMBIENTINGRAYSCALE: boolean;
  54406. OPACITY: boolean;
  54407. VERTEXALPHA: boolean;
  54408. OPACITYDIRECTUV: number;
  54409. OPACITYRGB: boolean;
  54410. ALPHATEST: boolean;
  54411. DEPTHPREPASS: boolean;
  54412. ALPHABLEND: boolean;
  54413. ALPHAFROMALBEDO: boolean;
  54414. ALPHATESTVALUE: string;
  54415. SPECULAROVERALPHA: boolean;
  54416. RADIANCEOVERALPHA: boolean;
  54417. ALPHAFRESNEL: boolean;
  54418. LINEARALPHAFRESNEL: boolean;
  54419. PREMULTIPLYALPHA: boolean;
  54420. EMISSIVE: boolean;
  54421. EMISSIVEDIRECTUV: number;
  54422. REFLECTIVITY: boolean;
  54423. REFLECTIVITYDIRECTUV: number;
  54424. SPECULARTERM: boolean;
  54425. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  54426. MICROSURFACEAUTOMATIC: boolean;
  54427. LODBASEDMICROSFURACE: boolean;
  54428. MICROSURFACEMAP: boolean;
  54429. MICROSURFACEMAPDIRECTUV: number;
  54430. METALLICWORKFLOW: boolean;
  54431. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  54432. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  54433. METALLNESSSTOREINMETALMAPBLUE: boolean;
  54434. AOSTOREINMETALMAPRED: boolean;
  54435. METALLIC_REFLECTANCE: boolean;
  54436. METALLIC_REFLECTANCEDIRECTUV: number;
  54437. ENVIRONMENTBRDF: boolean;
  54438. ENVIRONMENTBRDF_RGBD: boolean;
  54439. NORMAL: boolean;
  54440. TANGENT: boolean;
  54441. BUMP: boolean;
  54442. BUMPDIRECTUV: number;
  54443. OBJECTSPACE_NORMALMAP: boolean;
  54444. PARALLAX: boolean;
  54445. PARALLAXOCCLUSION: boolean;
  54446. NORMALXYSCALE: boolean;
  54447. LIGHTMAP: boolean;
  54448. LIGHTMAPDIRECTUV: number;
  54449. USELIGHTMAPASSHADOWMAP: boolean;
  54450. GAMMALIGHTMAP: boolean;
  54451. RGBDLIGHTMAP: boolean;
  54452. REFLECTION: boolean;
  54453. REFLECTIONMAP_3D: boolean;
  54454. REFLECTIONMAP_SPHERICAL: boolean;
  54455. REFLECTIONMAP_PLANAR: boolean;
  54456. REFLECTIONMAP_CUBIC: boolean;
  54457. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  54458. REFLECTIONMAP_PROJECTION: boolean;
  54459. REFLECTIONMAP_SKYBOX: boolean;
  54460. REFLECTIONMAP_EXPLICIT: boolean;
  54461. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  54462. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  54463. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  54464. INVERTCUBICMAP: boolean;
  54465. USESPHERICALFROMREFLECTIONMAP: boolean;
  54466. USEIRRADIANCEMAP: boolean;
  54467. SPHERICAL_HARMONICS: boolean;
  54468. USESPHERICALINVERTEX: boolean;
  54469. REFLECTIONMAP_OPPOSITEZ: boolean;
  54470. LODINREFLECTIONALPHA: boolean;
  54471. GAMMAREFLECTION: boolean;
  54472. RGBDREFLECTION: boolean;
  54473. LINEARSPECULARREFLECTION: boolean;
  54474. RADIANCEOCCLUSION: boolean;
  54475. HORIZONOCCLUSION: boolean;
  54476. INSTANCES: boolean;
  54477. NUM_BONE_INFLUENCERS: number;
  54478. BonesPerMesh: number;
  54479. BONETEXTURE: boolean;
  54480. NONUNIFORMSCALING: boolean;
  54481. MORPHTARGETS: boolean;
  54482. MORPHTARGETS_NORMAL: boolean;
  54483. MORPHTARGETS_TANGENT: boolean;
  54484. MORPHTARGETS_UV: boolean;
  54485. NUM_MORPH_INFLUENCERS: number;
  54486. IMAGEPROCESSING: boolean;
  54487. VIGNETTE: boolean;
  54488. VIGNETTEBLENDMODEMULTIPLY: boolean;
  54489. VIGNETTEBLENDMODEOPAQUE: boolean;
  54490. TONEMAPPING: boolean;
  54491. TONEMAPPING_ACES: boolean;
  54492. CONTRAST: boolean;
  54493. COLORCURVES: boolean;
  54494. COLORGRADING: boolean;
  54495. COLORGRADING3D: boolean;
  54496. SAMPLER3DGREENDEPTH: boolean;
  54497. SAMPLER3DBGRMAP: boolean;
  54498. IMAGEPROCESSINGPOSTPROCESS: boolean;
  54499. EXPOSURE: boolean;
  54500. MULTIVIEW: boolean;
  54501. USEPHYSICALLIGHTFALLOFF: boolean;
  54502. USEGLTFLIGHTFALLOFF: boolean;
  54503. TWOSIDEDLIGHTING: boolean;
  54504. SHADOWFLOAT: boolean;
  54505. CLIPPLANE: boolean;
  54506. CLIPPLANE2: boolean;
  54507. CLIPPLANE3: boolean;
  54508. CLIPPLANE4: boolean;
  54509. CLIPPLANE5: boolean;
  54510. CLIPPLANE6: boolean;
  54511. POINTSIZE: boolean;
  54512. FOG: boolean;
  54513. LOGARITHMICDEPTH: boolean;
  54514. FORCENORMALFORWARD: boolean;
  54515. SPECULARAA: boolean;
  54516. CLEARCOAT: boolean;
  54517. CLEARCOAT_DEFAULTIOR: boolean;
  54518. CLEARCOAT_TEXTURE: boolean;
  54519. CLEARCOAT_TEXTUREDIRECTUV: number;
  54520. CLEARCOAT_BUMP: boolean;
  54521. CLEARCOAT_BUMPDIRECTUV: number;
  54522. CLEARCOAT_TINT: boolean;
  54523. CLEARCOAT_TINT_TEXTURE: boolean;
  54524. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  54525. ANISOTROPIC: boolean;
  54526. ANISOTROPIC_TEXTURE: boolean;
  54527. ANISOTROPIC_TEXTUREDIRECTUV: number;
  54528. BRDF_V_HEIGHT_CORRELATED: boolean;
  54529. MS_BRDF_ENERGY_CONSERVATION: boolean;
  54530. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  54531. SHEEN: boolean;
  54532. SHEEN_TEXTURE: boolean;
  54533. SHEEN_TEXTUREDIRECTUV: number;
  54534. SHEEN_LINKWITHALBEDO: boolean;
  54535. SHEEN_ROUGHNESS: boolean;
  54536. SHEEN_ALBEDOSCALING: boolean;
  54537. SUBSURFACE: boolean;
  54538. SS_REFRACTION: boolean;
  54539. SS_TRANSLUCENCY: boolean;
  54540. SS_SCATERRING: boolean;
  54541. SS_THICKNESSANDMASK_TEXTURE: boolean;
  54542. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  54543. SS_REFRACTIONMAP_3D: boolean;
  54544. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  54545. SS_LODINREFRACTIONALPHA: boolean;
  54546. SS_GAMMAREFRACTION: boolean;
  54547. SS_RGBDREFRACTION: boolean;
  54548. SS_LINEARSPECULARREFRACTION: boolean;
  54549. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  54550. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  54551. UNLIT: boolean;
  54552. DEBUGMODE: number;
  54553. /**
  54554. * Initializes the PBR Material defines.
  54555. */
  54556. constructor();
  54557. /**
  54558. * Resets the PBR Material defines.
  54559. */
  54560. reset(): void;
  54561. }
  54562. /**
  54563. * The Physically based material base class of BJS.
  54564. *
  54565. * This offers the main features of a standard PBR material.
  54566. * For more information, please refer to the documentation :
  54567. * https://doc.babylonjs.com/how_to/physically_based_rendering
  54568. */
  54569. export abstract class PBRBaseMaterial extends PushMaterial {
  54570. /**
  54571. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  54572. */
  54573. static readonly PBRMATERIAL_OPAQUE: number;
  54574. /**
  54575. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  54576. */
  54577. static readonly PBRMATERIAL_ALPHATEST: number;
  54578. /**
  54579. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54580. */
  54581. static readonly PBRMATERIAL_ALPHABLEND: number;
  54582. /**
  54583. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54584. * They are also discarded below the alpha cutoff threshold to improve performances.
  54585. */
  54586. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  54587. /**
  54588. * Defines the default value of how much AO map is occluding the analytical lights
  54589. * (point spot...).
  54590. */
  54591. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  54592. /**
  54593. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  54594. */
  54595. static readonly LIGHTFALLOFF_PHYSICAL: number;
  54596. /**
  54597. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  54598. * to enhance interoperability with other engines.
  54599. */
  54600. static readonly LIGHTFALLOFF_GLTF: number;
  54601. /**
  54602. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  54603. * to enhance interoperability with other materials.
  54604. */
  54605. static readonly LIGHTFALLOFF_STANDARD: number;
  54606. /**
  54607. * Intensity of the direct lights e.g. the four lights available in your scene.
  54608. * This impacts both the direct diffuse and specular highlights.
  54609. */
  54610. protected _directIntensity: number;
  54611. /**
  54612. * Intensity of the emissive part of the material.
  54613. * This helps controlling the emissive effect without modifying the emissive color.
  54614. */
  54615. protected _emissiveIntensity: number;
  54616. /**
  54617. * Intensity of the environment e.g. how much the environment will light the object
  54618. * either through harmonics for rough material or through the refelction for shiny ones.
  54619. */
  54620. protected _environmentIntensity: number;
  54621. /**
  54622. * This is a special control allowing the reduction of the specular highlights coming from the
  54623. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  54624. */
  54625. protected _specularIntensity: number;
  54626. /**
  54627. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  54628. */
  54629. private _lightingInfos;
  54630. /**
  54631. * Debug Control allowing disabling the bump map on this material.
  54632. */
  54633. protected _disableBumpMap: boolean;
  54634. /**
  54635. * AKA Diffuse Texture in standard nomenclature.
  54636. */
  54637. protected _albedoTexture: Nullable<BaseTexture>;
  54638. /**
  54639. * AKA Occlusion Texture in other nomenclature.
  54640. */
  54641. protected _ambientTexture: Nullable<BaseTexture>;
  54642. /**
  54643. * AKA Occlusion Texture Intensity in other nomenclature.
  54644. */
  54645. protected _ambientTextureStrength: number;
  54646. /**
  54647. * Defines how much the AO map is occluding the analytical lights (point spot...).
  54648. * 1 means it completely occludes it
  54649. * 0 mean it has no impact
  54650. */
  54651. protected _ambientTextureImpactOnAnalyticalLights: number;
  54652. /**
  54653. * Stores the alpha values in a texture.
  54654. */
  54655. protected _opacityTexture: Nullable<BaseTexture>;
  54656. /**
  54657. * Stores the reflection values in a texture.
  54658. */
  54659. protected _reflectionTexture: Nullable<BaseTexture>;
  54660. /**
  54661. * Stores the emissive values in a texture.
  54662. */
  54663. protected _emissiveTexture: Nullable<BaseTexture>;
  54664. /**
  54665. * AKA Specular texture in other nomenclature.
  54666. */
  54667. protected _reflectivityTexture: Nullable<BaseTexture>;
  54668. /**
  54669. * Used to switch from specular/glossiness to metallic/roughness workflow.
  54670. */
  54671. protected _metallicTexture: Nullable<BaseTexture>;
  54672. /**
  54673. * Specifies the metallic scalar of the metallic/roughness workflow.
  54674. * Can also be used to scale the metalness values of the metallic texture.
  54675. */
  54676. protected _metallic: Nullable<number>;
  54677. /**
  54678. * Specifies the roughness scalar of the metallic/roughness workflow.
  54679. * Can also be used to scale the roughness values of the metallic texture.
  54680. */
  54681. protected _roughness: Nullable<number>;
  54682. /**
  54683. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  54684. * By default the indexOfrefraction is used to compute F0;
  54685. *
  54686. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  54687. *
  54688. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  54689. * F90 = metallicReflectanceColor;
  54690. */
  54691. protected _metallicF0Factor: number;
  54692. /**
  54693. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  54694. * By default the F90 is always 1;
  54695. *
  54696. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  54697. *
  54698. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  54699. * F90 = metallicReflectanceColor;
  54700. */
  54701. protected _metallicReflectanceColor: Color3;
  54702. /**
  54703. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  54704. * This is multiply against the scalar values defined in the material.
  54705. */
  54706. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  54707. /**
  54708. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  54709. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  54710. */
  54711. protected _microSurfaceTexture: Nullable<BaseTexture>;
  54712. /**
  54713. * Stores surface normal data used to displace a mesh in a texture.
  54714. */
  54715. protected _bumpTexture: Nullable<BaseTexture>;
  54716. /**
  54717. * Stores the pre-calculated light information of a mesh in a texture.
  54718. */
  54719. protected _lightmapTexture: Nullable<BaseTexture>;
  54720. /**
  54721. * The color of a material in ambient lighting.
  54722. */
  54723. protected _ambientColor: Color3;
  54724. /**
  54725. * AKA Diffuse Color in other nomenclature.
  54726. */
  54727. protected _albedoColor: Color3;
  54728. /**
  54729. * AKA Specular Color in other nomenclature.
  54730. */
  54731. protected _reflectivityColor: Color3;
  54732. /**
  54733. * The color applied when light is reflected from a material.
  54734. */
  54735. protected _reflectionColor: Color3;
  54736. /**
  54737. * The color applied when light is emitted from a material.
  54738. */
  54739. protected _emissiveColor: Color3;
  54740. /**
  54741. * AKA Glossiness in other nomenclature.
  54742. */
  54743. protected _microSurface: number;
  54744. /**
  54745. * Specifies that the material will use the light map as a show map.
  54746. */
  54747. protected _useLightmapAsShadowmap: boolean;
  54748. /**
  54749. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  54750. * makes the reflect vector face the model (under horizon).
  54751. */
  54752. protected _useHorizonOcclusion: boolean;
  54753. /**
  54754. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  54755. * too much the area relying on ambient texture to define their ambient occlusion.
  54756. */
  54757. protected _useRadianceOcclusion: boolean;
  54758. /**
  54759. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  54760. */
  54761. protected _useAlphaFromAlbedoTexture: boolean;
  54762. /**
  54763. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  54764. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  54765. */
  54766. protected _useSpecularOverAlpha: boolean;
  54767. /**
  54768. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  54769. */
  54770. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  54771. /**
  54772. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  54773. */
  54774. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  54775. /**
  54776. * Specifies if the metallic texture contains the roughness information in its green channel.
  54777. */
  54778. protected _useRoughnessFromMetallicTextureGreen: boolean;
  54779. /**
  54780. * Specifies if the metallic texture contains the metallness information in its blue channel.
  54781. */
  54782. protected _useMetallnessFromMetallicTextureBlue: boolean;
  54783. /**
  54784. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  54785. */
  54786. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  54787. /**
  54788. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  54789. */
  54790. protected _useAmbientInGrayScale: boolean;
  54791. /**
  54792. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  54793. * The material will try to infer what glossiness each pixel should be.
  54794. */
  54795. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  54796. /**
  54797. * Defines the falloff type used in this material.
  54798. * It by default is Physical.
  54799. */
  54800. protected _lightFalloff: number;
  54801. /**
  54802. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  54803. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  54804. */
  54805. protected _useRadianceOverAlpha: boolean;
  54806. /**
  54807. * Allows using an object space normal map (instead of tangent space).
  54808. */
  54809. protected _useObjectSpaceNormalMap: boolean;
  54810. /**
  54811. * Allows using the bump map in parallax mode.
  54812. */
  54813. protected _useParallax: boolean;
  54814. /**
  54815. * Allows using the bump map in parallax occlusion mode.
  54816. */
  54817. protected _useParallaxOcclusion: boolean;
  54818. /**
  54819. * Controls the scale bias of the parallax mode.
  54820. */
  54821. protected _parallaxScaleBias: number;
  54822. /**
  54823. * If sets to true, disables all the lights affecting the material.
  54824. */
  54825. protected _disableLighting: boolean;
  54826. /**
  54827. * Number of Simultaneous lights allowed on the material.
  54828. */
  54829. protected _maxSimultaneousLights: number;
  54830. /**
  54831. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  54832. */
  54833. protected _invertNormalMapX: boolean;
  54834. /**
  54835. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  54836. */
  54837. protected _invertNormalMapY: boolean;
  54838. /**
  54839. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54840. */
  54841. protected _twoSidedLighting: boolean;
  54842. /**
  54843. * Defines the alpha limits in alpha test mode.
  54844. */
  54845. protected _alphaCutOff: number;
  54846. /**
  54847. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  54848. */
  54849. protected _forceAlphaTest: boolean;
  54850. /**
  54851. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54852. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  54853. */
  54854. protected _useAlphaFresnel: boolean;
  54855. /**
  54856. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54857. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  54858. */
  54859. protected _useLinearAlphaFresnel: boolean;
  54860. /**
  54861. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  54862. * from cos thetav and roughness:
  54863. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  54864. */
  54865. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  54866. /**
  54867. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  54868. */
  54869. protected _forceIrradianceInFragment: boolean;
  54870. /**
  54871. * Force normal to face away from face.
  54872. */
  54873. protected _forceNormalForward: boolean;
  54874. /**
  54875. * Enables specular anti aliasing in the PBR shader.
  54876. * It will both interacts on the Geometry for analytical and IBL lighting.
  54877. * It also prefilter the roughness map based on the bump values.
  54878. */
  54879. protected _enableSpecularAntiAliasing: boolean;
  54880. /**
  54881. * Default configuration related to image processing available in the PBR Material.
  54882. */
  54883. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  54884. /**
  54885. * Keep track of the image processing observer to allow dispose and replace.
  54886. */
  54887. private _imageProcessingObserver;
  54888. /**
  54889. * Attaches a new image processing configuration to the PBR Material.
  54890. * @param configuration
  54891. */
  54892. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  54893. /**
  54894. * Stores the available render targets.
  54895. */
  54896. private _renderTargets;
  54897. /**
  54898. * Sets the global ambient color for the material used in lighting calculations.
  54899. */
  54900. private _globalAmbientColor;
  54901. /**
  54902. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  54903. */
  54904. private _useLogarithmicDepth;
  54905. /**
  54906. * If set to true, no lighting calculations will be applied.
  54907. */
  54908. private _unlit;
  54909. private _debugMode;
  54910. /**
  54911. * @hidden
  54912. * This is reserved for the inspector.
  54913. * Defines the material debug mode.
  54914. * It helps seeing only some components of the material while troubleshooting.
  54915. */
  54916. debugMode: number;
  54917. /**
  54918. * @hidden
  54919. * This is reserved for the inspector.
  54920. * Specify from where on screen the debug mode should start.
  54921. * The value goes from -1 (full screen) to 1 (not visible)
  54922. * It helps with side by side comparison against the final render
  54923. * This defaults to -1
  54924. */
  54925. private debugLimit;
  54926. /**
  54927. * @hidden
  54928. * This is reserved for the inspector.
  54929. * As the default viewing range might not be enough (if the ambient is really small for instance)
  54930. * You can use the factor to better multiply the final value.
  54931. */
  54932. private debugFactor;
  54933. /**
  54934. * Defines the clear coat layer parameters for the material.
  54935. */
  54936. readonly clearCoat: PBRClearCoatConfiguration;
  54937. /**
  54938. * Defines the anisotropic parameters for the material.
  54939. */
  54940. readonly anisotropy: PBRAnisotropicConfiguration;
  54941. /**
  54942. * Defines the BRDF parameters for the material.
  54943. */
  54944. readonly brdf: PBRBRDFConfiguration;
  54945. /**
  54946. * Defines the Sheen parameters for the material.
  54947. */
  54948. readonly sheen: PBRSheenConfiguration;
  54949. /**
  54950. * Defines the SubSurface parameters for the material.
  54951. */
  54952. readonly subSurface: PBRSubSurfaceConfiguration;
  54953. protected _rebuildInParallel: boolean;
  54954. /**
  54955. * Instantiates a new PBRMaterial instance.
  54956. *
  54957. * @param name The material name
  54958. * @param scene The scene the material will be use in.
  54959. */
  54960. constructor(name: string, scene: Scene);
  54961. /**
  54962. * Gets a boolean indicating that current material needs to register RTT
  54963. */
  54964. get hasRenderTargetTextures(): boolean;
  54965. /**
  54966. * Gets the name of the material class.
  54967. */
  54968. getClassName(): string;
  54969. /**
  54970. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  54971. */
  54972. get useLogarithmicDepth(): boolean;
  54973. /**
  54974. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  54975. */
  54976. set useLogarithmicDepth(value: boolean);
  54977. /**
  54978. * Returns true if alpha blending should be disabled.
  54979. */
  54980. protected get _disableAlphaBlending(): boolean;
  54981. /**
  54982. * Specifies whether or not this material should be rendered in alpha blend mode.
  54983. */
  54984. needAlphaBlending(): boolean;
  54985. /**
  54986. * Specifies whether or not this material should be rendered in alpha test mode.
  54987. */
  54988. needAlphaTesting(): boolean;
  54989. /**
  54990. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  54991. */
  54992. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  54993. /**
  54994. * Gets the texture used for the alpha test.
  54995. */
  54996. getAlphaTestTexture(): Nullable<BaseTexture>;
  54997. /**
  54998. * Specifies that the submesh is ready to be used.
  54999. * @param mesh - BJS mesh.
  55000. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  55001. * @param useInstances - Specifies that instances should be used.
  55002. * @returns - boolean indicating that the submesh is ready or not.
  55003. */
  55004. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  55005. /**
  55006. * Specifies if the material uses metallic roughness workflow.
  55007. * @returns boolean specifiying if the material uses metallic roughness workflow.
  55008. */
  55009. isMetallicWorkflow(): boolean;
  55010. private _prepareEffect;
  55011. private _prepareDefines;
  55012. /**
  55013. * Force shader compilation
  55014. */
  55015. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  55016. /**
  55017. * Initializes the uniform buffer layout for the shader.
  55018. */
  55019. buildUniformLayout(): void;
  55020. /**
  55021. * Unbinds the material from the mesh
  55022. */
  55023. unbind(): void;
  55024. /**
  55025. * Binds the submesh data.
  55026. * @param world - The world matrix.
  55027. * @param mesh - The BJS mesh.
  55028. * @param subMesh - A submesh of the BJS mesh.
  55029. */
  55030. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  55031. /**
  55032. * Returns the animatable textures.
  55033. * @returns - Array of animatable textures.
  55034. */
  55035. getAnimatables(): IAnimatable[];
  55036. /**
  55037. * Returns the texture used for reflections.
  55038. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  55039. */
  55040. private _getReflectionTexture;
  55041. /**
  55042. * Returns an array of the actively used textures.
  55043. * @returns - Array of BaseTextures
  55044. */
  55045. getActiveTextures(): BaseTexture[];
  55046. /**
  55047. * Checks to see if a texture is used in the material.
  55048. * @param texture - Base texture to use.
  55049. * @returns - Boolean specifying if a texture is used in the material.
  55050. */
  55051. hasTexture(texture: BaseTexture): boolean;
  55052. /**
  55053. * Disposes the resources of the material.
  55054. * @param forceDisposeEffect - Forces the disposal of effects.
  55055. * @param forceDisposeTextures - Forces the disposal of all textures.
  55056. */
  55057. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  55058. }
  55059. }
  55060. declare module BABYLON {
  55061. /**
  55062. * The Physically based material of BJS.
  55063. *
  55064. * This offers the main features of a standard PBR material.
  55065. * For more information, please refer to the documentation :
  55066. * https://doc.babylonjs.com/how_to/physically_based_rendering
  55067. */
  55068. export class PBRMaterial extends PBRBaseMaterial {
  55069. /**
  55070. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  55071. */
  55072. static readonly PBRMATERIAL_OPAQUE: number;
  55073. /**
  55074. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  55075. */
  55076. static readonly PBRMATERIAL_ALPHATEST: number;
  55077. /**
  55078. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55079. */
  55080. static readonly PBRMATERIAL_ALPHABLEND: number;
  55081. /**
  55082. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55083. * They are also discarded below the alpha cutoff threshold to improve performances.
  55084. */
  55085. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  55086. /**
  55087. * Defines the default value of how much AO map is occluding the analytical lights
  55088. * (point spot...).
  55089. */
  55090. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  55091. /**
  55092. * Intensity of the direct lights e.g. the four lights available in your scene.
  55093. * This impacts both the direct diffuse and specular highlights.
  55094. */
  55095. directIntensity: number;
  55096. /**
  55097. * Intensity of the emissive part of the material.
  55098. * This helps controlling the emissive effect without modifying the emissive color.
  55099. */
  55100. emissiveIntensity: number;
  55101. /**
  55102. * Intensity of the environment e.g. how much the environment will light the object
  55103. * either through harmonics for rough material or through the refelction for shiny ones.
  55104. */
  55105. environmentIntensity: number;
  55106. /**
  55107. * This is a special control allowing the reduction of the specular highlights coming from the
  55108. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  55109. */
  55110. specularIntensity: number;
  55111. /**
  55112. * Debug Control allowing disabling the bump map on this material.
  55113. */
  55114. disableBumpMap: boolean;
  55115. /**
  55116. * AKA Diffuse Texture in standard nomenclature.
  55117. */
  55118. albedoTexture: BaseTexture;
  55119. /**
  55120. * AKA Occlusion Texture in other nomenclature.
  55121. */
  55122. ambientTexture: BaseTexture;
  55123. /**
  55124. * AKA Occlusion Texture Intensity in other nomenclature.
  55125. */
  55126. ambientTextureStrength: number;
  55127. /**
  55128. * Defines how much the AO map is occluding the analytical lights (point spot...).
  55129. * 1 means it completely occludes it
  55130. * 0 mean it has no impact
  55131. */
  55132. ambientTextureImpactOnAnalyticalLights: number;
  55133. /**
  55134. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  55135. */
  55136. opacityTexture: BaseTexture;
  55137. /**
  55138. * Stores the reflection values in a texture.
  55139. */
  55140. reflectionTexture: Nullable<BaseTexture>;
  55141. /**
  55142. * Stores the emissive values in a texture.
  55143. */
  55144. emissiveTexture: BaseTexture;
  55145. /**
  55146. * AKA Specular texture in other nomenclature.
  55147. */
  55148. reflectivityTexture: BaseTexture;
  55149. /**
  55150. * Used to switch from specular/glossiness to metallic/roughness workflow.
  55151. */
  55152. metallicTexture: BaseTexture;
  55153. /**
  55154. * Specifies the metallic scalar of the metallic/roughness workflow.
  55155. * Can also be used to scale the metalness values of the metallic texture.
  55156. */
  55157. metallic: Nullable<number>;
  55158. /**
  55159. * Specifies the roughness scalar of the metallic/roughness workflow.
  55160. * Can also be used to scale the roughness values of the metallic texture.
  55161. */
  55162. roughness: Nullable<number>;
  55163. /**
  55164. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  55165. * By default the indexOfrefraction is used to compute F0;
  55166. *
  55167. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  55168. *
  55169. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  55170. * F90 = metallicReflectanceColor;
  55171. */
  55172. metallicF0Factor: number;
  55173. /**
  55174. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  55175. * By default the F90 is always 1;
  55176. *
  55177. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  55178. *
  55179. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  55180. * F90 = metallicReflectanceColor;
  55181. */
  55182. metallicReflectanceColor: Color3;
  55183. /**
  55184. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  55185. * This is multiply against the scalar values defined in the material.
  55186. */
  55187. metallicReflectanceTexture: Nullable<BaseTexture>;
  55188. /**
  55189. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  55190. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  55191. */
  55192. microSurfaceTexture: BaseTexture;
  55193. /**
  55194. * Stores surface normal data used to displace a mesh in a texture.
  55195. */
  55196. bumpTexture: BaseTexture;
  55197. /**
  55198. * Stores the pre-calculated light information of a mesh in a texture.
  55199. */
  55200. lightmapTexture: BaseTexture;
  55201. /**
  55202. * Stores the refracted light information in a texture.
  55203. */
  55204. get refractionTexture(): Nullable<BaseTexture>;
  55205. set refractionTexture(value: Nullable<BaseTexture>);
  55206. /**
  55207. * The color of a material in ambient lighting.
  55208. */
  55209. ambientColor: Color3;
  55210. /**
  55211. * AKA Diffuse Color in other nomenclature.
  55212. */
  55213. albedoColor: Color3;
  55214. /**
  55215. * AKA Specular Color in other nomenclature.
  55216. */
  55217. reflectivityColor: Color3;
  55218. /**
  55219. * The color reflected from the material.
  55220. */
  55221. reflectionColor: Color3;
  55222. /**
  55223. * The color emitted from the material.
  55224. */
  55225. emissiveColor: Color3;
  55226. /**
  55227. * AKA Glossiness in other nomenclature.
  55228. */
  55229. microSurface: number;
  55230. /**
  55231. * Index of refraction of the material base layer.
  55232. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  55233. *
  55234. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  55235. *
  55236. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  55237. */
  55238. get indexOfRefraction(): number;
  55239. set indexOfRefraction(value: number);
  55240. /**
  55241. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  55242. */
  55243. get invertRefractionY(): boolean;
  55244. set invertRefractionY(value: boolean);
  55245. /**
  55246. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  55247. * Materials half opaque for instance using refraction could benefit from this control.
  55248. */
  55249. get linkRefractionWithTransparency(): boolean;
  55250. set linkRefractionWithTransparency(value: boolean);
  55251. /**
  55252. * If true, the light map contains occlusion information instead of lighting info.
  55253. */
  55254. useLightmapAsShadowmap: boolean;
  55255. /**
  55256. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  55257. */
  55258. useAlphaFromAlbedoTexture: boolean;
  55259. /**
  55260. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  55261. */
  55262. forceAlphaTest: boolean;
  55263. /**
  55264. * Defines the alpha limits in alpha test mode.
  55265. */
  55266. alphaCutOff: number;
  55267. /**
  55268. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  55269. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  55270. */
  55271. useSpecularOverAlpha: boolean;
  55272. /**
  55273. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  55274. */
  55275. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  55276. /**
  55277. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  55278. */
  55279. useRoughnessFromMetallicTextureAlpha: boolean;
  55280. /**
  55281. * Specifies if the metallic texture contains the roughness information in its green channel.
  55282. */
  55283. useRoughnessFromMetallicTextureGreen: boolean;
  55284. /**
  55285. * Specifies if the metallic texture contains the metallness information in its blue channel.
  55286. */
  55287. useMetallnessFromMetallicTextureBlue: boolean;
  55288. /**
  55289. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  55290. */
  55291. useAmbientOcclusionFromMetallicTextureRed: boolean;
  55292. /**
  55293. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  55294. */
  55295. useAmbientInGrayScale: boolean;
  55296. /**
  55297. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  55298. * The material will try to infer what glossiness each pixel should be.
  55299. */
  55300. useAutoMicroSurfaceFromReflectivityMap: boolean;
  55301. /**
  55302. * BJS is using an harcoded light falloff based on a manually sets up range.
  55303. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  55304. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  55305. */
  55306. get usePhysicalLightFalloff(): boolean;
  55307. /**
  55308. * BJS is using an harcoded light falloff based on a manually sets up range.
  55309. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  55310. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  55311. */
  55312. set usePhysicalLightFalloff(value: boolean);
  55313. /**
  55314. * In order to support the falloff compatibility with gltf, a special mode has been added
  55315. * to reproduce the gltf light falloff.
  55316. */
  55317. get useGLTFLightFalloff(): boolean;
  55318. /**
  55319. * In order to support the falloff compatibility with gltf, a special mode has been added
  55320. * to reproduce the gltf light falloff.
  55321. */
  55322. set useGLTFLightFalloff(value: boolean);
  55323. /**
  55324. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  55325. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  55326. */
  55327. useRadianceOverAlpha: boolean;
  55328. /**
  55329. * Allows using an object space normal map (instead of tangent space).
  55330. */
  55331. useObjectSpaceNormalMap: boolean;
  55332. /**
  55333. * Allows using the bump map in parallax mode.
  55334. */
  55335. useParallax: boolean;
  55336. /**
  55337. * Allows using the bump map in parallax occlusion mode.
  55338. */
  55339. useParallaxOcclusion: boolean;
  55340. /**
  55341. * Controls the scale bias of the parallax mode.
  55342. */
  55343. parallaxScaleBias: number;
  55344. /**
  55345. * If sets to true, disables all the lights affecting the material.
  55346. */
  55347. disableLighting: boolean;
  55348. /**
  55349. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  55350. */
  55351. forceIrradianceInFragment: boolean;
  55352. /**
  55353. * Number of Simultaneous lights allowed on the material.
  55354. */
  55355. maxSimultaneousLights: number;
  55356. /**
  55357. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  55358. */
  55359. invertNormalMapX: boolean;
  55360. /**
  55361. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  55362. */
  55363. invertNormalMapY: boolean;
  55364. /**
  55365. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  55366. */
  55367. twoSidedLighting: boolean;
  55368. /**
  55369. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  55370. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  55371. */
  55372. useAlphaFresnel: boolean;
  55373. /**
  55374. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  55375. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  55376. */
  55377. useLinearAlphaFresnel: boolean;
  55378. /**
  55379. * Let user defines the brdf lookup texture used for IBL.
  55380. * A default 8bit version is embedded but you could point at :
  55381. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  55382. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  55383. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  55384. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  55385. */
  55386. environmentBRDFTexture: Nullable<BaseTexture>;
  55387. /**
  55388. * Force normal to face away from face.
  55389. */
  55390. forceNormalForward: boolean;
  55391. /**
  55392. * Enables specular anti aliasing in the PBR shader.
  55393. * It will both interacts on the Geometry for analytical and IBL lighting.
  55394. * It also prefilter the roughness map based on the bump values.
  55395. */
  55396. enableSpecularAntiAliasing: boolean;
  55397. /**
  55398. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  55399. * makes the reflect vector face the model (under horizon).
  55400. */
  55401. useHorizonOcclusion: boolean;
  55402. /**
  55403. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  55404. * too much the area relying on ambient texture to define their ambient occlusion.
  55405. */
  55406. useRadianceOcclusion: boolean;
  55407. /**
  55408. * If set to true, no lighting calculations will be applied.
  55409. */
  55410. unlit: boolean;
  55411. /**
  55412. * Gets the image processing configuration used either in this material.
  55413. */
  55414. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  55415. /**
  55416. * Sets the Default image processing configuration used either in the this material.
  55417. *
  55418. * If sets to null, the scene one is in use.
  55419. */
  55420. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  55421. /**
  55422. * Gets wether the color curves effect is enabled.
  55423. */
  55424. get cameraColorCurvesEnabled(): boolean;
  55425. /**
  55426. * Sets wether the color curves effect is enabled.
  55427. */
  55428. set cameraColorCurvesEnabled(value: boolean);
  55429. /**
  55430. * Gets wether the color grading effect is enabled.
  55431. */
  55432. get cameraColorGradingEnabled(): boolean;
  55433. /**
  55434. * Gets wether the color grading effect is enabled.
  55435. */
  55436. set cameraColorGradingEnabled(value: boolean);
  55437. /**
  55438. * Gets wether tonemapping is enabled or not.
  55439. */
  55440. get cameraToneMappingEnabled(): boolean;
  55441. /**
  55442. * Sets wether tonemapping is enabled or not
  55443. */
  55444. set cameraToneMappingEnabled(value: boolean);
  55445. /**
  55446. * The camera exposure used on this material.
  55447. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  55448. * This corresponds to a photographic exposure.
  55449. */
  55450. get cameraExposure(): number;
  55451. /**
  55452. * The camera exposure used on this material.
  55453. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  55454. * This corresponds to a photographic exposure.
  55455. */
  55456. set cameraExposure(value: number);
  55457. /**
  55458. * Gets The camera contrast used on this material.
  55459. */
  55460. get cameraContrast(): number;
  55461. /**
  55462. * Sets The camera contrast used on this material.
  55463. */
  55464. set cameraContrast(value: number);
  55465. /**
  55466. * Gets the Color Grading 2D Lookup Texture.
  55467. */
  55468. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  55469. /**
  55470. * Sets the Color Grading 2D Lookup Texture.
  55471. */
  55472. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  55473. /**
  55474. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  55475. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  55476. * 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;
  55477. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  55478. */
  55479. get cameraColorCurves(): Nullable<ColorCurves>;
  55480. /**
  55481. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  55482. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  55483. * 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;
  55484. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  55485. */
  55486. set cameraColorCurves(value: Nullable<ColorCurves>);
  55487. /**
  55488. * Instantiates a new PBRMaterial instance.
  55489. *
  55490. * @param name The material name
  55491. * @param scene The scene the material will be use in.
  55492. */
  55493. constructor(name: string, scene: Scene);
  55494. /**
  55495. * Returns the name of this material class.
  55496. */
  55497. getClassName(): string;
  55498. /**
  55499. * Makes a duplicate of the current material.
  55500. * @param name - name to use for the new material.
  55501. */
  55502. clone(name: string): PBRMaterial;
  55503. /**
  55504. * Serializes this PBR Material.
  55505. * @returns - An object with the serialized material.
  55506. */
  55507. serialize(): any;
  55508. /**
  55509. * Parses a PBR Material from a serialized object.
  55510. * @param source - Serialized object.
  55511. * @param scene - BJS scene instance.
  55512. * @param rootUrl - url for the scene object
  55513. * @returns - PBRMaterial
  55514. */
  55515. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  55516. }
  55517. }
  55518. declare module BABYLON {
  55519. /**
  55520. * Direct draw surface info
  55521. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  55522. */
  55523. export interface DDSInfo {
  55524. /**
  55525. * Width of the texture
  55526. */
  55527. width: number;
  55528. /**
  55529. * Width of the texture
  55530. */
  55531. height: number;
  55532. /**
  55533. * Number of Mipmaps for the texture
  55534. * @see https://en.wikipedia.org/wiki/Mipmap
  55535. */
  55536. mipmapCount: number;
  55537. /**
  55538. * If the textures format is a known fourCC format
  55539. * @see https://www.fourcc.org/
  55540. */
  55541. isFourCC: boolean;
  55542. /**
  55543. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  55544. */
  55545. isRGB: boolean;
  55546. /**
  55547. * If the texture is a lumincance format
  55548. */
  55549. isLuminance: boolean;
  55550. /**
  55551. * If this is a cube texture
  55552. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  55553. */
  55554. isCube: boolean;
  55555. /**
  55556. * If the texture is a compressed format eg. FOURCC_DXT1
  55557. */
  55558. isCompressed: boolean;
  55559. /**
  55560. * The dxgiFormat of the texture
  55561. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  55562. */
  55563. dxgiFormat: number;
  55564. /**
  55565. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  55566. */
  55567. textureType: number;
  55568. /**
  55569. * Sphericle polynomial created for the dds texture
  55570. */
  55571. sphericalPolynomial?: SphericalPolynomial;
  55572. }
  55573. /**
  55574. * Class used to provide DDS decompression tools
  55575. */
  55576. export class DDSTools {
  55577. /**
  55578. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  55579. */
  55580. static StoreLODInAlphaChannel: boolean;
  55581. /**
  55582. * Gets DDS information from an array buffer
  55583. * @param data defines the array buffer view to read data from
  55584. * @returns the DDS information
  55585. */
  55586. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  55587. private static _FloatView;
  55588. private static _Int32View;
  55589. private static _ToHalfFloat;
  55590. private static _FromHalfFloat;
  55591. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  55592. private static _GetHalfFloatRGBAArrayBuffer;
  55593. private static _GetFloatRGBAArrayBuffer;
  55594. private static _GetFloatAsUIntRGBAArrayBuffer;
  55595. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  55596. private static _GetRGBAArrayBuffer;
  55597. private static _ExtractLongWordOrder;
  55598. private static _GetRGBArrayBuffer;
  55599. private static _GetLuminanceArrayBuffer;
  55600. /**
  55601. * Uploads DDS Levels to a Babylon Texture
  55602. * @hidden
  55603. */
  55604. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  55605. }
  55606. interface ThinEngine {
  55607. /**
  55608. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  55609. * @param rootUrl defines the url where the file to load is located
  55610. * @param scene defines the current scene
  55611. * @param lodScale defines scale to apply to the mip map selection
  55612. * @param lodOffset defines offset to apply to the mip map selection
  55613. * @param onLoad defines an optional callback raised when the texture is loaded
  55614. * @param onError defines an optional callback raised if there is an issue to load the texture
  55615. * @param format defines the format of the data
  55616. * @param forcedExtension defines the extension to use to pick the right loader
  55617. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  55618. * @returns the cube texture as an InternalTexture
  55619. */
  55620. 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;
  55621. }
  55622. }
  55623. declare module BABYLON {
  55624. /**
  55625. * Implementation of the DDS Texture Loader.
  55626. * @hidden
  55627. */
  55628. export class _DDSTextureLoader implements IInternalTextureLoader {
  55629. /**
  55630. * Defines wether the loader supports cascade loading the different faces.
  55631. */
  55632. readonly supportCascades: boolean;
  55633. /**
  55634. * This returns if the loader support the current file information.
  55635. * @param extension defines the file extension of the file being loaded
  55636. * @returns true if the loader can load the specified file
  55637. */
  55638. canLoad(extension: string): boolean;
  55639. /**
  55640. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  55641. * @param data contains the texture data
  55642. * @param texture defines the BabylonJS internal texture
  55643. * @param createPolynomials will be true if polynomials have been requested
  55644. * @param onLoad defines the callback to trigger once the texture is ready
  55645. * @param onError defines the callback to trigger in case of error
  55646. */
  55647. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55648. /**
  55649. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  55650. * @param data contains the texture data
  55651. * @param texture defines the BabylonJS internal texture
  55652. * @param callback defines the method to call once ready to upload
  55653. */
  55654. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55655. }
  55656. }
  55657. declare module BABYLON {
  55658. /**
  55659. * Implementation of the ENV Texture Loader.
  55660. * @hidden
  55661. */
  55662. export class _ENVTextureLoader implements IInternalTextureLoader {
  55663. /**
  55664. * Defines wether the loader supports cascade loading the different faces.
  55665. */
  55666. readonly supportCascades: boolean;
  55667. /**
  55668. * This returns if the loader support the current file information.
  55669. * @param extension defines the file extension of the file being loaded
  55670. * @returns true if the loader can load the specified file
  55671. */
  55672. canLoad(extension: string): boolean;
  55673. /**
  55674. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  55675. * @param data contains the texture data
  55676. * @param texture defines the BabylonJS internal texture
  55677. * @param createPolynomials will be true if polynomials have been requested
  55678. * @param onLoad defines the callback to trigger once the texture is ready
  55679. * @param onError defines the callback to trigger in case of error
  55680. */
  55681. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55682. /**
  55683. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  55684. * @param data contains the texture data
  55685. * @param texture defines the BabylonJS internal texture
  55686. * @param callback defines the method to call once ready to upload
  55687. */
  55688. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55689. }
  55690. }
  55691. declare module BABYLON {
  55692. /**
  55693. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  55694. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  55695. */
  55696. export class KhronosTextureContainer {
  55697. /** contents of the KTX container file */
  55698. data: ArrayBufferView;
  55699. private static HEADER_LEN;
  55700. private static COMPRESSED_2D;
  55701. private static COMPRESSED_3D;
  55702. private static TEX_2D;
  55703. private static TEX_3D;
  55704. /**
  55705. * Gets the openGL type
  55706. */
  55707. glType: number;
  55708. /**
  55709. * Gets the openGL type size
  55710. */
  55711. glTypeSize: number;
  55712. /**
  55713. * Gets the openGL format
  55714. */
  55715. glFormat: number;
  55716. /**
  55717. * Gets the openGL internal format
  55718. */
  55719. glInternalFormat: number;
  55720. /**
  55721. * Gets the base internal format
  55722. */
  55723. glBaseInternalFormat: number;
  55724. /**
  55725. * Gets image width in pixel
  55726. */
  55727. pixelWidth: number;
  55728. /**
  55729. * Gets image height in pixel
  55730. */
  55731. pixelHeight: number;
  55732. /**
  55733. * Gets image depth in pixels
  55734. */
  55735. pixelDepth: number;
  55736. /**
  55737. * Gets the number of array elements
  55738. */
  55739. numberOfArrayElements: number;
  55740. /**
  55741. * Gets the number of faces
  55742. */
  55743. numberOfFaces: number;
  55744. /**
  55745. * Gets the number of mipmap levels
  55746. */
  55747. numberOfMipmapLevels: number;
  55748. /**
  55749. * Gets the bytes of key value data
  55750. */
  55751. bytesOfKeyValueData: number;
  55752. /**
  55753. * Gets the load type
  55754. */
  55755. loadType: number;
  55756. /**
  55757. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  55758. */
  55759. isInvalid: boolean;
  55760. /**
  55761. * Creates a new KhronosTextureContainer
  55762. * @param data contents of the KTX container file
  55763. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  55764. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  55765. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  55766. */
  55767. constructor(
  55768. /** contents of the KTX container file */
  55769. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  55770. /**
  55771. * Uploads KTX content to a Babylon Texture.
  55772. * It is assumed that the texture has already been created & is currently bound
  55773. * @hidden
  55774. */
  55775. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  55776. private _upload2DCompressedLevels;
  55777. /**
  55778. * Checks if the given data starts with a KTX file identifier.
  55779. * @param data the data to check
  55780. * @returns true if the data is a KTX file or false otherwise
  55781. */
  55782. static IsValid(data: ArrayBufferView): boolean;
  55783. }
  55784. }
  55785. declare module BABYLON {
  55786. /**
  55787. * Class for loading KTX2 files
  55788. * !!! Experimental Extension Subject to Changes !!!
  55789. * @hidden
  55790. */
  55791. export class KhronosTextureContainer2 {
  55792. private static _ModulePromise;
  55793. private static _TranscodeFormat;
  55794. constructor(engine: ThinEngine);
  55795. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  55796. private _determineTranscodeFormat;
  55797. /**
  55798. * Checks if the given data starts with a KTX2 file identifier.
  55799. * @param data the data to check
  55800. * @returns true if the data is a KTX2 file or false otherwise
  55801. */
  55802. static IsValid(data: ArrayBufferView): boolean;
  55803. }
  55804. }
  55805. declare module BABYLON {
  55806. /**
  55807. * Implementation of the KTX Texture Loader.
  55808. * @hidden
  55809. */
  55810. export class _KTXTextureLoader implements IInternalTextureLoader {
  55811. /**
  55812. * Defines wether the loader supports cascade loading the different faces.
  55813. */
  55814. readonly supportCascades: boolean;
  55815. /**
  55816. * This returns if the loader support the current file information.
  55817. * @param extension defines the file extension of the file being loaded
  55818. * @returns true if the loader can load the specified file
  55819. */
  55820. canLoad(extension: string): boolean;
  55821. /**
  55822. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  55823. * @param data contains the texture data
  55824. * @param texture defines the BabylonJS internal texture
  55825. * @param createPolynomials will be true if polynomials have been requested
  55826. * @param onLoad defines the callback to trigger once the texture is ready
  55827. * @param onError defines the callback to trigger in case of error
  55828. */
  55829. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55830. /**
  55831. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  55832. * @param data contains the texture data
  55833. * @param texture defines the BabylonJS internal texture
  55834. * @param callback defines the method to call once ready to upload
  55835. */
  55836. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  55837. }
  55838. }
  55839. declare module BABYLON {
  55840. /** @hidden */
  55841. export var _forceSceneHelpersToBundle: boolean;
  55842. interface Scene {
  55843. /**
  55844. * Creates a default light for the scene.
  55845. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  55846. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  55847. */
  55848. createDefaultLight(replace?: boolean): void;
  55849. /**
  55850. * Creates a default camera for the scene.
  55851. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  55852. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  55853. * @param replace has default false, when true replaces the active camera in the scene
  55854. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  55855. */
  55856. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  55857. /**
  55858. * Creates a default camera and a default light.
  55859. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  55860. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  55861. * @param replace has the default false, when true replaces the active camera/light in the scene
  55862. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  55863. */
  55864. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  55865. /**
  55866. * Creates a new sky box
  55867. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  55868. * @param environmentTexture defines the texture to use as environment texture
  55869. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  55870. * @param scale defines the overall scale of the skybox
  55871. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  55872. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  55873. * @returns a new mesh holding the sky box
  55874. */
  55875. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  55876. /**
  55877. * Creates a new environment
  55878. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  55879. * @param options defines the options you can use to configure the environment
  55880. * @returns the new EnvironmentHelper
  55881. */
  55882. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  55883. /**
  55884. * Creates a new VREXperienceHelper
  55885. * @see http://doc.babylonjs.com/how_to/webvr_helper
  55886. * @param webVROptions defines the options used to create the new VREXperienceHelper
  55887. * @returns a new VREXperienceHelper
  55888. */
  55889. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  55890. /**
  55891. * Creates a new WebXRDefaultExperience
  55892. * @see http://doc.babylonjs.com/how_to/webxr
  55893. * @param options experience options
  55894. * @returns a promise for a new WebXRDefaultExperience
  55895. */
  55896. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  55897. }
  55898. }
  55899. declare module BABYLON {
  55900. /**
  55901. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  55902. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  55903. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  55904. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  55905. */
  55906. export class VideoDome extends TransformNode {
  55907. /**
  55908. * Define the video source as a Monoscopic panoramic 360 video.
  55909. */
  55910. static readonly MODE_MONOSCOPIC: number;
  55911. /**
  55912. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  55913. */
  55914. static readonly MODE_TOPBOTTOM: number;
  55915. /**
  55916. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  55917. */
  55918. static readonly MODE_SIDEBYSIDE: number;
  55919. private _halfDome;
  55920. private _useDirectMapping;
  55921. /**
  55922. * The video texture being displayed on the sphere
  55923. */
  55924. protected _videoTexture: VideoTexture;
  55925. /**
  55926. * Gets the video texture being displayed on the sphere
  55927. */
  55928. get videoTexture(): VideoTexture;
  55929. /**
  55930. * The skybox material
  55931. */
  55932. protected _material: BackgroundMaterial;
  55933. /**
  55934. * The surface used for the skybox
  55935. */
  55936. protected _mesh: Mesh;
  55937. /**
  55938. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  55939. */
  55940. private _halfDomeMask;
  55941. /**
  55942. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  55943. * Also see the options.resolution property.
  55944. */
  55945. get fovMultiplier(): number;
  55946. set fovMultiplier(value: number);
  55947. private _videoMode;
  55948. /**
  55949. * Gets or set the current video mode for the video. It can be:
  55950. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  55951. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  55952. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  55953. */
  55954. get videoMode(): number;
  55955. set videoMode(value: number);
  55956. /**
  55957. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  55958. *
  55959. */
  55960. get halfDome(): boolean;
  55961. /**
  55962. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  55963. */
  55964. set halfDome(enabled: boolean);
  55965. /**
  55966. * Oberserver used in Stereoscopic VR Mode.
  55967. */
  55968. private _onBeforeCameraRenderObserver;
  55969. /**
  55970. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  55971. * @param name Element's name, child elements will append suffixes for their own names.
  55972. * @param urlsOrVideo defines the url(s) or the video element to use
  55973. * @param options An object containing optional or exposed sub element properties
  55974. */
  55975. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  55976. resolution?: number;
  55977. clickToPlay?: boolean;
  55978. autoPlay?: boolean;
  55979. loop?: boolean;
  55980. size?: number;
  55981. poster?: string;
  55982. faceForward?: boolean;
  55983. useDirectMapping?: boolean;
  55984. halfDomeMode?: boolean;
  55985. }, scene: Scene);
  55986. private _changeVideoMode;
  55987. /**
  55988. * Releases resources associated with this node.
  55989. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  55990. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  55991. */
  55992. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  55993. }
  55994. }
  55995. declare module BABYLON {
  55996. /**
  55997. * This class can be used to get instrumentation data from a Babylon engine
  55998. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  55999. */
  56000. export class EngineInstrumentation implements IDisposable {
  56001. /**
  56002. * Define the instrumented engine.
  56003. */
  56004. engine: Engine;
  56005. private _captureGPUFrameTime;
  56006. private _gpuFrameTimeToken;
  56007. private _gpuFrameTime;
  56008. private _captureShaderCompilationTime;
  56009. private _shaderCompilationTime;
  56010. private _onBeginFrameObserver;
  56011. private _onEndFrameObserver;
  56012. private _onBeforeShaderCompilationObserver;
  56013. private _onAfterShaderCompilationObserver;
  56014. /**
  56015. * Gets the perf counter used for GPU frame time
  56016. */
  56017. get gpuFrameTimeCounter(): PerfCounter;
  56018. /**
  56019. * Gets the GPU frame time capture status
  56020. */
  56021. get captureGPUFrameTime(): boolean;
  56022. /**
  56023. * Enable or disable the GPU frame time capture
  56024. */
  56025. set captureGPUFrameTime(value: boolean);
  56026. /**
  56027. * Gets the perf counter used for shader compilation time
  56028. */
  56029. get shaderCompilationTimeCounter(): PerfCounter;
  56030. /**
  56031. * Gets the shader compilation time capture status
  56032. */
  56033. get captureShaderCompilationTime(): boolean;
  56034. /**
  56035. * Enable or disable the shader compilation time capture
  56036. */
  56037. set captureShaderCompilationTime(value: boolean);
  56038. /**
  56039. * Instantiates a new engine instrumentation.
  56040. * This class can be used to get instrumentation data from a Babylon engine
  56041. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  56042. * @param engine Defines the engine to instrument
  56043. */
  56044. constructor(
  56045. /**
  56046. * Define the instrumented engine.
  56047. */
  56048. engine: Engine);
  56049. /**
  56050. * Dispose and release associated resources.
  56051. */
  56052. dispose(): void;
  56053. }
  56054. }
  56055. declare module BABYLON {
  56056. /**
  56057. * This class can be used to get instrumentation data from a Babylon engine
  56058. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  56059. */
  56060. export class SceneInstrumentation implements IDisposable {
  56061. /**
  56062. * Defines the scene to instrument
  56063. */
  56064. scene: Scene;
  56065. private _captureActiveMeshesEvaluationTime;
  56066. private _activeMeshesEvaluationTime;
  56067. private _captureRenderTargetsRenderTime;
  56068. private _renderTargetsRenderTime;
  56069. private _captureFrameTime;
  56070. private _frameTime;
  56071. private _captureRenderTime;
  56072. private _renderTime;
  56073. private _captureInterFrameTime;
  56074. private _interFrameTime;
  56075. private _captureParticlesRenderTime;
  56076. private _particlesRenderTime;
  56077. private _captureSpritesRenderTime;
  56078. private _spritesRenderTime;
  56079. private _capturePhysicsTime;
  56080. private _physicsTime;
  56081. private _captureAnimationsTime;
  56082. private _animationsTime;
  56083. private _captureCameraRenderTime;
  56084. private _cameraRenderTime;
  56085. private _onBeforeActiveMeshesEvaluationObserver;
  56086. private _onAfterActiveMeshesEvaluationObserver;
  56087. private _onBeforeRenderTargetsRenderObserver;
  56088. private _onAfterRenderTargetsRenderObserver;
  56089. private _onAfterRenderObserver;
  56090. private _onBeforeDrawPhaseObserver;
  56091. private _onAfterDrawPhaseObserver;
  56092. private _onBeforeAnimationsObserver;
  56093. private _onBeforeParticlesRenderingObserver;
  56094. private _onAfterParticlesRenderingObserver;
  56095. private _onBeforeSpritesRenderingObserver;
  56096. private _onAfterSpritesRenderingObserver;
  56097. private _onBeforePhysicsObserver;
  56098. private _onAfterPhysicsObserver;
  56099. private _onAfterAnimationsObserver;
  56100. private _onBeforeCameraRenderObserver;
  56101. private _onAfterCameraRenderObserver;
  56102. /**
  56103. * Gets the perf counter used for active meshes evaluation time
  56104. */
  56105. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  56106. /**
  56107. * Gets the active meshes evaluation time capture status
  56108. */
  56109. get captureActiveMeshesEvaluationTime(): boolean;
  56110. /**
  56111. * Enable or disable the active meshes evaluation time capture
  56112. */
  56113. set captureActiveMeshesEvaluationTime(value: boolean);
  56114. /**
  56115. * Gets the perf counter used for render targets render time
  56116. */
  56117. get renderTargetsRenderTimeCounter(): PerfCounter;
  56118. /**
  56119. * Gets the render targets render time capture status
  56120. */
  56121. get captureRenderTargetsRenderTime(): boolean;
  56122. /**
  56123. * Enable or disable the render targets render time capture
  56124. */
  56125. set captureRenderTargetsRenderTime(value: boolean);
  56126. /**
  56127. * Gets the perf counter used for particles render time
  56128. */
  56129. get particlesRenderTimeCounter(): PerfCounter;
  56130. /**
  56131. * Gets the particles render time capture status
  56132. */
  56133. get captureParticlesRenderTime(): boolean;
  56134. /**
  56135. * Enable or disable the particles render time capture
  56136. */
  56137. set captureParticlesRenderTime(value: boolean);
  56138. /**
  56139. * Gets the perf counter used for sprites render time
  56140. */
  56141. get spritesRenderTimeCounter(): PerfCounter;
  56142. /**
  56143. * Gets the sprites render time capture status
  56144. */
  56145. get captureSpritesRenderTime(): boolean;
  56146. /**
  56147. * Enable or disable the sprites render time capture
  56148. */
  56149. set captureSpritesRenderTime(value: boolean);
  56150. /**
  56151. * Gets the perf counter used for physics time
  56152. */
  56153. get physicsTimeCounter(): PerfCounter;
  56154. /**
  56155. * Gets the physics time capture status
  56156. */
  56157. get capturePhysicsTime(): boolean;
  56158. /**
  56159. * Enable or disable the physics time capture
  56160. */
  56161. set capturePhysicsTime(value: boolean);
  56162. /**
  56163. * Gets the perf counter used for animations time
  56164. */
  56165. get animationsTimeCounter(): PerfCounter;
  56166. /**
  56167. * Gets the animations time capture status
  56168. */
  56169. get captureAnimationsTime(): boolean;
  56170. /**
  56171. * Enable or disable the animations time capture
  56172. */
  56173. set captureAnimationsTime(value: boolean);
  56174. /**
  56175. * Gets the perf counter used for frame time capture
  56176. */
  56177. get frameTimeCounter(): PerfCounter;
  56178. /**
  56179. * Gets the frame time capture status
  56180. */
  56181. get captureFrameTime(): boolean;
  56182. /**
  56183. * Enable or disable the frame time capture
  56184. */
  56185. set captureFrameTime(value: boolean);
  56186. /**
  56187. * Gets the perf counter used for inter-frames time capture
  56188. */
  56189. get interFrameTimeCounter(): PerfCounter;
  56190. /**
  56191. * Gets the inter-frames time capture status
  56192. */
  56193. get captureInterFrameTime(): boolean;
  56194. /**
  56195. * Enable or disable the inter-frames time capture
  56196. */
  56197. set captureInterFrameTime(value: boolean);
  56198. /**
  56199. * Gets the perf counter used for render time capture
  56200. */
  56201. get renderTimeCounter(): PerfCounter;
  56202. /**
  56203. * Gets the render time capture status
  56204. */
  56205. get captureRenderTime(): boolean;
  56206. /**
  56207. * Enable or disable the render time capture
  56208. */
  56209. set captureRenderTime(value: boolean);
  56210. /**
  56211. * Gets the perf counter used for camera render time capture
  56212. */
  56213. get cameraRenderTimeCounter(): PerfCounter;
  56214. /**
  56215. * Gets the camera render time capture status
  56216. */
  56217. get captureCameraRenderTime(): boolean;
  56218. /**
  56219. * Enable or disable the camera render time capture
  56220. */
  56221. set captureCameraRenderTime(value: boolean);
  56222. /**
  56223. * Gets the perf counter used for draw calls
  56224. */
  56225. get drawCallsCounter(): PerfCounter;
  56226. /**
  56227. * Instantiates a new scene instrumentation.
  56228. * This class can be used to get instrumentation data from a Babylon engine
  56229. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  56230. * @param scene Defines the scene to instrument
  56231. */
  56232. constructor(
  56233. /**
  56234. * Defines the scene to instrument
  56235. */
  56236. scene: Scene);
  56237. /**
  56238. * Dispose and release associated resources.
  56239. */
  56240. dispose(): void;
  56241. }
  56242. }
  56243. declare module BABYLON {
  56244. /** @hidden */
  56245. export var glowMapGenerationPixelShader: {
  56246. name: string;
  56247. shader: string;
  56248. };
  56249. }
  56250. declare module BABYLON {
  56251. /** @hidden */
  56252. export var glowMapGenerationVertexShader: {
  56253. name: string;
  56254. shader: string;
  56255. };
  56256. }
  56257. declare module BABYLON {
  56258. /**
  56259. * Effect layer options. This helps customizing the behaviour
  56260. * of the effect layer.
  56261. */
  56262. export interface IEffectLayerOptions {
  56263. /**
  56264. * Multiplication factor apply to the canvas size to compute the render target size
  56265. * used to generated the objects (the smaller the faster).
  56266. */
  56267. mainTextureRatio: number;
  56268. /**
  56269. * Enforces a fixed size texture to ensure effect stability across devices.
  56270. */
  56271. mainTextureFixedSize?: number;
  56272. /**
  56273. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  56274. */
  56275. alphaBlendingMode: number;
  56276. /**
  56277. * The camera attached to the layer.
  56278. */
  56279. camera: Nullable<Camera>;
  56280. /**
  56281. * The rendering group to draw the layer in.
  56282. */
  56283. renderingGroupId: number;
  56284. }
  56285. /**
  56286. * The effect layer Helps adding post process effect blended with the main pass.
  56287. *
  56288. * This can be for instance use to generate glow or higlight effects on the scene.
  56289. *
  56290. * The effect layer class can not be used directly and is intented to inherited from to be
  56291. * customized per effects.
  56292. */
  56293. export abstract class EffectLayer {
  56294. private _vertexBuffers;
  56295. private _indexBuffer;
  56296. private _cachedDefines;
  56297. private _effectLayerMapGenerationEffect;
  56298. private _effectLayerOptions;
  56299. private _mergeEffect;
  56300. protected _scene: Scene;
  56301. protected _engine: Engine;
  56302. protected _maxSize: number;
  56303. protected _mainTextureDesiredSize: ISize;
  56304. protected _mainTexture: RenderTargetTexture;
  56305. protected _shouldRender: boolean;
  56306. protected _postProcesses: PostProcess[];
  56307. protected _textures: BaseTexture[];
  56308. protected _emissiveTextureAndColor: {
  56309. texture: Nullable<BaseTexture>;
  56310. color: Color4;
  56311. };
  56312. /**
  56313. * The name of the layer
  56314. */
  56315. name: string;
  56316. /**
  56317. * The clear color of the texture used to generate the glow map.
  56318. */
  56319. neutralColor: Color4;
  56320. /**
  56321. * Specifies whether the highlight layer is enabled or not.
  56322. */
  56323. isEnabled: boolean;
  56324. /**
  56325. * Gets the camera attached to the layer.
  56326. */
  56327. get camera(): Nullable<Camera>;
  56328. /**
  56329. * Gets the rendering group id the layer should render in.
  56330. */
  56331. get renderingGroupId(): number;
  56332. set renderingGroupId(renderingGroupId: number);
  56333. /**
  56334. * An event triggered when the effect layer has been disposed.
  56335. */
  56336. onDisposeObservable: Observable<EffectLayer>;
  56337. /**
  56338. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  56339. */
  56340. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  56341. /**
  56342. * An event triggered when the generated texture is being merged in the scene.
  56343. */
  56344. onBeforeComposeObservable: Observable<EffectLayer>;
  56345. /**
  56346. * An event triggered when the mesh is rendered into the effect render target.
  56347. */
  56348. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  56349. /**
  56350. * An event triggered after the mesh has been rendered into the effect render target.
  56351. */
  56352. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  56353. /**
  56354. * An event triggered when the generated texture has been merged in the scene.
  56355. */
  56356. onAfterComposeObservable: Observable<EffectLayer>;
  56357. /**
  56358. * An event triggered when the efffect layer changes its size.
  56359. */
  56360. onSizeChangedObservable: Observable<EffectLayer>;
  56361. /** @hidden */
  56362. static _SceneComponentInitialization: (scene: Scene) => void;
  56363. /**
  56364. * Instantiates a new effect Layer and references it in the scene.
  56365. * @param name The name of the layer
  56366. * @param scene The scene to use the layer in
  56367. */
  56368. constructor(
  56369. /** The Friendly of the effect in the scene */
  56370. name: string, scene: Scene);
  56371. /**
  56372. * Get the effect name of the layer.
  56373. * @return The effect name
  56374. */
  56375. abstract getEffectName(): string;
  56376. /**
  56377. * Checks for the readiness of the element composing the layer.
  56378. * @param subMesh the mesh to check for
  56379. * @param useInstances specify whether or not to use instances to render the mesh
  56380. * @return true if ready otherwise, false
  56381. */
  56382. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56383. /**
  56384. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  56385. * @returns true if the effect requires stencil during the main canvas render pass.
  56386. */
  56387. abstract needStencil(): boolean;
  56388. /**
  56389. * Create the merge effect. This is the shader use to blit the information back
  56390. * to the main canvas at the end of the scene rendering.
  56391. * @returns The effect containing the shader used to merge the effect on the main canvas
  56392. */
  56393. protected abstract _createMergeEffect(): Effect;
  56394. /**
  56395. * Creates the render target textures and post processes used in the effect layer.
  56396. */
  56397. protected abstract _createTextureAndPostProcesses(): void;
  56398. /**
  56399. * Implementation specific of rendering the generating effect on the main canvas.
  56400. * @param effect The effect used to render through
  56401. */
  56402. protected abstract _internalRender(effect: Effect): void;
  56403. /**
  56404. * Sets the required values for both the emissive texture and and the main color.
  56405. */
  56406. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  56407. /**
  56408. * Free any resources and references associated to a mesh.
  56409. * Internal use
  56410. * @param mesh The mesh to free.
  56411. */
  56412. abstract _disposeMesh(mesh: Mesh): void;
  56413. /**
  56414. * Serializes this layer (Glow or Highlight for example)
  56415. * @returns a serialized layer object
  56416. */
  56417. abstract serialize?(): any;
  56418. /**
  56419. * Initializes the effect layer with the required options.
  56420. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  56421. */
  56422. protected _init(options: Partial<IEffectLayerOptions>): void;
  56423. /**
  56424. * Generates the index buffer of the full screen quad blending to the main canvas.
  56425. */
  56426. private _generateIndexBuffer;
  56427. /**
  56428. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  56429. */
  56430. private _generateVertexBuffer;
  56431. /**
  56432. * Sets the main texture desired size which is the closest power of two
  56433. * of the engine canvas size.
  56434. */
  56435. private _setMainTextureSize;
  56436. /**
  56437. * Creates the main texture for the effect layer.
  56438. */
  56439. protected _createMainTexture(): void;
  56440. /**
  56441. * Adds specific effects defines.
  56442. * @param defines The defines to add specifics to.
  56443. */
  56444. protected _addCustomEffectDefines(defines: string[]): void;
  56445. /**
  56446. * Checks for the readiness of the element composing the layer.
  56447. * @param subMesh the mesh to check for
  56448. * @param useInstances specify whether or not to use instances to render the mesh
  56449. * @param emissiveTexture the associated emissive texture used to generate the glow
  56450. * @return true if ready otherwise, false
  56451. */
  56452. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  56453. /**
  56454. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  56455. */
  56456. render(): void;
  56457. /**
  56458. * Determine if a given mesh will be used in the current effect.
  56459. * @param mesh mesh to test
  56460. * @returns true if the mesh will be used
  56461. */
  56462. hasMesh(mesh: AbstractMesh): boolean;
  56463. /**
  56464. * Returns true if the layer contains information to display, otherwise false.
  56465. * @returns true if the glow layer should be rendered
  56466. */
  56467. shouldRender(): boolean;
  56468. /**
  56469. * Returns true if the mesh should render, otherwise false.
  56470. * @param mesh The mesh to render
  56471. * @returns true if it should render otherwise false
  56472. */
  56473. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  56474. /**
  56475. * Returns true if the mesh can be rendered, otherwise false.
  56476. * @param mesh The mesh to render
  56477. * @param material The material used on the mesh
  56478. * @returns true if it can be rendered otherwise false
  56479. */
  56480. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  56481. /**
  56482. * Returns true if the mesh should render, otherwise false.
  56483. * @param mesh The mesh to render
  56484. * @returns true if it should render otherwise false
  56485. */
  56486. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  56487. /**
  56488. * Renders the submesh passed in parameter to the generation map.
  56489. */
  56490. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  56491. /**
  56492. * Defines whether the current material of the mesh should be use to render the effect.
  56493. * @param mesh defines the current mesh to render
  56494. */
  56495. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  56496. /**
  56497. * Rebuild the required buffers.
  56498. * @hidden Internal use only.
  56499. */
  56500. _rebuild(): void;
  56501. /**
  56502. * Dispose only the render target textures and post process.
  56503. */
  56504. private _disposeTextureAndPostProcesses;
  56505. /**
  56506. * Dispose the highlight layer and free resources.
  56507. */
  56508. dispose(): void;
  56509. /**
  56510. * Gets the class name of the effect layer
  56511. * @returns the string with the class name of the effect layer
  56512. */
  56513. getClassName(): string;
  56514. /**
  56515. * Creates an effect layer from parsed effect layer data
  56516. * @param parsedEffectLayer defines effect layer data
  56517. * @param scene defines the current scene
  56518. * @param rootUrl defines the root URL containing the effect layer information
  56519. * @returns a parsed effect Layer
  56520. */
  56521. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  56522. }
  56523. }
  56524. declare module BABYLON {
  56525. interface AbstractScene {
  56526. /**
  56527. * The list of effect layers (highlights/glow) added to the scene
  56528. * @see http://doc.babylonjs.com/how_to/highlight_layer
  56529. * @see http://doc.babylonjs.com/how_to/glow_layer
  56530. */
  56531. effectLayers: Array<EffectLayer>;
  56532. /**
  56533. * Removes the given effect layer from this scene.
  56534. * @param toRemove defines the effect layer to remove
  56535. * @returns the index of the removed effect layer
  56536. */
  56537. removeEffectLayer(toRemove: EffectLayer): number;
  56538. /**
  56539. * Adds the given effect layer to this scene
  56540. * @param newEffectLayer defines the effect layer to add
  56541. */
  56542. addEffectLayer(newEffectLayer: EffectLayer): void;
  56543. }
  56544. /**
  56545. * Defines the layer scene component responsible to manage any effect layers
  56546. * in a given scene.
  56547. */
  56548. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  56549. /**
  56550. * The component name helpfull to identify the component in the list of scene components.
  56551. */
  56552. readonly name: string;
  56553. /**
  56554. * The scene the component belongs to.
  56555. */
  56556. scene: Scene;
  56557. private _engine;
  56558. private _renderEffects;
  56559. private _needStencil;
  56560. private _previousStencilState;
  56561. /**
  56562. * Creates a new instance of the component for the given scene
  56563. * @param scene Defines the scene to register the component in
  56564. */
  56565. constructor(scene: Scene);
  56566. /**
  56567. * Registers the component in a given scene
  56568. */
  56569. register(): void;
  56570. /**
  56571. * Rebuilds the elements related to this component in case of
  56572. * context lost for instance.
  56573. */
  56574. rebuild(): void;
  56575. /**
  56576. * Serializes the component data to the specified json object
  56577. * @param serializationObject The object to serialize to
  56578. */
  56579. serialize(serializationObject: any): void;
  56580. /**
  56581. * Adds all the elements from the container to the scene
  56582. * @param container the container holding the elements
  56583. */
  56584. addFromContainer(container: AbstractScene): void;
  56585. /**
  56586. * Removes all the elements in the container from the scene
  56587. * @param container contains the elements to remove
  56588. * @param dispose if the removed element should be disposed (default: false)
  56589. */
  56590. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56591. /**
  56592. * Disposes the component and the associated ressources.
  56593. */
  56594. dispose(): void;
  56595. private _isReadyForMesh;
  56596. private _renderMainTexture;
  56597. private _setStencil;
  56598. private _setStencilBack;
  56599. private _draw;
  56600. private _drawCamera;
  56601. private _drawRenderingGroup;
  56602. }
  56603. }
  56604. declare module BABYLON {
  56605. /** @hidden */
  56606. export var glowMapMergePixelShader: {
  56607. name: string;
  56608. shader: string;
  56609. };
  56610. }
  56611. declare module BABYLON {
  56612. /** @hidden */
  56613. export var glowMapMergeVertexShader: {
  56614. name: string;
  56615. shader: string;
  56616. };
  56617. }
  56618. declare module BABYLON {
  56619. interface AbstractScene {
  56620. /**
  56621. * Return a the first highlight layer of the scene with a given name.
  56622. * @param name The name of the highlight layer to look for.
  56623. * @return The highlight layer if found otherwise null.
  56624. */
  56625. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  56626. }
  56627. /**
  56628. * Glow layer options. This helps customizing the behaviour
  56629. * of the glow layer.
  56630. */
  56631. export interface IGlowLayerOptions {
  56632. /**
  56633. * Multiplication factor apply to the canvas size to compute the render target size
  56634. * used to generated the glowing objects (the smaller the faster).
  56635. */
  56636. mainTextureRatio: number;
  56637. /**
  56638. * Enforces a fixed size texture to ensure resize independant blur.
  56639. */
  56640. mainTextureFixedSize?: number;
  56641. /**
  56642. * How big is the kernel of the blur texture.
  56643. */
  56644. blurKernelSize: number;
  56645. /**
  56646. * The camera attached to the layer.
  56647. */
  56648. camera: Nullable<Camera>;
  56649. /**
  56650. * Enable MSAA by chosing the number of samples.
  56651. */
  56652. mainTextureSamples?: number;
  56653. /**
  56654. * The rendering group to draw the layer in.
  56655. */
  56656. renderingGroupId: number;
  56657. }
  56658. /**
  56659. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  56660. *
  56661. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  56662. *
  56663. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  56664. */
  56665. export class GlowLayer extends EffectLayer {
  56666. /**
  56667. * Effect Name of the layer.
  56668. */
  56669. static readonly EffectName: string;
  56670. /**
  56671. * The default blur kernel size used for the glow.
  56672. */
  56673. static DefaultBlurKernelSize: number;
  56674. /**
  56675. * The default texture size ratio used for the glow.
  56676. */
  56677. static DefaultTextureRatio: number;
  56678. /**
  56679. * Sets the kernel size of the blur.
  56680. */
  56681. set blurKernelSize(value: number);
  56682. /**
  56683. * Gets the kernel size of the blur.
  56684. */
  56685. get blurKernelSize(): number;
  56686. /**
  56687. * Sets the glow intensity.
  56688. */
  56689. set intensity(value: number);
  56690. /**
  56691. * Gets the glow intensity.
  56692. */
  56693. get intensity(): number;
  56694. private _options;
  56695. private _intensity;
  56696. private _horizontalBlurPostprocess1;
  56697. private _verticalBlurPostprocess1;
  56698. private _horizontalBlurPostprocess2;
  56699. private _verticalBlurPostprocess2;
  56700. private _blurTexture1;
  56701. private _blurTexture2;
  56702. private _postProcesses1;
  56703. private _postProcesses2;
  56704. private _includedOnlyMeshes;
  56705. private _excludedMeshes;
  56706. private _meshesUsingTheirOwnMaterials;
  56707. /**
  56708. * Callback used to let the user override the color selection on a per mesh basis
  56709. */
  56710. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  56711. /**
  56712. * Callback used to let the user override the texture selection on a per mesh basis
  56713. */
  56714. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  56715. /**
  56716. * Instantiates a new glow Layer and references it to the scene.
  56717. * @param name The name of the layer
  56718. * @param scene The scene to use the layer in
  56719. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  56720. */
  56721. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  56722. /**
  56723. * Get the effect name of the layer.
  56724. * @return The effect name
  56725. */
  56726. getEffectName(): string;
  56727. /**
  56728. * Create the merge effect. This is the shader use to blit the information back
  56729. * to the main canvas at the end of the scene rendering.
  56730. */
  56731. protected _createMergeEffect(): Effect;
  56732. /**
  56733. * Creates the render target textures and post processes used in the glow layer.
  56734. */
  56735. protected _createTextureAndPostProcesses(): void;
  56736. /**
  56737. * Checks for the readiness of the element composing the layer.
  56738. * @param subMesh the mesh to check for
  56739. * @param useInstances specify wether or not to use instances to render the mesh
  56740. * @param emissiveTexture the associated emissive texture used to generate the glow
  56741. * @return true if ready otherwise, false
  56742. */
  56743. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56744. /**
  56745. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  56746. */
  56747. needStencil(): boolean;
  56748. /**
  56749. * Returns true if the mesh can be rendered, otherwise false.
  56750. * @param mesh The mesh to render
  56751. * @param material The material used on the mesh
  56752. * @returns true if it can be rendered otherwise false
  56753. */
  56754. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  56755. /**
  56756. * Implementation specific of rendering the generating effect on the main canvas.
  56757. * @param effect The effect used to render through
  56758. */
  56759. protected _internalRender(effect: Effect): void;
  56760. /**
  56761. * Sets the required values for both the emissive texture and and the main color.
  56762. */
  56763. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  56764. /**
  56765. * Returns true if the mesh should render, otherwise false.
  56766. * @param mesh The mesh to render
  56767. * @returns true if it should render otherwise false
  56768. */
  56769. protected _shouldRenderMesh(mesh: Mesh): boolean;
  56770. /**
  56771. * Adds specific effects defines.
  56772. * @param defines The defines to add specifics to.
  56773. */
  56774. protected _addCustomEffectDefines(defines: string[]): void;
  56775. /**
  56776. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  56777. * @param mesh The mesh to exclude from the glow layer
  56778. */
  56779. addExcludedMesh(mesh: Mesh): void;
  56780. /**
  56781. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  56782. * @param mesh The mesh to remove
  56783. */
  56784. removeExcludedMesh(mesh: Mesh): void;
  56785. /**
  56786. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  56787. * @param mesh The mesh to include in the glow layer
  56788. */
  56789. addIncludedOnlyMesh(mesh: Mesh): void;
  56790. /**
  56791. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  56792. * @param mesh The mesh to remove
  56793. */
  56794. removeIncludedOnlyMesh(mesh: Mesh): void;
  56795. /**
  56796. * Determine if a given mesh will be used in the glow layer
  56797. * @param mesh The mesh to test
  56798. * @returns true if the mesh will be highlighted by the current glow layer
  56799. */
  56800. hasMesh(mesh: AbstractMesh): boolean;
  56801. /**
  56802. * Defines whether the current material of the mesh should be use to render the effect.
  56803. * @param mesh defines the current mesh to render
  56804. */
  56805. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  56806. /**
  56807. * Add a mesh to be rendered through its own material and not with emissive only.
  56808. * @param mesh The mesh for which we need to use its material
  56809. */
  56810. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  56811. /**
  56812. * Remove a mesh from being rendered through its own material and not with emissive only.
  56813. * @param mesh The mesh for which we need to not use its material
  56814. */
  56815. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  56816. /**
  56817. * Free any resources and references associated to a mesh.
  56818. * Internal use
  56819. * @param mesh The mesh to free.
  56820. * @hidden
  56821. */
  56822. _disposeMesh(mesh: Mesh): void;
  56823. /**
  56824. * Gets the class name of the effect layer
  56825. * @returns the string with the class name of the effect layer
  56826. */
  56827. getClassName(): string;
  56828. /**
  56829. * Serializes this glow layer
  56830. * @returns a serialized glow layer object
  56831. */
  56832. serialize(): any;
  56833. /**
  56834. * Creates a Glow Layer from parsed glow layer data
  56835. * @param parsedGlowLayer defines glow layer data
  56836. * @param scene defines the current scene
  56837. * @param rootUrl defines the root URL containing the glow layer information
  56838. * @returns a parsed Glow Layer
  56839. */
  56840. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  56841. }
  56842. }
  56843. declare module BABYLON {
  56844. /** @hidden */
  56845. export var glowBlurPostProcessPixelShader: {
  56846. name: string;
  56847. shader: string;
  56848. };
  56849. }
  56850. declare module BABYLON {
  56851. interface AbstractScene {
  56852. /**
  56853. * Return a the first highlight layer of the scene with a given name.
  56854. * @param name The name of the highlight layer to look for.
  56855. * @return The highlight layer if found otherwise null.
  56856. */
  56857. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  56858. }
  56859. /**
  56860. * Highlight layer options. This helps customizing the behaviour
  56861. * of the highlight layer.
  56862. */
  56863. export interface IHighlightLayerOptions {
  56864. /**
  56865. * Multiplication factor apply to the canvas size to compute the render target size
  56866. * used to generated the glowing objects (the smaller the faster).
  56867. */
  56868. mainTextureRatio: number;
  56869. /**
  56870. * Enforces a fixed size texture to ensure resize independant blur.
  56871. */
  56872. mainTextureFixedSize?: number;
  56873. /**
  56874. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  56875. * of the picture to blur (the smaller the faster).
  56876. */
  56877. blurTextureSizeRatio: number;
  56878. /**
  56879. * How big in texel of the blur texture is the vertical blur.
  56880. */
  56881. blurVerticalSize: number;
  56882. /**
  56883. * How big in texel of the blur texture is the horizontal blur.
  56884. */
  56885. blurHorizontalSize: number;
  56886. /**
  56887. * Alpha blending mode used to apply the blur. Default is combine.
  56888. */
  56889. alphaBlendingMode: number;
  56890. /**
  56891. * The camera attached to the layer.
  56892. */
  56893. camera: Nullable<Camera>;
  56894. /**
  56895. * Should we display highlight as a solid stroke?
  56896. */
  56897. isStroke?: boolean;
  56898. /**
  56899. * The rendering group to draw the layer in.
  56900. */
  56901. renderingGroupId: number;
  56902. }
  56903. /**
  56904. * The highlight layer Helps adding a glow effect around a mesh.
  56905. *
  56906. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  56907. * glowy meshes to your scene.
  56908. *
  56909. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  56910. */
  56911. export class HighlightLayer extends EffectLayer {
  56912. name: string;
  56913. /**
  56914. * Effect Name of the highlight layer.
  56915. */
  56916. static readonly EffectName: string;
  56917. /**
  56918. * The neutral color used during the preparation of the glow effect.
  56919. * This is black by default as the blend operation is a blend operation.
  56920. */
  56921. static NeutralColor: Color4;
  56922. /**
  56923. * Stencil value used for glowing meshes.
  56924. */
  56925. static GlowingMeshStencilReference: number;
  56926. /**
  56927. * Stencil value used for the other meshes in the scene.
  56928. */
  56929. static NormalMeshStencilReference: number;
  56930. /**
  56931. * Specifies whether or not the inner glow is ACTIVE in the layer.
  56932. */
  56933. innerGlow: boolean;
  56934. /**
  56935. * Specifies whether or not the outer glow is ACTIVE in the layer.
  56936. */
  56937. outerGlow: boolean;
  56938. /**
  56939. * Specifies the horizontal size of the blur.
  56940. */
  56941. set blurHorizontalSize(value: number);
  56942. /**
  56943. * Specifies the vertical size of the blur.
  56944. */
  56945. set blurVerticalSize(value: number);
  56946. /**
  56947. * Gets the horizontal size of the blur.
  56948. */
  56949. get blurHorizontalSize(): number;
  56950. /**
  56951. * Gets the vertical size of the blur.
  56952. */
  56953. get blurVerticalSize(): number;
  56954. /**
  56955. * An event triggered when the highlight layer is being blurred.
  56956. */
  56957. onBeforeBlurObservable: Observable<HighlightLayer>;
  56958. /**
  56959. * An event triggered when the highlight layer has been blurred.
  56960. */
  56961. onAfterBlurObservable: Observable<HighlightLayer>;
  56962. private _instanceGlowingMeshStencilReference;
  56963. private _options;
  56964. private _downSamplePostprocess;
  56965. private _horizontalBlurPostprocess;
  56966. private _verticalBlurPostprocess;
  56967. private _blurTexture;
  56968. private _meshes;
  56969. private _excludedMeshes;
  56970. /**
  56971. * Instantiates a new highlight Layer and references it to the scene..
  56972. * @param name The name of the layer
  56973. * @param scene The scene to use the layer in
  56974. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  56975. */
  56976. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  56977. /**
  56978. * Get the effect name of the layer.
  56979. * @return The effect name
  56980. */
  56981. getEffectName(): string;
  56982. /**
  56983. * Create the merge effect. This is the shader use to blit the information back
  56984. * to the main canvas at the end of the scene rendering.
  56985. */
  56986. protected _createMergeEffect(): Effect;
  56987. /**
  56988. * Creates the render target textures and post processes used in the highlight layer.
  56989. */
  56990. protected _createTextureAndPostProcesses(): void;
  56991. /**
  56992. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  56993. */
  56994. needStencil(): boolean;
  56995. /**
  56996. * Checks for the readiness of the element composing the layer.
  56997. * @param subMesh the mesh to check for
  56998. * @param useInstances specify wether or not to use instances to render the mesh
  56999. * @param emissiveTexture the associated emissive texture used to generate the glow
  57000. * @return true if ready otherwise, false
  57001. */
  57002. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57003. /**
  57004. * Implementation specific of rendering the generating effect on the main canvas.
  57005. * @param effect The effect used to render through
  57006. */
  57007. protected _internalRender(effect: Effect): void;
  57008. /**
  57009. * Returns true if the layer contains information to display, otherwise false.
  57010. */
  57011. shouldRender(): boolean;
  57012. /**
  57013. * Returns true if the mesh should render, otherwise false.
  57014. * @param mesh The mesh to render
  57015. * @returns true if it should render otherwise false
  57016. */
  57017. protected _shouldRenderMesh(mesh: Mesh): boolean;
  57018. /**
  57019. * Adds specific effects defines.
  57020. * @param defines The defines to add specifics to.
  57021. */
  57022. protected _addCustomEffectDefines(defines: string[]): void;
  57023. /**
  57024. * Sets the required values for both the emissive texture and and the main color.
  57025. */
  57026. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  57027. /**
  57028. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  57029. * @param mesh The mesh to exclude from the highlight layer
  57030. */
  57031. addExcludedMesh(mesh: Mesh): void;
  57032. /**
  57033. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  57034. * @param mesh The mesh to highlight
  57035. */
  57036. removeExcludedMesh(mesh: Mesh): void;
  57037. /**
  57038. * Determine if a given mesh will be highlighted by the current HighlightLayer
  57039. * @param mesh mesh to test
  57040. * @returns true if the mesh will be highlighted by the current HighlightLayer
  57041. */
  57042. hasMesh(mesh: AbstractMesh): boolean;
  57043. /**
  57044. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  57045. * @param mesh The mesh to highlight
  57046. * @param color The color of the highlight
  57047. * @param glowEmissiveOnly Extract the glow from the emissive texture
  57048. */
  57049. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  57050. /**
  57051. * Remove a mesh from the highlight layer in order to make it stop glowing.
  57052. * @param mesh The mesh to highlight
  57053. */
  57054. removeMesh(mesh: Mesh): void;
  57055. /**
  57056. * Remove all the meshes currently referenced in the highlight layer
  57057. */
  57058. removeAllMeshes(): void;
  57059. /**
  57060. * Force the stencil to the normal expected value for none glowing parts
  57061. */
  57062. private _defaultStencilReference;
  57063. /**
  57064. * Free any resources and references associated to a mesh.
  57065. * Internal use
  57066. * @param mesh The mesh to free.
  57067. * @hidden
  57068. */
  57069. _disposeMesh(mesh: Mesh): void;
  57070. /**
  57071. * Dispose the highlight layer and free resources.
  57072. */
  57073. dispose(): void;
  57074. /**
  57075. * Gets the class name of the effect layer
  57076. * @returns the string with the class name of the effect layer
  57077. */
  57078. getClassName(): string;
  57079. /**
  57080. * Serializes this Highlight layer
  57081. * @returns a serialized Highlight layer object
  57082. */
  57083. serialize(): any;
  57084. /**
  57085. * Creates a Highlight layer from parsed Highlight layer data
  57086. * @param parsedHightlightLayer defines the Highlight layer data
  57087. * @param scene defines the current scene
  57088. * @param rootUrl defines the root URL containing the Highlight layer information
  57089. * @returns a parsed Highlight layer
  57090. */
  57091. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  57092. }
  57093. }
  57094. declare module BABYLON {
  57095. interface AbstractScene {
  57096. /**
  57097. * The list of layers (background and foreground) of the scene
  57098. */
  57099. layers: Array<Layer>;
  57100. }
  57101. /**
  57102. * Defines the layer scene component responsible to manage any layers
  57103. * in a given scene.
  57104. */
  57105. export class LayerSceneComponent implements ISceneComponent {
  57106. /**
  57107. * The component name helpfull to identify the component in the list of scene components.
  57108. */
  57109. readonly name: string;
  57110. /**
  57111. * The scene the component belongs to.
  57112. */
  57113. scene: Scene;
  57114. private _engine;
  57115. /**
  57116. * Creates a new instance of the component for the given scene
  57117. * @param scene Defines the scene to register the component in
  57118. */
  57119. constructor(scene: Scene);
  57120. /**
  57121. * Registers the component in a given scene
  57122. */
  57123. register(): void;
  57124. /**
  57125. * Rebuilds the elements related to this component in case of
  57126. * context lost for instance.
  57127. */
  57128. rebuild(): void;
  57129. /**
  57130. * Disposes the component and the associated ressources.
  57131. */
  57132. dispose(): void;
  57133. private _draw;
  57134. private _drawCameraPredicate;
  57135. private _drawCameraBackground;
  57136. private _drawCameraForeground;
  57137. private _drawRenderTargetPredicate;
  57138. private _drawRenderTargetBackground;
  57139. private _drawRenderTargetForeground;
  57140. /**
  57141. * Adds all the elements from the container to the scene
  57142. * @param container the container holding the elements
  57143. */
  57144. addFromContainer(container: AbstractScene): void;
  57145. /**
  57146. * Removes all the elements in the container from the scene
  57147. * @param container contains the elements to remove
  57148. * @param dispose if the removed element should be disposed (default: false)
  57149. */
  57150. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57151. }
  57152. }
  57153. declare module BABYLON {
  57154. /** @hidden */
  57155. export var layerPixelShader: {
  57156. name: string;
  57157. shader: string;
  57158. };
  57159. }
  57160. declare module BABYLON {
  57161. /** @hidden */
  57162. export var layerVertexShader: {
  57163. name: string;
  57164. shader: string;
  57165. };
  57166. }
  57167. declare module BABYLON {
  57168. /**
  57169. * This represents a full screen 2d layer.
  57170. * This can be useful to display a picture in the background of your scene for instance.
  57171. * @see https://www.babylonjs-playground.com/#08A2BS#1
  57172. */
  57173. export class Layer {
  57174. /**
  57175. * Define the name of the layer.
  57176. */
  57177. name: string;
  57178. /**
  57179. * Define the texture the layer should display.
  57180. */
  57181. texture: Nullable<Texture>;
  57182. /**
  57183. * Is the layer in background or foreground.
  57184. */
  57185. isBackground: boolean;
  57186. /**
  57187. * Define the color of the layer (instead of texture).
  57188. */
  57189. color: Color4;
  57190. /**
  57191. * Define the scale of the layer in order to zoom in out of the texture.
  57192. */
  57193. scale: Vector2;
  57194. /**
  57195. * Define an offset for the layer in order to shift the texture.
  57196. */
  57197. offset: Vector2;
  57198. /**
  57199. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  57200. */
  57201. alphaBlendingMode: number;
  57202. /**
  57203. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  57204. * Alpha test will not mix with the background color in case of transparency.
  57205. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  57206. */
  57207. alphaTest: boolean;
  57208. /**
  57209. * Define a mask to restrict the layer to only some of the scene cameras.
  57210. */
  57211. layerMask: number;
  57212. /**
  57213. * Define the list of render target the layer is visible into.
  57214. */
  57215. renderTargetTextures: RenderTargetTexture[];
  57216. /**
  57217. * Define if the layer is only used in renderTarget or if it also
  57218. * renders in the main frame buffer of the canvas.
  57219. */
  57220. renderOnlyInRenderTargetTextures: boolean;
  57221. private _scene;
  57222. private _vertexBuffers;
  57223. private _indexBuffer;
  57224. private _effect;
  57225. private _previousDefines;
  57226. /**
  57227. * An event triggered when the layer is disposed.
  57228. */
  57229. onDisposeObservable: Observable<Layer>;
  57230. private _onDisposeObserver;
  57231. /**
  57232. * Back compatibility with callback before the onDisposeObservable existed.
  57233. * The set callback will be triggered when the layer has been disposed.
  57234. */
  57235. set onDispose(callback: () => void);
  57236. /**
  57237. * An event triggered before rendering the scene
  57238. */
  57239. onBeforeRenderObservable: Observable<Layer>;
  57240. private _onBeforeRenderObserver;
  57241. /**
  57242. * Back compatibility with callback before the onBeforeRenderObservable existed.
  57243. * The set callback will be triggered just before rendering the layer.
  57244. */
  57245. set onBeforeRender(callback: () => void);
  57246. /**
  57247. * An event triggered after rendering the scene
  57248. */
  57249. onAfterRenderObservable: Observable<Layer>;
  57250. private _onAfterRenderObserver;
  57251. /**
  57252. * Back compatibility with callback before the onAfterRenderObservable existed.
  57253. * The set callback will be triggered just after rendering the layer.
  57254. */
  57255. set onAfterRender(callback: () => void);
  57256. /**
  57257. * Instantiates a new layer.
  57258. * This represents a full screen 2d layer.
  57259. * This can be useful to display a picture in the background of your scene for instance.
  57260. * @see https://www.babylonjs-playground.com/#08A2BS#1
  57261. * @param name Define the name of the layer in the scene
  57262. * @param imgUrl Define the url of the texture to display in the layer
  57263. * @param scene Define the scene the layer belongs to
  57264. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  57265. * @param color Defines a color for the layer
  57266. */
  57267. constructor(
  57268. /**
  57269. * Define the name of the layer.
  57270. */
  57271. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  57272. private _createIndexBuffer;
  57273. /** @hidden */
  57274. _rebuild(): void;
  57275. /**
  57276. * Renders the layer in the scene.
  57277. */
  57278. render(): void;
  57279. /**
  57280. * Disposes and releases the associated ressources.
  57281. */
  57282. dispose(): void;
  57283. }
  57284. }
  57285. declare module BABYLON {
  57286. /** @hidden */
  57287. export var lensFlarePixelShader: {
  57288. name: string;
  57289. shader: string;
  57290. };
  57291. }
  57292. declare module BABYLON {
  57293. /** @hidden */
  57294. export var lensFlareVertexShader: {
  57295. name: string;
  57296. shader: string;
  57297. };
  57298. }
  57299. declare module BABYLON {
  57300. /**
  57301. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  57302. * It is usually composed of several `lensFlare`.
  57303. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57304. */
  57305. export class LensFlareSystem {
  57306. /**
  57307. * Define the name of the lens flare system
  57308. */
  57309. name: string;
  57310. /**
  57311. * List of lens flares used in this system.
  57312. */
  57313. lensFlares: LensFlare[];
  57314. /**
  57315. * Define a limit from the border the lens flare can be visible.
  57316. */
  57317. borderLimit: number;
  57318. /**
  57319. * Define a viewport border we do not want to see the lens flare in.
  57320. */
  57321. viewportBorder: number;
  57322. /**
  57323. * Define a predicate which could limit the list of meshes able to occlude the effect.
  57324. */
  57325. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  57326. /**
  57327. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  57328. */
  57329. layerMask: number;
  57330. /**
  57331. * Define the id of the lens flare system in the scene.
  57332. * (equal to name by default)
  57333. */
  57334. id: string;
  57335. private _scene;
  57336. private _emitter;
  57337. private _vertexBuffers;
  57338. private _indexBuffer;
  57339. private _effect;
  57340. private _positionX;
  57341. private _positionY;
  57342. private _isEnabled;
  57343. /** @hidden */
  57344. static _SceneComponentInitialization: (scene: Scene) => void;
  57345. /**
  57346. * Instantiates a lens flare system.
  57347. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  57348. * It is usually composed of several `lensFlare`.
  57349. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57350. * @param name Define the name of the lens flare system in the scene
  57351. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  57352. * @param scene Define the scene the lens flare system belongs to
  57353. */
  57354. constructor(
  57355. /**
  57356. * Define the name of the lens flare system
  57357. */
  57358. name: string, emitter: any, scene: Scene);
  57359. /**
  57360. * Define if the lens flare system is enabled.
  57361. */
  57362. get isEnabled(): boolean;
  57363. set isEnabled(value: boolean);
  57364. /**
  57365. * Get the scene the effects belongs to.
  57366. * @returns the scene holding the lens flare system
  57367. */
  57368. getScene(): Scene;
  57369. /**
  57370. * Get the emitter of the lens flare system.
  57371. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  57372. * @returns the emitter of the lens flare system
  57373. */
  57374. getEmitter(): any;
  57375. /**
  57376. * Set the emitter of the lens flare system.
  57377. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  57378. * @param newEmitter Define the new emitter of the system
  57379. */
  57380. setEmitter(newEmitter: any): void;
  57381. /**
  57382. * Get the lens flare system emitter position.
  57383. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  57384. * @returns the position
  57385. */
  57386. getEmitterPosition(): Vector3;
  57387. /**
  57388. * @hidden
  57389. */
  57390. computeEffectivePosition(globalViewport: Viewport): boolean;
  57391. /** @hidden */
  57392. _isVisible(): boolean;
  57393. /**
  57394. * @hidden
  57395. */
  57396. render(): boolean;
  57397. /**
  57398. * Dispose and release the lens flare with its associated resources.
  57399. */
  57400. dispose(): void;
  57401. /**
  57402. * Parse a lens flare system from a JSON repressentation
  57403. * @param parsedLensFlareSystem Define the JSON to parse
  57404. * @param scene Define the scene the parsed system should be instantiated in
  57405. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  57406. * @returns the parsed system
  57407. */
  57408. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  57409. /**
  57410. * Serialize the current Lens Flare System into a JSON representation.
  57411. * @returns the serialized JSON
  57412. */
  57413. serialize(): any;
  57414. }
  57415. }
  57416. declare module BABYLON {
  57417. /**
  57418. * This represents one of the lens effect in a `lensFlareSystem`.
  57419. * It controls one of the indiviual texture used in the effect.
  57420. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57421. */
  57422. export class LensFlare {
  57423. /**
  57424. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  57425. */
  57426. size: number;
  57427. /**
  57428. * 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.
  57429. */
  57430. position: number;
  57431. /**
  57432. * Define the lens color.
  57433. */
  57434. color: Color3;
  57435. /**
  57436. * Define the lens texture.
  57437. */
  57438. texture: Nullable<Texture>;
  57439. /**
  57440. * Define the alpha mode to render this particular lens.
  57441. */
  57442. alphaMode: number;
  57443. private _system;
  57444. /**
  57445. * Creates a new Lens Flare.
  57446. * This represents one of the lens effect in a `lensFlareSystem`.
  57447. * It controls one of the indiviual texture used in the effect.
  57448. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57449. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  57450. * @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.
  57451. * @param color Define the lens color
  57452. * @param imgUrl Define the lens texture url
  57453. * @param system Define the `lensFlareSystem` this flare is part of
  57454. * @returns The newly created Lens Flare
  57455. */
  57456. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  57457. /**
  57458. * Instantiates a new Lens Flare.
  57459. * This represents one of the lens effect in a `lensFlareSystem`.
  57460. * It controls one of the indiviual texture used in the effect.
  57461. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57462. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  57463. * @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.
  57464. * @param color Define the lens color
  57465. * @param imgUrl Define the lens texture url
  57466. * @param system Define the `lensFlareSystem` this flare is part of
  57467. */
  57468. constructor(
  57469. /**
  57470. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  57471. */
  57472. size: number,
  57473. /**
  57474. * 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.
  57475. */
  57476. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  57477. /**
  57478. * Dispose and release the lens flare with its associated resources.
  57479. */
  57480. dispose(): void;
  57481. }
  57482. }
  57483. declare module BABYLON {
  57484. interface AbstractScene {
  57485. /**
  57486. * The list of lens flare system added to the scene
  57487. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57488. */
  57489. lensFlareSystems: Array<LensFlareSystem>;
  57490. /**
  57491. * Removes the given lens flare system from this scene.
  57492. * @param toRemove The lens flare system to remove
  57493. * @returns The index of the removed lens flare system
  57494. */
  57495. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  57496. /**
  57497. * Adds the given lens flare system to this scene
  57498. * @param newLensFlareSystem The lens flare system to add
  57499. */
  57500. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  57501. /**
  57502. * Gets a lens flare system using its name
  57503. * @param name defines the name to look for
  57504. * @returns the lens flare system or null if not found
  57505. */
  57506. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  57507. /**
  57508. * Gets a lens flare system using its id
  57509. * @param id defines the id to look for
  57510. * @returns the lens flare system or null if not found
  57511. */
  57512. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  57513. }
  57514. /**
  57515. * Defines the lens flare scene component responsible to manage any lens flares
  57516. * in a given scene.
  57517. */
  57518. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  57519. /**
  57520. * The component name helpfull to identify the component in the list of scene components.
  57521. */
  57522. readonly name: string;
  57523. /**
  57524. * The scene the component belongs to.
  57525. */
  57526. scene: Scene;
  57527. /**
  57528. * Creates a new instance of the component for the given scene
  57529. * @param scene Defines the scene to register the component in
  57530. */
  57531. constructor(scene: Scene);
  57532. /**
  57533. * Registers the component in a given scene
  57534. */
  57535. register(): void;
  57536. /**
  57537. * Rebuilds the elements related to this component in case of
  57538. * context lost for instance.
  57539. */
  57540. rebuild(): void;
  57541. /**
  57542. * Adds all the elements from the container to the scene
  57543. * @param container the container holding the elements
  57544. */
  57545. addFromContainer(container: AbstractScene): void;
  57546. /**
  57547. * Removes all the elements in the container from the scene
  57548. * @param container contains the elements to remove
  57549. * @param dispose if the removed element should be disposed (default: false)
  57550. */
  57551. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57552. /**
  57553. * Serializes the component data to the specified json object
  57554. * @param serializationObject The object to serialize to
  57555. */
  57556. serialize(serializationObject: any): void;
  57557. /**
  57558. * Disposes the component and the associated ressources.
  57559. */
  57560. dispose(): void;
  57561. private _draw;
  57562. }
  57563. }
  57564. declare module BABYLON {
  57565. /** @hidden */
  57566. export var depthPixelShader: {
  57567. name: string;
  57568. shader: string;
  57569. };
  57570. }
  57571. declare module BABYLON {
  57572. /** @hidden */
  57573. export var depthVertexShader: {
  57574. name: string;
  57575. shader: string;
  57576. };
  57577. }
  57578. declare module BABYLON {
  57579. /**
  57580. * This represents a depth renderer in Babylon.
  57581. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  57582. */
  57583. export class DepthRenderer {
  57584. private _scene;
  57585. private _depthMap;
  57586. private _effect;
  57587. private readonly _storeNonLinearDepth;
  57588. private readonly _clearColor;
  57589. /** Get if the depth renderer is using packed depth or not */
  57590. readonly isPacked: boolean;
  57591. private _cachedDefines;
  57592. private _camera;
  57593. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  57594. enabled: boolean;
  57595. /**
  57596. * Specifiess that the depth renderer will only be used within
  57597. * the camera it is created for.
  57598. * This can help forcing its rendering during the camera processing.
  57599. */
  57600. useOnlyInActiveCamera: boolean;
  57601. /** @hidden */
  57602. static _SceneComponentInitialization: (scene: Scene) => void;
  57603. /**
  57604. * Instantiates a depth renderer
  57605. * @param scene The scene the renderer belongs to
  57606. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  57607. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  57608. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  57609. */
  57610. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  57611. /**
  57612. * Creates the depth rendering effect and checks if the effect is ready.
  57613. * @param subMesh The submesh to be used to render the depth map of
  57614. * @param useInstances If multiple world instances should be used
  57615. * @returns if the depth renderer is ready to render the depth map
  57616. */
  57617. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57618. /**
  57619. * Gets the texture which the depth map will be written to.
  57620. * @returns The depth map texture
  57621. */
  57622. getDepthMap(): RenderTargetTexture;
  57623. /**
  57624. * Disposes of the depth renderer.
  57625. */
  57626. dispose(): void;
  57627. }
  57628. }
  57629. declare module BABYLON {
  57630. /** @hidden */
  57631. export var minmaxReduxPixelShader: {
  57632. name: string;
  57633. shader: string;
  57634. };
  57635. }
  57636. declare module BABYLON {
  57637. /**
  57638. * This class computes a min/max reduction from a texture: it means it computes the minimum
  57639. * and maximum values from all values of the texture.
  57640. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  57641. * The source values are read from the red channel of the texture.
  57642. */
  57643. export class MinMaxReducer {
  57644. /**
  57645. * Observable triggered when the computation has been performed
  57646. */
  57647. onAfterReductionPerformed: Observable<{
  57648. min: number;
  57649. max: number;
  57650. }>;
  57651. protected _camera: Camera;
  57652. protected _sourceTexture: Nullable<RenderTargetTexture>;
  57653. protected _reductionSteps: Nullable<Array<PostProcess>>;
  57654. protected _postProcessManager: PostProcessManager;
  57655. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  57656. protected _forceFullscreenViewport: boolean;
  57657. /**
  57658. * Creates a min/max reducer
  57659. * @param camera The camera to use for the post processes
  57660. */
  57661. constructor(camera: Camera);
  57662. /**
  57663. * Gets the texture used to read the values from.
  57664. */
  57665. get sourceTexture(): Nullable<RenderTargetTexture>;
  57666. /**
  57667. * Sets the source texture to read the values from.
  57668. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  57669. * because in such textures '1' value must not be taken into account to compute the maximum
  57670. * as this value is used to clear the texture.
  57671. * Note that the computation is not activated by calling this function, you must call activate() for that!
  57672. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  57673. * @param depthRedux Indicates if the texture is a depth texture or not
  57674. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  57675. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  57676. */
  57677. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  57678. /**
  57679. * Defines the refresh rate of the computation.
  57680. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  57681. */
  57682. get refreshRate(): number;
  57683. set refreshRate(value: number);
  57684. protected _activated: boolean;
  57685. /**
  57686. * Gets the activation status of the reducer
  57687. */
  57688. get activated(): boolean;
  57689. /**
  57690. * Activates the reduction computation.
  57691. * When activated, the observers registered in onAfterReductionPerformed are
  57692. * called after the compuation is performed
  57693. */
  57694. activate(): void;
  57695. /**
  57696. * Deactivates the reduction computation.
  57697. */
  57698. deactivate(): void;
  57699. /**
  57700. * Disposes the min/max reducer
  57701. * @param disposeAll true to dispose all the resources. You should always call this function with true as the parameter (or without any parameter as it is the default one). This flag is meant to be used internally.
  57702. */
  57703. dispose(disposeAll?: boolean): void;
  57704. }
  57705. }
  57706. declare module BABYLON {
  57707. /**
  57708. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  57709. */
  57710. export class DepthReducer extends MinMaxReducer {
  57711. private _depthRenderer;
  57712. private _depthRendererId;
  57713. /**
  57714. * Gets the depth renderer used for the computation.
  57715. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  57716. */
  57717. get depthRenderer(): Nullable<DepthRenderer>;
  57718. /**
  57719. * Creates a depth reducer
  57720. * @param camera The camera used to render the depth texture
  57721. */
  57722. constructor(camera: Camera);
  57723. /**
  57724. * Sets the depth renderer to use to generate the depth map
  57725. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  57726. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  57727. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  57728. */
  57729. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  57730. /** @hidden */
  57731. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  57732. /**
  57733. * Activates the reduction computation.
  57734. * When activated, the observers registered in onAfterReductionPerformed are
  57735. * called after the compuation is performed
  57736. */
  57737. activate(): void;
  57738. /**
  57739. * Deactivates the reduction computation.
  57740. */
  57741. deactivate(): void;
  57742. /**
  57743. * Disposes the depth reducer
  57744. * @param disposeAll true to dispose all the resources. You should always call this function with true as the parameter (or without any parameter as it is the default one). This flag is meant to be used internally.
  57745. */
  57746. dispose(disposeAll?: boolean): void;
  57747. }
  57748. }
  57749. declare module BABYLON {
  57750. /**
  57751. * A CSM implementation allowing casting shadows on large scenes.
  57752. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  57753. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  57754. */
  57755. export class CascadedShadowGenerator extends ShadowGenerator {
  57756. private static readonly frustumCornersNDCSpace;
  57757. /**
  57758. * Name of the CSM class
  57759. */
  57760. static CLASSNAME: string;
  57761. /**
  57762. * Defines the default number of cascades used by the CSM.
  57763. */
  57764. static readonly DEFAULT_CASCADES_COUNT: number;
  57765. /**
  57766. * Defines the minimum number of cascades used by the CSM.
  57767. */
  57768. static readonly MIN_CASCADES_COUNT: number;
  57769. /**
  57770. * Defines the maximum number of cascades used by the CSM.
  57771. */
  57772. static readonly MAX_CASCADES_COUNT: number;
  57773. protected _validateFilter(filter: number): number;
  57774. /**
  57775. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  57776. */
  57777. penumbraDarkness: number;
  57778. private _numCascades;
  57779. /**
  57780. * Gets or set the number of cascades used by the CSM.
  57781. */
  57782. get numCascades(): number;
  57783. set numCascades(value: number);
  57784. /**
  57785. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  57786. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  57787. */
  57788. stabilizeCascades: boolean;
  57789. private _freezeShadowCastersBoundingInfo;
  57790. private _freezeShadowCastersBoundingInfoObservable;
  57791. /**
  57792. * Enables or disables the shadow casters bounding info computation.
  57793. * If your shadow casters don't move, you can disable this feature.
  57794. * If it is enabled, the bounding box computation is done every frame.
  57795. */
  57796. get freezeShadowCastersBoundingInfo(): boolean;
  57797. set freezeShadowCastersBoundingInfo(freeze: boolean);
  57798. private _scbiMin;
  57799. private _scbiMax;
  57800. protected _computeShadowCastersBoundingInfo(): void;
  57801. protected _shadowCastersBoundingInfo: BoundingInfo;
  57802. /**
  57803. * Gets or sets the shadow casters bounding info.
  57804. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  57805. * so that the system won't overwrite the bounds you provide
  57806. */
  57807. get shadowCastersBoundingInfo(): BoundingInfo;
  57808. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  57809. protected _breaksAreDirty: boolean;
  57810. protected _minDistance: number;
  57811. protected _maxDistance: number;
  57812. /**
  57813. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  57814. *
  57815. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  57816. * If you don't know these values, simply leave them to their defaults and don't call this function.
  57817. * @param min minimal distance for the breaks (default to 0.)
  57818. * @param max maximal distance for the breaks (default to 1.)
  57819. */
  57820. setMinMaxDistance(min: number, max: number): void;
  57821. /** Gets the minimal distance used in the cascade break computation */
  57822. get minDistance(): number;
  57823. /** Gets the maximal distance used in the cascade break computation */
  57824. get maxDistance(): number;
  57825. /**
  57826. * Gets the class name of that object
  57827. * @returns "CascadedShadowGenerator"
  57828. */
  57829. getClassName(): string;
  57830. private _cascadeMinExtents;
  57831. private _cascadeMaxExtents;
  57832. /**
  57833. * Gets a cascade minimum extents
  57834. * @param cascadeIndex index of the cascade
  57835. * @returns the minimum cascade extents
  57836. */
  57837. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  57838. /**
  57839. * Gets a cascade maximum extents
  57840. * @param cascadeIndex index of the cascade
  57841. * @returns the maximum cascade extents
  57842. */
  57843. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  57844. private _cascades;
  57845. private _currentLayer;
  57846. private _viewSpaceFrustumsZ;
  57847. private _viewMatrices;
  57848. private _projectionMatrices;
  57849. private _transformMatrices;
  57850. private _transformMatricesAsArray;
  57851. private _frustumLengths;
  57852. private _lightSizeUVCorrection;
  57853. private _depthCorrection;
  57854. private _frustumCornersWorldSpace;
  57855. private _frustumCenter;
  57856. private _shadowCameraPos;
  57857. private _shadowMaxZ;
  57858. /**
  57859. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  57860. * It defaults to camera.maxZ
  57861. */
  57862. get shadowMaxZ(): number;
  57863. /**
  57864. * Sets the shadow max z distance.
  57865. */
  57866. set shadowMaxZ(value: number);
  57867. protected _debug: boolean;
  57868. /**
  57869. * Gets or sets the debug flag.
  57870. * When enabled, the cascades are materialized by different colors on the screen.
  57871. */
  57872. get debug(): boolean;
  57873. set debug(dbg: boolean);
  57874. private _depthClamp;
  57875. /**
  57876. * Gets or sets the depth clamping value.
  57877. *
  57878. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  57879. * to account for the shadow casters far away.
  57880. *
  57881. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  57882. */
  57883. get depthClamp(): boolean;
  57884. set depthClamp(value: boolean);
  57885. private _cascadeBlendPercentage;
  57886. /**
  57887. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  57888. * It defaults to 0.1 (10% blending).
  57889. */
  57890. get cascadeBlendPercentage(): number;
  57891. set cascadeBlendPercentage(value: number);
  57892. private _lambda;
  57893. /**
  57894. * Gets or set the lambda parameter.
  57895. * This parameter is used to split the camera frustum and create the cascades.
  57896. * It's a value between 0. and 1.: If 0, the split is a uniform split of the frustum, if 1 it is a logarithmic split.
  57897. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  57898. */
  57899. get lambda(): number;
  57900. set lambda(value: number);
  57901. /**
  57902. * Gets the view matrix corresponding to a given cascade
  57903. * @param cascadeNum cascade to retrieve the view matrix from
  57904. * @returns the cascade view matrix
  57905. */
  57906. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  57907. /**
  57908. * Gets the projection matrix corresponding to a given cascade
  57909. * @param cascadeNum cascade to retrieve the projection matrix from
  57910. * @returns the cascade projection matrix
  57911. */
  57912. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  57913. /**
  57914. * Gets the transformation matrix corresponding to a given cascade
  57915. * @param cascadeNum cascade to retrieve the transformation matrix from
  57916. * @returns the cascade transformation matrix
  57917. */
  57918. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  57919. private _depthRenderer;
  57920. /**
  57921. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  57922. *
  57923. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  57924. *
  57925. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  57926. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  57927. * @param depthRenderer The depth renderer to use when autoCalcDepthBounds is enabled. If you pass null or don't call this function at all, a depth renderer will be automatically created
  57928. */
  57929. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  57930. private _depthReducer;
  57931. private _autoCalcDepthBounds;
  57932. /**
  57933. * Gets or sets the autoCalcDepthBounds property.
  57934. *
  57935. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  57936. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  57937. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  57938. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  57939. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  57940. */
  57941. get autoCalcDepthBounds(): boolean;
  57942. set autoCalcDepthBounds(value: boolean);
  57943. /**
  57944. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  57945. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  57946. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  57947. * for setting the refresh rate on the renderer yourself!
  57948. */
  57949. get autoCalcDepthBoundsRefreshRate(): number;
  57950. set autoCalcDepthBoundsRefreshRate(value: number);
  57951. /**
  57952. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  57953. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  57954. * you change the camera near/far planes!
  57955. */
  57956. splitFrustum(): void;
  57957. private _splitFrustum;
  57958. private _computeMatrices;
  57959. private _computeFrustumInWorldSpace;
  57960. private _computeCascadeFrustum;
  57961. /**
  57962. * Support test.
  57963. */
  57964. static get IsSupported(): boolean;
  57965. /** @hidden */
  57966. static _SceneComponentInitialization: (scene: Scene) => void;
  57967. /**
  57968. * Creates a Cascaded Shadow Generator object.
  57969. * A ShadowGenerator is the required tool to use the shadows.
  57970. * Each directional light casting shadows needs to use its own ShadowGenerator.
  57971. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  57972. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  57973. * @param light The directional light object generating the shadows.
  57974. * @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.
  57975. */
  57976. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  57977. protected _initializeGenerator(): void;
  57978. protected _createTargetRenderTexture(): void;
  57979. protected _initializeShadowMap(): void;
  57980. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  57981. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  57982. /**
  57983. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  57984. * @param defines Defines of the material we want to update
  57985. * @param lightIndex Index of the light in the enabled light list of the material
  57986. */
  57987. prepareDefines(defines: any, lightIndex: number): void;
  57988. /**
  57989. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  57990. * defined in the generator but impacting the effect).
  57991. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  57992. * @param effect The effect we are binfing the information for
  57993. */
  57994. bindShadowLight(lightIndex: string, effect: Effect): void;
  57995. /**
  57996. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  57997. * (eq to view projection * shadow projection matrices)
  57998. * @returns The transform matrix used to create the shadow map
  57999. */
  58000. getTransformMatrix(): Matrix;
  58001. /**
  58002. * Disposes the ShadowGenerator.
  58003. * Returns nothing.
  58004. */
  58005. dispose(): void;
  58006. /**
  58007. * Serializes the shadow generator setup to a json object.
  58008. * @returns The serialized JSON object
  58009. */
  58010. serialize(): any;
  58011. /**
  58012. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  58013. * @param parsedShadowGenerator The JSON object to parse
  58014. * @param scene The scene to create the shadow map for
  58015. * @returns The parsed shadow generator
  58016. */
  58017. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  58018. }
  58019. }
  58020. declare module BABYLON {
  58021. /**
  58022. * Defines the shadow generator component responsible to manage any shadow generators
  58023. * in a given scene.
  58024. */
  58025. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  58026. /**
  58027. * The component name helpfull to identify the component in the list of scene components.
  58028. */
  58029. readonly name: string;
  58030. /**
  58031. * The scene the component belongs to.
  58032. */
  58033. scene: Scene;
  58034. /**
  58035. * Creates a new instance of the component for the given scene
  58036. * @param scene Defines the scene to register the component in
  58037. */
  58038. constructor(scene: Scene);
  58039. /**
  58040. * Registers the component in a given scene
  58041. */
  58042. register(): void;
  58043. /**
  58044. * Rebuilds the elements related to this component in case of
  58045. * context lost for instance.
  58046. */
  58047. rebuild(): void;
  58048. /**
  58049. * Serializes the component data to the specified json object
  58050. * @param serializationObject The object to serialize to
  58051. */
  58052. serialize(serializationObject: any): void;
  58053. /**
  58054. * Adds all the elements from the container to the scene
  58055. * @param container the container holding the elements
  58056. */
  58057. addFromContainer(container: AbstractScene): void;
  58058. /**
  58059. * Removes all the elements in the container from the scene
  58060. * @param container contains the elements to remove
  58061. * @param dispose if the removed element should be disposed (default: false)
  58062. */
  58063. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  58064. /**
  58065. * Rebuilds the elements related to this component in case of
  58066. * context lost for instance.
  58067. */
  58068. dispose(): void;
  58069. private _gatherRenderTargets;
  58070. }
  58071. }
  58072. declare module BABYLON {
  58073. /**
  58074. * A point light is a light defined by an unique point in world space.
  58075. * The light is emitted in every direction from this point.
  58076. * A good example of a point light is a standard light bulb.
  58077. * Documentation: https://doc.babylonjs.com/babylon101/lights
  58078. */
  58079. export class PointLight extends ShadowLight {
  58080. private _shadowAngle;
  58081. /**
  58082. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58083. * This specifies what angle the shadow will use to be created.
  58084. *
  58085. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  58086. */
  58087. get shadowAngle(): number;
  58088. /**
  58089. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58090. * This specifies what angle the shadow will use to be created.
  58091. *
  58092. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  58093. */
  58094. set shadowAngle(value: number);
  58095. /**
  58096. * Gets the direction if it has been set.
  58097. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58098. */
  58099. get direction(): Vector3;
  58100. /**
  58101. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58102. */
  58103. set direction(value: Vector3);
  58104. /**
  58105. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  58106. * A PointLight emits the light in every direction.
  58107. * It can cast shadows.
  58108. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  58109. * ```javascript
  58110. * var pointLight = new PointLight("pl", camera.position, scene);
  58111. * ```
  58112. * Documentation : https://doc.babylonjs.com/babylon101/lights
  58113. * @param name The light friendly name
  58114. * @param position The position of the point light in the scene
  58115. * @param scene The scene the lights belongs to
  58116. */
  58117. constructor(name: string, position: Vector3, scene: Scene);
  58118. /**
  58119. * Returns the string "PointLight"
  58120. * @returns the class name
  58121. */
  58122. getClassName(): string;
  58123. /**
  58124. * Returns the integer 0.
  58125. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  58126. */
  58127. getTypeID(): number;
  58128. /**
  58129. * Specifies wether or not the shadowmap should be a cube texture.
  58130. * @returns true if the shadowmap needs to be a cube texture.
  58131. */
  58132. needCube(): boolean;
  58133. /**
  58134. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  58135. * @param faceIndex The index of the face we are computed the direction to generate shadow
  58136. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  58137. */
  58138. getShadowDirection(faceIndex?: number): Vector3;
  58139. /**
  58140. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  58141. * - fov = PI / 2
  58142. * - aspect ratio : 1.0
  58143. * - z-near and far equal to the active camera minZ and maxZ.
  58144. * Returns the PointLight.
  58145. */
  58146. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  58147. protected _buildUniformLayout(): void;
  58148. /**
  58149. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  58150. * @param effect The effect to update
  58151. * @param lightIndex The index of the light in the effect to update
  58152. * @returns The point light
  58153. */
  58154. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  58155. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  58156. /**
  58157. * Prepares the list of defines specific to the light type.
  58158. * @param defines the list of defines
  58159. * @param lightIndex defines the index of the light for the effect
  58160. */
  58161. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  58162. }
  58163. }
  58164. declare module BABYLON {
  58165. /**
  58166. * Header information of HDR texture files.
  58167. */
  58168. export interface HDRInfo {
  58169. /**
  58170. * The height of the texture in pixels.
  58171. */
  58172. height: number;
  58173. /**
  58174. * The width of the texture in pixels.
  58175. */
  58176. width: number;
  58177. /**
  58178. * The index of the beginning of the data in the binary file.
  58179. */
  58180. dataPosition: number;
  58181. }
  58182. /**
  58183. * This groups tools to convert HDR texture to native colors array.
  58184. */
  58185. export class HDRTools {
  58186. private static Ldexp;
  58187. private static Rgbe2float;
  58188. private static readStringLine;
  58189. /**
  58190. * Reads header information from an RGBE texture stored in a native array.
  58191. * More information on this format are available here:
  58192. * https://en.wikipedia.org/wiki/RGBE_image_format
  58193. *
  58194. * @param uint8array The binary file stored in native array.
  58195. * @return The header information.
  58196. */
  58197. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  58198. /**
  58199. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  58200. * This RGBE texture needs to store the information as a panorama.
  58201. *
  58202. * More information on this format are available here:
  58203. * https://en.wikipedia.org/wiki/RGBE_image_format
  58204. *
  58205. * @param buffer The binary file stored in an array buffer.
  58206. * @param size The expected size of the extracted cubemap.
  58207. * @return The Cube Map information.
  58208. */
  58209. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  58210. /**
  58211. * Returns the pixels data extracted from an RGBE texture.
  58212. * This pixels will be stored left to right up to down in the R G B order in one array.
  58213. *
  58214. * More information on this format are available here:
  58215. * https://en.wikipedia.org/wiki/RGBE_image_format
  58216. *
  58217. * @param uint8array The binary file stored in an array buffer.
  58218. * @param hdrInfo The header information of the file.
  58219. * @return The pixels data in RGB right to left up to down order.
  58220. */
  58221. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  58222. private static RGBE_ReadPixels_RLE;
  58223. }
  58224. }
  58225. declare module BABYLON {
  58226. /**
  58227. * Effect Render Options
  58228. */
  58229. export interface IEffectRendererOptions {
  58230. /**
  58231. * Defines the vertices positions.
  58232. */
  58233. positions?: number[];
  58234. /**
  58235. * Defines the indices.
  58236. */
  58237. indices?: number[];
  58238. }
  58239. /**
  58240. * Helper class to render one or more effects.
  58241. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  58242. */
  58243. export class EffectRenderer {
  58244. private engine;
  58245. private static _DefaultOptions;
  58246. private _vertexBuffers;
  58247. private _indexBuffer;
  58248. private _fullscreenViewport;
  58249. /**
  58250. * Creates an effect renderer
  58251. * @param engine the engine to use for rendering
  58252. * @param options defines the options of the effect renderer
  58253. */
  58254. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  58255. /**
  58256. * Sets the current viewport in normalized coordinates 0-1
  58257. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  58258. */
  58259. setViewport(viewport?: Viewport): void;
  58260. /**
  58261. * Binds the embedded attributes buffer to the effect.
  58262. * @param effect Defines the effect to bind the attributes for
  58263. */
  58264. bindBuffers(effect: Effect): void;
  58265. /**
  58266. * Sets the current effect wrapper to use during draw.
  58267. * The effect needs to be ready before calling this api.
  58268. * This also sets the default full screen position attribute.
  58269. * @param effectWrapper Defines the effect to draw with
  58270. */
  58271. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  58272. /**
  58273. * Restores engine states
  58274. */
  58275. restoreStates(): void;
  58276. /**
  58277. * Draws a full screen quad.
  58278. */
  58279. draw(): void;
  58280. private isRenderTargetTexture;
  58281. /**
  58282. * renders one or more effects to a specified texture
  58283. * @param effectWrapper the effect to renderer
  58284. * @param outputTexture texture to draw to, if null it will render to the screen.
  58285. */
  58286. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  58287. /**
  58288. * Disposes of the effect renderer
  58289. */
  58290. dispose(): void;
  58291. }
  58292. /**
  58293. * Options to create an EffectWrapper
  58294. */
  58295. interface EffectWrapperCreationOptions {
  58296. /**
  58297. * Engine to use to create the effect
  58298. */
  58299. engine: ThinEngine;
  58300. /**
  58301. * Fragment shader for the effect
  58302. */
  58303. fragmentShader: string;
  58304. /**
  58305. * Use the shader store instead of direct source code
  58306. */
  58307. useShaderStore?: boolean;
  58308. /**
  58309. * Vertex shader for the effect
  58310. */
  58311. vertexShader?: string;
  58312. /**
  58313. * Attributes to use in the shader
  58314. */
  58315. attributeNames?: Array<string>;
  58316. /**
  58317. * Uniforms to use in the shader
  58318. */
  58319. uniformNames?: Array<string>;
  58320. /**
  58321. * Texture sampler names to use in the shader
  58322. */
  58323. samplerNames?: Array<string>;
  58324. /**
  58325. * Defines to use in the shader
  58326. */
  58327. defines?: Array<string>;
  58328. /**
  58329. * Callback when effect is compiled
  58330. */
  58331. onCompiled?: Nullable<(effect: Effect) => void>;
  58332. /**
  58333. * The friendly name of the effect displayed in Spector.
  58334. */
  58335. name?: string;
  58336. }
  58337. /**
  58338. * Wraps an effect to be used for rendering
  58339. */
  58340. export class EffectWrapper {
  58341. /**
  58342. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  58343. */
  58344. onApplyObservable: Observable<{}>;
  58345. /**
  58346. * The underlying effect
  58347. */
  58348. effect: Effect;
  58349. /**
  58350. * Creates an effect to be renderer
  58351. * @param creationOptions options to create the effect
  58352. */
  58353. constructor(creationOptions: EffectWrapperCreationOptions);
  58354. /**
  58355. * Disposes of the effect wrapper
  58356. */
  58357. dispose(): void;
  58358. }
  58359. }
  58360. declare module BABYLON {
  58361. /** @hidden */
  58362. export var hdrFilteringVertexShader: {
  58363. name: string;
  58364. shader: string;
  58365. };
  58366. }
  58367. declare module BABYLON {
  58368. /** @hidden */
  58369. export var hdrFilteringPixelShader: {
  58370. name: string;
  58371. shader: string;
  58372. };
  58373. }
  58374. declare module BABYLON {
  58375. /**
  58376. * Options for texture filtering
  58377. */
  58378. interface IHDRFilteringOptions {
  58379. /**
  58380. * Scales pixel intensity for the input HDR map.
  58381. */
  58382. hdrScale?: number;
  58383. /**
  58384. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  58385. */
  58386. quality?: number;
  58387. }
  58388. /**
  58389. * Filters HDR maps to get correct renderings of PBR reflections
  58390. */
  58391. export class HDRFiltering {
  58392. private _engine;
  58393. private _effectRenderer;
  58394. private _effectWrapper;
  58395. private _lodGenerationOffset;
  58396. private _lodGenerationScale;
  58397. /**
  58398. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  58399. * you care about baking speed.
  58400. */
  58401. quality: number;
  58402. /**
  58403. * Scales pixel intensity for the input HDR map.
  58404. */
  58405. hdrScale: number;
  58406. /**
  58407. * Instantiates HDR filter for reflection maps
  58408. *
  58409. * @param engine Thin engine
  58410. * @param options Options
  58411. */
  58412. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  58413. private _createRenderTarget;
  58414. private _prefilterInternal;
  58415. private _createEffect;
  58416. /**
  58417. * Get a value indicating if the filter is ready to be used
  58418. * @param texture Texture to filter
  58419. * @returns true if the filter is ready
  58420. */
  58421. isReady(texture: BaseTexture): boolean;
  58422. /**
  58423. * Prefilters a cube texture to have mipmap levels representing roughness values.
  58424. * Prefiltering will be invoked at the end of next rendering pass.
  58425. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  58426. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  58427. * @param texture Texture to filter
  58428. * @param onFinished Callback when filtering is done
  58429. * @return Promise called when prefiltering is done
  58430. */
  58431. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown>;
  58432. }
  58433. }
  58434. declare module BABYLON {
  58435. /**
  58436. * This represents a texture coming from an HDR input.
  58437. *
  58438. * The only supported format is currently panorama picture stored in RGBE format.
  58439. * Example of such files can be found on HDRLib: http://hdrlib.com/
  58440. */
  58441. export class HDRCubeTexture extends BaseTexture {
  58442. private static _facesMapping;
  58443. private _generateHarmonics;
  58444. private _noMipmap;
  58445. private _prefilterOnLoad;
  58446. private _textureMatrix;
  58447. private _size;
  58448. private _onLoad;
  58449. private _onError;
  58450. /**
  58451. * The texture URL.
  58452. */
  58453. url: string;
  58454. /**
  58455. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  58456. */
  58457. coordinatesMode: number;
  58458. protected _isBlocking: boolean;
  58459. /**
  58460. * Sets wether or not the texture is blocking during loading.
  58461. */
  58462. set isBlocking(value: boolean);
  58463. /**
  58464. * Gets wether or not the texture is blocking during loading.
  58465. */
  58466. get isBlocking(): boolean;
  58467. protected _rotationY: number;
  58468. /**
  58469. * Sets texture matrix rotation angle around Y axis in radians.
  58470. */
  58471. set rotationY(value: number);
  58472. /**
  58473. * Gets texture matrix rotation angle around Y axis radians.
  58474. */
  58475. get rotationY(): number;
  58476. /**
  58477. * Gets or sets the center of the bounding box associated with the cube texture
  58478. * It must define where the camera used to render the texture was set
  58479. */
  58480. boundingBoxPosition: Vector3;
  58481. private _boundingBoxSize;
  58482. /**
  58483. * Gets or sets the size of the bounding box associated with the cube texture
  58484. * When defined, the cubemap will switch to local mode
  58485. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  58486. * @example https://www.babylonjs-playground.com/#RNASML
  58487. */
  58488. set boundingBoxSize(value: Vector3);
  58489. get boundingBoxSize(): Vector3;
  58490. /**
  58491. * Instantiates an HDRTexture from the following parameters.
  58492. *
  58493. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  58494. * @param sceneOrEngine The scene or engine the texture will be used in
  58495. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  58496. * @param noMipmap Forces to not generate the mipmap if true
  58497. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  58498. * @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)
  58499. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  58500. */
  58501. constructor(url: string, sceneOrEngine: Scene | ThinEngine, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, prefilterOnLoad?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  58502. /**
  58503. * Get the current class name of the texture useful for serialization or dynamic coding.
  58504. * @returns "HDRCubeTexture"
  58505. */
  58506. getClassName(): string;
  58507. /**
  58508. * Occurs when the file is raw .hdr file.
  58509. */
  58510. private loadTexture;
  58511. clone(): HDRCubeTexture;
  58512. delayLoad(): void;
  58513. /**
  58514. * Get the texture reflection matrix used to rotate/transform the reflection.
  58515. * @returns the reflection matrix
  58516. */
  58517. getReflectionTextureMatrix(): Matrix;
  58518. /**
  58519. * Set the texture reflection matrix used to rotate/transform the reflection.
  58520. * @param value Define the reflection matrix to set
  58521. */
  58522. setReflectionTextureMatrix(value: Matrix): void;
  58523. /**
  58524. * Parses a JSON representation of an HDR Texture in order to create the texture
  58525. * @param parsedTexture Define the JSON representation
  58526. * @param scene Define the scene the texture should be created in
  58527. * @param rootUrl Define the root url in case we need to load relative dependencies
  58528. * @returns the newly created texture after parsing
  58529. */
  58530. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  58531. serialize(): any;
  58532. }
  58533. }
  58534. declare module BABYLON {
  58535. /**
  58536. * Class used to control physics engine
  58537. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  58538. */
  58539. export class PhysicsEngine implements IPhysicsEngine {
  58540. private _physicsPlugin;
  58541. /**
  58542. * Global value used to control the smallest number supported by the simulation
  58543. */
  58544. static Epsilon: number;
  58545. private _impostors;
  58546. private _joints;
  58547. private _subTimeStep;
  58548. /**
  58549. * Gets the gravity vector used by the simulation
  58550. */
  58551. gravity: Vector3;
  58552. /**
  58553. * Factory used to create the default physics plugin.
  58554. * @returns The default physics plugin
  58555. */
  58556. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  58557. /**
  58558. * Creates a new Physics Engine
  58559. * @param gravity defines the gravity vector used by the simulation
  58560. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  58561. */
  58562. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  58563. /**
  58564. * Sets the gravity vector used by the simulation
  58565. * @param gravity defines the gravity vector to use
  58566. */
  58567. setGravity(gravity: Vector3): void;
  58568. /**
  58569. * Set the time step of the physics engine.
  58570. * Default is 1/60.
  58571. * To slow it down, enter 1/600 for example.
  58572. * To speed it up, 1/30
  58573. * @param newTimeStep defines the new timestep to apply to this world.
  58574. */
  58575. setTimeStep(newTimeStep?: number): void;
  58576. /**
  58577. * Get the time step of the physics engine.
  58578. * @returns the current time step
  58579. */
  58580. getTimeStep(): number;
  58581. /**
  58582. * Set the sub time step of the physics engine.
  58583. * Default is 0 meaning there is no sub steps
  58584. * To increase physics resolution precision, set a small value (like 1 ms)
  58585. * @param subTimeStep defines the new sub timestep used for physics resolution.
  58586. */
  58587. setSubTimeStep(subTimeStep?: number): void;
  58588. /**
  58589. * Get the sub time step of the physics engine.
  58590. * @returns the current sub time step
  58591. */
  58592. getSubTimeStep(): number;
  58593. /**
  58594. * Release all resources
  58595. */
  58596. dispose(): void;
  58597. /**
  58598. * Gets the name of the current physics plugin
  58599. * @returns the name of the plugin
  58600. */
  58601. getPhysicsPluginName(): string;
  58602. /**
  58603. * Adding a new impostor for the impostor tracking.
  58604. * This will be done by the impostor itself.
  58605. * @param impostor the impostor to add
  58606. */
  58607. addImpostor(impostor: PhysicsImpostor): void;
  58608. /**
  58609. * Remove an impostor from the engine.
  58610. * This impostor and its mesh will not longer be updated by the physics engine.
  58611. * @param impostor the impostor to remove
  58612. */
  58613. removeImpostor(impostor: PhysicsImpostor): void;
  58614. /**
  58615. * Add a joint to the physics engine
  58616. * @param mainImpostor defines the main impostor to which the joint is added.
  58617. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  58618. * @param joint defines the joint that will connect both impostors.
  58619. */
  58620. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  58621. /**
  58622. * Removes a joint from the simulation
  58623. * @param mainImpostor defines the impostor used with the joint
  58624. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  58625. * @param joint defines the joint to remove
  58626. */
  58627. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  58628. /**
  58629. * Called by the scene. No need to call it.
  58630. * @param delta defines the timespam between frames
  58631. */
  58632. _step(delta: number): void;
  58633. /**
  58634. * Gets the current plugin used to run the simulation
  58635. * @returns current plugin
  58636. */
  58637. getPhysicsPlugin(): IPhysicsEnginePlugin;
  58638. /**
  58639. * Gets the list of physic impostors
  58640. * @returns an array of PhysicsImpostor
  58641. */
  58642. getImpostors(): Array<PhysicsImpostor>;
  58643. /**
  58644. * Gets the impostor for a physics enabled object
  58645. * @param object defines the object impersonated by the impostor
  58646. * @returns the PhysicsImpostor or null if not found
  58647. */
  58648. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  58649. /**
  58650. * Gets the impostor for a physics body object
  58651. * @param body defines physics body used by the impostor
  58652. * @returns the PhysicsImpostor or null if not found
  58653. */
  58654. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  58655. /**
  58656. * Does a raycast in the physics world
  58657. * @param from when should the ray start?
  58658. * @param to when should the ray end?
  58659. * @returns PhysicsRaycastResult
  58660. */
  58661. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  58662. }
  58663. }
  58664. declare module BABYLON {
  58665. /** @hidden */
  58666. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  58667. private _useDeltaForWorldStep;
  58668. world: any;
  58669. name: string;
  58670. private _physicsMaterials;
  58671. private _fixedTimeStep;
  58672. private _cannonRaycastResult;
  58673. private _raycastResult;
  58674. private _physicsBodysToRemoveAfterStep;
  58675. BJSCANNON: any;
  58676. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  58677. setGravity(gravity: Vector3): void;
  58678. setTimeStep(timeStep: number): void;
  58679. getTimeStep(): number;
  58680. executeStep(delta: number): void;
  58681. private _removeMarkedPhysicsBodiesFromWorld;
  58682. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58683. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58684. generatePhysicsBody(impostor: PhysicsImpostor): void;
  58685. private _processChildMeshes;
  58686. removePhysicsBody(impostor: PhysicsImpostor): void;
  58687. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  58688. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  58689. private _addMaterial;
  58690. private _checkWithEpsilon;
  58691. private _createShape;
  58692. private _createHeightmap;
  58693. private _minus90X;
  58694. private _plus90X;
  58695. private _tmpPosition;
  58696. private _tmpDeltaPosition;
  58697. private _tmpUnityRotation;
  58698. private _updatePhysicsBodyTransformation;
  58699. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  58700. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  58701. isSupported(): boolean;
  58702. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58703. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58704. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58705. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58706. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  58707. getBodyMass(impostor: PhysicsImpostor): number;
  58708. getBodyFriction(impostor: PhysicsImpostor): number;
  58709. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  58710. getBodyRestitution(impostor: PhysicsImpostor): number;
  58711. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  58712. sleepBody(impostor: PhysicsImpostor): void;
  58713. wakeUpBody(impostor: PhysicsImpostor): void;
  58714. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  58715. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  58716. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  58717. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  58718. getRadius(impostor: PhysicsImpostor): number;
  58719. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  58720. dispose(): void;
  58721. private _extendNamespace;
  58722. /**
  58723. * Does a raycast in the physics world
  58724. * @param from when should the ray start?
  58725. * @param to when should the ray end?
  58726. * @returns PhysicsRaycastResult
  58727. */
  58728. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  58729. }
  58730. }
  58731. declare module BABYLON {
  58732. /** @hidden */
  58733. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  58734. private _useDeltaForWorldStep;
  58735. world: any;
  58736. name: string;
  58737. BJSOIMO: any;
  58738. private _raycastResult;
  58739. private _fixedTimeStep;
  58740. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  58741. setGravity(gravity: Vector3): void;
  58742. setTimeStep(timeStep: number): void;
  58743. getTimeStep(): number;
  58744. private _tmpImpostorsArray;
  58745. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  58746. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58747. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58748. generatePhysicsBody(impostor: PhysicsImpostor): void;
  58749. private _tmpPositionVector;
  58750. removePhysicsBody(impostor: PhysicsImpostor): void;
  58751. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  58752. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  58753. isSupported(): boolean;
  58754. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  58755. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  58756. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58757. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58758. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58759. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58760. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  58761. getBodyMass(impostor: PhysicsImpostor): number;
  58762. getBodyFriction(impostor: PhysicsImpostor): number;
  58763. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  58764. getBodyRestitution(impostor: PhysicsImpostor): number;
  58765. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  58766. sleepBody(impostor: PhysicsImpostor): void;
  58767. wakeUpBody(impostor: PhysicsImpostor): void;
  58768. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  58769. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  58770. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  58771. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  58772. getRadius(impostor: PhysicsImpostor): number;
  58773. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  58774. dispose(): void;
  58775. /**
  58776. * Does a raycast in the physics world
  58777. * @param from when should the ray start?
  58778. * @param to when should the ray end?
  58779. * @returns PhysicsRaycastResult
  58780. */
  58781. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  58782. }
  58783. }
  58784. declare module BABYLON {
  58785. /**
  58786. * Class containing static functions to help procedurally build meshes
  58787. */
  58788. export class RibbonBuilder {
  58789. /**
  58790. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58791. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  58792. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  58793. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  58794. * * 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
  58795. * * 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
  58796. * * 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
  58797. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58798. * * 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
  58799. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58800. * * 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
  58801. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  58802. * * 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
  58803. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  58804. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58805. * @param name defines the name of the mesh
  58806. * @param options defines the options used to create the mesh
  58807. * @param scene defines the hosting scene
  58808. * @returns the ribbon mesh
  58809. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  58810. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58811. */
  58812. static CreateRibbon(name: string, options: {
  58813. pathArray: Vector3[][];
  58814. closeArray?: boolean;
  58815. closePath?: boolean;
  58816. offset?: number;
  58817. updatable?: boolean;
  58818. sideOrientation?: number;
  58819. frontUVs?: Vector4;
  58820. backUVs?: Vector4;
  58821. instance?: Mesh;
  58822. invertUV?: boolean;
  58823. uvs?: Vector2[];
  58824. colors?: Color4[];
  58825. }, scene?: Nullable<Scene>): Mesh;
  58826. }
  58827. }
  58828. declare module BABYLON {
  58829. /**
  58830. * Class containing static functions to help procedurally build meshes
  58831. */
  58832. export class ShapeBuilder {
  58833. /**
  58834. * 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.
  58835. * * 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.
  58836. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58837. * * 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.
  58838. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  58839. * * 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
  58840. * * 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
  58841. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  58842. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58843. * * 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
  58844. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  58845. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58846. * @param name defines the name of the mesh
  58847. * @param options defines the options used to create the mesh
  58848. * @param scene defines the hosting scene
  58849. * @returns the extruded shape mesh
  58850. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58851. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58852. */
  58853. static ExtrudeShape(name: string, options: {
  58854. shape: Vector3[];
  58855. path: Vector3[];
  58856. scale?: number;
  58857. rotation?: number;
  58858. cap?: number;
  58859. updatable?: boolean;
  58860. sideOrientation?: number;
  58861. frontUVs?: Vector4;
  58862. backUVs?: Vector4;
  58863. instance?: Mesh;
  58864. invertUV?: boolean;
  58865. }, scene?: Nullable<Scene>): Mesh;
  58866. /**
  58867. * Creates an custom extruded shape mesh.
  58868. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  58869. * * 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.
  58870. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58871. * * 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
  58872. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  58873. * * 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
  58874. * * It must returns a float value that will be the scale value applied to the shape on each path point
  58875. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  58876. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  58877. * * 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
  58878. * * 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
  58879. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  58880. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58881. * * 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
  58882. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58883. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58884. * @param name defines the name of the mesh
  58885. * @param options defines the options used to create the mesh
  58886. * @param scene defines the hosting scene
  58887. * @returns the custom extruded shape mesh
  58888. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  58889. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58890. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58891. */
  58892. static ExtrudeShapeCustom(name: string, options: {
  58893. shape: Vector3[];
  58894. path: Vector3[];
  58895. scaleFunction?: any;
  58896. rotationFunction?: any;
  58897. ribbonCloseArray?: boolean;
  58898. ribbonClosePath?: boolean;
  58899. cap?: number;
  58900. updatable?: boolean;
  58901. sideOrientation?: number;
  58902. frontUVs?: Vector4;
  58903. backUVs?: Vector4;
  58904. instance?: Mesh;
  58905. invertUV?: boolean;
  58906. }, scene?: Nullable<Scene>): Mesh;
  58907. private static _ExtrudeShapeGeneric;
  58908. }
  58909. }
  58910. declare module BABYLON {
  58911. /**
  58912. * AmmoJS Physics plugin
  58913. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  58914. * @see https://github.com/kripken/ammo.js/
  58915. */
  58916. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  58917. private _useDeltaForWorldStep;
  58918. /**
  58919. * Reference to the Ammo library
  58920. */
  58921. bjsAMMO: any;
  58922. /**
  58923. * Created ammoJS world which physics bodies are added to
  58924. */
  58925. world: any;
  58926. /**
  58927. * Name of the plugin
  58928. */
  58929. name: string;
  58930. private _timeStep;
  58931. private _fixedTimeStep;
  58932. private _maxSteps;
  58933. private _tmpQuaternion;
  58934. private _tmpAmmoTransform;
  58935. private _tmpAmmoQuaternion;
  58936. private _tmpAmmoConcreteContactResultCallback;
  58937. private _collisionConfiguration;
  58938. private _dispatcher;
  58939. private _overlappingPairCache;
  58940. private _solver;
  58941. private _softBodySolver;
  58942. private _tmpAmmoVectorA;
  58943. private _tmpAmmoVectorB;
  58944. private _tmpAmmoVectorC;
  58945. private _tmpAmmoVectorD;
  58946. private _tmpContactCallbackResult;
  58947. private _tmpAmmoVectorRCA;
  58948. private _tmpAmmoVectorRCB;
  58949. private _raycastResult;
  58950. private static readonly DISABLE_COLLISION_FLAG;
  58951. private static readonly KINEMATIC_FLAG;
  58952. private static readonly DISABLE_DEACTIVATION_FLAG;
  58953. /**
  58954. * Initializes the ammoJS plugin
  58955. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  58956. * @param ammoInjection can be used to inject your own ammo reference
  58957. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  58958. */
  58959. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  58960. /**
  58961. * Sets the gravity of the physics world (m/(s^2))
  58962. * @param gravity Gravity to set
  58963. */
  58964. setGravity(gravity: Vector3): void;
  58965. /**
  58966. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  58967. * @param timeStep timestep to use in seconds
  58968. */
  58969. setTimeStep(timeStep: number): void;
  58970. /**
  58971. * 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)
  58972. * @param fixedTimeStep fixedTimeStep to use in seconds
  58973. */
  58974. setFixedTimeStep(fixedTimeStep: number): void;
  58975. /**
  58976. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  58977. * @param maxSteps the maximum number of steps by the physics engine per frame
  58978. */
  58979. setMaxSteps(maxSteps: number): void;
  58980. /**
  58981. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  58982. * @returns the current timestep in seconds
  58983. */
  58984. getTimeStep(): number;
  58985. /**
  58986. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  58987. */
  58988. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  58989. private _isImpostorInContact;
  58990. private _isImpostorPairInContact;
  58991. private _stepSimulation;
  58992. /**
  58993. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  58994. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  58995. * After the step the babylon meshes are set to the position of the physics imposters
  58996. * @param delta amount of time to step forward
  58997. * @param impostors array of imposters to update before/after the step
  58998. */
  58999. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  59000. /**
  59001. * Update babylon mesh to match physics world object
  59002. * @param impostor imposter to match
  59003. */
  59004. private _afterSoftStep;
  59005. /**
  59006. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  59007. * @param impostor imposter to match
  59008. */
  59009. private _ropeStep;
  59010. /**
  59011. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  59012. * @param impostor imposter to match
  59013. */
  59014. private _softbodyOrClothStep;
  59015. private _tmpMatrix;
  59016. /**
  59017. * Applies an impulse on the imposter
  59018. * @param impostor imposter to apply impulse to
  59019. * @param force amount of force to be applied to the imposter
  59020. * @param contactPoint the location to apply the impulse on the imposter
  59021. */
  59022. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59023. /**
  59024. * Applies a force on the imposter
  59025. * @param impostor imposter to apply force
  59026. * @param force amount of force to be applied to the imposter
  59027. * @param contactPoint the location to apply the force on the imposter
  59028. */
  59029. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59030. /**
  59031. * Creates a physics body using the plugin
  59032. * @param impostor the imposter to create the physics body on
  59033. */
  59034. generatePhysicsBody(impostor: PhysicsImpostor): void;
  59035. /**
  59036. * Removes the physics body from the imposter and disposes of the body's memory
  59037. * @param impostor imposter to remove the physics body from
  59038. */
  59039. removePhysicsBody(impostor: PhysicsImpostor): void;
  59040. /**
  59041. * Generates a joint
  59042. * @param impostorJoint the imposter joint to create the joint with
  59043. */
  59044. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  59045. /**
  59046. * Removes a joint
  59047. * @param impostorJoint the imposter joint to remove the joint from
  59048. */
  59049. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  59050. private _addMeshVerts;
  59051. /**
  59052. * Initialise the soft body vertices to match its object's (mesh) vertices
  59053. * Softbody vertices (nodes) are in world space and to match this
  59054. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  59055. * @param impostor to create the softbody for
  59056. */
  59057. private _softVertexData;
  59058. /**
  59059. * Create an impostor's soft body
  59060. * @param impostor to create the softbody for
  59061. */
  59062. private _createSoftbody;
  59063. /**
  59064. * Create cloth for an impostor
  59065. * @param impostor to create the softbody for
  59066. */
  59067. private _createCloth;
  59068. /**
  59069. * Create rope for an impostor
  59070. * @param impostor to create the softbody for
  59071. */
  59072. private _createRope;
  59073. /**
  59074. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  59075. * @param impostor to create the custom physics shape for
  59076. */
  59077. private _createCustom;
  59078. private _addHullVerts;
  59079. private _createShape;
  59080. /**
  59081. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  59082. * @param impostor imposter containing the physics body and babylon object
  59083. */
  59084. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  59085. /**
  59086. * Sets the babylon object's position/rotation from the physics body's position/rotation
  59087. * @param impostor imposter containing the physics body and babylon object
  59088. * @param newPosition new position
  59089. * @param newRotation new rotation
  59090. */
  59091. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  59092. /**
  59093. * If this plugin is supported
  59094. * @returns true if its supported
  59095. */
  59096. isSupported(): boolean;
  59097. /**
  59098. * Sets the linear velocity of the physics body
  59099. * @param impostor imposter to set the velocity on
  59100. * @param velocity velocity to set
  59101. */
  59102. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59103. /**
  59104. * Sets the angular velocity of the physics body
  59105. * @param impostor imposter to set the velocity on
  59106. * @param velocity velocity to set
  59107. */
  59108. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59109. /**
  59110. * gets the linear velocity
  59111. * @param impostor imposter to get linear velocity from
  59112. * @returns linear velocity
  59113. */
  59114. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59115. /**
  59116. * gets the angular velocity
  59117. * @param impostor imposter to get angular velocity from
  59118. * @returns angular velocity
  59119. */
  59120. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59121. /**
  59122. * Sets the mass of physics body
  59123. * @param impostor imposter to set the mass on
  59124. * @param mass mass to set
  59125. */
  59126. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  59127. /**
  59128. * Gets the mass of the physics body
  59129. * @param impostor imposter to get the mass from
  59130. * @returns mass
  59131. */
  59132. getBodyMass(impostor: PhysicsImpostor): number;
  59133. /**
  59134. * Gets friction of the impostor
  59135. * @param impostor impostor to get friction from
  59136. * @returns friction value
  59137. */
  59138. getBodyFriction(impostor: PhysicsImpostor): number;
  59139. /**
  59140. * Sets friction of the impostor
  59141. * @param impostor impostor to set friction on
  59142. * @param friction friction value
  59143. */
  59144. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  59145. /**
  59146. * Gets restitution of the impostor
  59147. * @param impostor impostor to get restitution from
  59148. * @returns restitution value
  59149. */
  59150. getBodyRestitution(impostor: PhysicsImpostor): number;
  59151. /**
  59152. * Sets resitution of the impostor
  59153. * @param impostor impostor to set resitution on
  59154. * @param restitution resitution value
  59155. */
  59156. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  59157. /**
  59158. * Gets pressure inside the impostor
  59159. * @param impostor impostor to get pressure from
  59160. * @returns pressure value
  59161. */
  59162. getBodyPressure(impostor: PhysicsImpostor): number;
  59163. /**
  59164. * Sets pressure inside a soft body impostor
  59165. * Cloth and rope must remain 0 pressure
  59166. * @param impostor impostor to set pressure on
  59167. * @param pressure pressure value
  59168. */
  59169. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  59170. /**
  59171. * Gets stiffness of the impostor
  59172. * @param impostor impostor to get stiffness from
  59173. * @returns pressure value
  59174. */
  59175. getBodyStiffness(impostor: PhysicsImpostor): number;
  59176. /**
  59177. * Sets stiffness of the impostor
  59178. * @param impostor impostor to set stiffness on
  59179. * @param stiffness stiffness value from 0 to 1
  59180. */
  59181. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  59182. /**
  59183. * Gets velocityIterations of the impostor
  59184. * @param impostor impostor to get velocity iterations from
  59185. * @returns velocityIterations value
  59186. */
  59187. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  59188. /**
  59189. * Sets velocityIterations of the impostor
  59190. * @param impostor impostor to set velocity iterations on
  59191. * @param velocityIterations velocityIterations value
  59192. */
  59193. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  59194. /**
  59195. * Gets positionIterations of the impostor
  59196. * @param impostor impostor to get position iterations from
  59197. * @returns positionIterations value
  59198. */
  59199. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  59200. /**
  59201. * Sets positionIterations of the impostor
  59202. * @param impostor impostor to set position on
  59203. * @param positionIterations positionIterations value
  59204. */
  59205. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  59206. /**
  59207. * Append an anchor to a cloth object
  59208. * @param impostor is the cloth impostor to add anchor to
  59209. * @param otherImpostor is the rigid impostor to anchor to
  59210. * @param width ratio across width from 0 to 1
  59211. * @param height ratio up height from 0 to 1
  59212. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  59213. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  59214. */
  59215. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  59216. /**
  59217. * Append an hook to a rope object
  59218. * @param impostor is the rope impostor to add hook to
  59219. * @param otherImpostor is the rigid impostor to hook to
  59220. * @param length ratio along the rope from 0 to 1
  59221. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  59222. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  59223. */
  59224. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  59225. /**
  59226. * Sleeps the physics body and stops it from being active
  59227. * @param impostor impostor to sleep
  59228. */
  59229. sleepBody(impostor: PhysicsImpostor): void;
  59230. /**
  59231. * Activates the physics body
  59232. * @param impostor impostor to activate
  59233. */
  59234. wakeUpBody(impostor: PhysicsImpostor): void;
  59235. /**
  59236. * Updates the distance parameters of the joint
  59237. * @param joint joint to update
  59238. * @param maxDistance maximum distance of the joint
  59239. * @param minDistance minimum distance of the joint
  59240. */
  59241. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  59242. /**
  59243. * Sets a motor on the joint
  59244. * @param joint joint to set motor on
  59245. * @param speed speed of the motor
  59246. * @param maxForce maximum force of the motor
  59247. * @param motorIndex index of the motor
  59248. */
  59249. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  59250. /**
  59251. * Sets the motors limit
  59252. * @param joint joint to set limit on
  59253. * @param upperLimit upper limit
  59254. * @param lowerLimit lower limit
  59255. */
  59256. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  59257. /**
  59258. * Syncs the position and rotation of a mesh with the impostor
  59259. * @param mesh mesh to sync
  59260. * @param impostor impostor to update the mesh with
  59261. */
  59262. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  59263. /**
  59264. * Gets the radius of the impostor
  59265. * @param impostor impostor to get radius from
  59266. * @returns the radius
  59267. */
  59268. getRadius(impostor: PhysicsImpostor): number;
  59269. /**
  59270. * Gets the box size of the impostor
  59271. * @param impostor impostor to get box size from
  59272. * @param result the resulting box size
  59273. */
  59274. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  59275. /**
  59276. * Disposes of the impostor
  59277. */
  59278. dispose(): void;
  59279. /**
  59280. * Does a raycast in the physics world
  59281. * @param from when should the ray start?
  59282. * @param to when should the ray end?
  59283. * @returns PhysicsRaycastResult
  59284. */
  59285. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  59286. }
  59287. }
  59288. declare module BABYLON {
  59289. interface AbstractScene {
  59290. /**
  59291. * The list of reflection probes added to the scene
  59292. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  59293. */
  59294. reflectionProbes: Array<ReflectionProbe>;
  59295. /**
  59296. * Removes the given reflection probe from this scene.
  59297. * @param toRemove The reflection probe to remove
  59298. * @returns The index of the removed reflection probe
  59299. */
  59300. removeReflectionProbe(toRemove: ReflectionProbe): number;
  59301. /**
  59302. * Adds the given reflection probe to this scene.
  59303. * @param newReflectionProbe The reflection probe to add
  59304. */
  59305. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  59306. }
  59307. /**
  59308. * Class used to generate realtime reflection / refraction cube textures
  59309. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  59310. */
  59311. export class ReflectionProbe {
  59312. /** defines the name of the probe */
  59313. name: string;
  59314. private _scene;
  59315. private _renderTargetTexture;
  59316. private _projectionMatrix;
  59317. private _viewMatrix;
  59318. private _target;
  59319. private _add;
  59320. private _attachedMesh;
  59321. private _invertYAxis;
  59322. /** Gets or sets probe position (center of the cube map) */
  59323. position: Vector3;
  59324. /**
  59325. * Creates a new reflection probe
  59326. * @param name defines the name of the probe
  59327. * @param size defines the texture resolution (for each face)
  59328. * @param scene defines the hosting scene
  59329. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  59330. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  59331. */
  59332. constructor(
  59333. /** defines the name of the probe */
  59334. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  59335. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  59336. get samples(): number;
  59337. set samples(value: number);
  59338. /** Gets or sets the refresh rate to use (on every frame by default) */
  59339. get refreshRate(): number;
  59340. set refreshRate(value: number);
  59341. /**
  59342. * Gets the hosting scene
  59343. * @returns a Scene
  59344. */
  59345. getScene(): Scene;
  59346. /** Gets the internal CubeTexture used to render to */
  59347. get cubeTexture(): RenderTargetTexture;
  59348. /** Gets the list of meshes to render */
  59349. get renderList(): Nullable<AbstractMesh[]>;
  59350. /**
  59351. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  59352. * @param mesh defines the mesh to attach to
  59353. */
  59354. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  59355. /**
  59356. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  59357. * @param renderingGroupId The rendering group id corresponding to its index
  59358. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  59359. */
  59360. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  59361. /**
  59362. * Clean all associated resources
  59363. */
  59364. dispose(): void;
  59365. /**
  59366. * Converts the reflection probe information to a readable string for debug purpose.
  59367. * @param fullDetails Supports for multiple levels of logging within scene loading
  59368. * @returns the human readable reflection probe info
  59369. */
  59370. toString(fullDetails?: boolean): string;
  59371. /**
  59372. * Get the class name of the relfection probe.
  59373. * @returns "ReflectionProbe"
  59374. */
  59375. getClassName(): string;
  59376. /**
  59377. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  59378. * @returns The JSON representation of the texture
  59379. */
  59380. serialize(): any;
  59381. /**
  59382. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  59383. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  59384. * @param scene Define the scene the parsed reflection probe should be instantiated in
  59385. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  59386. * @returns The parsed reflection probe if successful
  59387. */
  59388. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  59389. }
  59390. }
  59391. declare module BABYLON {
  59392. /** @hidden */
  59393. export var _BabylonLoaderRegistered: boolean;
  59394. /**
  59395. * Helps setting up some configuration for the babylon file loader.
  59396. */
  59397. export class BabylonFileLoaderConfiguration {
  59398. /**
  59399. * The loader does not allow injecting custom physix engine into the plugins.
  59400. * Unfortunately in ES6, we need to manually inject them into the plugin.
  59401. * So you could set this variable to your engine import to make it work.
  59402. */
  59403. static LoaderInjectedPhysicsEngine: any;
  59404. }
  59405. }
  59406. declare module BABYLON {
  59407. /**
  59408. * The Physically based simple base material of BJS.
  59409. *
  59410. * This enables better naming and convention enforcements on top of the pbrMaterial.
  59411. * It is used as the base class for both the specGloss and metalRough conventions.
  59412. */
  59413. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  59414. /**
  59415. * Number of Simultaneous lights allowed on the material.
  59416. */
  59417. maxSimultaneousLights: number;
  59418. /**
  59419. * If sets to true, disables all the lights affecting the material.
  59420. */
  59421. disableLighting: boolean;
  59422. /**
  59423. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  59424. */
  59425. environmentTexture: BaseTexture;
  59426. /**
  59427. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  59428. */
  59429. invertNormalMapX: boolean;
  59430. /**
  59431. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  59432. */
  59433. invertNormalMapY: boolean;
  59434. /**
  59435. * Normal map used in the model.
  59436. */
  59437. normalTexture: BaseTexture;
  59438. /**
  59439. * Emissivie color used to self-illuminate the model.
  59440. */
  59441. emissiveColor: Color3;
  59442. /**
  59443. * Emissivie texture used to self-illuminate the model.
  59444. */
  59445. emissiveTexture: BaseTexture;
  59446. /**
  59447. * Occlusion Channel Strenght.
  59448. */
  59449. occlusionStrength: number;
  59450. /**
  59451. * Occlusion Texture of the material (adding extra occlusion effects).
  59452. */
  59453. occlusionTexture: BaseTexture;
  59454. /**
  59455. * Defines the alpha limits in alpha test mode.
  59456. */
  59457. alphaCutOff: number;
  59458. /**
  59459. * Gets the current double sided mode.
  59460. */
  59461. get doubleSided(): boolean;
  59462. /**
  59463. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  59464. */
  59465. set doubleSided(value: boolean);
  59466. /**
  59467. * Stores the pre-calculated light information of a mesh in a texture.
  59468. */
  59469. lightmapTexture: BaseTexture;
  59470. /**
  59471. * If true, the light map contains occlusion information instead of lighting info.
  59472. */
  59473. useLightmapAsShadowmap: boolean;
  59474. /**
  59475. * Instantiates a new PBRMaterial instance.
  59476. *
  59477. * @param name The material name
  59478. * @param scene The scene the material will be use in.
  59479. */
  59480. constructor(name: string, scene: Scene);
  59481. getClassName(): string;
  59482. }
  59483. }
  59484. declare module BABYLON {
  59485. /**
  59486. * The PBR material of BJS following the metal roughness convention.
  59487. *
  59488. * This fits to the PBR convention in the GLTF definition:
  59489. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  59490. */
  59491. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  59492. /**
  59493. * The base color has two different interpretations depending on the value of metalness.
  59494. * When the material is a metal, the base color is the specific measured reflectance value
  59495. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  59496. * of the material.
  59497. */
  59498. baseColor: Color3;
  59499. /**
  59500. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  59501. * well as opacity information in the alpha channel.
  59502. */
  59503. baseTexture: BaseTexture;
  59504. /**
  59505. * Specifies the metallic scalar value of the material.
  59506. * Can also be used to scale the metalness values of the metallic texture.
  59507. */
  59508. metallic: number;
  59509. /**
  59510. * Specifies the roughness scalar value of the material.
  59511. * Can also be used to scale the roughness values of the metallic texture.
  59512. */
  59513. roughness: number;
  59514. /**
  59515. * Texture containing both the metallic value in the B channel and the
  59516. * roughness value in the G channel to keep better precision.
  59517. */
  59518. metallicRoughnessTexture: BaseTexture;
  59519. /**
  59520. * Instantiates a new PBRMetalRoughnessMaterial instance.
  59521. *
  59522. * @param name The material name
  59523. * @param scene The scene the material will be use in.
  59524. */
  59525. constructor(name: string, scene: Scene);
  59526. /**
  59527. * Return the currrent class name of the material.
  59528. */
  59529. getClassName(): string;
  59530. /**
  59531. * Makes a duplicate of the current material.
  59532. * @param name - name to use for the new material.
  59533. */
  59534. clone(name: string): PBRMetallicRoughnessMaterial;
  59535. /**
  59536. * Serialize the material to a parsable JSON object.
  59537. */
  59538. serialize(): any;
  59539. /**
  59540. * Parses a JSON object correponding to the serialize function.
  59541. */
  59542. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  59543. }
  59544. }
  59545. declare module BABYLON {
  59546. /**
  59547. * The PBR material of BJS following the specular glossiness convention.
  59548. *
  59549. * This fits to the PBR convention in the GLTF definition:
  59550. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  59551. */
  59552. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  59553. /**
  59554. * Specifies the diffuse color of the material.
  59555. */
  59556. diffuseColor: Color3;
  59557. /**
  59558. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  59559. * channel.
  59560. */
  59561. diffuseTexture: BaseTexture;
  59562. /**
  59563. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  59564. */
  59565. specularColor: Color3;
  59566. /**
  59567. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  59568. */
  59569. glossiness: number;
  59570. /**
  59571. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  59572. */
  59573. specularGlossinessTexture: BaseTexture;
  59574. /**
  59575. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  59576. *
  59577. * @param name The material name
  59578. * @param scene The scene the material will be use in.
  59579. */
  59580. constructor(name: string, scene: Scene);
  59581. /**
  59582. * Return the currrent class name of the material.
  59583. */
  59584. getClassName(): string;
  59585. /**
  59586. * Makes a duplicate of the current material.
  59587. * @param name - name to use for the new material.
  59588. */
  59589. clone(name: string): PBRSpecularGlossinessMaterial;
  59590. /**
  59591. * Serialize the material to a parsable JSON object.
  59592. */
  59593. serialize(): any;
  59594. /**
  59595. * Parses a JSON object correponding to the serialize function.
  59596. */
  59597. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  59598. }
  59599. }
  59600. declare module BABYLON {
  59601. /**
  59602. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  59603. * It can help converting any input color in a desired output one. This can then be used to create effects
  59604. * from sepia, black and white to sixties or futuristic rendering...
  59605. *
  59606. * The only supported format is currently 3dl.
  59607. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  59608. */
  59609. export class ColorGradingTexture extends BaseTexture {
  59610. /**
  59611. * The texture URL.
  59612. */
  59613. url: string;
  59614. /**
  59615. * Empty line regex stored for GC.
  59616. */
  59617. private static _noneEmptyLineRegex;
  59618. private _textureMatrix;
  59619. private _onLoad;
  59620. /**
  59621. * Instantiates a ColorGradingTexture from the following parameters.
  59622. *
  59623. * @param url The location of the color gradind data (currently only supporting 3dl)
  59624. * @param sceneOrEngine The scene or engine the texture will be used in
  59625. * @param onLoad defines a callback triggered when the texture has been loaded
  59626. */
  59627. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  59628. /**
  59629. * Fires the onload event from the constructor if requested.
  59630. */
  59631. private _triggerOnLoad;
  59632. /**
  59633. * Returns the texture matrix used in most of the material.
  59634. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  59635. */
  59636. getTextureMatrix(): Matrix;
  59637. /**
  59638. * Occurs when the file being loaded is a .3dl LUT file.
  59639. */
  59640. private load3dlTexture;
  59641. /**
  59642. * Starts the loading process of the texture.
  59643. */
  59644. private loadTexture;
  59645. /**
  59646. * Clones the color gradind texture.
  59647. */
  59648. clone(): ColorGradingTexture;
  59649. /**
  59650. * Called during delayed load for textures.
  59651. */
  59652. delayLoad(): void;
  59653. /**
  59654. * Parses a color grading texture serialized by Babylon.
  59655. * @param parsedTexture The texture information being parsedTexture
  59656. * @param scene The scene to load the texture in
  59657. * @param rootUrl The root url of the data assets to load
  59658. * @return A color gradind texture
  59659. */
  59660. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  59661. /**
  59662. * Serializes the LUT texture to json format.
  59663. */
  59664. serialize(): any;
  59665. }
  59666. }
  59667. declare module BABYLON {
  59668. /**
  59669. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  59670. */
  59671. export class EquiRectangularCubeTexture extends BaseTexture {
  59672. /** The six faces of the cube. */
  59673. private static _FacesMapping;
  59674. private _noMipmap;
  59675. private _onLoad;
  59676. private _onError;
  59677. /** The size of the cubemap. */
  59678. private _size;
  59679. /** The buffer of the image. */
  59680. private _buffer;
  59681. /** The width of the input image. */
  59682. private _width;
  59683. /** The height of the input image. */
  59684. private _height;
  59685. /** The URL to the image. */
  59686. url: string;
  59687. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  59688. coordinatesMode: number;
  59689. /**
  59690. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  59691. * @param url The location of the image
  59692. * @param scene The scene the texture will be used in
  59693. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  59694. * @param noMipmap Forces to not generate the mipmap if true
  59695. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  59696. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  59697. * @param onLoad — defines a callback called when texture is loaded
  59698. * @param onError — defines a callback called if there is an error
  59699. */
  59700. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  59701. /**
  59702. * Load the image data, by putting the image on a canvas and extracting its buffer.
  59703. */
  59704. private loadImage;
  59705. /**
  59706. * Convert the image buffer into a cubemap and create a CubeTexture.
  59707. */
  59708. private loadTexture;
  59709. /**
  59710. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  59711. * @param buffer The ArrayBuffer that should be converted.
  59712. * @returns The buffer as Float32Array.
  59713. */
  59714. private getFloat32ArrayFromArrayBuffer;
  59715. /**
  59716. * Get the current class name of the texture useful for serialization or dynamic coding.
  59717. * @returns "EquiRectangularCubeTexture"
  59718. */
  59719. getClassName(): string;
  59720. /**
  59721. * Create a clone of the current EquiRectangularCubeTexture and return it.
  59722. * @returns A clone of the current EquiRectangularCubeTexture.
  59723. */
  59724. clone(): EquiRectangularCubeTexture;
  59725. }
  59726. }
  59727. declare module BABYLON {
  59728. /**
  59729. * Defines the options related to the creation of an HtmlElementTexture
  59730. */
  59731. export interface IHtmlElementTextureOptions {
  59732. /**
  59733. * Defines wether mip maps should be created or not.
  59734. */
  59735. generateMipMaps?: boolean;
  59736. /**
  59737. * Defines the sampling mode of the texture.
  59738. */
  59739. samplingMode?: number;
  59740. /**
  59741. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  59742. */
  59743. engine: Nullable<ThinEngine>;
  59744. /**
  59745. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  59746. */
  59747. scene: Nullable<Scene>;
  59748. }
  59749. /**
  59750. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  59751. * To be as efficient as possible depending on your constraints nothing aside the first upload
  59752. * is automatically managed.
  59753. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  59754. * in your application.
  59755. *
  59756. * As the update is not automatic, you need to call them manually.
  59757. */
  59758. export class HtmlElementTexture extends BaseTexture {
  59759. /**
  59760. * The texture URL.
  59761. */
  59762. element: HTMLVideoElement | HTMLCanvasElement;
  59763. private static readonly DefaultOptions;
  59764. private _textureMatrix;
  59765. private _isVideo;
  59766. private _generateMipMaps;
  59767. private _samplingMode;
  59768. /**
  59769. * Instantiates a HtmlElementTexture from the following parameters.
  59770. *
  59771. * @param name Defines the name of the texture
  59772. * @param element Defines the video or canvas the texture is filled with
  59773. * @param options Defines the other none mandatory texture creation options
  59774. */
  59775. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  59776. private _createInternalTexture;
  59777. /**
  59778. * Returns the texture matrix used in most of the material.
  59779. */
  59780. getTextureMatrix(): Matrix;
  59781. /**
  59782. * Updates the content of the texture.
  59783. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  59784. */
  59785. update(invertY?: Nullable<boolean>): void;
  59786. }
  59787. }
  59788. declare module BABYLON {
  59789. /**
  59790. * Based on jsTGALoader - Javascript loader for TGA file
  59791. * By Vincent Thibault
  59792. * @see http://blog.robrowser.com/javascript-tga-loader.html
  59793. */
  59794. export class TGATools {
  59795. private static _TYPE_INDEXED;
  59796. private static _TYPE_RGB;
  59797. private static _TYPE_GREY;
  59798. private static _TYPE_RLE_INDEXED;
  59799. private static _TYPE_RLE_RGB;
  59800. private static _TYPE_RLE_GREY;
  59801. private static _ORIGIN_MASK;
  59802. private static _ORIGIN_SHIFT;
  59803. private static _ORIGIN_BL;
  59804. private static _ORIGIN_BR;
  59805. private static _ORIGIN_UL;
  59806. private static _ORIGIN_UR;
  59807. /**
  59808. * Gets the header of a TGA file
  59809. * @param data defines the TGA data
  59810. * @returns the header
  59811. */
  59812. static GetTGAHeader(data: Uint8Array): any;
  59813. /**
  59814. * Uploads TGA content to a Babylon Texture
  59815. * @hidden
  59816. */
  59817. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  59818. /** @hidden */
  59819. 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;
  59820. /** @hidden */
  59821. 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;
  59822. /** @hidden */
  59823. 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;
  59824. /** @hidden */
  59825. 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;
  59826. /** @hidden */
  59827. 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;
  59828. /** @hidden */
  59829. 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;
  59830. }
  59831. }
  59832. declare module BABYLON {
  59833. /**
  59834. * Implementation of the TGA Texture Loader.
  59835. * @hidden
  59836. */
  59837. export class _TGATextureLoader implements IInternalTextureLoader {
  59838. /**
  59839. * Defines wether the loader supports cascade loading the different faces.
  59840. */
  59841. readonly supportCascades: boolean;
  59842. /**
  59843. * This returns if the loader support the current file information.
  59844. * @param extension defines the file extension of the file being loaded
  59845. * @returns true if the loader can load the specified file
  59846. */
  59847. canLoad(extension: string): boolean;
  59848. /**
  59849. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59850. * @param data contains the texture data
  59851. * @param texture defines the BabylonJS internal texture
  59852. * @param createPolynomials will be true if polynomials have been requested
  59853. * @param onLoad defines the callback to trigger once the texture is ready
  59854. * @param onError defines the callback to trigger in case of error
  59855. */
  59856. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59857. /**
  59858. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59859. * @param data contains the texture data
  59860. * @param texture defines the BabylonJS internal texture
  59861. * @param callback defines the method to call once ready to upload
  59862. */
  59863. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  59864. }
  59865. }
  59866. declare module BABYLON {
  59867. /**
  59868. * Info about the .basis files
  59869. */
  59870. class BasisFileInfo {
  59871. /**
  59872. * If the file has alpha
  59873. */
  59874. hasAlpha: boolean;
  59875. /**
  59876. * Info about each image of the basis file
  59877. */
  59878. images: Array<{
  59879. levels: Array<{
  59880. width: number;
  59881. height: number;
  59882. transcodedPixels: ArrayBufferView;
  59883. }>;
  59884. }>;
  59885. }
  59886. /**
  59887. * Result of transcoding a basis file
  59888. */
  59889. class TranscodeResult {
  59890. /**
  59891. * Info about the .basis file
  59892. */
  59893. fileInfo: BasisFileInfo;
  59894. /**
  59895. * Format to use when loading the file
  59896. */
  59897. format: number;
  59898. }
  59899. /**
  59900. * Configuration options for the Basis transcoder
  59901. */
  59902. export class BasisTranscodeConfiguration {
  59903. /**
  59904. * Supported compression formats used to determine the supported output format of the transcoder
  59905. */
  59906. supportedCompressionFormats?: {
  59907. /**
  59908. * etc1 compression format
  59909. */
  59910. etc1?: boolean;
  59911. /**
  59912. * s3tc compression format
  59913. */
  59914. s3tc?: boolean;
  59915. /**
  59916. * pvrtc compression format
  59917. */
  59918. pvrtc?: boolean;
  59919. /**
  59920. * etc2 compression format
  59921. */
  59922. etc2?: boolean;
  59923. };
  59924. /**
  59925. * If mipmap levels should be loaded for transcoded images (Default: true)
  59926. */
  59927. loadMipmapLevels?: boolean;
  59928. /**
  59929. * Index of a single image to load (Default: all images)
  59930. */
  59931. loadSingleImage?: number;
  59932. }
  59933. /**
  59934. * Used to load .Basis files
  59935. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  59936. */
  59937. export class BasisTools {
  59938. private static _IgnoreSupportedFormats;
  59939. /**
  59940. * URL to use when loading the basis transcoder
  59941. */
  59942. static JSModuleURL: string;
  59943. /**
  59944. * URL to use when loading the wasm module for the transcoder
  59945. */
  59946. static WasmModuleURL: string;
  59947. /**
  59948. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  59949. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  59950. * @returns internal format corresponding to the Basis format
  59951. */
  59952. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  59953. private static _WorkerPromise;
  59954. private static _Worker;
  59955. private static _actionId;
  59956. private static _CreateWorkerAsync;
  59957. /**
  59958. * Transcodes a loaded image file to compressed pixel data
  59959. * @param data image data to transcode
  59960. * @param config configuration options for the transcoding
  59961. * @returns a promise resulting in the transcoded image
  59962. */
  59963. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  59964. /**
  59965. * Loads a texture from the transcode result
  59966. * @param texture texture load to
  59967. * @param transcodeResult the result of transcoding the basis file to load from
  59968. */
  59969. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  59970. }
  59971. }
  59972. declare module BABYLON {
  59973. /**
  59974. * Loader for .basis file format
  59975. */
  59976. export class _BasisTextureLoader implements IInternalTextureLoader {
  59977. /**
  59978. * Defines whether the loader supports cascade loading the different faces.
  59979. */
  59980. readonly supportCascades: boolean;
  59981. /**
  59982. * This returns if the loader support the current file information.
  59983. * @param extension defines the file extension of the file being loaded
  59984. * @returns true if the loader can load the specified file
  59985. */
  59986. canLoad(extension: string): boolean;
  59987. /**
  59988. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59989. * @param data contains the texture data
  59990. * @param texture defines the BabylonJS internal texture
  59991. * @param createPolynomials will be true if polynomials have been requested
  59992. * @param onLoad defines the callback to trigger once the texture is ready
  59993. * @param onError defines the callback to trigger in case of error
  59994. */
  59995. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59996. /**
  59997. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59998. * @param data contains the texture data
  59999. * @param texture defines the BabylonJS internal texture
  60000. * @param callback defines the method to call once ready to upload
  60001. */
  60002. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60003. }
  60004. }
  60005. declare module BABYLON {
  60006. /**
  60007. * Defines the basic options interface of a TexturePacker Frame
  60008. */
  60009. export interface ITexturePackerFrame {
  60010. /**
  60011. * The frame ID
  60012. */
  60013. id: number;
  60014. /**
  60015. * The frames Scale
  60016. */
  60017. scale: Vector2;
  60018. /**
  60019. * The Frames offset
  60020. */
  60021. offset: Vector2;
  60022. }
  60023. /**
  60024. * This is a support class for frame Data on texture packer sets.
  60025. */
  60026. export class TexturePackerFrame implements ITexturePackerFrame {
  60027. /**
  60028. * The frame ID
  60029. */
  60030. id: number;
  60031. /**
  60032. * The frames Scale
  60033. */
  60034. scale: Vector2;
  60035. /**
  60036. * The Frames offset
  60037. */
  60038. offset: Vector2;
  60039. /**
  60040. * Initializes a texture package frame.
  60041. * @param id The numerical frame identifier
  60042. * @param scale Scalar Vector2 for UV frame
  60043. * @param offset Vector2 for the frame position in UV units.
  60044. * @returns TexturePackerFrame
  60045. */
  60046. constructor(id: number, scale: Vector2, offset: Vector2);
  60047. }
  60048. }
  60049. declare module BABYLON {
  60050. /**
  60051. * Defines the basic options interface of a TexturePacker
  60052. */
  60053. export interface ITexturePackerOptions {
  60054. /**
  60055. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  60056. */
  60057. map?: string[];
  60058. /**
  60059. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  60060. */
  60061. uvsIn?: string;
  60062. /**
  60063. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  60064. */
  60065. uvsOut?: string;
  60066. /**
  60067. * number representing the layout style. Defaults to LAYOUT_STRIP
  60068. */
  60069. layout?: number;
  60070. /**
  60071. * number of columns if using custom column count layout(2). This defaults to 4.
  60072. */
  60073. colnum?: number;
  60074. /**
  60075. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  60076. */
  60077. updateInputMeshes?: boolean;
  60078. /**
  60079. * boolean flag to dispose all the source textures. Defaults to true.
  60080. */
  60081. disposeSources?: boolean;
  60082. /**
  60083. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  60084. */
  60085. fillBlanks?: boolean;
  60086. /**
  60087. * string value representing the context fill style color. Defaults to 'black'.
  60088. */
  60089. customFillColor?: string;
  60090. /**
  60091. * Width and Height Value of each Frame in the TexturePacker Sets
  60092. */
  60093. frameSize?: number;
  60094. /**
  60095. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  60096. */
  60097. paddingRatio?: number;
  60098. /**
  60099. * Number that declares the fill method for the padding gutter.
  60100. */
  60101. paddingMode?: number;
  60102. /**
  60103. * If in SUBUV_COLOR padding mode what color to use.
  60104. */
  60105. paddingColor?: Color3 | Color4;
  60106. }
  60107. /**
  60108. * Defines the basic interface of a TexturePacker JSON File
  60109. */
  60110. export interface ITexturePackerJSON {
  60111. /**
  60112. * The frame ID
  60113. */
  60114. name: string;
  60115. /**
  60116. * The base64 channel data
  60117. */
  60118. sets: any;
  60119. /**
  60120. * The options of the Packer
  60121. */
  60122. options: ITexturePackerOptions;
  60123. /**
  60124. * The frame data of the Packer
  60125. */
  60126. frames: Array<number>;
  60127. }
  60128. /**
  60129. * This is a support class that generates a series of packed texture sets.
  60130. * @see https://doc.babylonjs.com/babylon101/materials
  60131. */
  60132. export class TexturePacker {
  60133. /** Packer Layout Constant 0 */
  60134. static readonly LAYOUT_STRIP: number;
  60135. /** Packer Layout Constant 1 */
  60136. static readonly LAYOUT_POWER2: number;
  60137. /** Packer Layout Constant 2 */
  60138. static readonly LAYOUT_COLNUM: number;
  60139. /** Packer Layout Constant 0 */
  60140. static readonly SUBUV_WRAP: number;
  60141. /** Packer Layout Constant 1 */
  60142. static readonly SUBUV_EXTEND: number;
  60143. /** Packer Layout Constant 2 */
  60144. static readonly SUBUV_COLOR: number;
  60145. /** The Name of the Texture Package */
  60146. name: string;
  60147. /** The scene scope of the TexturePacker */
  60148. scene: Scene;
  60149. /** The Meshes to target */
  60150. meshes: AbstractMesh[];
  60151. /** Arguments passed with the Constructor */
  60152. options: ITexturePackerOptions;
  60153. /** The promise that is started upon initialization */
  60154. promise: Nullable<Promise<TexturePacker | string>>;
  60155. /** The Container object for the channel sets that are generated */
  60156. sets: object;
  60157. /** The Container array for the frames that are generated */
  60158. frames: TexturePackerFrame[];
  60159. /** The expected number of textures the system is parsing. */
  60160. private _expecting;
  60161. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  60162. private _paddingValue;
  60163. /**
  60164. * Initializes a texture package series from an array of meshes or a single mesh.
  60165. * @param name The name of the package
  60166. * @param meshes The target meshes to compose the package from
  60167. * @param options The arguments that texture packer should follow while building.
  60168. * @param scene The scene which the textures are scoped to.
  60169. * @returns TexturePacker
  60170. */
  60171. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  60172. /**
  60173. * Starts the package process
  60174. * @param resolve The promises resolution function
  60175. * @returns TexturePacker
  60176. */
  60177. private _createFrames;
  60178. /**
  60179. * Calculates the Size of the Channel Sets
  60180. * @returns Vector2
  60181. */
  60182. private _calculateSize;
  60183. /**
  60184. * Calculates the UV data for the frames.
  60185. * @param baseSize the base frameSize
  60186. * @param padding the base frame padding
  60187. * @param dtSize size of the Dynamic Texture for that channel
  60188. * @param dtUnits is 1/dtSize
  60189. * @param update flag to update the input meshes
  60190. */
  60191. private _calculateMeshUVFrames;
  60192. /**
  60193. * Calculates the frames Offset.
  60194. * @param index of the frame
  60195. * @returns Vector2
  60196. */
  60197. private _getFrameOffset;
  60198. /**
  60199. * Updates a Mesh to the frame data
  60200. * @param mesh that is the target
  60201. * @param frameID or the frame index
  60202. */
  60203. private _updateMeshUV;
  60204. /**
  60205. * Updates a Meshes materials to use the texture packer channels
  60206. * @param m is the mesh to target
  60207. * @param force all channels on the packer to be set.
  60208. */
  60209. private _updateTextureReferences;
  60210. /**
  60211. * Public method to set a Mesh to a frame
  60212. * @param m that is the target
  60213. * @param frameID or the frame index
  60214. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  60215. */
  60216. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  60217. /**
  60218. * Starts the async promise to compile the texture packer.
  60219. * @returns Promise<void>
  60220. */
  60221. processAsync(): Promise<void>;
  60222. /**
  60223. * Disposes all textures associated with this packer
  60224. */
  60225. dispose(): void;
  60226. /**
  60227. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  60228. * @param imageType is the image type to use.
  60229. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  60230. */
  60231. download(imageType?: string, quality?: number): void;
  60232. /**
  60233. * Public method to load a texturePacker JSON file.
  60234. * @param data of the JSON file in string format.
  60235. */
  60236. updateFromJSON(data: string): void;
  60237. }
  60238. }
  60239. declare module BABYLON {
  60240. /**
  60241. * 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.
  60242. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  60243. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  60244. */
  60245. export class CustomProceduralTexture extends ProceduralTexture {
  60246. private _animate;
  60247. private _time;
  60248. private _config;
  60249. private _texturePath;
  60250. /**
  60251. * Instantiates a new Custom Procedural Texture.
  60252. * 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.
  60253. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  60254. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  60255. * @param name Define the name of the texture
  60256. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  60257. * @param size Define the size of the texture to create
  60258. * @param scene Define the scene the texture belongs to
  60259. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  60260. * @param generateMipMaps Define if the texture should creates mip maps or not
  60261. */
  60262. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  60263. private _loadJson;
  60264. /**
  60265. * Is the texture ready to be used ? (rendered at least once)
  60266. * @returns true if ready, otherwise, false.
  60267. */
  60268. isReady(): boolean;
  60269. /**
  60270. * Render the texture to its associated render target.
  60271. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  60272. */
  60273. render(useCameraPostProcess?: boolean): void;
  60274. /**
  60275. * Update the list of dependant textures samplers in the shader.
  60276. */
  60277. updateTextures(): void;
  60278. /**
  60279. * Update the uniform values of the procedural texture in the shader.
  60280. */
  60281. updateShaderUniforms(): void;
  60282. /**
  60283. * Define if the texture animates or not.
  60284. */
  60285. get animate(): boolean;
  60286. set animate(value: boolean);
  60287. }
  60288. }
  60289. declare module BABYLON {
  60290. /** @hidden */
  60291. export var noisePixelShader: {
  60292. name: string;
  60293. shader: string;
  60294. };
  60295. }
  60296. declare module BABYLON {
  60297. /**
  60298. * Class used to generate noise procedural textures
  60299. */
  60300. export class NoiseProceduralTexture extends ProceduralTexture {
  60301. private _time;
  60302. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  60303. brightness: number;
  60304. /** Defines the number of octaves to process */
  60305. octaves: number;
  60306. /** Defines the level of persistence (0.8 by default) */
  60307. persistence: number;
  60308. /** Gets or sets animation speed factor (default is 1) */
  60309. animationSpeedFactor: number;
  60310. /**
  60311. * Creates a new NoiseProceduralTexture
  60312. * @param name defines the name fo the texture
  60313. * @param size defines the size of the texture (default is 256)
  60314. * @param scene defines the hosting scene
  60315. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  60316. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  60317. */
  60318. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  60319. private _updateShaderUniforms;
  60320. protected _getDefines(): string;
  60321. /** Generate the current state of the procedural texture */
  60322. render(useCameraPostProcess?: boolean): void;
  60323. /**
  60324. * Serializes this noise procedural texture
  60325. * @returns a serialized noise procedural texture object
  60326. */
  60327. serialize(): any;
  60328. /**
  60329. * Clone the texture.
  60330. * @returns the cloned texture
  60331. */
  60332. clone(): NoiseProceduralTexture;
  60333. /**
  60334. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  60335. * @param parsedTexture defines parsed texture data
  60336. * @param scene defines the current scene
  60337. * @param rootUrl defines the root URL containing noise procedural texture information
  60338. * @returns a parsed NoiseProceduralTexture
  60339. */
  60340. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  60341. }
  60342. }
  60343. declare module BABYLON {
  60344. /**
  60345. * Raw cube texture where the raw buffers are passed in
  60346. */
  60347. export class RawCubeTexture extends CubeTexture {
  60348. /**
  60349. * Creates a cube texture where the raw buffers are passed in.
  60350. * @param scene defines the scene the texture is attached to
  60351. * @param data defines the array of data to use to create each face
  60352. * @param size defines the size of the textures
  60353. * @param format defines the format of the data
  60354. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  60355. * @param generateMipMaps defines if the engine should generate the mip levels
  60356. * @param invertY defines if data must be stored with Y axis inverted
  60357. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  60358. * @param compression defines the compression used (null by default)
  60359. */
  60360. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  60361. /**
  60362. * Updates the raw cube texture.
  60363. * @param data defines the data to store
  60364. * @param format defines the data format
  60365. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  60366. * @param invertY defines if data must be stored with Y axis inverted
  60367. * @param compression defines the compression used (null by default)
  60368. * @param level defines which level of the texture to update
  60369. */
  60370. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  60371. /**
  60372. * Updates a raw cube texture with RGBD encoded data.
  60373. * @param data defines the array of data [mipmap][face] to use to create each face
  60374. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  60375. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  60376. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  60377. * @returns a promsie that resolves when the operation is complete
  60378. */
  60379. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  60380. /**
  60381. * Clones the raw cube texture.
  60382. * @return a new cube texture
  60383. */
  60384. clone(): CubeTexture;
  60385. /** @hidden */
  60386. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  60387. }
  60388. }
  60389. declare module BABYLON {
  60390. /**
  60391. * Class used to store 2D array textures containing user data
  60392. */
  60393. export class RawTexture2DArray extends Texture {
  60394. /** Gets or sets the texture format to use */
  60395. format: number;
  60396. /**
  60397. * Create a new RawTexture2DArray
  60398. * @param data defines the data of the texture
  60399. * @param width defines the width of the texture
  60400. * @param height defines the height of the texture
  60401. * @param depth defines the number of layers of the texture
  60402. * @param format defines the texture format to use
  60403. * @param scene defines the hosting scene
  60404. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  60405. * @param invertY defines if texture must be stored with Y axis inverted
  60406. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  60407. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  60408. */
  60409. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  60410. /** Gets or sets the texture format to use */
  60411. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  60412. /**
  60413. * Update the texture with new data
  60414. * @param data defines the data to store in the texture
  60415. */
  60416. update(data: ArrayBufferView): void;
  60417. }
  60418. }
  60419. declare module BABYLON {
  60420. /**
  60421. * Class used to store 3D textures containing user data
  60422. */
  60423. export class RawTexture3D extends Texture {
  60424. /** Gets or sets the texture format to use */
  60425. format: number;
  60426. /**
  60427. * Create a new RawTexture3D
  60428. * @param data defines the data of the texture
  60429. * @param width defines the width of the texture
  60430. * @param height defines the height of the texture
  60431. * @param depth defines the depth of the texture
  60432. * @param format defines the texture format to use
  60433. * @param scene defines the hosting scene
  60434. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  60435. * @param invertY defines if texture must be stored with Y axis inverted
  60436. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  60437. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  60438. */
  60439. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  60440. /** Gets or sets the texture format to use */
  60441. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  60442. /**
  60443. * Update the texture with new data
  60444. * @param data defines the data to store in the texture
  60445. */
  60446. update(data: ArrayBufferView): void;
  60447. }
  60448. }
  60449. declare module BABYLON {
  60450. /**
  60451. * Creates a refraction texture used by refraction channel of the standard material.
  60452. * It is like a mirror but to see through a material.
  60453. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  60454. */
  60455. export class RefractionTexture extends RenderTargetTexture {
  60456. /**
  60457. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  60458. * 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.
  60459. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  60460. */
  60461. refractionPlane: Plane;
  60462. /**
  60463. * Define how deep under the surface we should see.
  60464. */
  60465. depth: number;
  60466. /**
  60467. * Creates a refraction texture used by refraction channel of the standard material.
  60468. * It is like a mirror but to see through a material.
  60469. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  60470. * @param name Define the texture name
  60471. * @param size Define the size of the underlying texture
  60472. * @param scene Define the scene the refraction belongs to
  60473. * @param generateMipMaps Define if we need to generate mips level for the refraction
  60474. */
  60475. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  60476. /**
  60477. * Clone the refraction texture.
  60478. * @returns the cloned texture
  60479. */
  60480. clone(): RefractionTexture;
  60481. /**
  60482. * Serialize the texture to a JSON representation you could use in Parse later on
  60483. * @returns the serialized JSON representation
  60484. */
  60485. serialize(): any;
  60486. }
  60487. }
  60488. declare module BABYLON {
  60489. /**
  60490. * Block used to add support for vertex skinning (bones)
  60491. */
  60492. export class BonesBlock extends NodeMaterialBlock {
  60493. /**
  60494. * Creates a new BonesBlock
  60495. * @param name defines the block name
  60496. */
  60497. constructor(name: string);
  60498. /**
  60499. * Initialize the block and prepare the context for build
  60500. * @param state defines the state that will be used for the build
  60501. */
  60502. initialize(state: NodeMaterialBuildState): void;
  60503. /**
  60504. * Gets the current class name
  60505. * @returns the class name
  60506. */
  60507. getClassName(): string;
  60508. /**
  60509. * Gets the matrix indices input component
  60510. */
  60511. get matricesIndices(): NodeMaterialConnectionPoint;
  60512. /**
  60513. * Gets the matrix weights input component
  60514. */
  60515. get matricesWeights(): NodeMaterialConnectionPoint;
  60516. /**
  60517. * Gets the extra matrix indices input component
  60518. */
  60519. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  60520. /**
  60521. * Gets the extra matrix weights input component
  60522. */
  60523. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  60524. /**
  60525. * Gets the world input component
  60526. */
  60527. get world(): NodeMaterialConnectionPoint;
  60528. /**
  60529. * Gets the output component
  60530. */
  60531. get output(): NodeMaterialConnectionPoint;
  60532. autoConfigure(material: NodeMaterial): void;
  60533. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  60534. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60535. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60536. protected _buildBlock(state: NodeMaterialBuildState): this;
  60537. }
  60538. }
  60539. declare module BABYLON {
  60540. /**
  60541. * Block used to add support for instances
  60542. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  60543. */
  60544. export class InstancesBlock extends NodeMaterialBlock {
  60545. /**
  60546. * Creates a new InstancesBlock
  60547. * @param name defines the block name
  60548. */
  60549. constructor(name: string);
  60550. /**
  60551. * Gets the current class name
  60552. * @returns the class name
  60553. */
  60554. getClassName(): string;
  60555. /**
  60556. * Gets the first world row input component
  60557. */
  60558. get world0(): NodeMaterialConnectionPoint;
  60559. /**
  60560. * Gets the second world row input component
  60561. */
  60562. get world1(): NodeMaterialConnectionPoint;
  60563. /**
  60564. * Gets the third world row input component
  60565. */
  60566. get world2(): NodeMaterialConnectionPoint;
  60567. /**
  60568. * Gets the forth world row input component
  60569. */
  60570. get world3(): NodeMaterialConnectionPoint;
  60571. /**
  60572. * Gets the world input component
  60573. */
  60574. get world(): NodeMaterialConnectionPoint;
  60575. /**
  60576. * Gets the output component
  60577. */
  60578. get output(): NodeMaterialConnectionPoint;
  60579. /**
  60580. * Gets the isntanceID component
  60581. */
  60582. get instanceID(): NodeMaterialConnectionPoint;
  60583. autoConfigure(material: NodeMaterial): void;
  60584. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60585. protected _buildBlock(state: NodeMaterialBuildState): this;
  60586. }
  60587. }
  60588. declare module BABYLON {
  60589. /**
  60590. * Block used to add morph targets support to vertex shader
  60591. */
  60592. export class MorphTargetsBlock extends NodeMaterialBlock {
  60593. private _repeatableContentAnchor;
  60594. /**
  60595. * Create a new MorphTargetsBlock
  60596. * @param name defines the block name
  60597. */
  60598. constructor(name: string);
  60599. /**
  60600. * Gets the current class name
  60601. * @returns the class name
  60602. */
  60603. getClassName(): string;
  60604. /**
  60605. * Gets the position input component
  60606. */
  60607. get position(): NodeMaterialConnectionPoint;
  60608. /**
  60609. * Gets the normal input component
  60610. */
  60611. get normal(): NodeMaterialConnectionPoint;
  60612. /**
  60613. * Gets the tangent input component
  60614. */
  60615. get tangent(): NodeMaterialConnectionPoint;
  60616. /**
  60617. * Gets the tangent input component
  60618. */
  60619. get uv(): NodeMaterialConnectionPoint;
  60620. /**
  60621. * Gets the position output component
  60622. */
  60623. get positionOutput(): NodeMaterialConnectionPoint;
  60624. /**
  60625. * Gets the normal output component
  60626. */
  60627. get normalOutput(): NodeMaterialConnectionPoint;
  60628. /**
  60629. * Gets the tangent output component
  60630. */
  60631. get tangentOutput(): NodeMaterialConnectionPoint;
  60632. /**
  60633. * Gets the tangent output component
  60634. */
  60635. get uvOutput(): NodeMaterialConnectionPoint;
  60636. initialize(state: NodeMaterialBuildState): void;
  60637. autoConfigure(material: NodeMaterial): void;
  60638. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60639. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60640. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  60641. protected _buildBlock(state: NodeMaterialBuildState): this;
  60642. }
  60643. }
  60644. declare module BABYLON {
  60645. /**
  60646. * Block used to get data information from a light
  60647. */
  60648. export class LightInformationBlock extends NodeMaterialBlock {
  60649. private _lightDataUniformName;
  60650. private _lightColorUniformName;
  60651. private _lightTypeDefineName;
  60652. /**
  60653. * Gets or sets the light associated with this block
  60654. */
  60655. light: Nullable<Light>;
  60656. /**
  60657. * Creates a new LightInformationBlock
  60658. * @param name defines the block name
  60659. */
  60660. constructor(name: string);
  60661. /**
  60662. * Gets the current class name
  60663. * @returns the class name
  60664. */
  60665. getClassName(): string;
  60666. /**
  60667. * Gets the world position input component
  60668. */
  60669. get worldPosition(): NodeMaterialConnectionPoint;
  60670. /**
  60671. * Gets the direction output component
  60672. */
  60673. get direction(): NodeMaterialConnectionPoint;
  60674. /**
  60675. * Gets the direction output component
  60676. */
  60677. get color(): NodeMaterialConnectionPoint;
  60678. /**
  60679. * Gets the direction output component
  60680. */
  60681. get intensity(): NodeMaterialConnectionPoint;
  60682. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60683. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60684. protected _buildBlock(state: NodeMaterialBuildState): this;
  60685. serialize(): any;
  60686. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60687. }
  60688. }
  60689. declare module BABYLON {
  60690. /**
  60691. * Block used to add image processing support to fragment shader
  60692. */
  60693. export class ImageProcessingBlock extends NodeMaterialBlock {
  60694. /**
  60695. * Create a new ImageProcessingBlock
  60696. * @param name defines the block name
  60697. */
  60698. constructor(name: string);
  60699. /**
  60700. * Gets the current class name
  60701. * @returns the class name
  60702. */
  60703. getClassName(): string;
  60704. /**
  60705. * Gets the color input component
  60706. */
  60707. get color(): NodeMaterialConnectionPoint;
  60708. /**
  60709. * Gets the output component
  60710. */
  60711. get output(): NodeMaterialConnectionPoint;
  60712. /**
  60713. * Initialize the block and prepare the context for build
  60714. * @param state defines the state that will be used for the build
  60715. */
  60716. initialize(state: NodeMaterialBuildState): void;
  60717. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  60718. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60719. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60720. protected _buildBlock(state: NodeMaterialBuildState): this;
  60721. }
  60722. }
  60723. declare module BABYLON {
  60724. /**
  60725. * Block used to pertub normals based on a normal map
  60726. */
  60727. export class PerturbNormalBlock extends NodeMaterialBlock {
  60728. private _tangentSpaceParameterName;
  60729. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  60730. invertX: boolean;
  60731. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  60732. invertY: boolean;
  60733. /**
  60734. * Create a new PerturbNormalBlock
  60735. * @param name defines the block name
  60736. */
  60737. constructor(name: string);
  60738. /**
  60739. * Gets the current class name
  60740. * @returns the class name
  60741. */
  60742. getClassName(): string;
  60743. /**
  60744. * Gets the world position input component
  60745. */
  60746. get worldPosition(): NodeMaterialConnectionPoint;
  60747. /**
  60748. * Gets the world normal input component
  60749. */
  60750. get worldNormal(): NodeMaterialConnectionPoint;
  60751. /**
  60752. * Gets the world tangent input component
  60753. */
  60754. get worldTangent(): NodeMaterialConnectionPoint;
  60755. /**
  60756. * Gets the uv input component
  60757. */
  60758. get uv(): NodeMaterialConnectionPoint;
  60759. /**
  60760. * Gets the normal map color input component
  60761. */
  60762. get normalMapColor(): NodeMaterialConnectionPoint;
  60763. /**
  60764. * Gets the strength input component
  60765. */
  60766. get strength(): NodeMaterialConnectionPoint;
  60767. /**
  60768. * Gets the output component
  60769. */
  60770. get output(): NodeMaterialConnectionPoint;
  60771. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60772. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60773. autoConfigure(material: NodeMaterial): void;
  60774. protected _buildBlock(state: NodeMaterialBuildState): this;
  60775. protected _dumpPropertiesCode(): string;
  60776. serialize(): any;
  60777. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60778. }
  60779. }
  60780. declare module BABYLON {
  60781. /**
  60782. * Block used to discard a pixel if a value is smaller than a cutoff
  60783. */
  60784. export class DiscardBlock extends NodeMaterialBlock {
  60785. /**
  60786. * Create a new DiscardBlock
  60787. * @param name defines the block name
  60788. */
  60789. constructor(name: string);
  60790. /**
  60791. * Gets the current class name
  60792. * @returns the class name
  60793. */
  60794. getClassName(): string;
  60795. /**
  60796. * Gets the color input component
  60797. */
  60798. get value(): NodeMaterialConnectionPoint;
  60799. /**
  60800. * Gets the cutoff input component
  60801. */
  60802. get cutoff(): NodeMaterialConnectionPoint;
  60803. protected _buildBlock(state: NodeMaterialBuildState): this;
  60804. }
  60805. }
  60806. declare module BABYLON {
  60807. /**
  60808. * Block used to test if the fragment shader is front facing
  60809. */
  60810. export class FrontFacingBlock extends NodeMaterialBlock {
  60811. /**
  60812. * Creates a new FrontFacingBlock
  60813. * @param name defines the block name
  60814. */
  60815. constructor(name: string);
  60816. /**
  60817. * Gets the current class name
  60818. * @returns the class name
  60819. */
  60820. getClassName(): string;
  60821. /**
  60822. * Gets the output component
  60823. */
  60824. get output(): NodeMaterialConnectionPoint;
  60825. protected _buildBlock(state: NodeMaterialBuildState): this;
  60826. }
  60827. }
  60828. declare module BABYLON {
  60829. /**
  60830. * Block used to get the derivative value on x and y of a given input
  60831. */
  60832. export class DerivativeBlock extends NodeMaterialBlock {
  60833. /**
  60834. * Create a new DerivativeBlock
  60835. * @param name defines the block name
  60836. */
  60837. constructor(name: string);
  60838. /**
  60839. * Gets the current class name
  60840. * @returns the class name
  60841. */
  60842. getClassName(): string;
  60843. /**
  60844. * Gets the input component
  60845. */
  60846. get input(): NodeMaterialConnectionPoint;
  60847. /**
  60848. * Gets the derivative output on x
  60849. */
  60850. get dx(): NodeMaterialConnectionPoint;
  60851. /**
  60852. * Gets the derivative output on y
  60853. */
  60854. get dy(): NodeMaterialConnectionPoint;
  60855. protected _buildBlock(state: NodeMaterialBuildState): this;
  60856. }
  60857. }
  60858. declare module BABYLON {
  60859. /**
  60860. * Block used to add support for scene fog
  60861. */
  60862. export class FogBlock extends NodeMaterialBlock {
  60863. private _fogDistanceName;
  60864. private _fogParameters;
  60865. /**
  60866. * Create a new FogBlock
  60867. * @param name defines the block name
  60868. */
  60869. constructor(name: string);
  60870. /**
  60871. * Gets the current class name
  60872. * @returns the class name
  60873. */
  60874. getClassName(): string;
  60875. /**
  60876. * Gets the world position input component
  60877. */
  60878. get worldPosition(): NodeMaterialConnectionPoint;
  60879. /**
  60880. * Gets the view input component
  60881. */
  60882. get view(): NodeMaterialConnectionPoint;
  60883. /**
  60884. * Gets the color input component
  60885. */
  60886. get input(): NodeMaterialConnectionPoint;
  60887. /**
  60888. * Gets the fog color input component
  60889. */
  60890. get fogColor(): NodeMaterialConnectionPoint;
  60891. /**
  60892. * Gets the output component
  60893. */
  60894. get output(): NodeMaterialConnectionPoint;
  60895. autoConfigure(material: NodeMaterial): void;
  60896. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60897. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60898. protected _buildBlock(state: NodeMaterialBuildState): this;
  60899. }
  60900. }
  60901. declare module BABYLON {
  60902. /**
  60903. * Block used to add light in the fragment shader
  60904. */
  60905. export class LightBlock extends NodeMaterialBlock {
  60906. private _lightId;
  60907. /**
  60908. * Gets or sets the light associated with this block
  60909. */
  60910. light: Nullable<Light>;
  60911. /**
  60912. * Create a new LightBlock
  60913. * @param name defines the block name
  60914. */
  60915. constructor(name: string);
  60916. /**
  60917. * Gets the current class name
  60918. * @returns the class name
  60919. */
  60920. getClassName(): string;
  60921. /**
  60922. * Gets the world position input component
  60923. */
  60924. get worldPosition(): NodeMaterialConnectionPoint;
  60925. /**
  60926. * Gets the world normal input component
  60927. */
  60928. get worldNormal(): NodeMaterialConnectionPoint;
  60929. /**
  60930. * Gets the camera (or eye) position component
  60931. */
  60932. get cameraPosition(): NodeMaterialConnectionPoint;
  60933. /**
  60934. * Gets the glossiness component
  60935. */
  60936. get glossiness(): NodeMaterialConnectionPoint;
  60937. /**
  60938. * Gets the glossinness power component
  60939. */
  60940. get glossPower(): NodeMaterialConnectionPoint;
  60941. /**
  60942. * Gets the diffuse color component
  60943. */
  60944. get diffuseColor(): NodeMaterialConnectionPoint;
  60945. /**
  60946. * Gets the specular color component
  60947. */
  60948. get specularColor(): NodeMaterialConnectionPoint;
  60949. /**
  60950. * Gets the diffuse output component
  60951. */
  60952. get diffuseOutput(): NodeMaterialConnectionPoint;
  60953. /**
  60954. * Gets the specular output component
  60955. */
  60956. get specularOutput(): NodeMaterialConnectionPoint;
  60957. /**
  60958. * Gets the shadow output component
  60959. */
  60960. get shadow(): NodeMaterialConnectionPoint;
  60961. autoConfigure(material: NodeMaterial): void;
  60962. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60963. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  60964. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60965. private _injectVertexCode;
  60966. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60967. serialize(): any;
  60968. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60969. }
  60970. }
  60971. declare module BABYLON {
  60972. /**
  60973. * Block used to read a reflection texture from a sampler
  60974. */
  60975. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  60976. /**
  60977. * Create a new ReflectionTextureBlock
  60978. * @param name defines the block name
  60979. */
  60980. constructor(name: string);
  60981. /**
  60982. * Gets the current class name
  60983. * @returns the class name
  60984. */
  60985. getClassName(): string;
  60986. /**
  60987. * Gets the world position input component
  60988. */
  60989. get position(): NodeMaterialConnectionPoint;
  60990. /**
  60991. * Gets the world position input component
  60992. */
  60993. get worldPosition(): NodeMaterialConnectionPoint;
  60994. /**
  60995. * Gets the world normal input component
  60996. */
  60997. get worldNormal(): NodeMaterialConnectionPoint;
  60998. /**
  60999. * Gets the world input component
  61000. */
  61001. get world(): NodeMaterialConnectionPoint;
  61002. /**
  61003. * Gets the camera (or eye) position component
  61004. */
  61005. get cameraPosition(): NodeMaterialConnectionPoint;
  61006. /**
  61007. * Gets the view input component
  61008. */
  61009. get view(): NodeMaterialConnectionPoint;
  61010. /**
  61011. * Gets the rgb output component
  61012. */
  61013. get rgb(): NodeMaterialConnectionPoint;
  61014. /**
  61015. * Gets the r output component
  61016. */
  61017. get r(): NodeMaterialConnectionPoint;
  61018. /**
  61019. * Gets the g output component
  61020. */
  61021. get g(): NodeMaterialConnectionPoint;
  61022. /**
  61023. * Gets the b output component
  61024. */
  61025. get b(): NodeMaterialConnectionPoint;
  61026. autoConfigure(material: NodeMaterial): void;
  61027. protected _buildBlock(state: NodeMaterialBuildState): this;
  61028. }
  61029. }
  61030. declare module BABYLON {
  61031. /**
  61032. * Block used to add 2 vectors
  61033. */
  61034. export class AddBlock extends NodeMaterialBlock {
  61035. /**
  61036. * Creates a new AddBlock
  61037. * @param name defines the block name
  61038. */
  61039. constructor(name: string);
  61040. /**
  61041. * Gets the current class name
  61042. * @returns the class name
  61043. */
  61044. getClassName(): string;
  61045. /**
  61046. * Gets the left operand input component
  61047. */
  61048. get left(): NodeMaterialConnectionPoint;
  61049. /**
  61050. * Gets the right operand input component
  61051. */
  61052. get right(): NodeMaterialConnectionPoint;
  61053. /**
  61054. * Gets the output component
  61055. */
  61056. get output(): NodeMaterialConnectionPoint;
  61057. protected _buildBlock(state: NodeMaterialBuildState): this;
  61058. }
  61059. }
  61060. declare module BABYLON {
  61061. /**
  61062. * Block used to scale a vector by a float
  61063. */
  61064. export class ScaleBlock extends NodeMaterialBlock {
  61065. /**
  61066. * Creates a new ScaleBlock
  61067. * @param name defines the block name
  61068. */
  61069. constructor(name: string);
  61070. /**
  61071. * Gets the current class name
  61072. * @returns the class name
  61073. */
  61074. getClassName(): string;
  61075. /**
  61076. * Gets the input component
  61077. */
  61078. get input(): NodeMaterialConnectionPoint;
  61079. /**
  61080. * Gets the factor input component
  61081. */
  61082. get factor(): NodeMaterialConnectionPoint;
  61083. /**
  61084. * Gets the output component
  61085. */
  61086. get output(): NodeMaterialConnectionPoint;
  61087. protected _buildBlock(state: NodeMaterialBuildState): this;
  61088. }
  61089. }
  61090. declare module BABYLON {
  61091. /**
  61092. * Block used to clamp a float
  61093. */
  61094. export class ClampBlock extends NodeMaterialBlock {
  61095. /** Gets or sets the minimum range */
  61096. minimum: number;
  61097. /** Gets or sets the maximum range */
  61098. maximum: number;
  61099. /**
  61100. * Creates a new ClampBlock
  61101. * @param name defines the block name
  61102. */
  61103. constructor(name: string);
  61104. /**
  61105. * Gets the current class name
  61106. * @returns the class name
  61107. */
  61108. getClassName(): string;
  61109. /**
  61110. * Gets the value input component
  61111. */
  61112. get value(): NodeMaterialConnectionPoint;
  61113. /**
  61114. * Gets the output component
  61115. */
  61116. get output(): NodeMaterialConnectionPoint;
  61117. protected _buildBlock(state: NodeMaterialBuildState): this;
  61118. protected _dumpPropertiesCode(): string;
  61119. serialize(): any;
  61120. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61121. }
  61122. }
  61123. declare module BABYLON {
  61124. /**
  61125. * Block used to apply a cross product between 2 vectors
  61126. */
  61127. export class CrossBlock extends NodeMaterialBlock {
  61128. /**
  61129. * Creates a new CrossBlock
  61130. * @param name defines the block name
  61131. */
  61132. constructor(name: string);
  61133. /**
  61134. * Gets the current class name
  61135. * @returns the class name
  61136. */
  61137. getClassName(): string;
  61138. /**
  61139. * Gets the left operand input component
  61140. */
  61141. get left(): NodeMaterialConnectionPoint;
  61142. /**
  61143. * Gets the right operand input component
  61144. */
  61145. get right(): NodeMaterialConnectionPoint;
  61146. /**
  61147. * Gets the output component
  61148. */
  61149. get output(): NodeMaterialConnectionPoint;
  61150. protected _buildBlock(state: NodeMaterialBuildState): this;
  61151. }
  61152. }
  61153. declare module BABYLON {
  61154. /**
  61155. * Block used to apply a dot product between 2 vectors
  61156. */
  61157. export class DotBlock extends NodeMaterialBlock {
  61158. /**
  61159. * Creates a new DotBlock
  61160. * @param name defines the block name
  61161. */
  61162. constructor(name: string);
  61163. /**
  61164. * Gets the current class name
  61165. * @returns the class name
  61166. */
  61167. getClassName(): string;
  61168. /**
  61169. * Gets the left operand input component
  61170. */
  61171. get left(): NodeMaterialConnectionPoint;
  61172. /**
  61173. * Gets the right operand input component
  61174. */
  61175. get right(): NodeMaterialConnectionPoint;
  61176. /**
  61177. * Gets the output component
  61178. */
  61179. get output(): NodeMaterialConnectionPoint;
  61180. protected _buildBlock(state: NodeMaterialBuildState): this;
  61181. }
  61182. }
  61183. declare module BABYLON {
  61184. /**
  61185. * Block used to normalize a vector
  61186. */
  61187. export class NormalizeBlock extends NodeMaterialBlock {
  61188. /**
  61189. * Creates a new NormalizeBlock
  61190. * @param name defines the block name
  61191. */
  61192. constructor(name: string);
  61193. /**
  61194. * Gets the current class name
  61195. * @returns the class name
  61196. */
  61197. getClassName(): string;
  61198. /**
  61199. * Gets the input component
  61200. */
  61201. get input(): NodeMaterialConnectionPoint;
  61202. /**
  61203. * Gets the output component
  61204. */
  61205. get output(): NodeMaterialConnectionPoint;
  61206. protected _buildBlock(state: NodeMaterialBuildState): this;
  61207. }
  61208. }
  61209. declare module BABYLON {
  61210. /**
  61211. * Operations supported by the Trigonometry block
  61212. */
  61213. export enum TrigonometryBlockOperations {
  61214. /** Cos */
  61215. Cos = 0,
  61216. /** Sin */
  61217. Sin = 1,
  61218. /** Abs */
  61219. Abs = 2,
  61220. /** Exp */
  61221. Exp = 3,
  61222. /** Exp2 */
  61223. Exp2 = 4,
  61224. /** Round */
  61225. Round = 5,
  61226. /** Floor */
  61227. Floor = 6,
  61228. /** Ceiling */
  61229. Ceiling = 7,
  61230. /** Square root */
  61231. Sqrt = 8,
  61232. /** Log */
  61233. Log = 9,
  61234. /** Tangent */
  61235. Tan = 10,
  61236. /** Arc tangent */
  61237. ArcTan = 11,
  61238. /** Arc cosinus */
  61239. ArcCos = 12,
  61240. /** Arc sinus */
  61241. ArcSin = 13,
  61242. /** Fraction */
  61243. Fract = 14,
  61244. /** Sign */
  61245. Sign = 15,
  61246. /** To radians (from degrees) */
  61247. Radians = 16,
  61248. /** To degrees (from radians) */
  61249. Degrees = 17
  61250. }
  61251. /**
  61252. * Block used to apply trigonometry operation to floats
  61253. */
  61254. export class TrigonometryBlock extends NodeMaterialBlock {
  61255. /**
  61256. * Gets or sets the operation applied by the block
  61257. */
  61258. operation: TrigonometryBlockOperations;
  61259. /**
  61260. * Creates a new TrigonometryBlock
  61261. * @param name defines the block name
  61262. */
  61263. constructor(name: string);
  61264. /**
  61265. * Gets the current class name
  61266. * @returns the class name
  61267. */
  61268. getClassName(): string;
  61269. /**
  61270. * Gets the input component
  61271. */
  61272. get input(): NodeMaterialConnectionPoint;
  61273. /**
  61274. * Gets the output component
  61275. */
  61276. get output(): NodeMaterialConnectionPoint;
  61277. protected _buildBlock(state: NodeMaterialBuildState): this;
  61278. serialize(): any;
  61279. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61280. protected _dumpPropertiesCode(): string;
  61281. }
  61282. }
  61283. declare module BABYLON {
  61284. /**
  61285. * Block used to create a Color3/4 out of individual inputs (one for each component)
  61286. */
  61287. export class ColorMergerBlock extends NodeMaterialBlock {
  61288. /**
  61289. * Create a new ColorMergerBlock
  61290. * @param name defines the block name
  61291. */
  61292. constructor(name: string);
  61293. /**
  61294. * Gets the current class name
  61295. * @returns the class name
  61296. */
  61297. getClassName(): string;
  61298. /**
  61299. * Gets the rgb component (input)
  61300. */
  61301. get rgbIn(): NodeMaterialConnectionPoint;
  61302. /**
  61303. * Gets the r component (input)
  61304. */
  61305. get r(): NodeMaterialConnectionPoint;
  61306. /**
  61307. * Gets the g component (input)
  61308. */
  61309. get g(): NodeMaterialConnectionPoint;
  61310. /**
  61311. * Gets the b component (input)
  61312. */
  61313. get b(): NodeMaterialConnectionPoint;
  61314. /**
  61315. * Gets the a component (input)
  61316. */
  61317. get a(): NodeMaterialConnectionPoint;
  61318. /**
  61319. * Gets the rgba component (output)
  61320. */
  61321. get rgba(): NodeMaterialConnectionPoint;
  61322. /**
  61323. * Gets the rgb component (output)
  61324. */
  61325. get rgbOut(): NodeMaterialConnectionPoint;
  61326. /**
  61327. * Gets the rgb component (output)
  61328. * @deprecated Please use rgbOut instead.
  61329. */
  61330. get rgb(): NodeMaterialConnectionPoint;
  61331. protected _buildBlock(state: NodeMaterialBuildState): this;
  61332. }
  61333. }
  61334. declare module BABYLON {
  61335. /**
  61336. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  61337. */
  61338. export class VectorSplitterBlock extends NodeMaterialBlock {
  61339. /**
  61340. * Create a new VectorSplitterBlock
  61341. * @param name defines the block name
  61342. */
  61343. constructor(name: string);
  61344. /**
  61345. * Gets the current class name
  61346. * @returns the class name
  61347. */
  61348. getClassName(): string;
  61349. /**
  61350. * Gets the xyzw component (input)
  61351. */
  61352. get xyzw(): NodeMaterialConnectionPoint;
  61353. /**
  61354. * Gets the xyz component (input)
  61355. */
  61356. get xyzIn(): NodeMaterialConnectionPoint;
  61357. /**
  61358. * Gets the xy component (input)
  61359. */
  61360. get xyIn(): NodeMaterialConnectionPoint;
  61361. /**
  61362. * Gets the xyz component (output)
  61363. */
  61364. get xyzOut(): NodeMaterialConnectionPoint;
  61365. /**
  61366. * Gets the xy component (output)
  61367. */
  61368. get xyOut(): NodeMaterialConnectionPoint;
  61369. /**
  61370. * Gets the x component (output)
  61371. */
  61372. get x(): NodeMaterialConnectionPoint;
  61373. /**
  61374. * Gets the y component (output)
  61375. */
  61376. get y(): NodeMaterialConnectionPoint;
  61377. /**
  61378. * Gets the z component (output)
  61379. */
  61380. get z(): NodeMaterialConnectionPoint;
  61381. /**
  61382. * Gets the w component (output)
  61383. */
  61384. get w(): NodeMaterialConnectionPoint;
  61385. protected _inputRename(name: string): string;
  61386. protected _outputRename(name: string): string;
  61387. protected _buildBlock(state: NodeMaterialBuildState): this;
  61388. }
  61389. }
  61390. declare module BABYLON {
  61391. /**
  61392. * Block used to lerp between 2 values
  61393. */
  61394. export class LerpBlock extends NodeMaterialBlock {
  61395. /**
  61396. * Creates a new LerpBlock
  61397. * @param name defines the block name
  61398. */
  61399. constructor(name: string);
  61400. /**
  61401. * Gets the current class name
  61402. * @returns the class name
  61403. */
  61404. getClassName(): string;
  61405. /**
  61406. * Gets the left operand input component
  61407. */
  61408. get left(): NodeMaterialConnectionPoint;
  61409. /**
  61410. * Gets the right operand input component
  61411. */
  61412. get right(): NodeMaterialConnectionPoint;
  61413. /**
  61414. * Gets the gradient operand input component
  61415. */
  61416. get gradient(): NodeMaterialConnectionPoint;
  61417. /**
  61418. * Gets the output component
  61419. */
  61420. get output(): NodeMaterialConnectionPoint;
  61421. protected _buildBlock(state: NodeMaterialBuildState): this;
  61422. }
  61423. }
  61424. declare module BABYLON {
  61425. /**
  61426. * Block used to divide 2 vectors
  61427. */
  61428. export class DivideBlock extends NodeMaterialBlock {
  61429. /**
  61430. * Creates a new DivideBlock
  61431. * @param name defines the block name
  61432. */
  61433. constructor(name: string);
  61434. /**
  61435. * Gets the current class name
  61436. * @returns the class name
  61437. */
  61438. getClassName(): string;
  61439. /**
  61440. * Gets the left operand input component
  61441. */
  61442. get left(): NodeMaterialConnectionPoint;
  61443. /**
  61444. * Gets the right operand input component
  61445. */
  61446. get right(): NodeMaterialConnectionPoint;
  61447. /**
  61448. * Gets the output component
  61449. */
  61450. get output(): NodeMaterialConnectionPoint;
  61451. protected _buildBlock(state: NodeMaterialBuildState): this;
  61452. }
  61453. }
  61454. declare module BABYLON {
  61455. /**
  61456. * Block used to subtract 2 vectors
  61457. */
  61458. export class SubtractBlock extends NodeMaterialBlock {
  61459. /**
  61460. * Creates a new SubtractBlock
  61461. * @param name defines the block name
  61462. */
  61463. constructor(name: string);
  61464. /**
  61465. * Gets the current class name
  61466. * @returns the class name
  61467. */
  61468. getClassName(): string;
  61469. /**
  61470. * Gets the left operand input component
  61471. */
  61472. get left(): NodeMaterialConnectionPoint;
  61473. /**
  61474. * Gets the right operand input component
  61475. */
  61476. get right(): NodeMaterialConnectionPoint;
  61477. /**
  61478. * Gets the output component
  61479. */
  61480. get output(): NodeMaterialConnectionPoint;
  61481. protected _buildBlock(state: NodeMaterialBuildState): this;
  61482. }
  61483. }
  61484. declare module BABYLON {
  61485. /**
  61486. * Block used to step a value
  61487. */
  61488. export class StepBlock extends NodeMaterialBlock {
  61489. /**
  61490. * Creates a new StepBlock
  61491. * @param name defines the block name
  61492. */
  61493. constructor(name: string);
  61494. /**
  61495. * Gets the current class name
  61496. * @returns the class name
  61497. */
  61498. getClassName(): string;
  61499. /**
  61500. * Gets the value operand input component
  61501. */
  61502. get value(): NodeMaterialConnectionPoint;
  61503. /**
  61504. * Gets the edge operand input component
  61505. */
  61506. get edge(): NodeMaterialConnectionPoint;
  61507. /**
  61508. * Gets the output component
  61509. */
  61510. get output(): NodeMaterialConnectionPoint;
  61511. protected _buildBlock(state: NodeMaterialBuildState): this;
  61512. }
  61513. }
  61514. declare module BABYLON {
  61515. /**
  61516. * Block used to get the opposite (1 - x) of a value
  61517. */
  61518. export class OneMinusBlock extends NodeMaterialBlock {
  61519. /**
  61520. * Creates a new OneMinusBlock
  61521. * @param name defines the block name
  61522. */
  61523. constructor(name: string);
  61524. /**
  61525. * Gets the current class name
  61526. * @returns the class name
  61527. */
  61528. getClassName(): string;
  61529. /**
  61530. * Gets the input component
  61531. */
  61532. get input(): NodeMaterialConnectionPoint;
  61533. /**
  61534. * Gets the output component
  61535. */
  61536. get output(): NodeMaterialConnectionPoint;
  61537. protected _buildBlock(state: NodeMaterialBuildState): this;
  61538. }
  61539. }
  61540. declare module BABYLON {
  61541. /**
  61542. * Block used to get the view direction
  61543. */
  61544. export class ViewDirectionBlock extends NodeMaterialBlock {
  61545. /**
  61546. * Creates a new ViewDirectionBlock
  61547. * @param name defines the block name
  61548. */
  61549. constructor(name: string);
  61550. /**
  61551. * Gets the current class name
  61552. * @returns the class name
  61553. */
  61554. getClassName(): string;
  61555. /**
  61556. * Gets the world position component
  61557. */
  61558. get worldPosition(): NodeMaterialConnectionPoint;
  61559. /**
  61560. * Gets the camera position component
  61561. */
  61562. get cameraPosition(): NodeMaterialConnectionPoint;
  61563. /**
  61564. * Gets the output component
  61565. */
  61566. get output(): NodeMaterialConnectionPoint;
  61567. autoConfigure(material: NodeMaterial): void;
  61568. protected _buildBlock(state: NodeMaterialBuildState): this;
  61569. }
  61570. }
  61571. declare module BABYLON {
  61572. /**
  61573. * Block used to compute fresnel value
  61574. */
  61575. export class FresnelBlock extends NodeMaterialBlock {
  61576. /**
  61577. * Create a new FresnelBlock
  61578. * @param name defines the block name
  61579. */
  61580. constructor(name: string);
  61581. /**
  61582. * Gets the current class name
  61583. * @returns the class name
  61584. */
  61585. getClassName(): string;
  61586. /**
  61587. * Gets the world normal input component
  61588. */
  61589. get worldNormal(): NodeMaterialConnectionPoint;
  61590. /**
  61591. * Gets the view direction input component
  61592. */
  61593. get viewDirection(): NodeMaterialConnectionPoint;
  61594. /**
  61595. * Gets the bias input component
  61596. */
  61597. get bias(): NodeMaterialConnectionPoint;
  61598. /**
  61599. * Gets the camera (or eye) position component
  61600. */
  61601. get power(): NodeMaterialConnectionPoint;
  61602. /**
  61603. * Gets the fresnel output component
  61604. */
  61605. get fresnel(): NodeMaterialConnectionPoint;
  61606. autoConfigure(material: NodeMaterial): void;
  61607. protected _buildBlock(state: NodeMaterialBuildState): this;
  61608. }
  61609. }
  61610. declare module BABYLON {
  61611. /**
  61612. * Block used to get the max of 2 values
  61613. */
  61614. export class MaxBlock extends NodeMaterialBlock {
  61615. /**
  61616. * Creates a new MaxBlock
  61617. * @param name defines the block name
  61618. */
  61619. constructor(name: string);
  61620. /**
  61621. * Gets the current class name
  61622. * @returns the class name
  61623. */
  61624. getClassName(): string;
  61625. /**
  61626. * Gets the left operand input component
  61627. */
  61628. get left(): NodeMaterialConnectionPoint;
  61629. /**
  61630. * Gets the right operand input component
  61631. */
  61632. get right(): NodeMaterialConnectionPoint;
  61633. /**
  61634. * Gets the output component
  61635. */
  61636. get output(): NodeMaterialConnectionPoint;
  61637. protected _buildBlock(state: NodeMaterialBuildState): this;
  61638. }
  61639. }
  61640. declare module BABYLON {
  61641. /**
  61642. * Block used to get the min of 2 values
  61643. */
  61644. export class MinBlock extends NodeMaterialBlock {
  61645. /**
  61646. * Creates a new MinBlock
  61647. * @param name defines the block name
  61648. */
  61649. constructor(name: string);
  61650. /**
  61651. * Gets the current class name
  61652. * @returns the class name
  61653. */
  61654. getClassName(): string;
  61655. /**
  61656. * Gets the left operand input component
  61657. */
  61658. get left(): NodeMaterialConnectionPoint;
  61659. /**
  61660. * Gets the right operand input component
  61661. */
  61662. get right(): NodeMaterialConnectionPoint;
  61663. /**
  61664. * Gets the output component
  61665. */
  61666. get output(): NodeMaterialConnectionPoint;
  61667. protected _buildBlock(state: NodeMaterialBuildState): this;
  61668. }
  61669. }
  61670. declare module BABYLON {
  61671. /**
  61672. * Block used to get the distance between 2 values
  61673. */
  61674. export class DistanceBlock extends NodeMaterialBlock {
  61675. /**
  61676. * Creates a new DistanceBlock
  61677. * @param name defines the block name
  61678. */
  61679. constructor(name: string);
  61680. /**
  61681. * Gets the current class name
  61682. * @returns the class name
  61683. */
  61684. getClassName(): string;
  61685. /**
  61686. * Gets the left operand input component
  61687. */
  61688. get left(): NodeMaterialConnectionPoint;
  61689. /**
  61690. * Gets the right operand input component
  61691. */
  61692. get right(): NodeMaterialConnectionPoint;
  61693. /**
  61694. * Gets the output component
  61695. */
  61696. get output(): NodeMaterialConnectionPoint;
  61697. protected _buildBlock(state: NodeMaterialBuildState): this;
  61698. }
  61699. }
  61700. declare module BABYLON {
  61701. /**
  61702. * Block used to get the length of a vector
  61703. */
  61704. export class LengthBlock extends NodeMaterialBlock {
  61705. /**
  61706. * Creates a new LengthBlock
  61707. * @param name defines the block name
  61708. */
  61709. constructor(name: string);
  61710. /**
  61711. * Gets the current class name
  61712. * @returns the class name
  61713. */
  61714. getClassName(): string;
  61715. /**
  61716. * Gets the value input component
  61717. */
  61718. get value(): NodeMaterialConnectionPoint;
  61719. /**
  61720. * Gets the output component
  61721. */
  61722. get output(): NodeMaterialConnectionPoint;
  61723. protected _buildBlock(state: NodeMaterialBuildState): this;
  61724. }
  61725. }
  61726. declare module BABYLON {
  61727. /**
  61728. * Block used to get negative version of a value (i.e. x * -1)
  61729. */
  61730. export class NegateBlock extends NodeMaterialBlock {
  61731. /**
  61732. * Creates a new NegateBlock
  61733. * @param name defines the block name
  61734. */
  61735. constructor(name: string);
  61736. /**
  61737. * Gets the current class name
  61738. * @returns the class name
  61739. */
  61740. getClassName(): string;
  61741. /**
  61742. * Gets the value input component
  61743. */
  61744. get value(): NodeMaterialConnectionPoint;
  61745. /**
  61746. * Gets the output component
  61747. */
  61748. get output(): NodeMaterialConnectionPoint;
  61749. protected _buildBlock(state: NodeMaterialBuildState): this;
  61750. }
  61751. }
  61752. declare module BABYLON {
  61753. /**
  61754. * Block used to get the value of the first parameter raised to the power of the second
  61755. */
  61756. export class PowBlock extends NodeMaterialBlock {
  61757. /**
  61758. * Creates a new PowBlock
  61759. * @param name defines the block name
  61760. */
  61761. constructor(name: string);
  61762. /**
  61763. * Gets the current class name
  61764. * @returns the class name
  61765. */
  61766. getClassName(): string;
  61767. /**
  61768. * Gets the value operand input component
  61769. */
  61770. get value(): NodeMaterialConnectionPoint;
  61771. /**
  61772. * Gets the power operand input component
  61773. */
  61774. get power(): NodeMaterialConnectionPoint;
  61775. /**
  61776. * Gets the output component
  61777. */
  61778. get output(): NodeMaterialConnectionPoint;
  61779. protected _buildBlock(state: NodeMaterialBuildState): this;
  61780. }
  61781. }
  61782. declare module BABYLON {
  61783. /**
  61784. * Block used to get a random number
  61785. */
  61786. export class RandomNumberBlock extends NodeMaterialBlock {
  61787. /**
  61788. * Creates a new RandomNumberBlock
  61789. * @param name defines the block name
  61790. */
  61791. constructor(name: string);
  61792. /**
  61793. * Gets the current class name
  61794. * @returns the class name
  61795. */
  61796. getClassName(): string;
  61797. /**
  61798. * Gets the seed input component
  61799. */
  61800. get seed(): NodeMaterialConnectionPoint;
  61801. /**
  61802. * Gets the output component
  61803. */
  61804. get output(): NodeMaterialConnectionPoint;
  61805. protected _buildBlock(state: NodeMaterialBuildState): this;
  61806. }
  61807. }
  61808. declare module BABYLON {
  61809. /**
  61810. * Block used to compute arc tangent of 2 values
  61811. */
  61812. export class ArcTan2Block extends NodeMaterialBlock {
  61813. /**
  61814. * Creates a new ArcTan2Block
  61815. * @param name defines the block name
  61816. */
  61817. constructor(name: string);
  61818. /**
  61819. * Gets the current class name
  61820. * @returns the class name
  61821. */
  61822. getClassName(): string;
  61823. /**
  61824. * Gets the x operand input component
  61825. */
  61826. get x(): NodeMaterialConnectionPoint;
  61827. /**
  61828. * Gets the y operand input component
  61829. */
  61830. get y(): NodeMaterialConnectionPoint;
  61831. /**
  61832. * Gets the output component
  61833. */
  61834. get output(): NodeMaterialConnectionPoint;
  61835. protected _buildBlock(state: NodeMaterialBuildState): this;
  61836. }
  61837. }
  61838. declare module BABYLON {
  61839. /**
  61840. * Block used to smooth step a value
  61841. */
  61842. export class SmoothStepBlock extends NodeMaterialBlock {
  61843. /**
  61844. * Creates a new SmoothStepBlock
  61845. * @param name defines the block name
  61846. */
  61847. constructor(name: string);
  61848. /**
  61849. * Gets the current class name
  61850. * @returns the class name
  61851. */
  61852. getClassName(): string;
  61853. /**
  61854. * Gets the value operand input component
  61855. */
  61856. get value(): NodeMaterialConnectionPoint;
  61857. /**
  61858. * Gets the first edge operand input component
  61859. */
  61860. get edge0(): NodeMaterialConnectionPoint;
  61861. /**
  61862. * Gets the second edge operand input component
  61863. */
  61864. get edge1(): NodeMaterialConnectionPoint;
  61865. /**
  61866. * Gets the output component
  61867. */
  61868. get output(): NodeMaterialConnectionPoint;
  61869. protected _buildBlock(state: NodeMaterialBuildState): this;
  61870. }
  61871. }
  61872. declare module BABYLON {
  61873. /**
  61874. * Block used to get the reciprocal (1 / x) of a value
  61875. */
  61876. export class ReciprocalBlock extends NodeMaterialBlock {
  61877. /**
  61878. * Creates a new ReciprocalBlock
  61879. * @param name defines the block name
  61880. */
  61881. constructor(name: string);
  61882. /**
  61883. * Gets the current class name
  61884. * @returns the class name
  61885. */
  61886. getClassName(): string;
  61887. /**
  61888. * Gets the input component
  61889. */
  61890. get input(): NodeMaterialConnectionPoint;
  61891. /**
  61892. * Gets the output component
  61893. */
  61894. get output(): NodeMaterialConnectionPoint;
  61895. protected _buildBlock(state: NodeMaterialBuildState): this;
  61896. }
  61897. }
  61898. declare module BABYLON {
  61899. /**
  61900. * Block used to replace a color by another one
  61901. */
  61902. export class ReplaceColorBlock extends NodeMaterialBlock {
  61903. /**
  61904. * Creates a new ReplaceColorBlock
  61905. * @param name defines the block name
  61906. */
  61907. constructor(name: string);
  61908. /**
  61909. * Gets the current class name
  61910. * @returns the class name
  61911. */
  61912. getClassName(): string;
  61913. /**
  61914. * Gets the value input component
  61915. */
  61916. get value(): NodeMaterialConnectionPoint;
  61917. /**
  61918. * Gets the reference input component
  61919. */
  61920. get reference(): NodeMaterialConnectionPoint;
  61921. /**
  61922. * Gets the distance input component
  61923. */
  61924. get distance(): NodeMaterialConnectionPoint;
  61925. /**
  61926. * Gets the replacement input component
  61927. */
  61928. get replacement(): NodeMaterialConnectionPoint;
  61929. /**
  61930. * Gets the output component
  61931. */
  61932. get output(): NodeMaterialConnectionPoint;
  61933. protected _buildBlock(state: NodeMaterialBuildState): this;
  61934. }
  61935. }
  61936. declare module BABYLON {
  61937. /**
  61938. * Block used to posterize a value
  61939. * @see https://en.wikipedia.org/wiki/Posterization
  61940. */
  61941. export class PosterizeBlock extends NodeMaterialBlock {
  61942. /**
  61943. * Creates a new PosterizeBlock
  61944. * @param name defines the block name
  61945. */
  61946. constructor(name: string);
  61947. /**
  61948. * Gets the current class name
  61949. * @returns the class name
  61950. */
  61951. getClassName(): string;
  61952. /**
  61953. * Gets the value input component
  61954. */
  61955. get value(): NodeMaterialConnectionPoint;
  61956. /**
  61957. * Gets the steps input component
  61958. */
  61959. get steps(): NodeMaterialConnectionPoint;
  61960. /**
  61961. * Gets the output component
  61962. */
  61963. get output(): NodeMaterialConnectionPoint;
  61964. protected _buildBlock(state: NodeMaterialBuildState): this;
  61965. }
  61966. }
  61967. declare module BABYLON {
  61968. /**
  61969. * Operations supported by the Wave block
  61970. */
  61971. export enum WaveBlockKind {
  61972. /** SawTooth */
  61973. SawTooth = 0,
  61974. /** Square */
  61975. Square = 1,
  61976. /** Triangle */
  61977. Triangle = 2
  61978. }
  61979. /**
  61980. * Block used to apply wave operation to floats
  61981. */
  61982. export class WaveBlock extends NodeMaterialBlock {
  61983. /**
  61984. * Gets or sets the kibnd of wave to be applied by the block
  61985. */
  61986. kind: WaveBlockKind;
  61987. /**
  61988. * Creates a new WaveBlock
  61989. * @param name defines the block name
  61990. */
  61991. constructor(name: string);
  61992. /**
  61993. * Gets the current class name
  61994. * @returns the class name
  61995. */
  61996. getClassName(): string;
  61997. /**
  61998. * Gets the input component
  61999. */
  62000. get input(): NodeMaterialConnectionPoint;
  62001. /**
  62002. * Gets the output component
  62003. */
  62004. get output(): NodeMaterialConnectionPoint;
  62005. protected _buildBlock(state: NodeMaterialBuildState): this;
  62006. serialize(): any;
  62007. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62008. }
  62009. }
  62010. declare module BABYLON {
  62011. /**
  62012. * Class used to store a color step for the GradientBlock
  62013. */
  62014. export class GradientBlockColorStep {
  62015. /**
  62016. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62017. */
  62018. step: number;
  62019. /**
  62020. * Gets or sets the color associated with this step
  62021. */
  62022. color: Color3;
  62023. /**
  62024. * Creates a new GradientBlockColorStep
  62025. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  62026. * @param color defines the color associated with this step
  62027. */
  62028. constructor(
  62029. /**
  62030. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62031. */
  62032. step: number,
  62033. /**
  62034. * Gets or sets the color associated with this step
  62035. */
  62036. color: Color3);
  62037. }
  62038. /**
  62039. * Block used to return a color from a gradient based on an input value between 0 and 1
  62040. */
  62041. export class GradientBlock extends NodeMaterialBlock {
  62042. /**
  62043. * Gets or sets the list of color steps
  62044. */
  62045. colorSteps: GradientBlockColorStep[];
  62046. /**
  62047. * Creates a new GradientBlock
  62048. * @param name defines the block name
  62049. */
  62050. constructor(name: string);
  62051. /**
  62052. * Gets the current class name
  62053. * @returns the class name
  62054. */
  62055. getClassName(): string;
  62056. /**
  62057. * Gets the gradient input component
  62058. */
  62059. get gradient(): NodeMaterialConnectionPoint;
  62060. /**
  62061. * Gets the output component
  62062. */
  62063. get output(): NodeMaterialConnectionPoint;
  62064. private _writeColorConstant;
  62065. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62066. serialize(): any;
  62067. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62068. protected _dumpPropertiesCode(): string;
  62069. }
  62070. }
  62071. declare module BABYLON {
  62072. /**
  62073. * Block used to normalize lerp between 2 values
  62074. */
  62075. export class NLerpBlock extends NodeMaterialBlock {
  62076. /**
  62077. * Creates a new NLerpBlock
  62078. * @param name defines the block name
  62079. */
  62080. constructor(name: string);
  62081. /**
  62082. * Gets the current class name
  62083. * @returns the class name
  62084. */
  62085. getClassName(): string;
  62086. /**
  62087. * Gets the left operand input component
  62088. */
  62089. get left(): NodeMaterialConnectionPoint;
  62090. /**
  62091. * Gets the right operand input component
  62092. */
  62093. get right(): NodeMaterialConnectionPoint;
  62094. /**
  62095. * Gets the gradient operand input component
  62096. */
  62097. get gradient(): NodeMaterialConnectionPoint;
  62098. /**
  62099. * Gets the output component
  62100. */
  62101. get output(): NodeMaterialConnectionPoint;
  62102. protected _buildBlock(state: NodeMaterialBuildState): this;
  62103. }
  62104. }
  62105. declare module BABYLON {
  62106. /**
  62107. * block used to Generate a Worley Noise 3D Noise Pattern
  62108. */
  62109. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  62110. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  62111. manhattanDistance: boolean;
  62112. /**
  62113. * Creates a new WorleyNoise3DBlock
  62114. * @param name defines the block name
  62115. */
  62116. constructor(name: string);
  62117. /**
  62118. * Gets the current class name
  62119. * @returns the class name
  62120. */
  62121. getClassName(): string;
  62122. /**
  62123. * Gets the seed input component
  62124. */
  62125. get seed(): NodeMaterialConnectionPoint;
  62126. /**
  62127. * Gets the jitter input component
  62128. */
  62129. get jitter(): NodeMaterialConnectionPoint;
  62130. /**
  62131. * Gets the output component
  62132. */
  62133. get output(): NodeMaterialConnectionPoint;
  62134. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62135. /**
  62136. * Exposes the properties to the UI?
  62137. */
  62138. protected _dumpPropertiesCode(): string;
  62139. /**
  62140. * Exposes the properties to the Seralize?
  62141. */
  62142. serialize(): any;
  62143. /**
  62144. * Exposes the properties to the deseralize?
  62145. */
  62146. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62147. }
  62148. }
  62149. declare module BABYLON {
  62150. /**
  62151. * block used to Generate a Simplex Perlin 3d Noise Pattern
  62152. */
  62153. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  62154. /**
  62155. * Creates a new SimplexPerlin3DBlock
  62156. * @param name defines the block name
  62157. */
  62158. constructor(name: string);
  62159. /**
  62160. * Gets the current class name
  62161. * @returns the class name
  62162. */
  62163. getClassName(): string;
  62164. /**
  62165. * Gets the seed operand input component
  62166. */
  62167. get seed(): NodeMaterialConnectionPoint;
  62168. /**
  62169. * Gets the output component
  62170. */
  62171. get output(): NodeMaterialConnectionPoint;
  62172. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62173. }
  62174. }
  62175. declare module BABYLON {
  62176. /**
  62177. * Block used to blend normals
  62178. */
  62179. export class NormalBlendBlock extends NodeMaterialBlock {
  62180. /**
  62181. * Creates a new NormalBlendBlock
  62182. * @param name defines the block name
  62183. */
  62184. constructor(name: string);
  62185. /**
  62186. * Gets the current class name
  62187. * @returns the class name
  62188. */
  62189. getClassName(): string;
  62190. /**
  62191. * Gets the first input component
  62192. */
  62193. get normalMap0(): NodeMaterialConnectionPoint;
  62194. /**
  62195. * Gets the second input component
  62196. */
  62197. get normalMap1(): NodeMaterialConnectionPoint;
  62198. /**
  62199. * Gets the output component
  62200. */
  62201. get output(): NodeMaterialConnectionPoint;
  62202. protected _buildBlock(state: NodeMaterialBuildState): this;
  62203. }
  62204. }
  62205. declare module BABYLON {
  62206. /**
  62207. * Block used to rotate a 2d vector by a given angle
  62208. */
  62209. export class Rotate2dBlock extends NodeMaterialBlock {
  62210. /**
  62211. * Creates a new Rotate2dBlock
  62212. * @param name defines the block name
  62213. */
  62214. constructor(name: string);
  62215. /**
  62216. * Gets the current class name
  62217. * @returns the class name
  62218. */
  62219. getClassName(): string;
  62220. /**
  62221. * Gets the input vector
  62222. */
  62223. get input(): NodeMaterialConnectionPoint;
  62224. /**
  62225. * Gets the input angle
  62226. */
  62227. get angle(): NodeMaterialConnectionPoint;
  62228. /**
  62229. * Gets the output component
  62230. */
  62231. get output(): NodeMaterialConnectionPoint;
  62232. autoConfigure(material: NodeMaterial): void;
  62233. protected _buildBlock(state: NodeMaterialBuildState): this;
  62234. }
  62235. }
  62236. declare module BABYLON {
  62237. /**
  62238. * Block used to get the reflected vector from a direction and a normal
  62239. */
  62240. export class ReflectBlock extends NodeMaterialBlock {
  62241. /**
  62242. * Creates a new ReflectBlock
  62243. * @param name defines the block name
  62244. */
  62245. constructor(name: string);
  62246. /**
  62247. * Gets the current class name
  62248. * @returns the class name
  62249. */
  62250. getClassName(): string;
  62251. /**
  62252. * Gets the incident component
  62253. */
  62254. get incident(): NodeMaterialConnectionPoint;
  62255. /**
  62256. * Gets the normal component
  62257. */
  62258. get normal(): NodeMaterialConnectionPoint;
  62259. /**
  62260. * Gets the output component
  62261. */
  62262. get output(): NodeMaterialConnectionPoint;
  62263. protected _buildBlock(state: NodeMaterialBuildState): this;
  62264. }
  62265. }
  62266. declare module BABYLON {
  62267. /**
  62268. * Block used to get the refracted vector from a direction and a normal
  62269. */
  62270. export class RefractBlock extends NodeMaterialBlock {
  62271. /**
  62272. * Creates a new RefractBlock
  62273. * @param name defines the block name
  62274. */
  62275. constructor(name: string);
  62276. /**
  62277. * Gets the current class name
  62278. * @returns the class name
  62279. */
  62280. getClassName(): string;
  62281. /**
  62282. * Gets the incident component
  62283. */
  62284. get incident(): NodeMaterialConnectionPoint;
  62285. /**
  62286. * Gets the normal component
  62287. */
  62288. get normal(): NodeMaterialConnectionPoint;
  62289. /**
  62290. * Gets the index of refraction component
  62291. */
  62292. get ior(): NodeMaterialConnectionPoint;
  62293. /**
  62294. * Gets the output component
  62295. */
  62296. get output(): NodeMaterialConnectionPoint;
  62297. protected _buildBlock(state: NodeMaterialBuildState): this;
  62298. }
  62299. }
  62300. declare module BABYLON {
  62301. /**
  62302. * Block used to desaturate a color
  62303. */
  62304. export class DesaturateBlock extends NodeMaterialBlock {
  62305. /**
  62306. * Creates a new DesaturateBlock
  62307. * @param name defines the block name
  62308. */
  62309. constructor(name: string);
  62310. /**
  62311. * Gets the current class name
  62312. * @returns the class name
  62313. */
  62314. getClassName(): string;
  62315. /**
  62316. * Gets the color operand input component
  62317. */
  62318. get color(): NodeMaterialConnectionPoint;
  62319. /**
  62320. * Gets the level operand input component
  62321. */
  62322. get level(): NodeMaterialConnectionPoint;
  62323. /**
  62324. * Gets the output component
  62325. */
  62326. get output(): NodeMaterialConnectionPoint;
  62327. protected _buildBlock(state: NodeMaterialBuildState): this;
  62328. }
  62329. }
  62330. declare module BABYLON {
  62331. /**
  62332. * Block used to implement the ambient occlusion module of the PBR material
  62333. */
  62334. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  62335. /**
  62336. * Create a new AmbientOcclusionBlock
  62337. * @param name defines the block name
  62338. */
  62339. constructor(name: string);
  62340. /**
  62341. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  62342. */
  62343. useAmbientInGrayScale: boolean;
  62344. /**
  62345. * Initialize the block and prepare the context for build
  62346. * @param state defines the state that will be used for the build
  62347. */
  62348. initialize(state: NodeMaterialBuildState): void;
  62349. /**
  62350. * Gets the current class name
  62351. * @returns the class name
  62352. */
  62353. getClassName(): string;
  62354. /**
  62355. * Gets the texture input component
  62356. */
  62357. get texture(): NodeMaterialConnectionPoint;
  62358. /**
  62359. * Gets the texture intensity component
  62360. */
  62361. get intensity(): NodeMaterialConnectionPoint;
  62362. /**
  62363. * Gets the direct light intensity input component
  62364. */
  62365. get directLightIntensity(): NodeMaterialConnectionPoint;
  62366. /**
  62367. * Gets the ambient occlusion object output component
  62368. */
  62369. get ambientOcclusion(): NodeMaterialConnectionPoint;
  62370. /**
  62371. * Gets the main code of the block (fragment side)
  62372. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  62373. * @returns the shader code
  62374. */
  62375. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  62376. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62377. protected _buildBlock(state: NodeMaterialBuildState): this;
  62378. protected _dumpPropertiesCode(): string;
  62379. serialize(): any;
  62380. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62381. }
  62382. }
  62383. declare module BABYLON {
  62384. /**
  62385. * Block used to implement the reflection module of the PBR material
  62386. */
  62387. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  62388. /** @hidden */
  62389. _defineLODReflectionAlpha: string;
  62390. /** @hidden */
  62391. _defineLinearSpecularReflection: string;
  62392. private _vEnvironmentIrradianceName;
  62393. /** @hidden */
  62394. _vReflectionMicrosurfaceInfosName: string;
  62395. /** @hidden */
  62396. _vReflectionInfosName: string;
  62397. private _scene;
  62398. /**
  62399. * The three properties below are set by the main PBR block prior to calling methods of this class.
  62400. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  62401. * It's less burden on the user side in the editor part.
  62402. */
  62403. /** @hidden */
  62404. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  62405. /** @hidden */
  62406. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  62407. /** @hidden */
  62408. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  62409. /**
  62410. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  62411. * diffuse part of the IBL.
  62412. */
  62413. useSphericalHarmonics: boolean;
  62414. /**
  62415. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  62416. */
  62417. forceIrradianceInFragment: boolean;
  62418. /**
  62419. * Create a new ReflectionBlock
  62420. * @param name defines the block name
  62421. */
  62422. constructor(name: string);
  62423. /**
  62424. * Gets the current class name
  62425. * @returns the class name
  62426. */
  62427. getClassName(): string;
  62428. /**
  62429. * Gets the position input component
  62430. */
  62431. get position(): NodeMaterialConnectionPoint;
  62432. /**
  62433. * Gets the world position input component
  62434. */
  62435. get worldPosition(): NodeMaterialConnectionPoint;
  62436. /**
  62437. * Gets the world normal input component
  62438. */
  62439. get worldNormal(): NodeMaterialConnectionPoint;
  62440. /**
  62441. * Gets the world input component
  62442. */
  62443. get world(): NodeMaterialConnectionPoint;
  62444. /**
  62445. * Gets the camera (or eye) position component
  62446. */
  62447. get cameraPosition(): NodeMaterialConnectionPoint;
  62448. /**
  62449. * Gets the view input component
  62450. */
  62451. get view(): NodeMaterialConnectionPoint;
  62452. /**
  62453. * Gets the color input component
  62454. */
  62455. get color(): NodeMaterialConnectionPoint;
  62456. /**
  62457. * Gets the reflection object output component
  62458. */
  62459. get reflection(): NodeMaterialConnectionPoint;
  62460. /**
  62461. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  62462. */
  62463. get hasTexture(): boolean;
  62464. /**
  62465. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  62466. */
  62467. get reflectionColor(): string;
  62468. protected _getTexture(): Nullable<BaseTexture>;
  62469. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62470. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  62471. /**
  62472. * Gets the code to inject in the vertex shader
  62473. * @param state current state of the node material building
  62474. * @returns the shader code
  62475. */
  62476. handleVertexSide(state: NodeMaterialBuildState): string;
  62477. /**
  62478. * Gets the main code of the block (fragment side)
  62479. * @param state current state of the node material building
  62480. * @param normalVarName name of the existing variable corresponding to the normal
  62481. * @returns the shader code
  62482. */
  62483. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  62484. protected _buildBlock(state: NodeMaterialBuildState): this;
  62485. protected _dumpPropertiesCode(): string;
  62486. serialize(): any;
  62487. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62488. }
  62489. }
  62490. declare module BABYLON {
  62491. /**
  62492. * Block used to implement the sheen module of the PBR material
  62493. */
  62494. export class SheenBlock extends NodeMaterialBlock {
  62495. /**
  62496. * Create a new SheenBlock
  62497. * @param name defines the block name
  62498. */
  62499. constructor(name: string);
  62500. /**
  62501. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  62502. * It allows the strength of the sheen effect to not depend on the base color of the material,
  62503. * making it easier to setup and tweak the effect
  62504. */
  62505. albedoScaling: boolean;
  62506. /**
  62507. * Defines if the sheen is linked to the sheen color.
  62508. */
  62509. linkSheenWithAlbedo: boolean;
  62510. /**
  62511. * Initialize the block and prepare the context for build
  62512. * @param state defines the state that will be used for the build
  62513. */
  62514. initialize(state: NodeMaterialBuildState): void;
  62515. /**
  62516. * Gets the current class name
  62517. * @returns the class name
  62518. */
  62519. getClassName(): string;
  62520. /**
  62521. * Gets the intensity input component
  62522. */
  62523. get intensity(): NodeMaterialConnectionPoint;
  62524. /**
  62525. * Gets the color input component
  62526. */
  62527. get color(): NodeMaterialConnectionPoint;
  62528. /**
  62529. * Gets the roughness input component
  62530. */
  62531. get roughness(): NodeMaterialConnectionPoint;
  62532. /**
  62533. * Gets the texture input component
  62534. */
  62535. get texture(): NodeMaterialConnectionPoint;
  62536. /**
  62537. * Gets the sheen object output component
  62538. */
  62539. get sheen(): NodeMaterialConnectionPoint;
  62540. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62541. /**
  62542. * Gets the main code of the block (fragment side)
  62543. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  62544. * @returns the shader code
  62545. */
  62546. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  62547. protected _buildBlock(state: NodeMaterialBuildState): this;
  62548. protected _dumpPropertiesCode(): string;
  62549. serialize(): any;
  62550. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62551. }
  62552. }
  62553. declare module BABYLON {
  62554. /**
  62555. * Block used to implement the reflectivity module of the PBR material
  62556. */
  62557. export class ReflectivityBlock extends NodeMaterialBlock {
  62558. /**
  62559. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  62560. */
  62561. useAmbientOcclusionFromMetallicTextureRed: boolean;
  62562. /**
  62563. * Specifies if the metallic texture contains the metallness information in its blue channel.
  62564. */
  62565. useMetallnessFromMetallicTextureBlue: boolean;
  62566. /**
  62567. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  62568. */
  62569. useRoughnessFromMetallicTextureAlpha: boolean;
  62570. /**
  62571. * Specifies if the metallic texture contains the roughness information in its green channel.
  62572. */
  62573. useRoughnessFromMetallicTextureGreen: boolean;
  62574. /**
  62575. * Create a new ReflectivityBlock
  62576. * @param name defines the block name
  62577. */
  62578. constructor(name: string);
  62579. /**
  62580. * Initialize the block and prepare the context for build
  62581. * @param state defines the state that will be used for the build
  62582. */
  62583. initialize(state: NodeMaterialBuildState): void;
  62584. /**
  62585. * Gets the current class name
  62586. * @returns the class name
  62587. */
  62588. getClassName(): string;
  62589. /**
  62590. * Gets the metallic input component
  62591. */
  62592. get metallic(): NodeMaterialConnectionPoint;
  62593. /**
  62594. * Gets the roughness input component
  62595. */
  62596. get roughness(): NodeMaterialConnectionPoint;
  62597. /**
  62598. * Gets the texture input component
  62599. */
  62600. get texture(): NodeMaterialConnectionPoint;
  62601. /**
  62602. * Gets the reflectivity object output component
  62603. */
  62604. get reflectivity(): NodeMaterialConnectionPoint;
  62605. /**
  62606. * Gets the main code of the block (fragment side)
  62607. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  62608. * @returns the shader code
  62609. */
  62610. getCode(aoIntensityVarName: string): string;
  62611. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62612. protected _buildBlock(state: NodeMaterialBuildState): this;
  62613. protected _dumpPropertiesCode(): string;
  62614. serialize(): any;
  62615. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62616. }
  62617. }
  62618. declare module BABYLON {
  62619. /**
  62620. * Block used to implement the anisotropy module of the PBR material
  62621. */
  62622. export class AnisotropyBlock extends NodeMaterialBlock {
  62623. /**
  62624. * The two properties below are set by the main PBR block prior to calling methods of this class.
  62625. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  62626. * It's less burden on the user side in the editor part.
  62627. */
  62628. /** @hidden */
  62629. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  62630. /** @hidden */
  62631. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  62632. /**
  62633. * Create a new AnisotropyBlock
  62634. * @param name defines the block name
  62635. */
  62636. constructor(name: string);
  62637. /**
  62638. * Initialize the block and prepare the context for build
  62639. * @param state defines the state that will be used for the build
  62640. */
  62641. initialize(state: NodeMaterialBuildState): void;
  62642. /**
  62643. * Gets the current class name
  62644. * @returns the class name
  62645. */
  62646. getClassName(): string;
  62647. /**
  62648. * Gets the intensity input component
  62649. */
  62650. get intensity(): NodeMaterialConnectionPoint;
  62651. /**
  62652. * Gets the direction input component
  62653. */
  62654. get direction(): NodeMaterialConnectionPoint;
  62655. /**
  62656. * Gets the texture input component
  62657. */
  62658. get texture(): NodeMaterialConnectionPoint;
  62659. /**
  62660. * Gets the uv input component
  62661. */
  62662. get uv(): NodeMaterialConnectionPoint;
  62663. /**
  62664. * Gets the worldTangent input component
  62665. */
  62666. get worldTangent(): NodeMaterialConnectionPoint;
  62667. /**
  62668. * Gets the anisotropy object output component
  62669. */
  62670. get anisotropy(): NodeMaterialConnectionPoint;
  62671. private _generateTBNSpace;
  62672. /**
  62673. * Gets the main code of the block (fragment side)
  62674. * @param state current state of the node material building
  62675. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  62676. * @returns the shader code
  62677. */
  62678. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  62679. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62680. protected _buildBlock(state: NodeMaterialBuildState): this;
  62681. }
  62682. }
  62683. declare module BABYLON {
  62684. /**
  62685. * Block used to implement the clear coat module of the PBR material
  62686. */
  62687. export class ClearCoatBlock extends NodeMaterialBlock {
  62688. private _scene;
  62689. /**
  62690. * Create a new ClearCoatBlock
  62691. * @param name defines the block name
  62692. */
  62693. constructor(name: string);
  62694. /**
  62695. * Initialize the block and prepare the context for build
  62696. * @param state defines the state that will be used for the build
  62697. */
  62698. initialize(state: NodeMaterialBuildState): void;
  62699. /**
  62700. * Gets the current class name
  62701. * @returns the class name
  62702. */
  62703. getClassName(): string;
  62704. /**
  62705. * Gets the intensity input component
  62706. */
  62707. get intensity(): NodeMaterialConnectionPoint;
  62708. /**
  62709. * Gets the roughness input component
  62710. */
  62711. get roughness(): NodeMaterialConnectionPoint;
  62712. /**
  62713. * Gets the ior input component
  62714. */
  62715. get ior(): NodeMaterialConnectionPoint;
  62716. /**
  62717. * Gets the texture input component
  62718. */
  62719. get texture(): NodeMaterialConnectionPoint;
  62720. /**
  62721. * Gets the bump texture input component
  62722. */
  62723. get bumpTexture(): NodeMaterialConnectionPoint;
  62724. /**
  62725. * Gets the uv input component
  62726. */
  62727. get uv(): NodeMaterialConnectionPoint;
  62728. /**
  62729. * Gets the tint color input component
  62730. */
  62731. get tintColor(): NodeMaterialConnectionPoint;
  62732. /**
  62733. * Gets the tint "at distance" input component
  62734. */
  62735. get tintAtDistance(): NodeMaterialConnectionPoint;
  62736. /**
  62737. * Gets the tint thickness input component
  62738. */
  62739. get tintThickness(): NodeMaterialConnectionPoint;
  62740. /**
  62741. * Gets the tint texture input component
  62742. */
  62743. get tintTexture(): NodeMaterialConnectionPoint;
  62744. /**
  62745. * Gets the world tangent input component
  62746. */
  62747. get worldTangent(): NodeMaterialConnectionPoint;
  62748. /**
  62749. * Gets the clear coat object output component
  62750. */
  62751. get clearcoat(): NodeMaterialConnectionPoint;
  62752. autoConfigure(material: NodeMaterial): void;
  62753. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62754. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  62755. private _generateTBNSpace;
  62756. /**
  62757. * Gets the main code of the block (fragment side)
  62758. * @param state current state of the node material building
  62759. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  62760. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  62761. * @param worldPosVarName name of the variable holding the world position
  62762. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  62763. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  62764. * @param worldNormalVarName name of the variable holding the world normal
  62765. * @returns the shader code
  62766. */
  62767. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  62768. protected _buildBlock(state: NodeMaterialBuildState): this;
  62769. }
  62770. }
  62771. declare module BABYLON {
  62772. /**
  62773. * Block used to implement the sub surface module of the PBR material
  62774. */
  62775. export class SubSurfaceBlock extends NodeMaterialBlock {
  62776. /**
  62777. * Create a new SubSurfaceBlock
  62778. * @param name defines the block name
  62779. */
  62780. constructor(name: string);
  62781. /**
  62782. * Stores the intensity of the different subsurface effects in the thickness texture.
  62783. * * the green channel is the translucency intensity.
  62784. * * the blue channel is the scattering intensity.
  62785. * * the alpha channel is the refraction intensity.
  62786. */
  62787. useMaskFromThicknessTexture: boolean;
  62788. /**
  62789. * Initialize the block and prepare the context for build
  62790. * @param state defines the state that will be used for the build
  62791. */
  62792. initialize(state: NodeMaterialBuildState): void;
  62793. /**
  62794. * Gets the current class name
  62795. * @returns the class name
  62796. */
  62797. getClassName(): string;
  62798. /**
  62799. * Gets the min thickness input component
  62800. */
  62801. get minThickness(): NodeMaterialConnectionPoint;
  62802. /**
  62803. * Gets the max thickness input component
  62804. */
  62805. get maxThickness(): NodeMaterialConnectionPoint;
  62806. /**
  62807. * Gets the thickness texture component
  62808. */
  62809. get thicknessTexture(): NodeMaterialConnectionPoint;
  62810. /**
  62811. * Gets the tint color input component
  62812. */
  62813. get tintColor(): NodeMaterialConnectionPoint;
  62814. /**
  62815. * Gets the translucency intensity input component
  62816. */
  62817. get translucencyIntensity(): NodeMaterialConnectionPoint;
  62818. /**
  62819. * Gets the translucency diffusion distance input component
  62820. */
  62821. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  62822. /**
  62823. * Gets the refraction object parameters
  62824. */
  62825. get refraction(): NodeMaterialConnectionPoint;
  62826. /**
  62827. * Gets the sub surface object output component
  62828. */
  62829. get subsurface(): NodeMaterialConnectionPoint;
  62830. autoConfigure(material: NodeMaterial): void;
  62831. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62832. /**
  62833. * Gets the main code of the block (fragment side)
  62834. * @param state current state of the node material building
  62835. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  62836. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  62837. * @param worldPosVarName name of the variable holding the world position
  62838. * @returns the shader code
  62839. */
  62840. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  62841. protected _buildBlock(state: NodeMaterialBuildState): this;
  62842. }
  62843. }
  62844. declare module BABYLON {
  62845. /**
  62846. * Block used to implement the PBR metallic/roughness model
  62847. */
  62848. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  62849. /**
  62850. * Gets or sets the light associated with this block
  62851. */
  62852. light: Nullable<Light>;
  62853. private _lightId;
  62854. private _scene;
  62855. private _environmentBRDFTexture;
  62856. private _environmentBrdfSamplerName;
  62857. private _vNormalWName;
  62858. private _invertNormalName;
  62859. /**
  62860. * Create a new ReflectionBlock
  62861. * @param name defines the block name
  62862. */
  62863. constructor(name: string);
  62864. /**
  62865. * Intensity of the direct lights e.g. the four lights available in your scene.
  62866. * This impacts both the direct diffuse and specular highlights.
  62867. */
  62868. directIntensity: number;
  62869. /**
  62870. * Intensity of the environment e.g. how much the environment will light the object
  62871. * either through harmonics for rough material or through the refelction for shiny ones.
  62872. */
  62873. environmentIntensity: number;
  62874. /**
  62875. * This is a special control allowing the reduction of the specular highlights coming from the
  62876. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  62877. */
  62878. specularIntensity: number;
  62879. /**
  62880. * Defines the falloff type used in this material.
  62881. * It by default is Physical.
  62882. */
  62883. lightFalloff: number;
  62884. /**
  62885. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  62886. */
  62887. useAlphaFromAlbedoTexture: boolean;
  62888. /**
  62889. * Specifies that alpha test should be used
  62890. */
  62891. useAlphaTest: boolean;
  62892. /**
  62893. * Defines the alpha limits in alpha test mode.
  62894. */
  62895. alphaTestCutoff: number;
  62896. /**
  62897. * Specifies that alpha blending should be used
  62898. */
  62899. useAlphaBlending: boolean;
  62900. /**
  62901. * Defines if the alpha value should be determined via the rgb values.
  62902. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  62903. */
  62904. opacityRGB: boolean;
  62905. /**
  62906. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  62907. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  62908. */
  62909. useRadianceOverAlpha: boolean;
  62910. /**
  62911. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  62912. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  62913. */
  62914. useSpecularOverAlpha: boolean;
  62915. /**
  62916. * Enables specular anti aliasing in the PBR shader.
  62917. * It will both interacts on the Geometry for analytical and IBL lighting.
  62918. * It also prefilter the roughness map based on the bump values.
  62919. */
  62920. enableSpecularAntiAliasing: boolean;
  62921. /**
  62922. * Defines if the material uses energy conservation.
  62923. */
  62924. useEnergyConservation: boolean;
  62925. /**
  62926. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  62927. * too much the area relying on ambient texture to define their ambient occlusion.
  62928. */
  62929. useRadianceOcclusion: boolean;
  62930. /**
  62931. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  62932. * makes the reflect vector face the model (under horizon).
  62933. */
  62934. useHorizonOcclusion: boolean;
  62935. /**
  62936. * If set to true, no lighting calculations will be applied.
  62937. */
  62938. unlit: boolean;
  62939. /**
  62940. * Force normal to face away from face.
  62941. */
  62942. forceNormalForward: boolean;
  62943. /**
  62944. * Defines the material debug mode.
  62945. * It helps seeing only some components of the material while troubleshooting.
  62946. */
  62947. debugMode: number;
  62948. /**
  62949. * Specify from where on screen the debug mode should start.
  62950. * The value goes from -1 (full screen) to 1 (not visible)
  62951. * It helps with side by side comparison against the final render
  62952. * This defaults to 0
  62953. */
  62954. debugLimit: number;
  62955. /**
  62956. * As the default viewing range might not be enough (if the ambient is really small for instance)
  62957. * You can use the factor to better multiply the final value.
  62958. */
  62959. debugFactor: number;
  62960. /**
  62961. * Initialize the block and prepare the context for build
  62962. * @param state defines the state that will be used for the build
  62963. */
  62964. initialize(state: NodeMaterialBuildState): void;
  62965. /**
  62966. * Gets the current class name
  62967. * @returns the class name
  62968. */
  62969. getClassName(): string;
  62970. /**
  62971. * Gets the world position input component
  62972. */
  62973. get worldPosition(): NodeMaterialConnectionPoint;
  62974. /**
  62975. * Gets the world normal input component
  62976. */
  62977. get worldNormal(): NodeMaterialConnectionPoint;
  62978. /**
  62979. * Gets the perturbed normal input component
  62980. */
  62981. get perturbedNormal(): NodeMaterialConnectionPoint;
  62982. /**
  62983. * Gets the camera position input component
  62984. */
  62985. get cameraPosition(): NodeMaterialConnectionPoint;
  62986. /**
  62987. * Gets the base color input component
  62988. */
  62989. get baseColor(): NodeMaterialConnectionPoint;
  62990. /**
  62991. * Gets the base texture input component
  62992. */
  62993. get baseTexture(): NodeMaterialConnectionPoint;
  62994. /**
  62995. * Gets the opacity texture input component
  62996. */
  62997. get opacityTexture(): NodeMaterialConnectionPoint;
  62998. /**
  62999. * Gets the ambient color input component
  63000. */
  63001. get ambientColor(): NodeMaterialConnectionPoint;
  63002. /**
  63003. * Gets the reflectivity object parameters
  63004. */
  63005. get reflectivity(): NodeMaterialConnectionPoint;
  63006. /**
  63007. * Gets the ambient occlusion object parameters
  63008. */
  63009. get ambientOcclusion(): NodeMaterialConnectionPoint;
  63010. /**
  63011. * Gets the reflection object parameters
  63012. */
  63013. get reflection(): NodeMaterialConnectionPoint;
  63014. /**
  63015. * Gets the sheen object parameters
  63016. */
  63017. get sheen(): NodeMaterialConnectionPoint;
  63018. /**
  63019. * Gets the clear coat object parameters
  63020. */
  63021. get clearcoat(): NodeMaterialConnectionPoint;
  63022. /**
  63023. * Gets the sub surface object parameters
  63024. */
  63025. get subsurface(): NodeMaterialConnectionPoint;
  63026. /**
  63027. * Gets the anisotropy object parameters
  63028. */
  63029. get anisotropy(): NodeMaterialConnectionPoint;
  63030. /**
  63031. * Gets the ambient output component
  63032. */
  63033. get ambient(): NodeMaterialConnectionPoint;
  63034. /**
  63035. * Gets the diffuse output component
  63036. */
  63037. get diffuse(): NodeMaterialConnectionPoint;
  63038. /**
  63039. * Gets the specular output component
  63040. */
  63041. get specular(): NodeMaterialConnectionPoint;
  63042. /**
  63043. * Gets the sheen output component
  63044. */
  63045. get sheenDir(): NodeMaterialConnectionPoint;
  63046. /**
  63047. * Gets the clear coat output component
  63048. */
  63049. get clearcoatDir(): NodeMaterialConnectionPoint;
  63050. /**
  63051. * Gets the indirect diffuse output component
  63052. */
  63053. get diffuseIndirect(): NodeMaterialConnectionPoint;
  63054. /**
  63055. * Gets the indirect specular output component
  63056. */
  63057. get specularIndirect(): NodeMaterialConnectionPoint;
  63058. /**
  63059. * Gets the indirect sheen output component
  63060. */
  63061. get sheenIndirect(): NodeMaterialConnectionPoint;
  63062. /**
  63063. * Gets the indirect clear coat output component
  63064. */
  63065. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  63066. /**
  63067. * Gets the refraction output component
  63068. */
  63069. get refraction(): NodeMaterialConnectionPoint;
  63070. /**
  63071. * Gets the global lighting output component
  63072. */
  63073. get lighting(): NodeMaterialConnectionPoint;
  63074. /**
  63075. * Gets the shadow output component
  63076. */
  63077. get shadow(): NodeMaterialConnectionPoint;
  63078. /**
  63079. * Gets the alpha output component
  63080. */
  63081. get alpha(): NodeMaterialConnectionPoint;
  63082. autoConfigure(material: NodeMaterial): void;
  63083. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63084. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  63085. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63086. private _injectVertexCode;
  63087. /**
  63088. * Gets the code corresponding to the albedo/opacity module
  63089. * @returns the shader code
  63090. */
  63091. getAlbedoOpacityCode(): string;
  63092. protected _buildBlock(state: NodeMaterialBuildState): this;
  63093. protected _dumpPropertiesCode(): string;
  63094. serialize(): any;
  63095. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63096. }
  63097. }
  63098. declare module BABYLON {
  63099. /**
  63100. * Block used to compute value of one parameter modulo another
  63101. */
  63102. export class ModBlock extends NodeMaterialBlock {
  63103. /**
  63104. * Creates a new ModBlock
  63105. * @param name defines the block name
  63106. */
  63107. constructor(name: string);
  63108. /**
  63109. * Gets the current class name
  63110. * @returns the class name
  63111. */
  63112. getClassName(): string;
  63113. /**
  63114. * Gets the left operand input component
  63115. */
  63116. get left(): NodeMaterialConnectionPoint;
  63117. /**
  63118. * Gets the right operand input component
  63119. */
  63120. get right(): NodeMaterialConnectionPoint;
  63121. /**
  63122. * Gets the output component
  63123. */
  63124. get output(): NodeMaterialConnectionPoint;
  63125. protected _buildBlock(state: NodeMaterialBuildState): this;
  63126. }
  63127. }
  63128. declare module BABYLON {
  63129. /**
  63130. * Helper class to push actions to a pool of workers.
  63131. */
  63132. export class WorkerPool implements IDisposable {
  63133. private _workerInfos;
  63134. private _pendingActions;
  63135. /**
  63136. * Constructor
  63137. * @param workers Array of workers to use for actions
  63138. */
  63139. constructor(workers: Array<Worker>);
  63140. /**
  63141. * Terminates all workers and clears any pending actions.
  63142. */
  63143. dispose(): void;
  63144. /**
  63145. * Pushes an action to the worker pool. If all the workers are active, the action will be
  63146. * pended until a worker has completed its action.
  63147. * @param action The action to perform. Call onComplete when the action is complete.
  63148. */
  63149. push(action: (worker: Worker, onComplete: () => void) => void): void;
  63150. private _execute;
  63151. }
  63152. }
  63153. declare module BABYLON {
  63154. /**
  63155. * Configuration for Draco compression
  63156. */
  63157. export interface IDracoCompressionConfiguration {
  63158. /**
  63159. * Configuration for the decoder.
  63160. */
  63161. decoder: {
  63162. /**
  63163. * The url to the WebAssembly module.
  63164. */
  63165. wasmUrl?: string;
  63166. /**
  63167. * The url to the WebAssembly binary.
  63168. */
  63169. wasmBinaryUrl?: string;
  63170. /**
  63171. * The url to the fallback JavaScript module.
  63172. */
  63173. fallbackUrl?: string;
  63174. };
  63175. }
  63176. /**
  63177. * Draco compression (https://google.github.io/draco/)
  63178. *
  63179. * This class wraps the Draco module.
  63180. *
  63181. * **Encoder**
  63182. *
  63183. * The encoder is not currently implemented.
  63184. *
  63185. * **Decoder**
  63186. *
  63187. * 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.
  63188. *
  63189. * To update the configuration, use the following code:
  63190. * ```javascript
  63191. * DracoCompression.Configuration = {
  63192. * decoder: {
  63193. * wasmUrl: "<url to the WebAssembly library>",
  63194. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  63195. * fallbackUrl: "<url to the fallback JavaScript library>",
  63196. * }
  63197. * };
  63198. * ```
  63199. *
  63200. * 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.
  63201. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  63202. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  63203. *
  63204. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  63205. * ```javascript
  63206. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  63207. * ```
  63208. *
  63209. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  63210. */
  63211. export class DracoCompression implements IDisposable {
  63212. private _workerPoolPromise?;
  63213. private _decoderModulePromise?;
  63214. /**
  63215. * The configuration. Defaults to the following urls:
  63216. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  63217. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  63218. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  63219. */
  63220. static Configuration: IDracoCompressionConfiguration;
  63221. /**
  63222. * Returns true if the decoder configuration is available.
  63223. */
  63224. static get DecoderAvailable(): boolean;
  63225. /**
  63226. * Default number of workers to create when creating the draco compression object.
  63227. */
  63228. static DefaultNumWorkers: number;
  63229. private static GetDefaultNumWorkers;
  63230. private static _Default;
  63231. /**
  63232. * Default instance for the draco compression object.
  63233. */
  63234. static get Default(): DracoCompression;
  63235. /**
  63236. * Constructor
  63237. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  63238. */
  63239. constructor(numWorkers?: number);
  63240. /**
  63241. * Stop all async operations and release resources.
  63242. */
  63243. dispose(): void;
  63244. /**
  63245. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  63246. * @returns a promise that resolves when ready
  63247. */
  63248. whenReadyAsync(): Promise<void>;
  63249. /**
  63250. * Decode Draco compressed mesh data to vertex data.
  63251. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  63252. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  63253. * @returns A promise that resolves with the decoded vertex data
  63254. */
  63255. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  63256. [kind: string]: number;
  63257. }): Promise<VertexData>;
  63258. }
  63259. }
  63260. declare module BABYLON {
  63261. /**
  63262. * Class for building Constructive Solid Geometry
  63263. */
  63264. export class CSG {
  63265. private polygons;
  63266. /**
  63267. * The world matrix
  63268. */
  63269. matrix: Matrix;
  63270. /**
  63271. * Stores the position
  63272. */
  63273. position: Vector3;
  63274. /**
  63275. * Stores the rotation
  63276. */
  63277. rotation: Vector3;
  63278. /**
  63279. * Stores the rotation quaternion
  63280. */
  63281. rotationQuaternion: Nullable<Quaternion>;
  63282. /**
  63283. * Stores the scaling vector
  63284. */
  63285. scaling: Vector3;
  63286. /**
  63287. * Convert the Mesh to CSG
  63288. * @param mesh The Mesh to convert to CSG
  63289. * @returns A new CSG from the Mesh
  63290. */
  63291. static FromMesh(mesh: Mesh): CSG;
  63292. /**
  63293. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  63294. * @param polygons Polygons used to construct a CSG solid
  63295. */
  63296. private static FromPolygons;
  63297. /**
  63298. * Clones, or makes a deep copy, of the CSG
  63299. * @returns A new CSG
  63300. */
  63301. clone(): CSG;
  63302. /**
  63303. * Unions this CSG with another CSG
  63304. * @param csg The CSG to union against this CSG
  63305. * @returns The unioned CSG
  63306. */
  63307. union(csg: CSG): CSG;
  63308. /**
  63309. * Unions this CSG with another CSG in place
  63310. * @param csg The CSG to union against this CSG
  63311. */
  63312. unionInPlace(csg: CSG): void;
  63313. /**
  63314. * Subtracts this CSG with another CSG
  63315. * @param csg The CSG to subtract against this CSG
  63316. * @returns A new CSG
  63317. */
  63318. subtract(csg: CSG): CSG;
  63319. /**
  63320. * Subtracts this CSG with another CSG in place
  63321. * @param csg The CSG to subtact against this CSG
  63322. */
  63323. subtractInPlace(csg: CSG): void;
  63324. /**
  63325. * Intersect this CSG with another CSG
  63326. * @param csg The CSG to intersect against this CSG
  63327. * @returns A new CSG
  63328. */
  63329. intersect(csg: CSG): CSG;
  63330. /**
  63331. * Intersects this CSG with another CSG in place
  63332. * @param csg The CSG to intersect against this CSG
  63333. */
  63334. intersectInPlace(csg: CSG): void;
  63335. /**
  63336. * Return a new CSG solid with solid and empty space switched. This solid is
  63337. * not modified.
  63338. * @returns A new CSG solid with solid and empty space switched
  63339. */
  63340. inverse(): CSG;
  63341. /**
  63342. * Inverses the CSG in place
  63343. */
  63344. inverseInPlace(): void;
  63345. /**
  63346. * This is used to keep meshes transformations so they can be restored
  63347. * when we build back a Babylon Mesh
  63348. * NB : All CSG operations are performed in world coordinates
  63349. * @param csg The CSG to copy the transform attributes from
  63350. * @returns This CSG
  63351. */
  63352. copyTransformAttributes(csg: CSG): CSG;
  63353. /**
  63354. * Build Raw mesh from CSG
  63355. * Coordinates here are in world space
  63356. * @param name The name of the mesh geometry
  63357. * @param scene The Scene
  63358. * @param keepSubMeshes Specifies if the submeshes should be kept
  63359. * @returns A new Mesh
  63360. */
  63361. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  63362. /**
  63363. * Build Mesh from CSG taking material and transforms into account
  63364. * @param name The name of the Mesh
  63365. * @param material The material of the Mesh
  63366. * @param scene The Scene
  63367. * @param keepSubMeshes Specifies if submeshes should be kept
  63368. * @returns The new Mesh
  63369. */
  63370. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  63371. }
  63372. }
  63373. declare module BABYLON {
  63374. /**
  63375. * Class used to create a trail following a mesh
  63376. */
  63377. export class TrailMesh extends Mesh {
  63378. private _generator;
  63379. private _autoStart;
  63380. private _running;
  63381. private _diameter;
  63382. private _length;
  63383. private _sectionPolygonPointsCount;
  63384. private _sectionVectors;
  63385. private _sectionNormalVectors;
  63386. private _beforeRenderObserver;
  63387. /**
  63388. * @constructor
  63389. * @param name The value used by scene.getMeshByName() to do a lookup.
  63390. * @param generator The mesh or transform node to generate a trail.
  63391. * @param scene The scene to add this mesh to.
  63392. * @param diameter Diameter of trailing mesh. Default is 1.
  63393. * @param length Length of trailing mesh. Default is 60.
  63394. * @param autoStart Automatically start trailing mesh. Default true.
  63395. */
  63396. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  63397. /**
  63398. * "TrailMesh"
  63399. * @returns "TrailMesh"
  63400. */
  63401. getClassName(): string;
  63402. private _createMesh;
  63403. /**
  63404. * Start trailing mesh.
  63405. */
  63406. start(): void;
  63407. /**
  63408. * Stop trailing mesh.
  63409. */
  63410. stop(): void;
  63411. /**
  63412. * Update trailing mesh geometry.
  63413. */
  63414. update(): void;
  63415. /**
  63416. * Returns a new TrailMesh object.
  63417. * @param name is a string, the name given to the new mesh
  63418. * @param newGenerator use new generator object for cloned trail mesh
  63419. * @returns a new mesh
  63420. */
  63421. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  63422. /**
  63423. * Serializes this trail mesh
  63424. * @param serializationObject object to write serialization to
  63425. */
  63426. serialize(serializationObject: any): void;
  63427. /**
  63428. * Parses a serialized trail mesh
  63429. * @param parsedMesh the serialized mesh
  63430. * @param scene the scene to create the trail mesh in
  63431. * @returns the created trail mesh
  63432. */
  63433. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  63434. }
  63435. }
  63436. declare module BABYLON {
  63437. /**
  63438. * Class containing static functions to help procedurally build meshes
  63439. */
  63440. export class TiledBoxBuilder {
  63441. /**
  63442. * Creates a box mesh
  63443. * 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)
  63444. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63445. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63446. * * 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
  63447. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63448. * @param name defines the name of the mesh
  63449. * @param options defines the options used to create the mesh
  63450. * @param scene defines the hosting scene
  63451. * @returns the box mesh
  63452. */
  63453. static CreateTiledBox(name: string, options: {
  63454. pattern?: number;
  63455. width?: number;
  63456. height?: number;
  63457. depth?: number;
  63458. tileSize?: number;
  63459. tileWidth?: number;
  63460. tileHeight?: number;
  63461. alignHorizontal?: number;
  63462. alignVertical?: number;
  63463. faceUV?: Vector4[];
  63464. faceColors?: Color4[];
  63465. sideOrientation?: number;
  63466. updatable?: boolean;
  63467. }, scene?: Nullable<Scene>): Mesh;
  63468. }
  63469. }
  63470. declare module BABYLON {
  63471. /**
  63472. * Class containing static functions to help procedurally build meshes
  63473. */
  63474. export class TorusKnotBuilder {
  63475. /**
  63476. * Creates a torus knot mesh
  63477. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  63478. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  63479. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  63480. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  63481. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63482. * * 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
  63483. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63484. * @param name defines the name of the mesh
  63485. * @param options defines the options used to create the mesh
  63486. * @param scene defines the hosting scene
  63487. * @returns the torus knot mesh
  63488. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  63489. */
  63490. static CreateTorusKnot(name: string, options: {
  63491. radius?: number;
  63492. tube?: number;
  63493. radialSegments?: number;
  63494. tubularSegments?: number;
  63495. p?: number;
  63496. q?: number;
  63497. updatable?: boolean;
  63498. sideOrientation?: number;
  63499. frontUVs?: Vector4;
  63500. backUVs?: Vector4;
  63501. }, scene: any): Mesh;
  63502. }
  63503. }
  63504. declare module BABYLON {
  63505. /**
  63506. * Polygon
  63507. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  63508. */
  63509. export class Polygon {
  63510. /**
  63511. * Creates a rectangle
  63512. * @param xmin bottom X coord
  63513. * @param ymin bottom Y coord
  63514. * @param xmax top X coord
  63515. * @param ymax top Y coord
  63516. * @returns points that make the resulting rectation
  63517. */
  63518. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  63519. /**
  63520. * Creates a circle
  63521. * @param radius radius of circle
  63522. * @param cx scale in x
  63523. * @param cy scale in y
  63524. * @param numberOfSides number of sides that make up the circle
  63525. * @returns points that make the resulting circle
  63526. */
  63527. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  63528. /**
  63529. * Creates a polygon from input string
  63530. * @param input Input polygon data
  63531. * @returns the parsed points
  63532. */
  63533. static Parse(input: string): Vector2[];
  63534. /**
  63535. * Starts building a polygon from x and y coordinates
  63536. * @param x x coordinate
  63537. * @param y y coordinate
  63538. * @returns the started path2
  63539. */
  63540. static StartingAt(x: number, y: number): Path2;
  63541. }
  63542. /**
  63543. * Builds a polygon
  63544. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  63545. */
  63546. export class PolygonMeshBuilder {
  63547. private _points;
  63548. private _outlinepoints;
  63549. private _holes;
  63550. private _name;
  63551. private _scene;
  63552. private _epoints;
  63553. private _eholes;
  63554. private _addToepoint;
  63555. /**
  63556. * Babylon reference to the earcut plugin.
  63557. */
  63558. bjsEarcut: any;
  63559. /**
  63560. * Creates a PolygonMeshBuilder
  63561. * @param name name of the builder
  63562. * @param contours Path of the polygon
  63563. * @param scene scene to add to when creating the mesh
  63564. * @param earcutInjection can be used to inject your own earcut reference
  63565. */
  63566. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  63567. /**
  63568. * Adds a whole within the polygon
  63569. * @param hole Array of points defining the hole
  63570. * @returns this
  63571. */
  63572. addHole(hole: Vector2[]): PolygonMeshBuilder;
  63573. /**
  63574. * Creates the polygon
  63575. * @param updatable If the mesh should be updatable
  63576. * @param depth The depth of the mesh created
  63577. * @returns the created mesh
  63578. */
  63579. build(updatable?: boolean, depth?: number): Mesh;
  63580. /**
  63581. * Creates the polygon
  63582. * @param depth The depth of the mesh created
  63583. * @returns the created VertexData
  63584. */
  63585. buildVertexData(depth?: number): VertexData;
  63586. /**
  63587. * Adds a side to the polygon
  63588. * @param positions points that make the polygon
  63589. * @param normals normals of the polygon
  63590. * @param uvs uvs of the polygon
  63591. * @param indices indices of the polygon
  63592. * @param bounds bounds of the polygon
  63593. * @param points points of the polygon
  63594. * @param depth depth of the polygon
  63595. * @param flip flip of the polygon
  63596. */
  63597. private addSide;
  63598. }
  63599. }
  63600. declare module BABYLON {
  63601. /**
  63602. * Class containing static functions to help procedurally build meshes
  63603. */
  63604. export class PolygonBuilder {
  63605. /**
  63606. * Creates a polygon mesh
  63607. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  63608. * * 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
  63609. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  63610. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63611. * * 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)
  63612. * * Remember you can only change the shape positions, not their number when updating a polygon
  63613. * @param name defines the name of the mesh
  63614. * @param options defines the options used to create the mesh
  63615. * @param scene defines the hosting scene
  63616. * @param earcutInjection can be used to inject your own earcut reference
  63617. * @returns the polygon mesh
  63618. */
  63619. static CreatePolygon(name: string, options: {
  63620. shape: Vector3[];
  63621. holes?: Vector3[][];
  63622. depth?: number;
  63623. faceUV?: Vector4[];
  63624. faceColors?: Color4[];
  63625. updatable?: boolean;
  63626. sideOrientation?: number;
  63627. frontUVs?: Vector4;
  63628. backUVs?: Vector4;
  63629. wrap?: boolean;
  63630. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63631. /**
  63632. * Creates an extruded polygon mesh, with depth in the Y direction.
  63633. * * 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)
  63634. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63635. * @param name defines the name of the mesh
  63636. * @param options defines the options used to create the mesh
  63637. * @param scene defines the hosting scene
  63638. * @param earcutInjection can be used to inject your own earcut reference
  63639. * @returns the polygon mesh
  63640. */
  63641. static ExtrudePolygon(name: string, options: {
  63642. shape: Vector3[];
  63643. holes?: Vector3[][];
  63644. depth?: number;
  63645. faceUV?: Vector4[];
  63646. faceColors?: Color4[];
  63647. updatable?: boolean;
  63648. sideOrientation?: number;
  63649. frontUVs?: Vector4;
  63650. backUVs?: Vector4;
  63651. wrap?: boolean;
  63652. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63653. }
  63654. }
  63655. declare module BABYLON {
  63656. /**
  63657. * Class containing static functions to help procedurally build meshes
  63658. */
  63659. export class LatheBuilder {
  63660. /**
  63661. * Creates lathe mesh.
  63662. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  63663. * * 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
  63664. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  63665. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  63666. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  63667. * * 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
  63668. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  63669. * * 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
  63670. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63671. * * 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
  63672. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63673. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63674. * @param name defines the name of the mesh
  63675. * @param options defines the options used to create the mesh
  63676. * @param scene defines the hosting scene
  63677. * @returns the lathe mesh
  63678. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  63679. */
  63680. static CreateLathe(name: string, options: {
  63681. shape: Vector3[];
  63682. radius?: number;
  63683. tessellation?: number;
  63684. clip?: number;
  63685. arc?: number;
  63686. closed?: boolean;
  63687. updatable?: boolean;
  63688. sideOrientation?: number;
  63689. frontUVs?: Vector4;
  63690. backUVs?: Vector4;
  63691. cap?: number;
  63692. invertUV?: boolean;
  63693. }, scene?: Nullable<Scene>): Mesh;
  63694. }
  63695. }
  63696. declare module BABYLON {
  63697. /**
  63698. * Class containing static functions to help procedurally build meshes
  63699. */
  63700. export class TiledPlaneBuilder {
  63701. /**
  63702. * Creates a tiled plane mesh
  63703. * * The parameter `pattern` will, depending on value, do nothing or
  63704. * * * flip (reflect about central vertical) alternate tiles across and up
  63705. * * * flip every tile on alternate rows
  63706. * * * rotate (180 degs) alternate tiles across and up
  63707. * * * rotate every tile on alternate rows
  63708. * * * flip and rotate alternate tiles across and up
  63709. * * * flip and rotate every tile on alternate rows
  63710. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  63711. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  63712. * * 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
  63713. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  63714. * * 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)
  63715. * * 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)
  63716. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  63717. * @param name defines the name of the mesh
  63718. * @param options defines the options used to create the mesh
  63719. * @param scene defines the hosting scene
  63720. * @returns the box mesh
  63721. */
  63722. static CreateTiledPlane(name: string, options: {
  63723. pattern?: number;
  63724. tileSize?: number;
  63725. tileWidth?: number;
  63726. tileHeight?: number;
  63727. size?: number;
  63728. width?: number;
  63729. height?: number;
  63730. alignHorizontal?: number;
  63731. alignVertical?: number;
  63732. sideOrientation?: number;
  63733. frontUVs?: Vector4;
  63734. backUVs?: Vector4;
  63735. updatable?: boolean;
  63736. }, scene?: Nullable<Scene>): Mesh;
  63737. }
  63738. }
  63739. declare module BABYLON {
  63740. /**
  63741. * Class containing static functions to help procedurally build meshes
  63742. */
  63743. export class TubeBuilder {
  63744. /**
  63745. * Creates a tube mesh.
  63746. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  63747. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  63748. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  63749. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  63750. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  63751. * * 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)
  63752. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  63753. * * 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
  63754. * * 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
  63755. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63756. * * 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
  63757. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63758. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63759. * @param name defines the name of the mesh
  63760. * @param options defines the options used to create the mesh
  63761. * @param scene defines the hosting scene
  63762. * @returns the tube mesh
  63763. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  63764. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  63765. */
  63766. static CreateTube(name: string, options: {
  63767. path: Vector3[];
  63768. radius?: number;
  63769. tessellation?: number;
  63770. radiusFunction?: {
  63771. (i: number, distance: number): number;
  63772. };
  63773. cap?: number;
  63774. arc?: number;
  63775. updatable?: boolean;
  63776. sideOrientation?: number;
  63777. frontUVs?: Vector4;
  63778. backUVs?: Vector4;
  63779. instance?: Mesh;
  63780. invertUV?: boolean;
  63781. }, scene?: Nullable<Scene>): Mesh;
  63782. }
  63783. }
  63784. declare module BABYLON {
  63785. /**
  63786. * Class containing static functions to help procedurally build meshes
  63787. */
  63788. export class IcoSphereBuilder {
  63789. /**
  63790. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  63791. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  63792. * * 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`)
  63793. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  63794. * * 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
  63795. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63796. * * 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
  63797. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63798. * @param name defines the name of the mesh
  63799. * @param options defines the options used to create the mesh
  63800. * @param scene defines the hosting scene
  63801. * @returns the icosahedron mesh
  63802. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  63803. */
  63804. static CreateIcoSphere(name: string, options: {
  63805. radius?: number;
  63806. radiusX?: number;
  63807. radiusY?: number;
  63808. radiusZ?: number;
  63809. flat?: boolean;
  63810. subdivisions?: number;
  63811. sideOrientation?: number;
  63812. frontUVs?: Vector4;
  63813. backUVs?: Vector4;
  63814. updatable?: boolean;
  63815. }, scene?: Nullable<Scene>): Mesh;
  63816. }
  63817. }
  63818. declare module BABYLON {
  63819. /**
  63820. * Class containing static functions to help procedurally build meshes
  63821. */
  63822. export class DecalBuilder {
  63823. /**
  63824. * Creates a decal mesh.
  63825. * 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
  63826. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  63827. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  63828. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  63829. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  63830. * @param name defines the name of the mesh
  63831. * @param sourceMesh defines the mesh where the decal must be applied
  63832. * @param options defines the options used to create the mesh
  63833. * @param scene defines the hosting scene
  63834. * @returns the decal mesh
  63835. * @see https://doc.babylonjs.com/how_to/decals
  63836. */
  63837. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  63838. position?: Vector3;
  63839. normal?: Vector3;
  63840. size?: Vector3;
  63841. angle?: number;
  63842. }): Mesh;
  63843. }
  63844. }
  63845. declare module BABYLON {
  63846. /**
  63847. * Class containing static functions to help procedurally build meshes
  63848. */
  63849. export class MeshBuilder {
  63850. /**
  63851. * Creates a box mesh
  63852. * * The parameter `size` sets the size (float) of each box side (default 1)
  63853. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  63854. * * 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)
  63855. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63856. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63857. * * 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
  63858. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63859. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  63860. * @param name defines the name of the mesh
  63861. * @param options defines the options used to create the mesh
  63862. * @param scene defines the hosting scene
  63863. * @returns the box mesh
  63864. */
  63865. static CreateBox(name: string, options: {
  63866. size?: number;
  63867. width?: number;
  63868. height?: number;
  63869. depth?: number;
  63870. faceUV?: Vector4[];
  63871. faceColors?: Color4[];
  63872. sideOrientation?: number;
  63873. frontUVs?: Vector4;
  63874. backUVs?: Vector4;
  63875. wrap?: boolean;
  63876. topBaseAt?: number;
  63877. bottomBaseAt?: number;
  63878. updatable?: boolean;
  63879. }, scene?: Nullable<Scene>): Mesh;
  63880. /**
  63881. * Creates a tiled box mesh
  63882. * * faceTiles sets the pattern, tile size and number of tiles for a face
  63883. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63884. * @param name defines the name of the mesh
  63885. * @param options defines the options used to create the mesh
  63886. * @param scene defines the hosting scene
  63887. * @returns the tiled box mesh
  63888. */
  63889. static CreateTiledBox(name: string, options: {
  63890. pattern?: number;
  63891. size?: number;
  63892. width?: number;
  63893. height?: number;
  63894. depth: number;
  63895. tileSize?: number;
  63896. tileWidth?: number;
  63897. tileHeight?: number;
  63898. faceUV?: Vector4[];
  63899. faceColors?: Color4[];
  63900. alignHorizontal?: number;
  63901. alignVertical?: number;
  63902. sideOrientation?: number;
  63903. updatable?: boolean;
  63904. }, scene?: Nullable<Scene>): Mesh;
  63905. /**
  63906. * Creates a sphere mesh
  63907. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  63908. * * 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`)
  63909. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  63910. * * 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
  63911. * * 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)
  63912. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63913. * * 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
  63914. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63915. * @param name defines the name of the mesh
  63916. * @param options defines the options used to create the mesh
  63917. * @param scene defines the hosting scene
  63918. * @returns the sphere mesh
  63919. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  63920. */
  63921. static CreateSphere(name: string, options: {
  63922. segments?: number;
  63923. diameter?: number;
  63924. diameterX?: number;
  63925. diameterY?: number;
  63926. diameterZ?: number;
  63927. arc?: number;
  63928. slice?: number;
  63929. sideOrientation?: number;
  63930. frontUVs?: Vector4;
  63931. backUVs?: Vector4;
  63932. updatable?: boolean;
  63933. }, scene?: Nullable<Scene>): Mesh;
  63934. /**
  63935. * Creates a plane polygonal mesh. By default, this is a disc
  63936. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  63937. * * 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
  63938. * * 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
  63939. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63940. * * 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
  63941. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63942. * @param name defines the name of the mesh
  63943. * @param options defines the options used to create the mesh
  63944. * @param scene defines the hosting scene
  63945. * @returns the plane polygonal mesh
  63946. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  63947. */
  63948. static CreateDisc(name: string, options: {
  63949. radius?: number;
  63950. tessellation?: number;
  63951. arc?: number;
  63952. updatable?: boolean;
  63953. sideOrientation?: number;
  63954. frontUVs?: Vector4;
  63955. backUVs?: Vector4;
  63956. }, scene?: Nullable<Scene>): Mesh;
  63957. /**
  63958. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  63959. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  63960. * * 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`)
  63961. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  63962. * * 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
  63963. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63964. * * 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
  63965. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63966. * @param name defines the name of the mesh
  63967. * @param options defines the options used to create the mesh
  63968. * @param scene defines the hosting scene
  63969. * @returns the icosahedron mesh
  63970. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  63971. */
  63972. static CreateIcoSphere(name: string, options: {
  63973. radius?: number;
  63974. radiusX?: number;
  63975. radiusY?: number;
  63976. radiusZ?: number;
  63977. flat?: boolean;
  63978. subdivisions?: number;
  63979. sideOrientation?: number;
  63980. frontUVs?: Vector4;
  63981. backUVs?: Vector4;
  63982. updatable?: boolean;
  63983. }, scene?: Nullable<Scene>): Mesh;
  63984. /**
  63985. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  63986. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  63987. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  63988. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  63989. * * 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
  63990. * * 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
  63991. * * 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
  63992. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63993. * * 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
  63994. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63995. * * 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
  63996. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  63997. * * 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
  63998. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  63999. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64000. * @param name defines the name of the mesh
  64001. * @param options defines the options used to create the mesh
  64002. * @param scene defines the hosting scene
  64003. * @returns the ribbon mesh
  64004. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  64005. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64006. */
  64007. static CreateRibbon(name: string, options: {
  64008. pathArray: Vector3[][];
  64009. closeArray?: boolean;
  64010. closePath?: boolean;
  64011. offset?: number;
  64012. updatable?: boolean;
  64013. sideOrientation?: number;
  64014. frontUVs?: Vector4;
  64015. backUVs?: Vector4;
  64016. instance?: Mesh;
  64017. invertUV?: boolean;
  64018. uvs?: Vector2[];
  64019. colors?: Color4[];
  64020. }, scene?: Nullable<Scene>): Mesh;
  64021. /**
  64022. * Creates a cylinder or a cone mesh
  64023. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  64024. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  64025. * * 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.
  64026. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  64027. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  64028. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  64029. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  64030. * * 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).
  64031. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  64032. * * 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).
  64033. * * 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
  64034. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  64035. * * 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
  64036. * * 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.
  64037. * * If `enclose` is false, a ring surface is one element.
  64038. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  64039. * * 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
  64040. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64041. * * 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
  64042. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64043. * @param name defines the name of the mesh
  64044. * @param options defines the options used to create the mesh
  64045. * @param scene defines the hosting scene
  64046. * @returns the cylinder mesh
  64047. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  64048. */
  64049. static CreateCylinder(name: string, options: {
  64050. height?: number;
  64051. diameterTop?: number;
  64052. diameterBottom?: number;
  64053. diameter?: number;
  64054. tessellation?: number;
  64055. subdivisions?: number;
  64056. arc?: number;
  64057. faceColors?: Color4[];
  64058. faceUV?: Vector4[];
  64059. updatable?: boolean;
  64060. hasRings?: boolean;
  64061. enclose?: boolean;
  64062. cap?: number;
  64063. sideOrientation?: number;
  64064. frontUVs?: Vector4;
  64065. backUVs?: Vector4;
  64066. }, scene?: Nullable<Scene>): Mesh;
  64067. /**
  64068. * Creates a torus mesh
  64069. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  64070. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  64071. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  64072. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64073. * * 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
  64074. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64075. * @param name defines the name of the mesh
  64076. * @param options defines the options used to create the mesh
  64077. * @param scene defines the hosting scene
  64078. * @returns the torus mesh
  64079. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  64080. */
  64081. static CreateTorus(name: string, options: {
  64082. diameter?: number;
  64083. thickness?: number;
  64084. tessellation?: number;
  64085. updatable?: boolean;
  64086. sideOrientation?: number;
  64087. frontUVs?: Vector4;
  64088. backUVs?: Vector4;
  64089. }, scene?: Nullable<Scene>): Mesh;
  64090. /**
  64091. * Creates a torus knot mesh
  64092. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  64093. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  64094. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  64095. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  64096. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64097. * * 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
  64098. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64099. * @param name defines the name of the mesh
  64100. * @param options defines the options used to create the mesh
  64101. * @param scene defines the hosting scene
  64102. * @returns the torus knot mesh
  64103. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  64104. */
  64105. static CreateTorusKnot(name: string, options: {
  64106. radius?: number;
  64107. tube?: number;
  64108. radialSegments?: number;
  64109. tubularSegments?: number;
  64110. p?: number;
  64111. q?: number;
  64112. updatable?: boolean;
  64113. sideOrientation?: number;
  64114. frontUVs?: Vector4;
  64115. backUVs?: Vector4;
  64116. }, scene?: Nullable<Scene>): Mesh;
  64117. /**
  64118. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  64119. * * 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
  64120. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  64121. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  64122. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  64123. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  64124. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  64125. * * 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
  64126. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  64127. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64128. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  64129. * @param name defines the name of the new line system
  64130. * @param options defines the options used to create the line system
  64131. * @param scene defines the hosting scene
  64132. * @returns a new line system mesh
  64133. */
  64134. static CreateLineSystem(name: string, options: {
  64135. lines: Vector3[][];
  64136. updatable?: boolean;
  64137. instance?: Nullable<LinesMesh>;
  64138. colors?: Nullable<Color4[][]>;
  64139. useVertexAlpha?: boolean;
  64140. }, scene: Nullable<Scene>): LinesMesh;
  64141. /**
  64142. * Creates a line mesh
  64143. * 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
  64144. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64145. * * The parameter `points` is an array successive Vector3
  64146. * * 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
  64147. * * The optional parameter `colors` is an array of successive Color4, one per line point
  64148. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  64149. * * When updating an instance, remember that only point positions can change, not the number of points
  64150. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64151. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  64152. * @param name defines the name of the new line system
  64153. * @param options defines the options used to create the line system
  64154. * @param scene defines the hosting scene
  64155. * @returns a new line mesh
  64156. */
  64157. static CreateLines(name: string, options: {
  64158. points: Vector3[];
  64159. updatable?: boolean;
  64160. instance?: Nullable<LinesMesh>;
  64161. colors?: Color4[];
  64162. useVertexAlpha?: boolean;
  64163. }, scene?: Nullable<Scene>): LinesMesh;
  64164. /**
  64165. * Creates a dashed line mesh
  64166. * * 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
  64167. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64168. * * The parameter `points` is an array successive Vector3
  64169. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  64170. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  64171. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  64172. * * 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
  64173. * * When updating an instance, remember that only point positions can change, not the number of points
  64174. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64175. * @param name defines the name of the mesh
  64176. * @param options defines the options used to create the mesh
  64177. * @param scene defines the hosting scene
  64178. * @returns the dashed line mesh
  64179. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  64180. */
  64181. static CreateDashedLines(name: string, options: {
  64182. points: Vector3[];
  64183. dashSize?: number;
  64184. gapSize?: number;
  64185. dashNb?: number;
  64186. updatable?: boolean;
  64187. instance?: LinesMesh;
  64188. }, scene?: Nullable<Scene>): LinesMesh;
  64189. /**
  64190. * 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.
  64191. * * 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.
  64192. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64193. * * 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.
  64194. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  64195. * * 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
  64196. * * 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
  64197. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  64198. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64199. * * 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
  64200. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  64201. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64202. * @param name defines the name of the mesh
  64203. * @param options defines the options used to create the mesh
  64204. * @param scene defines the hosting scene
  64205. * @returns the extruded shape mesh
  64206. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64207. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64208. */
  64209. static ExtrudeShape(name: string, options: {
  64210. shape: Vector3[];
  64211. path: Vector3[];
  64212. scale?: number;
  64213. rotation?: number;
  64214. cap?: number;
  64215. updatable?: boolean;
  64216. sideOrientation?: number;
  64217. frontUVs?: Vector4;
  64218. backUVs?: Vector4;
  64219. instance?: Mesh;
  64220. invertUV?: boolean;
  64221. }, scene?: Nullable<Scene>): Mesh;
  64222. /**
  64223. * Creates an custom extruded shape mesh.
  64224. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  64225. * * 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.
  64226. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64227. * * 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
  64228. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  64229. * * 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
  64230. * * It must returns a float value that will be the scale value applied to the shape on each path point
  64231. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  64232. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  64233. * * 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
  64234. * * 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
  64235. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  64236. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64237. * * 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
  64238. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64239. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64240. * @param name defines the name of the mesh
  64241. * @param options defines the options used to create the mesh
  64242. * @param scene defines the hosting scene
  64243. * @returns the custom extruded shape mesh
  64244. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  64245. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64246. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64247. */
  64248. static ExtrudeShapeCustom(name: string, options: {
  64249. shape: Vector3[];
  64250. path: Vector3[];
  64251. scaleFunction?: any;
  64252. rotationFunction?: any;
  64253. ribbonCloseArray?: boolean;
  64254. ribbonClosePath?: boolean;
  64255. cap?: number;
  64256. updatable?: boolean;
  64257. sideOrientation?: number;
  64258. frontUVs?: Vector4;
  64259. backUVs?: Vector4;
  64260. instance?: Mesh;
  64261. invertUV?: boolean;
  64262. }, scene?: Nullable<Scene>): Mesh;
  64263. /**
  64264. * Creates lathe mesh.
  64265. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  64266. * * 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
  64267. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  64268. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  64269. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  64270. * * 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
  64271. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  64272. * * 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
  64273. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64274. * * 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
  64275. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64276. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64277. * @param name defines the name of the mesh
  64278. * @param options defines the options used to create the mesh
  64279. * @param scene defines the hosting scene
  64280. * @returns the lathe mesh
  64281. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  64282. */
  64283. static CreateLathe(name: string, options: {
  64284. shape: Vector3[];
  64285. radius?: number;
  64286. tessellation?: number;
  64287. clip?: number;
  64288. arc?: number;
  64289. closed?: boolean;
  64290. updatable?: boolean;
  64291. sideOrientation?: number;
  64292. frontUVs?: Vector4;
  64293. backUVs?: Vector4;
  64294. cap?: number;
  64295. invertUV?: boolean;
  64296. }, scene?: Nullable<Scene>): Mesh;
  64297. /**
  64298. * Creates a tiled plane mesh
  64299. * * You can set a limited pattern arrangement with the tiles
  64300. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64301. * * 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
  64302. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64303. * @param name defines the name of the mesh
  64304. * @param options defines the options used to create the mesh
  64305. * @param scene defines the hosting scene
  64306. * @returns the plane mesh
  64307. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64308. */
  64309. static CreateTiledPlane(name: string, options: {
  64310. pattern?: number;
  64311. tileSize?: number;
  64312. tileWidth?: number;
  64313. tileHeight?: number;
  64314. size?: number;
  64315. width?: number;
  64316. height?: number;
  64317. alignHorizontal?: number;
  64318. alignVertical?: number;
  64319. sideOrientation?: number;
  64320. frontUVs?: Vector4;
  64321. backUVs?: Vector4;
  64322. updatable?: boolean;
  64323. }, scene?: Nullable<Scene>): Mesh;
  64324. /**
  64325. * Creates a plane mesh
  64326. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  64327. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  64328. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  64329. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64330. * * 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
  64331. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64332. * @param name defines the name of the mesh
  64333. * @param options defines the options used to create the mesh
  64334. * @param scene defines the hosting scene
  64335. * @returns the plane mesh
  64336. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64337. */
  64338. static CreatePlane(name: string, options: {
  64339. size?: number;
  64340. width?: number;
  64341. height?: number;
  64342. sideOrientation?: number;
  64343. frontUVs?: Vector4;
  64344. backUVs?: Vector4;
  64345. updatable?: boolean;
  64346. sourcePlane?: Plane;
  64347. }, scene?: Nullable<Scene>): Mesh;
  64348. /**
  64349. * Creates a ground mesh
  64350. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  64351. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  64352. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64353. * @param name defines the name of the mesh
  64354. * @param options defines the options used to create the mesh
  64355. * @param scene defines the hosting scene
  64356. * @returns the ground mesh
  64357. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  64358. */
  64359. static CreateGround(name: string, options: {
  64360. width?: number;
  64361. height?: number;
  64362. subdivisions?: number;
  64363. subdivisionsX?: number;
  64364. subdivisionsY?: number;
  64365. updatable?: boolean;
  64366. }, scene?: Nullable<Scene>): Mesh;
  64367. /**
  64368. * Creates a tiled ground mesh
  64369. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  64370. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  64371. * * 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
  64372. * * 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
  64373. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64374. * @param name defines the name of the mesh
  64375. * @param options defines the options used to create the mesh
  64376. * @param scene defines the hosting scene
  64377. * @returns the tiled ground mesh
  64378. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  64379. */
  64380. static CreateTiledGround(name: string, options: {
  64381. xmin: number;
  64382. zmin: number;
  64383. xmax: number;
  64384. zmax: number;
  64385. subdivisions?: {
  64386. w: number;
  64387. h: number;
  64388. };
  64389. precision?: {
  64390. w: number;
  64391. h: number;
  64392. };
  64393. updatable?: boolean;
  64394. }, scene?: Nullable<Scene>): Mesh;
  64395. /**
  64396. * Creates a ground mesh from a height map
  64397. * * The parameter `url` sets the URL of the height map image resource.
  64398. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  64399. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  64400. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  64401. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  64402. * * 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.
  64403. * * 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).
  64404. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  64405. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64406. * @param name defines the name of the mesh
  64407. * @param url defines the url to the height map
  64408. * @param options defines the options used to create the mesh
  64409. * @param scene defines the hosting scene
  64410. * @returns the ground mesh
  64411. * @see https://doc.babylonjs.com/babylon101/height_map
  64412. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  64413. */
  64414. static CreateGroundFromHeightMap(name: string, url: string, options: {
  64415. width?: number;
  64416. height?: number;
  64417. subdivisions?: number;
  64418. minHeight?: number;
  64419. maxHeight?: number;
  64420. colorFilter?: Color3;
  64421. alphaFilter?: number;
  64422. updatable?: boolean;
  64423. onReady?: (mesh: GroundMesh) => void;
  64424. }, scene?: Nullable<Scene>): GroundMesh;
  64425. /**
  64426. * Creates a polygon mesh
  64427. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  64428. * * 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
  64429. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64430. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64431. * * 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)
  64432. * * Remember you can only change the shape positions, not their number when updating a polygon
  64433. * @param name defines the name of the mesh
  64434. * @param options defines the options used to create the mesh
  64435. * @param scene defines the hosting scene
  64436. * @param earcutInjection can be used to inject your own earcut reference
  64437. * @returns the polygon mesh
  64438. */
  64439. static CreatePolygon(name: string, options: {
  64440. shape: Vector3[];
  64441. holes?: Vector3[][];
  64442. depth?: number;
  64443. faceUV?: Vector4[];
  64444. faceColors?: Color4[];
  64445. updatable?: boolean;
  64446. sideOrientation?: number;
  64447. frontUVs?: Vector4;
  64448. backUVs?: Vector4;
  64449. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64450. /**
  64451. * Creates an extruded polygon mesh, with depth in the Y direction.
  64452. * * 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)
  64453. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64454. * @param name defines the name of the mesh
  64455. * @param options defines the options used to create the mesh
  64456. * @param scene defines the hosting scene
  64457. * @param earcutInjection can be used to inject your own earcut reference
  64458. * @returns the polygon mesh
  64459. */
  64460. static ExtrudePolygon(name: string, options: {
  64461. shape: Vector3[];
  64462. holes?: Vector3[][];
  64463. depth?: number;
  64464. faceUV?: Vector4[];
  64465. faceColors?: Color4[];
  64466. updatable?: boolean;
  64467. sideOrientation?: number;
  64468. frontUVs?: Vector4;
  64469. backUVs?: Vector4;
  64470. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64471. /**
  64472. * Creates a tube mesh.
  64473. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64474. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  64475. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  64476. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  64477. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  64478. * * 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)
  64479. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  64480. * * 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
  64481. * * 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
  64482. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64483. * * 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
  64484. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64485. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64486. * @param name defines the name of the mesh
  64487. * @param options defines the options used to create the mesh
  64488. * @param scene defines the hosting scene
  64489. * @returns the tube mesh
  64490. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64491. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  64492. */
  64493. static CreateTube(name: string, options: {
  64494. path: Vector3[];
  64495. radius?: number;
  64496. tessellation?: number;
  64497. radiusFunction?: {
  64498. (i: number, distance: number): number;
  64499. };
  64500. cap?: number;
  64501. arc?: number;
  64502. updatable?: boolean;
  64503. sideOrientation?: number;
  64504. frontUVs?: Vector4;
  64505. backUVs?: Vector4;
  64506. instance?: Mesh;
  64507. invertUV?: boolean;
  64508. }, scene?: Nullable<Scene>): Mesh;
  64509. /**
  64510. * Creates a polyhedron mesh
  64511. * * 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
  64512. * * The parameter `size` (positive float, default 1) sets the polygon size
  64513. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  64514. * * 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`
  64515. * * 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
  64516. * * 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)`)
  64517. * * 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
  64518. * * 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
  64519. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64520. * * 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
  64521. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64522. * @param name defines the name of the mesh
  64523. * @param options defines the options used to create the mesh
  64524. * @param scene defines the hosting scene
  64525. * @returns the polyhedron mesh
  64526. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  64527. */
  64528. static CreatePolyhedron(name: string, options: {
  64529. type?: number;
  64530. size?: number;
  64531. sizeX?: number;
  64532. sizeY?: number;
  64533. sizeZ?: number;
  64534. custom?: any;
  64535. faceUV?: Vector4[];
  64536. faceColors?: Color4[];
  64537. flat?: boolean;
  64538. updatable?: boolean;
  64539. sideOrientation?: number;
  64540. frontUVs?: Vector4;
  64541. backUVs?: Vector4;
  64542. }, scene?: Nullable<Scene>): Mesh;
  64543. /**
  64544. * Creates a decal mesh.
  64545. * 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
  64546. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  64547. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  64548. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  64549. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  64550. * @param name defines the name of the mesh
  64551. * @param sourceMesh defines the mesh where the decal must be applied
  64552. * @param options defines the options used to create the mesh
  64553. * @param scene defines the hosting scene
  64554. * @returns the decal mesh
  64555. * @see https://doc.babylonjs.com/how_to/decals
  64556. */
  64557. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  64558. position?: Vector3;
  64559. normal?: Vector3;
  64560. size?: Vector3;
  64561. angle?: number;
  64562. }): Mesh;
  64563. }
  64564. }
  64565. declare module BABYLON {
  64566. /**
  64567. * A simplifier interface for future simplification implementations
  64568. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64569. */
  64570. export interface ISimplifier {
  64571. /**
  64572. * Simplification of a given mesh according to the given settings.
  64573. * Since this requires computation, it is assumed that the function runs async.
  64574. * @param settings The settings of the simplification, including quality and distance
  64575. * @param successCallback A callback that will be called after the mesh was simplified.
  64576. * @param errorCallback in case of an error, this callback will be called. optional.
  64577. */
  64578. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  64579. }
  64580. /**
  64581. * Expected simplification settings.
  64582. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  64583. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64584. */
  64585. export interface ISimplificationSettings {
  64586. /**
  64587. * Gets or sets the expected quality
  64588. */
  64589. quality: number;
  64590. /**
  64591. * Gets or sets the distance when this optimized version should be used
  64592. */
  64593. distance: number;
  64594. /**
  64595. * Gets an already optimized mesh
  64596. */
  64597. optimizeMesh?: boolean;
  64598. }
  64599. /**
  64600. * Class used to specify simplification options
  64601. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64602. */
  64603. export class SimplificationSettings implements ISimplificationSettings {
  64604. /** expected quality */
  64605. quality: number;
  64606. /** distance when this optimized version should be used */
  64607. distance: number;
  64608. /** already optimized mesh */
  64609. optimizeMesh?: boolean | undefined;
  64610. /**
  64611. * Creates a SimplificationSettings
  64612. * @param quality expected quality
  64613. * @param distance distance when this optimized version should be used
  64614. * @param optimizeMesh already optimized mesh
  64615. */
  64616. constructor(
  64617. /** expected quality */
  64618. quality: number,
  64619. /** distance when this optimized version should be used */
  64620. distance: number,
  64621. /** already optimized mesh */
  64622. optimizeMesh?: boolean | undefined);
  64623. }
  64624. /**
  64625. * Interface used to define a simplification task
  64626. */
  64627. export interface ISimplificationTask {
  64628. /**
  64629. * Array of settings
  64630. */
  64631. settings: Array<ISimplificationSettings>;
  64632. /**
  64633. * Simplification type
  64634. */
  64635. simplificationType: SimplificationType;
  64636. /**
  64637. * Mesh to simplify
  64638. */
  64639. mesh: Mesh;
  64640. /**
  64641. * Callback called on success
  64642. */
  64643. successCallback?: () => void;
  64644. /**
  64645. * Defines if parallel processing can be used
  64646. */
  64647. parallelProcessing: boolean;
  64648. }
  64649. /**
  64650. * Queue used to order the simplification tasks
  64651. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64652. */
  64653. export class SimplificationQueue {
  64654. private _simplificationArray;
  64655. /**
  64656. * Gets a boolean indicating that the process is still running
  64657. */
  64658. running: boolean;
  64659. /**
  64660. * Creates a new queue
  64661. */
  64662. constructor();
  64663. /**
  64664. * Adds a new simplification task
  64665. * @param task defines a task to add
  64666. */
  64667. addTask(task: ISimplificationTask): void;
  64668. /**
  64669. * Execute next task
  64670. */
  64671. executeNext(): void;
  64672. /**
  64673. * Execute a simplification task
  64674. * @param task defines the task to run
  64675. */
  64676. runSimplification(task: ISimplificationTask): void;
  64677. private getSimplifier;
  64678. }
  64679. /**
  64680. * The implemented types of simplification
  64681. * At the moment only Quadratic Error Decimation is implemented
  64682. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64683. */
  64684. export enum SimplificationType {
  64685. /** Quadratic error decimation */
  64686. QUADRATIC = 0
  64687. }
  64688. /**
  64689. * An implementation of the Quadratic Error simplification algorithm.
  64690. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  64691. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  64692. * @author RaananW
  64693. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64694. */
  64695. export class QuadraticErrorSimplification implements ISimplifier {
  64696. private _mesh;
  64697. private triangles;
  64698. private vertices;
  64699. private references;
  64700. private _reconstructedMesh;
  64701. /** Gets or sets the number pf sync interations */
  64702. syncIterations: number;
  64703. /** Gets or sets the aggressiveness of the simplifier */
  64704. aggressiveness: number;
  64705. /** Gets or sets the number of allowed iterations for decimation */
  64706. decimationIterations: number;
  64707. /** Gets or sets the espilon to use for bounding box computation */
  64708. boundingBoxEpsilon: number;
  64709. /**
  64710. * Creates a new QuadraticErrorSimplification
  64711. * @param _mesh defines the target mesh
  64712. */
  64713. constructor(_mesh: Mesh);
  64714. /**
  64715. * Simplification of a given mesh according to the given settings.
  64716. * Since this requires computation, it is assumed that the function runs async.
  64717. * @param settings The settings of the simplification, including quality and distance
  64718. * @param successCallback A callback that will be called after the mesh was simplified.
  64719. */
  64720. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  64721. private runDecimation;
  64722. private initWithMesh;
  64723. private init;
  64724. private reconstructMesh;
  64725. private initDecimatedMesh;
  64726. private isFlipped;
  64727. private updateTriangles;
  64728. private identifyBorder;
  64729. private updateMesh;
  64730. private vertexError;
  64731. private calculateError;
  64732. }
  64733. }
  64734. declare module BABYLON {
  64735. interface Scene {
  64736. /** @hidden (Backing field) */
  64737. _simplificationQueue: SimplificationQueue;
  64738. /**
  64739. * Gets or sets the simplification queue attached to the scene
  64740. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64741. */
  64742. simplificationQueue: SimplificationQueue;
  64743. }
  64744. interface Mesh {
  64745. /**
  64746. * Simplify the mesh according to the given array of settings.
  64747. * Function will return immediately and will simplify async
  64748. * @param settings a collection of simplification settings
  64749. * @param parallelProcessing should all levels calculate parallel or one after the other
  64750. * @param simplificationType the type of simplification to run
  64751. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  64752. * @returns the current mesh
  64753. */
  64754. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  64755. }
  64756. /**
  64757. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  64758. * created in a scene
  64759. */
  64760. export class SimplicationQueueSceneComponent implements ISceneComponent {
  64761. /**
  64762. * The component name helpfull to identify the component in the list of scene components.
  64763. */
  64764. readonly name: string;
  64765. /**
  64766. * The scene the component belongs to.
  64767. */
  64768. scene: Scene;
  64769. /**
  64770. * Creates a new instance of the component for the given scene
  64771. * @param scene Defines the scene to register the component in
  64772. */
  64773. constructor(scene: Scene);
  64774. /**
  64775. * Registers the component in a given scene
  64776. */
  64777. register(): void;
  64778. /**
  64779. * Rebuilds the elements related to this component in case of
  64780. * context lost for instance.
  64781. */
  64782. rebuild(): void;
  64783. /**
  64784. * Disposes the component and the associated ressources
  64785. */
  64786. dispose(): void;
  64787. private _beforeCameraUpdate;
  64788. }
  64789. }
  64790. declare module BABYLON {
  64791. /**
  64792. * Navigation plugin interface to add navigation constrained by a navigation mesh
  64793. */
  64794. export interface INavigationEnginePlugin {
  64795. /**
  64796. * plugin name
  64797. */
  64798. name: string;
  64799. /**
  64800. * Creates a navigation mesh
  64801. * @param meshes array of all the geometry used to compute the navigatio mesh
  64802. * @param parameters bunch of parameters used to filter geometry
  64803. */
  64804. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  64805. /**
  64806. * Create a navigation mesh debug mesh
  64807. * @param scene is where the mesh will be added
  64808. * @returns debug display mesh
  64809. */
  64810. createDebugNavMesh(scene: Scene): Mesh;
  64811. /**
  64812. * Get a navigation mesh constrained position, closest to the parameter position
  64813. * @param position world position
  64814. * @returns the closest point to position constrained by the navigation mesh
  64815. */
  64816. getClosestPoint(position: Vector3): Vector3;
  64817. /**
  64818. * Get a navigation mesh constrained position, closest to the parameter position
  64819. * @param position world position
  64820. * @param result output the closest point to position constrained by the navigation mesh
  64821. */
  64822. getClosestPointToRef(position: Vector3, result: Vector3): void;
  64823. /**
  64824. * Get a navigation mesh constrained position, within a particular radius
  64825. * @param position world position
  64826. * @param maxRadius the maximum distance to the constrained world position
  64827. * @returns the closest point to position constrained by the navigation mesh
  64828. */
  64829. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  64830. /**
  64831. * Get a navigation mesh constrained position, within a particular radius
  64832. * @param position world position
  64833. * @param maxRadius the maximum distance to the constrained world position
  64834. * @param result output the closest point to position constrained by the navigation mesh
  64835. */
  64836. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  64837. /**
  64838. * Compute the final position from a segment made of destination-position
  64839. * @param position world position
  64840. * @param destination world position
  64841. * @returns the resulting point along the navmesh
  64842. */
  64843. moveAlong(position: Vector3, destination: Vector3): Vector3;
  64844. /**
  64845. * Compute the final position from a segment made of destination-position
  64846. * @param position world position
  64847. * @param destination world position
  64848. * @param result output the resulting point along the navmesh
  64849. */
  64850. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  64851. /**
  64852. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  64853. * @param start world position
  64854. * @param end world position
  64855. * @returns array containing world position composing the path
  64856. */
  64857. computePath(start: Vector3, end: Vector3): Vector3[];
  64858. /**
  64859. * If this plugin is supported
  64860. * @returns true if plugin is supported
  64861. */
  64862. isSupported(): boolean;
  64863. /**
  64864. * Create a new Crowd so you can add agents
  64865. * @param maxAgents the maximum agent count in the crowd
  64866. * @param maxAgentRadius the maximum radius an agent can have
  64867. * @param scene to attach the crowd to
  64868. * @returns the crowd you can add agents to
  64869. */
  64870. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  64871. /**
  64872. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  64873. * The queries will try to find a solution within those bounds
  64874. * default is (1,1,1)
  64875. * @param extent x,y,z value that define the extent around the queries point of reference
  64876. */
  64877. setDefaultQueryExtent(extent: Vector3): void;
  64878. /**
  64879. * Get the Bounding box extent specified by setDefaultQueryExtent
  64880. * @returns the box extent values
  64881. */
  64882. getDefaultQueryExtent(): Vector3;
  64883. /**
  64884. * build the navmesh from a previously saved state using getNavmeshData
  64885. * @param data the Uint8Array returned by getNavmeshData
  64886. */
  64887. buildFromNavmeshData(data: Uint8Array): void;
  64888. /**
  64889. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  64890. * @returns data the Uint8Array that can be saved and reused
  64891. */
  64892. getNavmeshData(): Uint8Array;
  64893. /**
  64894. * Get the Bounding box extent result specified by setDefaultQueryExtent
  64895. * @param result output the box extent values
  64896. */
  64897. getDefaultQueryExtentToRef(result: Vector3): void;
  64898. /**
  64899. * Release all resources
  64900. */
  64901. dispose(): void;
  64902. }
  64903. /**
  64904. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  64905. */
  64906. export interface ICrowd {
  64907. /**
  64908. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  64909. * You can attach anything to that node. The node position is updated in the scene update tick.
  64910. * @param pos world position that will be constrained by the navigation mesh
  64911. * @param parameters agent parameters
  64912. * @param transform hooked to the agent that will be update by the scene
  64913. * @returns agent index
  64914. */
  64915. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  64916. /**
  64917. * Returns the agent position in world space
  64918. * @param index agent index returned by addAgent
  64919. * @returns world space position
  64920. */
  64921. getAgentPosition(index: number): Vector3;
  64922. /**
  64923. * Gets the agent position result in world space
  64924. * @param index agent index returned by addAgent
  64925. * @param result output world space position
  64926. */
  64927. getAgentPositionToRef(index: number, result: Vector3): void;
  64928. /**
  64929. * Gets the agent velocity in world space
  64930. * @param index agent index returned by addAgent
  64931. * @returns world space velocity
  64932. */
  64933. getAgentVelocity(index: number): Vector3;
  64934. /**
  64935. * Gets the agent velocity result in world space
  64936. * @param index agent index returned by addAgent
  64937. * @param result output world space velocity
  64938. */
  64939. getAgentVelocityToRef(index: number, result: Vector3): void;
  64940. /**
  64941. * remove a particular agent previously created
  64942. * @param index agent index returned by addAgent
  64943. */
  64944. removeAgent(index: number): void;
  64945. /**
  64946. * get the list of all agents attached to this crowd
  64947. * @returns list of agent indices
  64948. */
  64949. getAgents(): number[];
  64950. /**
  64951. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  64952. * @param deltaTime in seconds
  64953. */
  64954. update(deltaTime: number): void;
  64955. /**
  64956. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  64957. * @param index agent index returned by addAgent
  64958. * @param destination targeted world position
  64959. */
  64960. agentGoto(index: number, destination: Vector3): void;
  64961. /**
  64962. * Teleport the agent to a new position
  64963. * @param index agent index returned by addAgent
  64964. * @param destination targeted world position
  64965. */
  64966. agentTeleport(index: number, destination: Vector3): void;
  64967. /**
  64968. * Update agent parameters
  64969. * @param index agent index returned by addAgent
  64970. * @param parameters agent parameters
  64971. */
  64972. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  64973. /**
  64974. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  64975. * The queries will try to find a solution within those bounds
  64976. * default is (1,1,1)
  64977. * @param extent x,y,z value that define the extent around the queries point of reference
  64978. */
  64979. setDefaultQueryExtent(extent: Vector3): void;
  64980. /**
  64981. * Get the Bounding box extent specified by setDefaultQueryExtent
  64982. * @returns the box extent values
  64983. */
  64984. getDefaultQueryExtent(): Vector3;
  64985. /**
  64986. * Get the Bounding box extent result specified by setDefaultQueryExtent
  64987. * @param result output the box extent values
  64988. */
  64989. getDefaultQueryExtentToRef(result: Vector3): void;
  64990. /**
  64991. * Release all resources
  64992. */
  64993. dispose(): void;
  64994. }
  64995. /**
  64996. * Configures an agent
  64997. */
  64998. export interface IAgentParameters {
  64999. /**
  65000. * Agent radius. [Limit: >= 0]
  65001. */
  65002. radius: number;
  65003. /**
  65004. * Agent height. [Limit: > 0]
  65005. */
  65006. height: number;
  65007. /**
  65008. * Maximum allowed acceleration. [Limit: >= 0]
  65009. */
  65010. maxAcceleration: number;
  65011. /**
  65012. * Maximum allowed speed. [Limit: >= 0]
  65013. */
  65014. maxSpeed: number;
  65015. /**
  65016. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  65017. */
  65018. collisionQueryRange: number;
  65019. /**
  65020. * The path visibility optimization range. [Limit: > 0]
  65021. */
  65022. pathOptimizationRange: number;
  65023. /**
  65024. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  65025. */
  65026. separationWeight: number;
  65027. }
  65028. /**
  65029. * Configures the navigation mesh creation
  65030. */
  65031. export interface INavMeshParameters {
  65032. /**
  65033. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  65034. */
  65035. cs: number;
  65036. /**
  65037. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  65038. */
  65039. ch: number;
  65040. /**
  65041. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  65042. */
  65043. walkableSlopeAngle: number;
  65044. /**
  65045. * Minimum floor to 'ceiling' height that will still allow the floor area to
  65046. * be considered walkable. [Limit: >= 3] [Units: vx]
  65047. */
  65048. walkableHeight: number;
  65049. /**
  65050. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  65051. */
  65052. walkableClimb: number;
  65053. /**
  65054. * The distance to erode/shrink the walkable area of the heightfield away from
  65055. * obstructions. [Limit: >=0] [Units: vx]
  65056. */
  65057. walkableRadius: number;
  65058. /**
  65059. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  65060. */
  65061. maxEdgeLen: number;
  65062. /**
  65063. * The maximum distance a simplfied contour's border edges should deviate
  65064. * the original raw contour. [Limit: >=0] [Units: vx]
  65065. */
  65066. maxSimplificationError: number;
  65067. /**
  65068. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  65069. */
  65070. minRegionArea: number;
  65071. /**
  65072. * Any regions with a span count smaller than this value will, if possible,
  65073. * be merged with larger regions. [Limit: >=0] [Units: vx]
  65074. */
  65075. mergeRegionArea: number;
  65076. /**
  65077. * The maximum number of vertices allowed for polygons generated during the
  65078. * contour to polygon conversion process. [Limit: >= 3]
  65079. */
  65080. maxVertsPerPoly: number;
  65081. /**
  65082. * Sets the sampling distance to use when generating the detail mesh.
  65083. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  65084. */
  65085. detailSampleDist: number;
  65086. /**
  65087. * The maximum distance the detail mesh surface should deviate from heightfield
  65088. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  65089. */
  65090. detailSampleMaxError: number;
  65091. }
  65092. }
  65093. declare module BABYLON {
  65094. /**
  65095. * RecastJS navigation plugin
  65096. */
  65097. export class RecastJSPlugin implements INavigationEnginePlugin {
  65098. /**
  65099. * Reference to the Recast library
  65100. */
  65101. bjsRECAST: any;
  65102. /**
  65103. * plugin name
  65104. */
  65105. name: string;
  65106. /**
  65107. * the first navmesh created. We might extend this to support multiple navmeshes
  65108. */
  65109. navMesh: any;
  65110. /**
  65111. * Initializes the recastJS plugin
  65112. * @param recastInjection can be used to inject your own recast reference
  65113. */
  65114. constructor(recastInjection?: any);
  65115. /**
  65116. * Creates a navigation mesh
  65117. * @param meshes array of all the geometry used to compute the navigatio mesh
  65118. * @param parameters bunch of parameters used to filter geometry
  65119. */
  65120. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65121. /**
  65122. * Create a navigation mesh debug mesh
  65123. * @param scene is where the mesh will be added
  65124. * @returns debug display mesh
  65125. */
  65126. createDebugNavMesh(scene: Scene): Mesh;
  65127. /**
  65128. * Get a navigation mesh constrained position, closest to the parameter position
  65129. * @param position world position
  65130. * @returns the closest point to position constrained by the navigation mesh
  65131. */
  65132. getClosestPoint(position: Vector3): Vector3;
  65133. /**
  65134. * Get a navigation mesh constrained position, closest to the parameter position
  65135. * @param position world position
  65136. * @param result output the closest point to position constrained by the navigation mesh
  65137. */
  65138. getClosestPointToRef(position: Vector3, result: Vector3): void;
  65139. /**
  65140. * Get a navigation mesh constrained position, within a particular radius
  65141. * @param position world position
  65142. * @param maxRadius the maximum distance to the constrained world position
  65143. * @returns the closest point to position constrained by the navigation mesh
  65144. */
  65145. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65146. /**
  65147. * Get a navigation mesh constrained position, within a particular radius
  65148. * @param position world position
  65149. * @param maxRadius the maximum distance to the constrained world position
  65150. * @param result output the closest point to position constrained by the navigation mesh
  65151. */
  65152. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  65153. /**
  65154. * Compute the final position from a segment made of destination-position
  65155. * @param position world position
  65156. * @param destination world position
  65157. * @returns the resulting point along the navmesh
  65158. */
  65159. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65160. /**
  65161. * Compute the final position from a segment made of destination-position
  65162. * @param position world position
  65163. * @param destination world position
  65164. * @param result output the resulting point along the navmesh
  65165. */
  65166. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  65167. /**
  65168. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65169. * @param start world position
  65170. * @param end world position
  65171. * @returns array containing world position composing the path
  65172. */
  65173. computePath(start: Vector3, end: Vector3): Vector3[];
  65174. /**
  65175. * Create a new Crowd so you can add agents
  65176. * @param maxAgents the maximum agent count in the crowd
  65177. * @param maxAgentRadius the maximum radius an agent can have
  65178. * @param scene to attach the crowd to
  65179. * @returns the crowd you can add agents to
  65180. */
  65181. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65182. /**
  65183. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65184. * The queries will try to find a solution within those bounds
  65185. * default is (1,1,1)
  65186. * @param extent x,y,z value that define the extent around the queries point of reference
  65187. */
  65188. setDefaultQueryExtent(extent: Vector3): void;
  65189. /**
  65190. * Get the Bounding box extent specified by setDefaultQueryExtent
  65191. * @returns the box extent values
  65192. */
  65193. getDefaultQueryExtent(): Vector3;
  65194. /**
  65195. * build the navmesh from a previously saved state using getNavmeshData
  65196. * @param data the Uint8Array returned by getNavmeshData
  65197. */
  65198. buildFromNavmeshData(data: Uint8Array): void;
  65199. /**
  65200. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  65201. * @returns data the Uint8Array that can be saved and reused
  65202. */
  65203. getNavmeshData(): Uint8Array;
  65204. /**
  65205. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65206. * @param result output the box extent values
  65207. */
  65208. getDefaultQueryExtentToRef(result: Vector3): void;
  65209. /**
  65210. * Disposes
  65211. */
  65212. dispose(): void;
  65213. /**
  65214. * If this plugin is supported
  65215. * @returns true if plugin is supported
  65216. */
  65217. isSupported(): boolean;
  65218. }
  65219. /**
  65220. * Recast detour crowd implementation
  65221. */
  65222. export class RecastJSCrowd implements ICrowd {
  65223. /**
  65224. * Recast/detour plugin
  65225. */
  65226. bjsRECASTPlugin: RecastJSPlugin;
  65227. /**
  65228. * Link to the detour crowd
  65229. */
  65230. recastCrowd: any;
  65231. /**
  65232. * One transform per agent
  65233. */
  65234. transforms: TransformNode[];
  65235. /**
  65236. * All agents created
  65237. */
  65238. agents: number[];
  65239. /**
  65240. * Link to the scene is kept to unregister the crowd from the scene
  65241. */
  65242. private _scene;
  65243. /**
  65244. * Observer for crowd updates
  65245. */
  65246. private _onBeforeAnimationsObserver;
  65247. /**
  65248. * Constructor
  65249. * @param plugin recastJS plugin
  65250. * @param maxAgents the maximum agent count in the crowd
  65251. * @param maxAgentRadius the maximum radius an agent can have
  65252. * @param scene to attach the crowd to
  65253. * @returns the crowd you can add agents to
  65254. */
  65255. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  65256. /**
  65257. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65258. * You can attach anything to that node. The node position is updated in the scene update tick.
  65259. * @param pos world position that will be constrained by the navigation mesh
  65260. * @param parameters agent parameters
  65261. * @param transform hooked to the agent that will be update by the scene
  65262. * @returns agent index
  65263. */
  65264. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65265. /**
  65266. * Returns the agent position in world space
  65267. * @param index agent index returned by addAgent
  65268. * @returns world space position
  65269. */
  65270. getAgentPosition(index: number): Vector3;
  65271. /**
  65272. * Returns the agent position result in world space
  65273. * @param index agent index returned by addAgent
  65274. * @param result output world space position
  65275. */
  65276. getAgentPositionToRef(index: number, result: Vector3): void;
  65277. /**
  65278. * Returns the agent velocity in world space
  65279. * @param index agent index returned by addAgent
  65280. * @returns world space velocity
  65281. */
  65282. getAgentVelocity(index: number): Vector3;
  65283. /**
  65284. * Returns the agent velocity result in world space
  65285. * @param index agent index returned by addAgent
  65286. * @param result output world space velocity
  65287. */
  65288. getAgentVelocityToRef(index: number, result: Vector3): void;
  65289. /**
  65290. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65291. * @param index agent index returned by addAgent
  65292. * @param destination targeted world position
  65293. */
  65294. agentGoto(index: number, destination: Vector3): void;
  65295. /**
  65296. * Teleport the agent to a new position
  65297. * @param index agent index returned by addAgent
  65298. * @param destination targeted world position
  65299. */
  65300. agentTeleport(index: number, destination: Vector3): void;
  65301. /**
  65302. * Update agent parameters
  65303. * @param index agent index returned by addAgent
  65304. * @param parameters agent parameters
  65305. */
  65306. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65307. /**
  65308. * remove a particular agent previously created
  65309. * @param index agent index returned by addAgent
  65310. */
  65311. removeAgent(index: number): void;
  65312. /**
  65313. * get the list of all agents attached to this crowd
  65314. * @returns list of agent indices
  65315. */
  65316. getAgents(): number[];
  65317. /**
  65318. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65319. * @param deltaTime in seconds
  65320. */
  65321. update(deltaTime: number): void;
  65322. /**
  65323. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65324. * The queries will try to find a solution within those bounds
  65325. * default is (1,1,1)
  65326. * @param extent x,y,z value that define the extent around the queries point of reference
  65327. */
  65328. setDefaultQueryExtent(extent: Vector3): void;
  65329. /**
  65330. * Get the Bounding box extent specified by setDefaultQueryExtent
  65331. * @returns the box extent values
  65332. */
  65333. getDefaultQueryExtent(): Vector3;
  65334. /**
  65335. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65336. * @param result output the box extent values
  65337. */
  65338. getDefaultQueryExtentToRef(result: Vector3): void;
  65339. /**
  65340. * Release all resources
  65341. */
  65342. dispose(): void;
  65343. }
  65344. }
  65345. declare module BABYLON {
  65346. /**
  65347. * Class used to enable access to IndexedDB
  65348. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  65349. */
  65350. export class Database implements IOfflineProvider {
  65351. private _callbackManifestChecked;
  65352. private _currentSceneUrl;
  65353. private _db;
  65354. private _enableSceneOffline;
  65355. private _enableTexturesOffline;
  65356. private _manifestVersionFound;
  65357. private _mustUpdateRessources;
  65358. private _hasReachedQuota;
  65359. private _isSupported;
  65360. private _idbFactory;
  65361. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  65362. private static IsUASupportingBlobStorage;
  65363. /**
  65364. * Gets a boolean indicating if Database storate is enabled (off by default)
  65365. */
  65366. static IDBStorageEnabled: boolean;
  65367. /**
  65368. * Gets a boolean indicating if scene must be saved in the database
  65369. */
  65370. get enableSceneOffline(): boolean;
  65371. /**
  65372. * Gets a boolean indicating if textures must be saved in the database
  65373. */
  65374. get enableTexturesOffline(): boolean;
  65375. /**
  65376. * Creates a new Database
  65377. * @param urlToScene defines the url to load the scene
  65378. * @param callbackManifestChecked defines the callback to use when manifest is checked
  65379. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  65380. */
  65381. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  65382. private static _ParseURL;
  65383. private static _ReturnFullUrlLocation;
  65384. private _checkManifestFile;
  65385. /**
  65386. * Open the database and make it available
  65387. * @param successCallback defines the callback to call on success
  65388. * @param errorCallback defines the callback to call on error
  65389. */
  65390. open(successCallback: () => void, errorCallback: () => void): void;
  65391. /**
  65392. * Loads an image from the database
  65393. * @param url defines the url to load from
  65394. * @param image defines the target DOM image
  65395. */
  65396. loadImage(url: string, image: HTMLImageElement): void;
  65397. private _loadImageFromDBAsync;
  65398. private _saveImageIntoDBAsync;
  65399. private _checkVersionFromDB;
  65400. private _loadVersionFromDBAsync;
  65401. private _saveVersionIntoDBAsync;
  65402. /**
  65403. * Loads a file from database
  65404. * @param url defines the URL to load from
  65405. * @param sceneLoaded defines a callback to call on success
  65406. * @param progressCallBack defines a callback to call when progress changed
  65407. * @param errorCallback defines a callback to call on error
  65408. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  65409. */
  65410. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  65411. private _loadFileAsync;
  65412. private _saveFileAsync;
  65413. /**
  65414. * Validates if xhr data is correct
  65415. * @param xhr defines the request to validate
  65416. * @param dataType defines the expected data type
  65417. * @returns true if data is correct
  65418. */
  65419. private static _ValidateXHRData;
  65420. }
  65421. }
  65422. declare module BABYLON {
  65423. /** @hidden */
  65424. export var gpuUpdateParticlesPixelShader: {
  65425. name: string;
  65426. shader: string;
  65427. };
  65428. }
  65429. declare module BABYLON {
  65430. /** @hidden */
  65431. export var gpuUpdateParticlesVertexShader: {
  65432. name: string;
  65433. shader: string;
  65434. };
  65435. }
  65436. declare module BABYLON {
  65437. /** @hidden */
  65438. export var clipPlaneFragmentDeclaration2: {
  65439. name: string;
  65440. shader: string;
  65441. };
  65442. }
  65443. declare module BABYLON {
  65444. /** @hidden */
  65445. export var gpuRenderParticlesPixelShader: {
  65446. name: string;
  65447. shader: string;
  65448. };
  65449. }
  65450. declare module BABYLON {
  65451. /** @hidden */
  65452. export var clipPlaneVertexDeclaration2: {
  65453. name: string;
  65454. shader: string;
  65455. };
  65456. }
  65457. declare module BABYLON {
  65458. /** @hidden */
  65459. export var gpuRenderParticlesVertexShader: {
  65460. name: string;
  65461. shader: string;
  65462. };
  65463. }
  65464. declare module BABYLON {
  65465. /**
  65466. * This represents a GPU particle system in Babylon
  65467. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  65468. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  65469. */
  65470. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  65471. /**
  65472. * The layer mask we are rendering the particles through.
  65473. */
  65474. layerMask: number;
  65475. private _capacity;
  65476. private _activeCount;
  65477. private _currentActiveCount;
  65478. private _accumulatedCount;
  65479. private _renderEffect;
  65480. private _updateEffect;
  65481. private _buffer0;
  65482. private _buffer1;
  65483. private _spriteBuffer;
  65484. private _updateVAO;
  65485. private _renderVAO;
  65486. private _targetIndex;
  65487. private _sourceBuffer;
  65488. private _targetBuffer;
  65489. private _engine;
  65490. private _currentRenderId;
  65491. private _started;
  65492. private _stopped;
  65493. private _timeDelta;
  65494. private _randomTexture;
  65495. private _randomTexture2;
  65496. private _attributesStrideSize;
  65497. private _updateEffectOptions;
  65498. private _randomTextureSize;
  65499. private _actualFrame;
  65500. private _customEffect;
  65501. private readonly _rawTextureWidth;
  65502. /**
  65503. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  65504. */
  65505. static get IsSupported(): boolean;
  65506. /**
  65507. * An event triggered when the system is disposed.
  65508. */
  65509. onDisposeObservable: Observable<IParticleSystem>;
  65510. /**
  65511. * Gets the maximum number of particles active at the same time.
  65512. * @returns The max number of active particles.
  65513. */
  65514. getCapacity(): number;
  65515. /**
  65516. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  65517. * to override the particles.
  65518. */
  65519. forceDepthWrite: boolean;
  65520. /**
  65521. * Gets or set the number of active particles
  65522. */
  65523. get activeParticleCount(): number;
  65524. set activeParticleCount(value: number);
  65525. private _preWarmDone;
  65526. /**
  65527. * Specifies if the particles are updated in emitter local space or world space.
  65528. */
  65529. isLocal: boolean;
  65530. /**
  65531. * Is this system ready to be used/rendered
  65532. * @return true if the system is ready
  65533. */
  65534. isReady(): boolean;
  65535. /**
  65536. * Gets if the system has been started. (Note: this will still be true after stop is called)
  65537. * @returns True if it has been started, otherwise false.
  65538. */
  65539. isStarted(): boolean;
  65540. /**
  65541. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  65542. * @returns True if it has been stopped, otherwise false.
  65543. */
  65544. isStopped(): boolean;
  65545. /**
  65546. * Gets a boolean indicating that the system is stopping
  65547. * @returns true if the system is currently stopping
  65548. */
  65549. isStopping(): boolean;
  65550. /**
  65551. * Gets the number of particles active at the same time.
  65552. * @returns The number of active particles.
  65553. */
  65554. getActiveCount(): number;
  65555. /**
  65556. * Starts the particle system and begins to emit
  65557. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  65558. */
  65559. start(delay?: number): void;
  65560. /**
  65561. * Stops the particle system.
  65562. */
  65563. stop(): void;
  65564. /**
  65565. * Remove all active particles
  65566. */
  65567. reset(): void;
  65568. /**
  65569. * Returns the string "GPUParticleSystem"
  65570. * @returns a string containing the class name
  65571. */
  65572. getClassName(): string;
  65573. /**
  65574. * Gets the custom effect used to render the particles
  65575. * @param blendMode Blend mode for which the effect should be retrieved
  65576. * @returns The effect
  65577. */
  65578. getCustomEffect(blendMode?: number): Nullable<Effect>;
  65579. /**
  65580. * Sets the custom effect used to render the particles
  65581. * @param effect The effect to set
  65582. * @param blendMode Blend mode for which the effect should be set
  65583. */
  65584. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  65585. /** @hidden */
  65586. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  65587. /**
  65588. * Observable that will be called just before the particles are drawn
  65589. */
  65590. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  65591. /**
  65592. * Gets the name of the particle vertex shader
  65593. */
  65594. get vertexShaderName(): string;
  65595. private _colorGradientsTexture;
  65596. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  65597. /**
  65598. * Adds a new color gradient
  65599. * @param gradient defines the gradient to use (between 0 and 1)
  65600. * @param color1 defines the color to affect to the specified gradient
  65601. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  65602. * @returns the current particle system
  65603. */
  65604. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  65605. private _refreshColorGradient;
  65606. /** Force the system to rebuild all gradients that need to be resync */
  65607. forceRefreshGradients(): void;
  65608. /**
  65609. * Remove a specific color gradient
  65610. * @param gradient defines the gradient to remove
  65611. * @returns the current particle system
  65612. */
  65613. removeColorGradient(gradient: number): GPUParticleSystem;
  65614. private _angularSpeedGradientsTexture;
  65615. private _sizeGradientsTexture;
  65616. private _velocityGradientsTexture;
  65617. private _limitVelocityGradientsTexture;
  65618. private _dragGradientsTexture;
  65619. private _addFactorGradient;
  65620. /**
  65621. * Adds a new size gradient
  65622. * @param gradient defines the gradient to use (between 0 and 1)
  65623. * @param factor defines the size factor to affect to the specified gradient
  65624. * @returns the current particle system
  65625. */
  65626. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  65627. /**
  65628. * Remove a specific size gradient
  65629. * @param gradient defines the gradient to remove
  65630. * @returns the current particle system
  65631. */
  65632. removeSizeGradient(gradient: number): GPUParticleSystem;
  65633. private _refreshFactorGradient;
  65634. /**
  65635. * Adds a new angular speed gradient
  65636. * @param gradient defines the gradient to use (between 0 and 1)
  65637. * @param factor defines the angular speed to affect to the specified gradient
  65638. * @returns the current particle system
  65639. */
  65640. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  65641. /**
  65642. * Remove a specific angular speed gradient
  65643. * @param gradient defines the gradient to remove
  65644. * @returns the current particle system
  65645. */
  65646. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  65647. /**
  65648. * Adds a new velocity gradient
  65649. * @param gradient defines the gradient to use (between 0 and 1)
  65650. * @param factor defines the velocity to affect to the specified gradient
  65651. * @returns the current particle system
  65652. */
  65653. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  65654. /**
  65655. * Remove a specific velocity gradient
  65656. * @param gradient defines the gradient to remove
  65657. * @returns the current particle system
  65658. */
  65659. removeVelocityGradient(gradient: number): GPUParticleSystem;
  65660. /**
  65661. * Adds a new limit velocity gradient
  65662. * @param gradient defines the gradient to use (between 0 and 1)
  65663. * @param factor defines the limit velocity value to affect to the specified gradient
  65664. * @returns the current particle system
  65665. */
  65666. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  65667. /**
  65668. * Remove a specific limit velocity gradient
  65669. * @param gradient defines the gradient to remove
  65670. * @returns the current particle system
  65671. */
  65672. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  65673. /**
  65674. * Adds a new drag gradient
  65675. * @param gradient defines the gradient to use (between 0 and 1)
  65676. * @param factor defines the drag value to affect to the specified gradient
  65677. * @returns the current particle system
  65678. */
  65679. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  65680. /**
  65681. * Remove a specific drag gradient
  65682. * @param gradient defines the gradient to remove
  65683. * @returns the current particle system
  65684. */
  65685. removeDragGradient(gradient: number): GPUParticleSystem;
  65686. /**
  65687. * Not supported by GPUParticleSystem
  65688. * @param gradient defines the gradient to use (between 0 and 1)
  65689. * @param factor defines the emit rate value to affect to the specified gradient
  65690. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65691. * @returns the current particle system
  65692. */
  65693. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65694. /**
  65695. * Not supported by GPUParticleSystem
  65696. * @param gradient defines the gradient to remove
  65697. * @returns the current particle system
  65698. */
  65699. removeEmitRateGradient(gradient: number): IParticleSystem;
  65700. /**
  65701. * Not supported by GPUParticleSystem
  65702. * @param gradient defines the gradient to use (between 0 and 1)
  65703. * @param factor defines the start size value to affect to the specified gradient
  65704. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65705. * @returns the current particle system
  65706. */
  65707. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65708. /**
  65709. * Not supported by GPUParticleSystem
  65710. * @param gradient defines the gradient to remove
  65711. * @returns the current particle system
  65712. */
  65713. removeStartSizeGradient(gradient: number): IParticleSystem;
  65714. /**
  65715. * Not supported by GPUParticleSystem
  65716. * @param gradient defines the gradient to use (between 0 and 1)
  65717. * @param min defines the color remap minimal range
  65718. * @param max defines the color remap maximal range
  65719. * @returns the current particle system
  65720. */
  65721. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  65722. /**
  65723. * Not supported by GPUParticleSystem
  65724. * @param gradient defines the gradient to remove
  65725. * @returns the current particle system
  65726. */
  65727. removeColorRemapGradient(): IParticleSystem;
  65728. /**
  65729. * Not supported by GPUParticleSystem
  65730. * @param gradient defines the gradient to use (between 0 and 1)
  65731. * @param min defines the alpha remap minimal range
  65732. * @param max defines the alpha remap maximal range
  65733. * @returns the current particle system
  65734. */
  65735. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  65736. /**
  65737. * Not supported by GPUParticleSystem
  65738. * @param gradient defines the gradient to remove
  65739. * @returns the current particle system
  65740. */
  65741. removeAlphaRemapGradient(): IParticleSystem;
  65742. /**
  65743. * Not supported by GPUParticleSystem
  65744. * @param gradient defines the gradient to use (between 0 and 1)
  65745. * @param color defines the color to affect to the specified gradient
  65746. * @returns the current particle system
  65747. */
  65748. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  65749. /**
  65750. * Not supported by GPUParticleSystem
  65751. * @param gradient defines the gradient to remove
  65752. * @returns the current particle system
  65753. */
  65754. removeRampGradient(): IParticleSystem;
  65755. /**
  65756. * Not supported by GPUParticleSystem
  65757. * @returns the list of ramp gradients
  65758. */
  65759. getRampGradients(): Nullable<Array<Color3Gradient>>;
  65760. /**
  65761. * Not supported by GPUParticleSystem
  65762. * Gets or sets a boolean indicating that ramp gradients must be used
  65763. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  65764. */
  65765. get useRampGradients(): boolean;
  65766. set useRampGradients(value: boolean);
  65767. /**
  65768. * Not supported by GPUParticleSystem
  65769. * @param gradient defines the gradient to use (between 0 and 1)
  65770. * @param factor defines the life time factor to affect to the specified gradient
  65771. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65772. * @returns the current particle system
  65773. */
  65774. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65775. /**
  65776. * Not supported by GPUParticleSystem
  65777. * @param gradient defines the gradient to remove
  65778. * @returns the current particle system
  65779. */
  65780. removeLifeTimeGradient(gradient: number): IParticleSystem;
  65781. /**
  65782. * Instantiates a GPU particle system.
  65783. * 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.
  65784. * @param name The name of the particle system
  65785. * @param options The options used to create the system
  65786. * @param scene The scene the particle system belongs to
  65787. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  65788. * @param customEffect a custom effect used to change the way particles are rendered by default
  65789. */
  65790. constructor(name: string, options: Partial<{
  65791. capacity: number;
  65792. randomTextureSize: number;
  65793. }>, scene: Scene, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  65794. protected _reset(): void;
  65795. private _createUpdateVAO;
  65796. private _createRenderVAO;
  65797. private _initialize;
  65798. /** @hidden */
  65799. _recreateUpdateEffect(): void;
  65800. private _getEffect;
  65801. /**
  65802. * Fill the defines array according to the current settings of the particle system
  65803. * @param defines Array to be updated
  65804. * @param blendMode blend mode to take into account when updating the array
  65805. */
  65806. fillDefines(defines: Array<string>, blendMode?: number): void;
  65807. /**
  65808. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  65809. * @param uniforms Uniforms array to fill
  65810. * @param attributes Attributes array to fill
  65811. * @param samplers Samplers array to fill
  65812. */
  65813. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  65814. /** @hidden */
  65815. _recreateRenderEffect(): Effect;
  65816. /**
  65817. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  65818. * @param preWarm defines if we are in the pre-warmimg phase
  65819. */
  65820. animate(preWarm?: boolean): void;
  65821. private _createFactorGradientTexture;
  65822. private _createSizeGradientTexture;
  65823. private _createAngularSpeedGradientTexture;
  65824. private _createVelocityGradientTexture;
  65825. private _createLimitVelocityGradientTexture;
  65826. private _createDragGradientTexture;
  65827. private _createColorGradientTexture;
  65828. /**
  65829. * Renders the particle system in its current state
  65830. * @param preWarm defines if the system should only update the particles but not render them
  65831. * @returns the current number of particles
  65832. */
  65833. render(preWarm?: boolean): number;
  65834. /**
  65835. * Rebuilds the particle system
  65836. */
  65837. rebuild(): void;
  65838. private _releaseBuffers;
  65839. private _releaseVAOs;
  65840. /**
  65841. * Disposes the particle system and free the associated resources
  65842. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  65843. */
  65844. dispose(disposeTexture?: boolean): void;
  65845. /**
  65846. * Clones the particle system.
  65847. * @param name The name of the cloned object
  65848. * @param newEmitter The new emitter to use
  65849. * @returns the cloned particle system
  65850. */
  65851. clone(name: string, newEmitter: any): GPUParticleSystem;
  65852. /**
  65853. * Serializes the particle system to a JSON object
  65854. * @param serializeTexture defines if the texture must be serialized as well
  65855. * @returns the JSON object
  65856. */
  65857. serialize(serializeTexture?: boolean): any;
  65858. /**
  65859. * Parses a JSON object to create a GPU particle system.
  65860. * @param parsedParticleSystem The JSON object to parse
  65861. * @param scene The scene to create the particle system in
  65862. * @param rootUrl The root url to use to load external dependencies like texture
  65863. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  65864. * @returns the parsed GPU particle system
  65865. */
  65866. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  65867. }
  65868. }
  65869. declare module BABYLON {
  65870. /**
  65871. * Represents a set of particle systems working together to create a specific effect
  65872. */
  65873. export class ParticleSystemSet implements IDisposable {
  65874. /**
  65875. * Gets or sets base Assets URL
  65876. */
  65877. static BaseAssetsUrl: string;
  65878. private _emitterCreationOptions;
  65879. private _emitterNode;
  65880. /**
  65881. * Gets the particle system list
  65882. */
  65883. systems: IParticleSystem[];
  65884. /**
  65885. * Gets the emitter node used with this set
  65886. */
  65887. get emitterNode(): Nullable<TransformNode>;
  65888. /**
  65889. * Creates a new emitter mesh as a sphere
  65890. * @param options defines the options used to create the sphere
  65891. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  65892. * @param scene defines the hosting scene
  65893. */
  65894. setEmitterAsSphere(options: {
  65895. diameter: number;
  65896. segments: number;
  65897. color: Color3;
  65898. }, renderingGroupId: number, scene: Scene): void;
  65899. /**
  65900. * Starts all particle systems of the set
  65901. * @param emitter defines an optional mesh to use as emitter for the particle systems
  65902. */
  65903. start(emitter?: AbstractMesh): void;
  65904. /**
  65905. * Release all associated resources
  65906. */
  65907. dispose(): void;
  65908. /**
  65909. * Serialize the set into a JSON compatible object
  65910. * @param serializeTexture defines if the texture must be serialized as well
  65911. * @returns a JSON compatible representation of the set
  65912. */
  65913. serialize(serializeTexture?: boolean): any;
  65914. /**
  65915. * Parse a new ParticleSystemSet from a serialized source
  65916. * @param data defines a JSON compatible representation of the set
  65917. * @param scene defines the hosting scene
  65918. * @param gpu defines if we want GPU particles or CPU particles
  65919. * @returns a new ParticleSystemSet
  65920. */
  65921. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  65922. }
  65923. }
  65924. declare module BABYLON {
  65925. /**
  65926. * This class is made for on one-liner static method to help creating particle system set.
  65927. */
  65928. export class ParticleHelper {
  65929. /**
  65930. * Gets or sets base Assets URL
  65931. */
  65932. static BaseAssetsUrl: string;
  65933. /** Define the Url to load snippets */
  65934. static SnippetUrl: string;
  65935. /**
  65936. * Create a default particle system that you can tweak
  65937. * @param emitter defines the emitter to use
  65938. * @param capacity defines the system capacity (default is 500 particles)
  65939. * @param scene defines the hosting scene
  65940. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  65941. * @returns the new Particle system
  65942. */
  65943. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  65944. /**
  65945. * This is the main static method (one-liner) of this helper to create different particle systems
  65946. * @param type This string represents the type to the particle system to create
  65947. * @param scene The scene where the particle system should live
  65948. * @param gpu If the system will use gpu
  65949. * @returns the ParticleSystemSet created
  65950. */
  65951. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  65952. /**
  65953. * Static function used to export a particle system to a ParticleSystemSet variable.
  65954. * Please note that the emitter shape is not exported
  65955. * @param systems defines the particle systems to export
  65956. * @returns the created particle system set
  65957. */
  65958. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  65959. /**
  65960. * Creates a particle system from a snippet saved in a remote file
  65961. * @param name defines the name of the particle system to create
  65962. * @param url defines the url to load from
  65963. * @param scene defines the hosting scene
  65964. * @param gpu If the system will use gpu
  65965. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  65966. * @returns a promise that will resolve to the new particle system
  65967. */
  65968. static ParseFromFileAsync(name: string, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  65969. /**
  65970. * Creates a particle system from a snippet saved by the particle system editor
  65971. * @param snippetId defines the snippet to load
  65972. * @param scene defines the hosting scene
  65973. * @param gpu If the system will use gpu
  65974. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  65975. * @returns a promise that will resolve to the new particle system
  65976. */
  65977. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  65978. }
  65979. }
  65980. declare module BABYLON {
  65981. interface Engine {
  65982. /**
  65983. * Create an effect to use with particle systems.
  65984. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  65985. * the particle system for which you want to create a custom effect in the last parameter
  65986. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  65987. * @param uniformsNames defines a list of attribute names
  65988. * @param samplers defines an array of string used to represent textures
  65989. * @param defines defines the string containing the defines to use to compile the shaders
  65990. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  65991. * @param onCompiled defines a function to call when the effect creation is successful
  65992. * @param onError defines a function to call when the effect creation has failed
  65993. * @param particleSystem the particle system you want to create the effect for
  65994. * @returns the new Effect
  65995. */
  65996. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  65997. }
  65998. interface Mesh {
  65999. /**
  66000. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  66001. * @returns an array of IParticleSystem
  66002. */
  66003. getEmittedParticleSystems(): IParticleSystem[];
  66004. /**
  66005. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  66006. * @returns an array of IParticleSystem
  66007. */
  66008. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  66009. }
  66010. /**
  66011. * @hidden
  66012. */
  66013. export var _IDoNeedToBeInTheBuild: number;
  66014. }
  66015. declare module BABYLON {
  66016. /** Defines the 4 color options */
  66017. export enum PointColor {
  66018. /** color value */
  66019. Color = 2,
  66020. /** uv value */
  66021. UV = 1,
  66022. /** random value */
  66023. Random = 0,
  66024. /** stated value */
  66025. Stated = 3
  66026. }
  66027. /**
  66028. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  66029. * 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.
  66030. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  66031. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  66032. *
  66033. * Full documentation here : TO BE ENTERED
  66034. */
  66035. export class PointsCloudSystem implements IDisposable {
  66036. /**
  66037. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  66038. * Example : var p = SPS.particles[i];
  66039. */
  66040. particles: CloudPoint[];
  66041. /**
  66042. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  66043. */
  66044. nbParticles: number;
  66045. /**
  66046. * This a counter for your own usage. It's not set by any SPS functions.
  66047. */
  66048. counter: number;
  66049. /**
  66050. * The PCS name. This name is also given to the underlying mesh.
  66051. */
  66052. name: string;
  66053. /**
  66054. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  66055. */
  66056. mesh: Mesh;
  66057. /**
  66058. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  66059. * Please read :
  66060. */
  66061. vars: any;
  66062. /**
  66063. * @hidden
  66064. */
  66065. _size: number;
  66066. private _scene;
  66067. private _promises;
  66068. private _positions;
  66069. private _indices;
  66070. private _normals;
  66071. private _colors;
  66072. private _uvs;
  66073. private _indices32;
  66074. private _positions32;
  66075. private _colors32;
  66076. private _uvs32;
  66077. private _updatable;
  66078. private _isVisibilityBoxLocked;
  66079. private _alwaysVisible;
  66080. private _groups;
  66081. private _groupCounter;
  66082. private _computeParticleColor;
  66083. private _computeParticleTexture;
  66084. private _computeParticleRotation;
  66085. private _computeBoundingBox;
  66086. private _isReady;
  66087. /**
  66088. * Creates a PCS (Points Cloud System) object
  66089. * @param name (String) is the PCS name, this will be the underlying mesh name
  66090. * @param pointSize (number) is the size for each point
  66091. * @param scene (Scene) is the scene in which the PCS is added
  66092. * @param options defines the options of the PCS e.g.
  66093. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  66094. */
  66095. constructor(name: string, pointSize: number, scene: Scene, options?: {
  66096. updatable?: boolean;
  66097. });
  66098. /**
  66099. * Builds the PCS underlying mesh. Returns a standard Mesh.
  66100. * If no points were added to the PCS, the returned mesh is just a single point.
  66101. * @returns a promise for the created mesh
  66102. */
  66103. buildMeshAsync(): Promise<Mesh>;
  66104. /**
  66105. * @hidden
  66106. */
  66107. private _buildMesh;
  66108. private _addParticle;
  66109. private _randomUnitVector;
  66110. private _getColorIndicesForCoord;
  66111. private _setPointsColorOrUV;
  66112. private _colorFromTexture;
  66113. private _calculateDensity;
  66114. /**
  66115. * Adds points to the PCS in random positions within a unit sphere
  66116. * @param nb (positive integer) the number of particles to be created from this model
  66117. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  66118. * @returns the number of groups in the system
  66119. */
  66120. addPoints(nb: number, pointFunction?: any): number;
  66121. /**
  66122. * Adds points to the PCS from the surface of the model shape
  66123. * @param mesh is any Mesh object that will be used as a surface model for the points
  66124. * @param nb (positive integer) the number of particles to be created from this model
  66125. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66126. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66127. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66128. * @returns the number of groups in the system
  66129. */
  66130. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66131. /**
  66132. * Adds points to the PCS inside the model shape
  66133. * @param mesh is any Mesh object that will be used as a surface model for the points
  66134. * @param nb (positive integer) the number of particles to be created from this model
  66135. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66136. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66137. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66138. * @returns the number of groups in the system
  66139. */
  66140. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66141. /**
  66142. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  66143. * This method calls `updateParticle()` for each particle of the SPS.
  66144. * For an animated SPS, it is usually called within the render loop.
  66145. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  66146. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  66147. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  66148. * @returns the PCS.
  66149. */
  66150. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  66151. /**
  66152. * Disposes the PCS.
  66153. */
  66154. dispose(): void;
  66155. /**
  66156. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  66157. * doc :
  66158. * @returns the PCS.
  66159. */
  66160. refreshVisibleSize(): PointsCloudSystem;
  66161. /**
  66162. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  66163. * @param size the size (float) of the visibility box
  66164. * note : this doesn't lock the PCS mesh bounding box.
  66165. * doc :
  66166. */
  66167. setVisibilityBox(size: number): void;
  66168. /**
  66169. * Gets whether the PCS is always visible or not
  66170. * doc :
  66171. */
  66172. get isAlwaysVisible(): boolean;
  66173. /**
  66174. * Sets the PCS as always visible or not
  66175. * doc :
  66176. */
  66177. set isAlwaysVisible(val: boolean);
  66178. /**
  66179. * Tells to `setParticles()` to compute the particle rotations or not
  66180. * Default value : false. The PCS is faster when it's set to false
  66181. * Note : particle rotations are only applied to parent particles
  66182. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  66183. */
  66184. set computeParticleRotation(val: boolean);
  66185. /**
  66186. * Tells to `setParticles()` to compute the particle colors or not.
  66187. * Default value : true. The PCS is faster when it's set to false.
  66188. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66189. */
  66190. set computeParticleColor(val: boolean);
  66191. set computeParticleTexture(val: boolean);
  66192. /**
  66193. * Gets if `setParticles()` computes the particle colors or not.
  66194. * Default value : false. The PCS is faster when it's set to false.
  66195. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66196. */
  66197. get computeParticleColor(): boolean;
  66198. /**
  66199. * Gets if `setParticles()` computes the particle textures or not.
  66200. * Default value : false. The PCS is faster when it's set to false.
  66201. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  66202. */
  66203. get computeParticleTexture(): boolean;
  66204. /**
  66205. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  66206. */
  66207. set computeBoundingBox(val: boolean);
  66208. /**
  66209. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  66210. */
  66211. get computeBoundingBox(): boolean;
  66212. /**
  66213. * This function does nothing. It may be overwritten to set all the particle first values.
  66214. * The PCS doesn't call this function, you may have to call it by your own.
  66215. * doc :
  66216. */
  66217. initParticles(): void;
  66218. /**
  66219. * This function does nothing. It may be overwritten to recycle a particle
  66220. * The PCS doesn't call this function, you can to call it
  66221. * doc :
  66222. * @param particle The particle to recycle
  66223. * @returns the recycled particle
  66224. */
  66225. recycleParticle(particle: CloudPoint): CloudPoint;
  66226. /**
  66227. * Updates a particle : this function should be overwritten by the user.
  66228. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  66229. * doc :
  66230. * @example : just set a particle position or velocity and recycle conditions
  66231. * @param particle The particle to update
  66232. * @returns the updated particle
  66233. */
  66234. updateParticle(particle: CloudPoint): CloudPoint;
  66235. /**
  66236. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  66237. * This does nothing and may be overwritten by the user.
  66238. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66239. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66240. * @param update the boolean update value actually passed to setParticles()
  66241. */
  66242. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66243. /**
  66244. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  66245. * This will be passed three parameters.
  66246. * This does nothing and may be overwritten by the user.
  66247. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66248. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66249. * @param update the boolean update value actually passed to setParticles()
  66250. */
  66251. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66252. }
  66253. }
  66254. declare module BABYLON {
  66255. /**
  66256. * Represents one particle of a points cloud system.
  66257. */
  66258. export class CloudPoint {
  66259. /**
  66260. * particle global index
  66261. */
  66262. idx: number;
  66263. /**
  66264. * The color of the particle
  66265. */
  66266. color: Nullable<Color4>;
  66267. /**
  66268. * The world space position of the particle.
  66269. */
  66270. position: Vector3;
  66271. /**
  66272. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  66273. */
  66274. rotation: Vector3;
  66275. /**
  66276. * The world space rotation quaternion of the particle.
  66277. */
  66278. rotationQuaternion: Nullable<Quaternion>;
  66279. /**
  66280. * The uv of the particle.
  66281. */
  66282. uv: Nullable<Vector2>;
  66283. /**
  66284. * The current speed of the particle.
  66285. */
  66286. velocity: Vector3;
  66287. /**
  66288. * The pivot point in the particle local space.
  66289. */
  66290. pivot: Vector3;
  66291. /**
  66292. * Must the particle be translated from its pivot point in its local space ?
  66293. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  66294. * Default : false
  66295. */
  66296. translateFromPivot: boolean;
  66297. /**
  66298. * Index of this particle in the global "positions" array (Internal use)
  66299. * @hidden
  66300. */
  66301. _pos: number;
  66302. /**
  66303. * @hidden Index of this particle in the global "indices" array (Internal use)
  66304. */
  66305. _ind: number;
  66306. /**
  66307. * Group this particle belongs to
  66308. */
  66309. _group: PointsGroup;
  66310. /**
  66311. * Group id of this particle
  66312. */
  66313. groupId: number;
  66314. /**
  66315. * Index of the particle in its group id (Internal use)
  66316. */
  66317. idxInGroup: number;
  66318. /**
  66319. * @hidden Particle BoundingInfo object (Internal use)
  66320. */
  66321. _boundingInfo: BoundingInfo;
  66322. /**
  66323. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  66324. */
  66325. _pcs: PointsCloudSystem;
  66326. /**
  66327. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  66328. */
  66329. _stillInvisible: boolean;
  66330. /**
  66331. * @hidden Last computed particle rotation matrix
  66332. */
  66333. _rotationMatrix: number[];
  66334. /**
  66335. * Parent particle Id, if any.
  66336. * Default null.
  66337. */
  66338. parentId: Nullable<number>;
  66339. /**
  66340. * @hidden Internal global position in the PCS.
  66341. */
  66342. _globalPosition: Vector3;
  66343. /**
  66344. * Creates a Point Cloud object.
  66345. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  66346. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  66347. * @param group (PointsGroup) is the group the particle belongs to
  66348. * @param groupId (integer) is the group identifier in the PCS.
  66349. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  66350. * @param pcs defines the PCS it is associated to
  66351. */
  66352. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  66353. /**
  66354. * get point size
  66355. */
  66356. get size(): Vector3;
  66357. /**
  66358. * Set point size
  66359. */
  66360. set size(scale: Vector3);
  66361. /**
  66362. * Legacy support, changed quaternion to rotationQuaternion
  66363. */
  66364. get quaternion(): Nullable<Quaternion>;
  66365. /**
  66366. * Legacy support, changed quaternion to rotationQuaternion
  66367. */
  66368. set quaternion(q: Nullable<Quaternion>);
  66369. /**
  66370. * Returns a boolean. True if the particle intersects a mesh, else false
  66371. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  66372. * @param target is the object (point or mesh) what the intersection is computed against
  66373. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  66374. * @returns true if it intersects
  66375. */
  66376. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  66377. /**
  66378. * get the rotation matrix of the particle
  66379. * @hidden
  66380. */
  66381. getRotationMatrix(m: Matrix): void;
  66382. }
  66383. /**
  66384. * Represents a group of points in a points cloud system
  66385. * * PCS internal tool, don't use it manually.
  66386. */
  66387. export class PointsGroup {
  66388. /**
  66389. * The group id
  66390. * @hidden
  66391. */
  66392. groupID: number;
  66393. /**
  66394. * image data for group (internal use)
  66395. * @hidden
  66396. */
  66397. _groupImageData: Nullable<ArrayBufferView>;
  66398. /**
  66399. * Image Width (internal use)
  66400. * @hidden
  66401. */
  66402. _groupImgWidth: number;
  66403. /**
  66404. * Image Height (internal use)
  66405. * @hidden
  66406. */
  66407. _groupImgHeight: number;
  66408. /**
  66409. * Custom position function (internal use)
  66410. * @hidden
  66411. */
  66412. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  66413. /**
  66414. * density per facet for surface points
  66415. * @hidden
  66416. */
  66417. _groupDensity: number[];
  66418. /**
  66419. * Only when points are colored by texture carries pointer to texture list array
  66420. * @hidden
  66421. */
  66422. _textureNb: number;
  66423. /**
  66424. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  66425. * PCS internal tool, don't use it manually.
  66426. * @hidden
  66427. */
  66428. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  66429. }
  66430. }
  66431. declare module BABYLON {
  66432. interface Scene {
  66433. /** @hidden (Backing field) */
  66434. _physicsEngine: Nullable<IPhysicsEngine>;
  66435. /** @hidden */
  66436. _physicsTimeAccumulator: number;
  66437. /**
  66438. * Gets the current physics engine
  66439. * @returns a IPhysicsEngine or null if none attached
  66440. */
  66441. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  66442. /**
  66443. * Enables physics to the current scene
  66444. * @param gravity defines the scene's gravity for the physics engine
  66445. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  66446. * @return a boolean indicating if the physics engine was initialized
  66447. */
  66448. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  66449. /**
  66450. * Disables and disposes the physics engine associated with the scene
  66451. */
  66452. disablePhysicsEngine(): void;
  66453. /**
  66454. * Gets a boolean indicating if there is an active physics engine
  66455. * @returns a boolean indicating if there is an active physics engine
  66456. */
  66457. isPhysicsEnabled(): boolean;
  66458. /**
  66459. * Deletes a physics compound impostor
  66460. * @param compound defines the compound to delete
  66461. */
  66462. deleteCompoundImpostor(compound: any): void;
  66463. /**
  66464. * An event triggered when physic simulation is about to be run
  66465. */
  66466. onBeforePhysicsObservable: Observable<Scene>;
  66467. /**
  66468. * An event triggered when physic simulation has been done
  66469. */
  66470. onAfterPhysicsObservable: Observable<Scene>;
  66471. }
  66472. interface AbstractMesh {
  66473. /** @hidden */
  66474. _physicsImpostor: Nullable<PhysicsImpostor>;
  66475. /**
  66476. * Gets or sets impostor used for physic simulation
  66477. * @see http://doc.babylonjs.com/features/physics_engine
  66478. */
  66479. physicsImpostor: Nullable<PhysicsImpostor>;
  66480. /**
  66481. * Gets the current physics impostor
  66482. * @see http://doc.babylonjs.com/features/physics_engine
  66483. * @returns a physics impostor or null
  66484. */
  66485. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  66486. /** Apply a physic impulse to the mesh
  66487. * @param force defines the force to apply
  66488. * @param contactPoint defines where to apply the force
  66489. * @returns the current mesh
  66490. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  66491. */
  66492. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  66493. /**
  66494. * Creates a physic joint between two meshes
  66495. * @param otherMesh defines the other mesh to use
  66496. * @param pivot1 defines the pivot to use on this mesh
  66497. * @param pivot2 defines the pivot to use on the other mesh
  66498. * @param options defines additional options (can be plugin dependent)
  66499. * @returns the current mesh
  66500. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  66501. */
  66502. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  66503. /** @hidden */
  66504. _disposePhysicsObserver: Nullable<Observer<Node>>;
  66505. }
  66506. /**
  66507. * Defines the physics engine scene component responsible to manage a physics engine
  66508. */
  66509. export class PhysicsEngineSceneComponent implements ISceneComponent {
  66510. /**
  66511. * The component name helpful to identify the component in the list of scene components.
  66512. */
  66513. readonly name: string;
  66514. /**
  66515. * The scene the component belongs to.
  66516. */
  66517. scene: Scene;
  66518. /**
  66519. * Creates a new instance of the component for the given scene
  66520. * @param scene Defines the scene to register the component in
  66521. */
  66522. constructor(scene: Scene);
  66523. /**
  66524. * Registers the component in a given scene
  66525. */
  66526. register(): void;
  66527. /**
  66528. * Rebuilds the elements related to this component in case of
  66529. * context lost for instance.
  66530. */
  66531. rebuild(): void;
  66532. /**
  66533. * Disposes the component and the associated ressources
  66534. */
  66535. dispose(): void;
  66536. }
  66537. }
  66538. declare module BABYLON {
  66539. /**
  66540. * A helper for physics simulations
  66541. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66542. */
  66543. export class PhysicsHelper {
  66544. private _scene;
  66545. private _physicsEngine;
  66546. /**
  66547. * Initializes the Physics helper
  66548. * @param scene Babylon.js scene
  66549. */
  66550. constructor(scene: Scene);
  66551. /**
  66552. * Applies a radial explosion impulse
  66553. * @param origin the origin of the explosion
  66554. * @param radiusOrEventOptions the radius or the options of radial explosion
  66555. * @param strength the explosion strength
  66556. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66557. * @returns A physics radial explosion event, or null
  66558. */
  66559. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  66560. /**
  66561. * Applies a radial explosion force
  66562. * @param origin the origin of the explosion
  66563. * @param radiusOrEventOptions the radius or the options of radial explosion
  66564. * @param strength the explosion strength
  66565. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66566. * @returns A physics radial explosion event, or null
  66567. */
  66568. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  66569. /**
  66570. * Creates a gravitational field
  66571. * @param origin the origin of the explosion
  66572. * @param radiusOrEventOptions the radius or the options of radial explosion
  66573. * @param strength the explosion strength
  66574. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66575. * @returns A physics gravitational field event, or null
  66576. */
  66577. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  66578. /**
  66579. * Creates a physics updraft event
  66580. * @param origin the origin of the updraft
  66581. * @param radiusOrEventOptions the radius or the options of the updraft
  66582. * @param strength the strength of the updraft
  66583. * @param height the height of the updraft
  66584. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  66585. * @returns A physics updraft event, or null
  66586. */
  66587. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  66588. /**
  66589. * Creates a physics vortex event
  66590. * @param origin the of the vortex
  66591. * @param radiusOrEventOptions the radius or the options of the vortex
  66592. * @param strength the strength of the vortex
  66593. * @param height the height of the vortex
  66594. * @returns a Physics vortex event, or null
  66595. * A physics vortex event or null
  66596. */
  66597. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  66598. }
  66599. /**
  66600. * Represents a physics radial explosion event
  66601. */
  66602. class PhysicsRadialExplosionEvent {
  66603. private _scene;
  66604. private _options;
  66605. private _sphere;
  66606. private _dataFetched;
  66607. /**
  66608. * Initializes a radial explosioin event
  66609. * @param _scene BabylonJS scene
  66610. * @param _options The options for the vortex event
  66611. */
  66612. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  66613. /**
  66614. * Returns the data related to the radial explosion event (sphere).
  66615. * @returns The radial explosion event data
  66616. */
  66617. getData(): PhysicsRadialExplosionEventData;
  66618. /**
  66619. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  66620. * @param impostor A physics imposter
  66621. * @param origin the origin of the explosion
  66622. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  66623. */
  66624. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  66625. /**
  66626. * Triggers affecterd impostors callbacks
  66627. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  66628. */
  66629. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  66630. /**
  66631. * Disposes the sphere.
  66632. * @param force Specifies if the sphere should be disposed by force
  66633. */
  66634. dispose(force?: boolean): void;
  66635. /*** Helpers ***/
  66636. private _prepareSphere;
  66637. private _intersectsWithSphere;
  66638. }
  66639. /**
  66640. * Represents a gravitational field event
  66641. */
  66642. class PhysicsGravitationalFieldEvent {
  66643. private _physicsHelper;
  66644. private _scene;
  66645. private _origin;
  66646. private _options;
  66647. private _tickCallback;
  66648. private _sphere;
  66649. private _dataFetched;
  66650. /**
  66651. * Initializes the physics gravitational field event
  66652. * @param _physicsHelper A physics helper
  66653. * @param _scene BabylonJS scene
  66654. * @param _origin The origin position of the gravitational field event
  66655. * @param _options The options for the vortex event
  66656. */
  66657. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  66658. /**
  66659. * Returns the data related to the gravitational field event (sphere).
  66660. * @returns A gravitational field event
  66661. */
  66662. getData(): PhysicsGravitationalFieldEventData;
  66663. /**
  66664. * Enables the gravitational field.
  66665. */
  66666. enable(): void;
  66667. /**
  66668. * Disables the gravitational field.
  66669. */
  66670. disable(): void;
  66671. /**
  66672. * Disposes the sphere.
  66673. * @param force The force to dispose from the gravitational field event
  66674. */
  66675. dispose(force?: boolean): void;
  66676. private _tick;
  66677. }
  66678. /**
  66679. * Represents a physics updraft event
  66680. */
  66681. class PhysicsUpdraftEvent {
  66682. private _scene;
  66683. private _origin;
  66684. private _options;
  66685. private _physicsEngine;
  66686. private _originTop;
  66687. private _originDirection;
  66688. private _tickCallback;
  66689. private _cylinder;
  66690. private _cylinderPosition;
  66691. private _dataFetched;
  66692. /**
  66693. * Initializes the physics updraft event
  66694. * @param _scene BabylonJS scene
  66695. * @param _origin The origin position of the updraft
  66696. * @param _options The options for the updraft event
  66697. */
  66698. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  66699. /**
  66700. * Returns the data related to the updraft event (cylinder).
  66701. * @returns A physics updraft event
  66702. */
  66703. getData(): PhysicsUpdraftEventData;
  66704. /**
  66705. * Enables the updraft.
  66706. */
  66707. enable(): void;
  66708. /**
  66709. * Disables the updraft.
  66710. */
  66711. disable(): void;
  66712. /**
  66713. * Disposes the cylinder.
  66714. * @param force Specifies if the updraft should be disposed by force
  66715. */
  66716. dispose(force?: boolean): void;
  66717. private getImpostorHitData;
  66718. private _tick;
  66719. /*** Helpers ***/
  66720. private _prepareCylinder;
  66721. private _intersectsWithCylinder;
  66722. }
  66723. /**
  66724. * Represents a physics vortex event
  66725. */
  66726. class PhysicsVortexEvent {
  66727. private _scene;
  66728. private _origin;
  66729. private _options;
  66730. private _physicsEngine;
  66731. private _originTop;
  66732. private _tickCallback;
  66733. private _cylinder;
  66734. private _cylinderPosition;
  66735. private _dataFetched;
  66736. /**
  66737. * Initializes the physics vortex event
  66738. * @param _scene The BabylonJS scene
  66739. * @param _origin The origin position of the vortex
  66740. * @param _options The options for the vortex event
  66741. */
  66742. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  66743. /**
  66744. * Returns the data related to the vortex event (cylinder).
  66745. * @returns The physics vortex event data
  66746. */
  66747. getData(): PhysicsVortexEventData;
  66748. /**
  66749. * Enables the vortex.
  66750. */
  66751. enable(): void;
  66752. /**
  66753. * Disables the cortex.
  66754. */
  66755. disable(): void;
  66756. /**
  66757. * Disposes the sphere.
  66758. * @param force
  66759. */
  66760. dispose(force?: boolean): void;
  66761. private getImpostorHitData;
  66762. private _tick;
  66763. /*** Helpers ***/
  66764. private _prepareCylinder;
  66765. private _intersectsWithCylinder;
  66766. }
  66767. /**
  66768. * Options fot the radial explosion event
  66769. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66770. */
  66771. export class PhysicsRadialExplosionEventOptions {
  66772. /**
  66773. * The radius of the sphere for the radial explosion.
  66774. */
  66775. radius: number;
  66776. /**
  66777. * The strenth of the explosion.
  66778. */
  66779. strength: number;
  66780. /**
  66781. * The strenght of the force in correspondence to the distance of the affected object
  66782. */
  66783. falloff: PhysicsRadialImpulseFalloff;
  66784. /**
  66785. * Sphere options for the radial explosion.
  66786. */
  66787. sphere: {
  66788. segments: number;
  66789. diameter: number;
  66790. };
  66791. /**
  66792. * Sphere options for the radial explosion.
  66793. */
  66794. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  66795. }
  66796. /**
  66797. * Options fot the updraft event
  66798. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66799. */
  66800. export class PhysicsUpdraftEventOptions {
  66801. /**
  66802. * The radius of the cylinder for the vortex
  66803. */
  66804. radius: number;
  66805. /**
  66806. * The strenth of the updraft.
  66807. */
  66808. strength: number;
  66809. /**
  66810. * The height of the cylinder for the updraft.
  66811. */
  66812. height: number;
  66813. /**
  66814. * The mode for the the updraft.
  66815. */
  66816. updraftMode: PhysicsUpdraftMode;
  66817. }
  66818. /**
  66819. * Options fot the vortex event
  66820. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66821. */
  66822. export class PhysicsVortexEventOptions {
  66823. /**
  66824. * The radius of the cylinder for the vortex
  66825. */
  66826. radius: number;
  66827. /**
  66828. * The strenth of the vortex.
  66829. */
  66830. strength: number;
  66831. /**
  66832. * The height of the cylinder for the vortex.
  66833. */
  66834. height: number;
  66835. /**
  66836. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  66837. */
  66838. centripetalForceThreshold: number;
  66839. /**
  66840. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  66841. */
  66842. centripetalForceMultiplier: number;
  66843. /**
  66844. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  66845. */
  66846. centrifugalForceMultiplier: number;
  66847. /**
  66848. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  66849. */
  66850. updraftForceMultiplier: number;
  66851. }
  66852. /**
  66853. * The strenght of the force in correspondence to the distance of the affected object
  66854. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66855. */
  66856. export enum PhysicsRadialImpulseFalloff {
  66857. /** Defines that impulse is constant in strength across it's whole radius */
  66858. Constant = 0,
  66859. /** Defines that impulse gets weaker if it's further from the origin */
  66860. Linear = 1
  66861. }
  66862. /**
  66863. * The strength of the force in correspondence to the distance of the affected object
  66864. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66865. */
  66866. export enum PhysicsUpdraftMode {
  66867. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  66868. Center = 0,
  66869. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  66870. Perpendicular = 1
  66871. }
  66872. /**
  66873. * Interface for a physics hit data
  66874. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66875. */
  66876. export interface PhysicsHitData {
  66877. /**
  66878. * The force applied at the contact point
  66879. */
  66880. force: Vector3;
  66881. /**
  66882. * The contact point
  66883. */
  66884. contactPoint: Vector3;
  66885. /**
  66886. * The distance from the origin to the contact point
  66887. */
  66888. distanceFromOrigin: number;
  66889. }
  66890. /**
  66891. * Interface for radial explosion event data
  66892. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66893. */
  66894. export interface PhysicsRadialExplosionEventData {
  66895. /**
  66896. * A sphere used for the radial explosion event
  66897. */
  66898. sphere: Mesh;
  66899. }
  66900. /**
  66901. * Interface for gravitational field event data
  66902. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66903. */
  66904. export interface PhysicsGravitationalFieldEventData {
  66905. /**
  66906. * A sphere mesh used for the gravitational field event
  66907. */
  66908. sphere: Mesh;
  66909. }
  66910. /**
  66911. * Interface for updraft event data
  66912. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66913. */
  66914. export interface PhysicsUpdraftEventData {
  66915. /**
  66916. * A cylinder used for the updraft event
  66917. */
  66918. cylinder: Mesh;
  66919. }
  66920. /**
  66921. * Interface for vortex event data
  66922. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66923. */
  66924. export interface PhysicsVortexEventData {
  66925. /**
  66926. * A cylinder used for the vortex event
  66927. */
  66928. cylinder: Mesh;
  66929. }
  66930. /**
  66931. * Interface for an affected physics impostor
  66932. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66933. */
  66934. export interface PhysicsAffectedImpostorWithData {
  66935. /**
  66936. * The impostor affected by the effect
  66937. */
  66938. impostor: PhysicsImpostor;
  66939. /**
  66940. * The data about the hit/horce from the explosion
  66941. */
  66942. hitData: PhysicsHitData;
  66943. }
  66944. }
  66945. declare module BABYLON {
  66946. /** @hidden */
  66947. export var blackAndWhitePixelShader: {
  66948. name: string;
  66949. shader: string;
  66950. };
  66951. }
  66952. declare module BABYLON {
  66953. /**
  66954. * Post process used to render in black and white
  66955. */
  66956. export class BlackAndWhitePostProcess extends PostProcess {
  66957. /**
  66958. * Linear about to convert he result to black and white (default: 1)
  66959. */
  66960. degree: number;
  66961. /**
  66962. * Creates a black and white post process
  66963. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  66964. * @param name The name of the effect.
  66965. * @param options The required width/height ratio to downsize to before computing the render pass.
  66966. * @param camera The camera to apply the render pass to.
  66967. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66968. * @param engine The engine which the post process will be applied. (default: current engine)
  66969. * @param reusable If the post process can be reused on the same frame. (default: false)
  66970. */
  66971. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  66972. }
  66973. }
  66974. declare module BABYLON {
  66975. /**
  66976. * This represents a set of one or more post processes in Babylon.
  66977. * A post process can be used to apply a shader to a texture after it is rendered.
  66978. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  66979. */
  66980. export class PostProcessRenderEffect {
  66981. private _postProcesses;
  66982. private _getPostProcesses;
  66983. private _singleInstance;
  66984. private _cameras;
  66985. private _indicesForCamera;
  66986. /**
  66987. * Name of the effect
  66988. * @hidden
  66989. */
  66990. _name: string;
  66991. /**
  66992. * Instantiates a post process render effect.
  66993. * A post process can be used to apply a shader to a texture after it is rendered.
  66994. * @param engine The engine the effect is tied to
  66995. * @param name The name of the effect
  66996. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  66997. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  66998. */
  66999. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  67000. /**
  67001. * Checks if all the post processes in the effect are supported.
  67002. */
  67003. get isSupported(): boolean;
  67004. /**
  67005. * Updates the current state of the effect
  67006. * @hidden
  67007. */
  67008. _update(): void;
  67009. /**
  67010. * Attaches the effect on cameras
  67011. * @param cameras The camera to attach to.
  67012. * @hidden
  67013. */
  67014. _attachCameras(cameras: Camera): void;
  67015. /**
  67016. * Attaches the effect on cameras
  67017. * @param cameras The camera to attach to.
  67018. * @hidden
  67019. */
  67020. _attachCameras(cameras: Camera[]): void;
  67021. /**
  67022. * Detaches the effect on cameras
  67023. * @param cameras The camera to detatch from.
  67024. * @hidden
  67025. */
  67026. _detachCameras(cameras: Camera): void;
  67027. /**
  67028. * Detatches the effect on cameras
  67029. * @param cameras The camera to detatch from.
  67030. * @hidden
  67031. */
  67032. _detachCameras(cameras: Camera[]): void;
  67033. /**
  67034. * Enables the effect on given cameras
  67035. * @param cameras The camera to enable.
  67036. * @hidden
  67037. */
  67038. _enable(cameras: Camera): void;
  67039. /**
  67040. * Enables the effect on given cameras
  67041. * @param cameras The camera to enable.
  67042. * @hidden
  67043. */
  67044. _enable(cameras: Nullable<Camera[]>): void;
  67045. /**
  67046. * Disables the effect on the given cameras
  67047. * @param cameras The camera to disable.
  67048. * @hidden
  67049. */
  67050. _disable(cameras: Camera): void;
  67051. /**
  67052. * Disables the effect on the given cameras
  67053. * @param cameras The camera to disable.
  67054. * @hidden
  67055. */
  67056. _disable(cameras: Nullable<Camera[]>): void;
  67057. /**
  67058. * Gets a list of the post processes contained in the effect.
  67059. * @param camera The camera to get the post processes on.
  67060. * @returns The list of the post processes in the effect.
  67061. */
  67062. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  67063. }
  67064. }
  67065. declare module BABYLON {
  67066. /** @hidden */
  67067. export var extractHighlightsPixelShader: {
  67068. name: string;
  67069. shader: string;
  67070. };
  67071. }
  67072. declare module BABYLON {
  67073. /**
  67074. * 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.
  67075. */
  67076. export class ExtractHighlightsPostProcess extends PostProcess {
  67077. /**
  67078. * The luminance threshold, pixels below this value will be set to black.
  67079. */
  67080. threshold: number;
  67081. /** @hidden */
  67082. _exposure: number;
  67083. /**
  67084. * Post process which has the input texture to be used when performing highlight extraction
  67085. * @hidden
  67086. */
  67087. _inputPostProcess: Nullable<PostProcess>;
  67088. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67089. }
  67090. }
  67091. declare module BABYLON {
  67092. /** @hidden */
  67093. export var bloomMergePixelShader: {
  67094. name: string;
  67095. shader: string;
  67096. };
  67097. }
  67098. declare module BABYLON {
  67099. /**
  67100. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67101. */
  67102. export class BloomMergePostProcess extends PostProcess {
  67103. /** Weight of the bloom to be added to the original input. */
  67104. weight: number;
  67105. /**
  67106. * Creates a new instance of @see BloomMergePostProcess
  67107. * @param name The name of the effect.
  67108. * @param originalFromInput Post process which's input will be used for the merge.
  67109. * @param blurred Blurred highlights post process which's output will be used.
  67110. * @param weight Weight of the bloom to be added to the original input.
  67111. * @param options The required width/height ratio to downsize to before computing the render pass.
  67112. * @param camera The camera to apply the render pass to.
  67113. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67114. * @param engine The engine which the post process will be applied. (default: current engine)
  67115. * @param reusable If the post process can be reused on the same frame. (default: false)
  67116. * @param textureType Type of textures used when performing the post process. (default: 0)
  67117. * @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)
  67118. */
  67119. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  67120. /** Weight of the bloom to be added to the original input. */
  67121. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67122. }
  67123. }
  67124. declare module BABYLON {
  67125. /**
  67126. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  67127. */
  67128. export class BloomEffect extends PostProcessRenderEffect {
  67129. private bloomScale;
  67130. /**
  67131. * @hidden Internal
  67132. */
  67133. _effects: Array<PostProcess>;
  67134. /**
  67135. * @hidden Internal
  67136. */
  67137. _downscale: ExtractHighlightsPostProcess;
  67138. private _blurX;
  67139. private _blurY;
  67140. private _merge;
  67141. /**
  67142. * The luminance threshold to find bright areas of the image to bloom.
  67143. */
  67144. get threshold(): number;
  67145. set threshold(value: number);
  67146. /**
  67147. * The strength of the bloom.
  67148. */
  67149. get weight(): number;
  67150. set weight(value: number);
  67151. /**
  67152. * Specifies the size of the bloom blur kernel, relative to the final output size
  67153. */
  67154. get kernel(): number;
  67155. set kernel(value: number);
  67156. /**
  67157. * Creates a new instance of @see BloomEffect
  67158. * @param scene The scene the effect belongs to.
  67159. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  67160. * @param bloomKernel The size of the kernel to be used when applying the blur.
  67161. * @param bloomWeight The the strength of bloom.
  67162. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  67163. * @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)
  67164. */
  67165. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  67166. /**
  67167. * Disposes each of the internal effects for a given camera.
  67168. * @param camera The camera to dispose the effect on.
  67169. */
  67170. disposeEffects(camera: Camera): void;
  67171. /**
  67172. * @hidden Internal
  67173. */
  67174. _updateEffects(): void;
  67175. /**
  67176. * Internal
  67177. * @returns if all the contained post processes are ready.
  67178. * @hidden
  67179. */
  67180. _isReady(): boolean;
  67181. }
  67182. }
  67183. declare module BABYLON {
  67184. /** @hidden */
  67185. export var chromaticAberrationPixelShader: {
  67186. name: string;
  67187. shader: string;
  67188. };
  67189. }
  67190. declare module BABYLON {
  67191. /**
  67192. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  67193. */
  67194. export class ChromaticAberrationPostProcess extends PostProcess {
  67195. /**
  67196. * The amount of seperation of rgb channels (default: 30)
  67197. */
  67198. aberrationAmount: number;
  67199. /**
  67200. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  67201. */
  67202. radialIntensity: number;
  67203. /**
  67204. * 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))
  67205. */
  67206. direction: Vector2;
  67207. /**
  67208. * 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))
  67209. */
  67210. centerPosition: Vector2;
  67211. /**
  67212. * Creates a new instance ChromaticAberrationPostProcess
  67213. * @param name The name of the effect.
  67214. * @param screenWidth The width of the screen to apply the effect on.
  67215. * @param screenHeight The height of the screen to apply the effect on.
  67216. * @param options The required width/height ratio to downsize to before computing the render pass.
  67217. * @param camera The camera to apply the render pass to.
  67218. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67219. * @param engine The engine which the post process will be applied. (default: current engine)
  67220. * @param reusable If the post process can be reused on the same frame. (default: false)
  67221. * @param textureType Type of textures used when performing the post process. (default: 0)
  67222. * @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)
  67223. */
  67224. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67225. }
  67226. }
  67227. declare module BABYLON {
  67228. /** @hidden */
  67229. export var circleOfConfusionPixelShader: {
  67230. name: string;
  67231. shader: string;
  67232. };
  67233. }
  67234. declare module BABYLON {
  67235. /**
  67236. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  67237. */
  67238. export class CircleOfConfusionPostProcess extends PostProcess {
  67239. /**
  67240. * 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.
  67241. */
  67242. lensSize: number;
  67243. /**
  67244. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  67245. */
  67246. fStop: number;
  67247. /**
  67248. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  67249. */
  67250. focusDistance: number;
  67251. /**
  67252. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  67253. */
  67254. focalLength: number;
  67255. private _depthTexture;
  67256. /**
  67257. * Creates a new instance CircleOfConfusionPostProcess
  67258. * @param name The name of the effect.
  67259. * @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.
  67260. * @param options The required width/height ratio to downsize to before computing the render pass.
  67261. * @param camera The camera to apply the render pass to.
  67262. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67263. * @param engine The engine which the post process will be applied. (default: current engine)
  67264. * @param reusable If the post process can be reused on the same frame. (default: false)
  67265. * @param textureType Type of textures used when performing the post process. (default: 0)
  67266. * @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)
  67267. */
  67268. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67269. /**
  67270. * 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.
  67271. */
  67272. set depthTexture(value: RenderTargetTexture);
  67273. }
  67274. }
  67275. declare module BABYLON {
  67276. /** @hidden */
  67277. export var colorCorrectionPixelShader: {
  67278. name: string;
  67279. shader: string;
  67280. };
  67281. }
  67282. declare module BABYLON {
  67283. /**
  67284. *
  67285. * This post-process allows the modification of rendered colors by using
  67286. * a 'look-up table' (LUT). This effect is also called Color Grading.
  67287. *
  67288. * The object needs to be provided an url to a texture containing the color
  67289. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  67290. * Use an image editing software to tweak the LUT to match your needs.
  67291. *
  67292. * For an example of a color LUT, see here:
  67293. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  67294. * For explanations on color grading, see here:
  67295. * @see http://udn.epicgames.com/Three/ColorGrading.html
  67296. *
  67297. */
  67298. export class ColorCorrectionPostProcess extends PostProcess {
  67299. private _colorTableTexture;
  67300. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67301. }
  67302. }
  67303. declare module BABYLON {
  67304. /** @hidden */
  67305. export var convolutionPixelShader: {
  67306. name: string;
  67307. shader: string;
  67308. };
  67309. }
  67310. declare module BABYLON {
  67311. /**
  67312. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  67313. * input texture to perform effects such as edge detection or sharpening
  67314. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  67315. */
  67316. export class ConvolutionPostProcess extends PostProcess {
  67317. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  67318. kernel: number[];
  67319. /**
  67320. * Creates a new instance ConvolutionPostProcess
  67321. * @param name The name of the effect.
  67322. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  67323. * @param options The required width/height ratio to downsize to before computing the render pass.
  67324. * @param camera The camera to apply the render pass to.
  67325. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67326. * @param engine The engine which the post process will be applied. (default: current engine)
  67327. * @param reusable If the post process can be reused on the same frame. (default: false)
  67328. * @param textureType Type of textures used when performing the post process. (default: 0)
  67329. */
  67330. constructor(name: string,
  67331. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  67332. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67333. /**
  67334. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67335. */
  67336. static EdgeDetect0Kernel: number[];
  67337. /**
  67338. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67339. */
  67340. static EdgeDetect1Kernel: number[];
  67341. /**
  67342. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67343. */
  67344. static EdgeDetect2Kernel: number[];
  67345. /**
  67346. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67347. */
  67348. static SharpenKernel: number[];
  67349. /**
  67350. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67351. */
  67352. static EmbossKernel: number[];
  67353. /**
  67354. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67355. */
  67356. static GaussianKernel: number[];
  67357. }
  67358. }
  67359. declare module BABYLON {
  67360. /**
  67361. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  67362. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  67363. * based on samples that have a large difference in distance than the center pixel.
  67364. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  67365. */
  67366. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  67367. direction: Vector2;
  67368. /**
  67369. * Creates a new instance CircleOfConfusionPostProcess
  67370. * @param name The name of the effect.
  67371. * @param scene The scene the effect belongs to.
  67372. * @param direction The direction the blur should be applied.
  67373. * @param kernel The size of the kernel used to blur.
  67374. * @param options The required width/height ratio to downsize to before computing the render pass.
  67375. * @param camera The camera to apply the render pass to.
  67376. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  67377. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  67378. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67379. * @param engine The engine which the post process will be applied. (default: current engine)
  67380. * @param reusable If the post process can be reused on the same frame. (default: false)
  67381. * @param textureType Type of textures used when performing the post process. (default: 0)
  67382. * @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)
  67383. */
  67384. 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);
  67385. }
  67386. }
  67387. declare module BABYLON {
  67388. /** @hidden */
  67389. export var depthOfFieldMergePixelShader: {
  67390. name: string;
  67391. shader: string;
  67392. };
  67393. }
  67394. declare module BABYLON {
  67395. /**
  67396. * Options to be set when merging outputs from the default pipeline.
  67397. */
  67398. export class DepthOfFieldMergePostProcessOptions {
  67399. /**
  67400. * The original image to merge on top of
  67401. */
  67402. originalFromInput: PostProcess;
  67403. /**
  67404. * Parameters to perform the merge of the depth of field effect
  67405. */
  67406. depthOfField?: {
  67407. circleOfConfusion: PostProcess;
  67408. blurSteps: Array<PostProcess>;
  67409. };
  67410. /**
  67411. * Parameters to perform the merge of bloom effect
  67412. */
  67413. bloom?: {
  67414. blurred: PostProcess;
  67415. weight: number;
  67416. };
  67417. }
  67418. /**
  67419. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67420. */
  67421. export class DepthOfFieldMergePostProcess extends PostProcess {
  67422. private blurSteps;
  67423. /**
  67424. * Creates a new instance of DepthOfFieldMergePostProcess
  67425. * @param name The name of the effect.
  67426. * @param originalFromInput Post process which's input will be used for the merge.
  67427. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  67428. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  67429. * @param options The required width/height ratio to downsize to before computing the render pass.
  67430. * @param camera The camera to apply the render pass to.
  67431. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67432. * @param engine The engine which the post process will be applied. (default: current engine)
  67433. * @param reusable If the post process can be reused on the same frame. (default: false)
  67434. * @param textureType Type of textures used when performing the post process. (default: 0)
  67435. * @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)
  67436. */
  67437. 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);
  67438. /**
  67439. * Updates the effect with the current post process compile time values and recompiles the shader.
  67440. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  67441. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  67442. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  67443. * @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
  67444. * @param onCompiled Called when the shader has been compiled.
  67445. * @param onError Called if there is an error when compiling a shader.
  67446. */
  67447. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  67448. }
  67449. }
  67450. declare module BABYLON {
  67451. /**
  67452. * Specifies the level of max blur that should be applied when using the depth of field effect
  67453. */
  67454. export enum DepthOfFieldEffectBlurLevel {
  67455. /**
  67456. * Subtle blur
  67457. */
  67458. Low = 0,
  67459. /**
  67460. * Medium blur
  67461. */
  67462. Medium = 1,
  67463. /**
  67464. * Large blur
  67465. */
  67466. High = 2
  67467. }
  67468. /**
  67469. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  67470. */
  67471. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  67472. private _circleOfConfusion;
  67473. /**
  67474. * @hidden Internal, blurs from high to low
  67475. */
  67476. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  67477. private _depthOfFieldBlurY;
  67478. private _dofMerge;
  67479. /**
  67480. * @hidden Internal post processes in depth of field effect
  67481. */
  67482. _effects: Array<PostProcess>;
  67483. /**
  67484. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  67485. */
  67486. set focalLength(value: number);
  67487. get focalLength(): number;
  67488. /**
  67489. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  67490. */
  67491. set fStop(value: number);
  67492. get fStop(): number;
  67493. /**
  67494. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  67495. */
  67496. set focusDistance(value: number);
  67497. get focusDistance(): number;
  67498. /**
  67499. * 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.
  67500. */
  67501. set lensSize(value: number);
  67502. get lensSize(): number;
  67503. /**
  67504. * Creates a new instance DepthOfFieldEffect
  67505. * @param scene The scene the effect belongs to.
  67506. * @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.
  67507. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  67508. * @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)
  67509. */
  67510. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  67511. /**
  67512. * Get the current class name of the current effet
  67513. * @returns "DepthOfFieldEffect"
  67514. */
  67515. getClassName(): string;
  67516. /**
  67517. * 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.
  67518. */
  67519. set depthTexture(value: RenderTargetTexture);
  67520. /**
  67521. * Disposes each of the internal effects for a given camera.
  67522. * @param camera The camera to dispose the effect on.
  67523. */
  67524. disposeEffects(camera: Camera): void;
  67525. /**
  67526. * @hidden Internal
  67527. */
  67528. _updateEffects(): void;
  67529. /**
  67530. * Internal
  67531. * @returns if all the contained post processes are ready.
  67532. * @hidden
  67533. */
  67534. _isReady(): boolean;
  67535. }
  67536. }
  67537. declare module BABYLON {
  67538. /** @hidden */
  67539. export var displayPassPixelShader: {
  67540. name: string;
  67541. shader: string;
  67542. };
  67543. }
  67544. declare module BABYLON {
  67545. /**
  67546. * DisplayPassPostProcess which produces an output the same as it's input
  67547. */
  67548. export class DisplayPassPostProcess extends PostProcess {
  67549. /**
  67550. * Creates the DisplayPassPostProcess
  67551. * @param name The name of the effect.
  67552. * @param options The required width/height ratio to downsize to before computing the render pass.
  67553. * @param camera The camera to apply the render pass to.
  67554. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67555. * @param engine The engine which the post process will be applied. (default: current engine)
  67556. * @param reusable If the post process can be reused on the same frame. (default: false)
  67557. */
  67558. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67559. }
  67560. }
  67561. declare module BABYLON {
  67562. /** @hidden */
  67563. export var filterPixelShader: {
  67564. name: string;
  67565. shader: string;
  67566. };
  67567. }
  67568. declare module BABYLON {
  67569. /**
  67570. * Applies a kernel filter to the image
  67571. */
  67572. export class FilterPostProcess extends PostProcess {
  67573. /** The matrix to be applied to the image */
  67574. kernelMatrix: Matrix;
  67575. /**
  67576. *
  67577. * @param name The name of the effect.
  67578. * @param kernelMatrix The matrix to be applied to the image
  67579. * @param options The required width/height ratio to downsize to before computing the render pass.
  67580. * @param camera The camera to apply the render pass to.
  67581. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67582. * @param engine The engine which the post process will be applied. (default: current engine)
  67583. * @param reusable If the post process can be reused on the same frame. (default: false)
  67584. */
  67585. constructor(name: string,
  67586. /** The matrix to be applied to the image */
  67587. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67588. }
  67589. }
  67590. declare module BABYLON {
  67591. /** @hidden */
  67592. export var fxaaPixelShader: {
  67593. name: string;
  67594. shader: string;
  67595. };
  67596. }
  67597. declare module BABYLON {
  67598. /** @hidden */
  67599. export var fxaaVertexShader: {
  67600. name: string;
  67601. shader: string;
  67602. };
  67603. }
  67604. declare module BABYLON {
  67605. /**
  67606. * Fxaa post process
  67607. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  67608. */
  67609. export class FxaaPostProcess extends PostProcess {
  67610. /** @hidden */
  67611. texelWidth: number;
  67612. /** @hidden */
  67613. texelHeight: number;
  67614. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67615. private _getDefines;
  67616. }
  67617. }
  67618. declare module BABYLON {
  67619. /** @hidden */
  67620. export var grainPixelShader: {
  67621. name: string;
  67622. shader: string;
  67623. };
  67624. }
  67625. declare module BABYLON {
  67626. /**
  67627. * The GrainPostProcess adds noise to the image at mid luminance levels
  67628. */
  67629. export class GrainPostProcess extends PostProcess {
  67630. /**
  67631. * The intensity of the grain added (default: 30)
  67632. */
  67633. intensity: number;
  67634. /**
  67635. * If the grain should be randomized on every frame
  67636. */
  67637. animated: boolean;
  67638. /**
  67639. * Creates a new instance of @see GrainPostProcess
  67640. * @param name The name of the effect.
  67641. * @param options The required width/height ratio to downsize to before computing the render pass.
  67642. * @param camera The camera to apply the render pass to.
  67643. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67644. * @param engine The engine which the post process will be applied. (default: current engine)
  67645. * @param reusable If the post process can be reused on the same frame. (default: false)
  67646. * @param textureType Type of textures used when performing the post process. (default: 0)
  67647. * @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)
  67648. */
  67649. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67650. }
  67651. }
  67652. declare module BABYLON {
  67653. /** @hidden */
  67654. export var highlightsPixelShader: {
  67655. name: string;
  67656. shader: string;
  67657. };
  67658. }
  67659. declare module BABYLON {
  67660. /**
  67661. * Extracts highlights from the image
  67662. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  67663. */
  67664. export class HighlightsPostProcess extends PostProcess {
  67665. /**
  67666. * Extracts highlights from the image
  67667. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  67668. * @param name The name of the effect.
  67669. * @param options The required width/height ratio to downsize to before computing the render pass.
  67670. * @param camera The camera to apply the render pass to.
  67671. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67672. * @param engine The engine which the post process will be applied. (default: current engine)
  67673. * @param reusable If the post process can be reused on the same frame. (default: false)
  67674. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  67675. */
  67676. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67677. }
  67678. }
  67679. declare module BABYLON {
  67680. /** @hidden */
  67681. export var mrtFragmentDeclaration: {
  67682. name: string;
  67683. shader: string;
  67684. };
  67685. }
  67686. declare module BABYLON {
  67687. /** @hidden */
  67688. export var geometryPixelShader: {
  67689. name: string;
  67690. shader: string;
  67691. };
  67692. }
  67693. declare module BABYLON {
  67694. /** @hidden */
  67695. export var geometryVertexShader: {
  67696. name: string;
  67697. shader: string;
  67698. };
  67699. }
  67700. declare module BABYLON {
  67701. /** @hidden */
  67702. interface ISavedTransformationMatrix {
  67703. world: Matrix;
  67704. viewProjection: Matrix;
  67705. }
  67706. /**
  67707. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  67708. */
  67709. export class GeometryBufferRenderer {
  67710. /**
  67711. * Constant used to retrieve the position texture index in the G-Buffer textures array
  67712. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  67713. */
  67714. static readonly POSITION_TEXTURE_TYPE: number;
  67715. /**
  67716. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  67717. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  67718. */
  67719. static readonly VELOCITY_TEXTURE_TYPE: number;
  67720. /**
  67721. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  67722. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  67723. */
  67724. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  67725. /**
  67726. * Dictionary used to store the previous transformation matrices of each rendered mesh
  67727. * in order to compute objects velocities when enableVelocity is set to "true"
  67728. * @hidden
  67729. */
  67730. _previousTransformationMatrices: {
  67731. [index: number]: ISavedTransformationMatrix;
  67732. };
  67733. /**
  67734. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  67735. * in order to compute objects velocities when enableVelocity is set to "true"
  67736. * @hidden
  67737. */
  67738. _previousBonesTransformationMatrices: {
  67739. [index: number]: Float32Array;
  67740. };
  67741. /**
  67742. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  67743. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  67744. */
  67745. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  67746. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  67747. renderTransparentMeshes: boolean;
  67748. private _scene;
  67749. private _multiRenderTarget;
  67750. private _ratio;
  67751. private _enablePosition;
  67752. private _enableVelocity;
  67753. private _enableReflectivity;
  67754. private _positionIndex;
  67755. private _velocityIndex;
  67756. private _reflectivityIndex;
  67757. protected _effect: Effect;
  67758. protected _cachedDefines: string;
  67759. /**
  67760. * Set the render list (meshes to be rendered) used in the G buffer.
  67761. */
  67762. set renderList(meshes: Mesh[]);
  67763. /**
  67764. * Gets wether or not G buffer are supported by the running hardware.
  67765. * This requires draw buffer supports
  67766. */
  67767. get isSupported(): boolean;
  67768. /**
  67769. * Returns the index of the given texture type in the G-Buffer textures array
  67770. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  67771. * @returns the index of the given texture type in the G-Buffer textures array
  67772. */
  67773. getTextureIndex(textureType: number): number;
  67774. /**
  67775. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  67776. */
  67777. get enablePosition(): boolean;
  67778. /**
  67779. * Sets whether or not objects positions are enabled for the G buffer.
  67780. */
  67781. set enablePosition(enable: boolean);
  67782. /**
  67783. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  67784. */
  67785. get enableVelocity(): boolean;
  67786. /**
  67787. * Sets wether or not objects velocities are enabled for the G buffer.
  67788. */
  67789. set enableVelocity(enable: boolean);
  67790. /**
  67791. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  67792. */
  67793. get enableReflectivity(): boolean;
  67794. /**
  67795. * Sets wether or not objects roughness are enabled for the G buffer.
  67796. */
  67797. set enableReflectivity(enable: boolean);
  67798. /**
  67799. * Gets the scene associated with the buffer.
  67800. */
  67801. get scene(): Scene;
  67802. /**
  67803. * Gets the ratio used by the buffer during its creation.
  67804. * How big is the buffer related to the main canvas.
  67805. */
  67806. get ratio(): number;
  67807. /** @hidden */
  67808. static _SceneComponentInitialization: (scene: Scene) => void;
  67809. /**
  67810. * Creates a new G Buffer for the scene
  67811. * @param scene The scene the buffer belongs to
  67812. * @param ratio How big is the buffer related to the main canvas.
  67813. */
  67814. constructor(scene: Scene, ratio?: number);
  67815. /**
  67816. * Checks wether everything is ready to render a submesh to the G buffer.
  67817. * @param subMesh the submesh to check readiness for
  67818. * @param useInstances is the mesh drawn using instance or not
  67819. * @returns true if ready otherwise false
  67820. */
  67821. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  67822. /**
  67823. * Gets the current underlying G Buffer.
  67824. * @returns the buffer
  67825. */
  67826. getGBuffer(): MultiRenderTarget;
  67827. /**
  67828. * Gets the number of samples used to render the buffer (anti aliasing).
  67829. */
  67830. get samples(): number;
  67831. /**
  67832. * Sets the number of samples used to render the buffer (anti aliasing).
  67833. */
  67834. set samples(value: number);
  67835. /**
  67836. * Disposes the renderer and frees up associated resources.
  67837. */
  67838. dispose(): void;
  67839. protected _createRenderTargets(): void;
  67840. private _copyBonesTransformationMatrices;
  67841. }
  67842. }
  67843. declare module BABYLON {
  67844. interface Scene {
  67845. /** @hidden (Backing field) */
  67846. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  67847. /**
  67848. * Gets or Sets the current geometry buffer associated to the scene.
  67849. */
  67850. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  67851. /**
  67852. * Enables a GeometryBufferRender and associates it with the scene
  67853. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  67854. * @returns the GeometryBufferRenderer
  67855. */
  67856. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  67857. /**
  67858. * Disables the GeometryBufferRender associated with the scene
  67859. */
  67860. disableGeometryBufferRenderer(): void;
  67861. }
  67862. /**
  67863. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  67864. * in several rendering techniques.
  67865. */
  67866. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  67867. /**
  67868. * The component name helpful to identify the component in the list of scene components.
  67869. */
  67870. readonly name: string;
  67871. /**
  67872. * The scene the component belongs to.
  67873. */
  67874. scene: Scene;
  67875. /**
  67876. * Creates a new instance of the component for the given scene
  67877. * @param scene Defines the scene to register the component in
  67878. */
  67879. constructor(scene: Scene);
  67880. /**
  67881. * Registers the component in a given scene
  67882. */
  67883. register(): void;
  67884. /**
  67885. * Rebuilds the elements related to this component in case of
  67886. * context lost for instance.
  67887. */
  67888. rebuild(): void;
  67889. /**
  67890. * Disposes the component and the associated ressources
  67891. */
  67892. dispose(): void;
  67893. private _gatherRenderTargets;
  67894. }
  67895. }
  67896. declare module BABYLON {
  67897. /** @hidden */
  67898. export var motionBlurPixelShader: {
  67899. name: string;
  67900. shader: string;
  67901. };
  67902. }
  67903. declare module BABYLON {
  67904. /**
  67905. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  67906. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  67907. * As an example, all you have to do is to create the post-process:
  67908. * var mb = new BABYLON.MotionBlurPostProcess(
  67909. * 'mb', // The name of the effect.
  67910. * scene, // The scene containing the objects to blur according to their velocity.
  67911. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  67912. * camera // The camera to apply the render pass to.
  67913. * );
  67914. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  67915. */
  67916. export class MotionBlurPostProcess extends PostProcess {
  67917. /**
  67918. * Defines how much the image is blurred by the movement. Default value is equal to 1
  67919. */
  67920. motionStrength: number;
  67921. /**
  67922. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  67923. */
  67924. get motionBlurSamples(): number;
  67925. /**
  67926. * Sets the number of iterations to be used for motion blur quality
  67927. */
  67928. set motionBlurSamples(samples: number);
  67929. private _motionBlurSamples;
  67930. private _geometryBufferRenderer;
  67931. /**
  67932. * Creates a new instance MotionBlurPostProcess
  67933. * @param name The name of the effect.
  67934. * @param scene The scene containing the objects to blur according to their velocity.
  67935. * @param options The required width/height ratio to downsize to before computing the render pass.
  67936. * @param camera The camera to apply the render pass to.
  67937. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67938. * @param engine The engine which the post process will be applied. (default: current engine)
  67939. * @param reusable If the post process can be reused on the same frame. (default: false)
  67940. * @param textureType Type of textures used when performing the post process. (default: 0)
  67941. * @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)
  67942. */
  67943. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67944. /**
  67945. * Excludes the given skinned mesh from computing bones velocities.
  67946. * 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.
  67947. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  67948. */
  67949. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  67950. /**
  67951. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  67952. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  67953. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  67954. */
  67955. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  67956. /**
  67957. * Disposes the post process.
  67958. * @param camera The camera to dispose the post process on.
  67959. */
  67960. dispose(camera?: Camera): void;
  67961. }
  67962. }
  67963. declare module BABYLON {
  67964. /** @hidden */
  67965. export var refractionPixelShader: {
  67966. name: string;
  67967. shader: string;
  67968. };
  67969. }
  67970. declare module BABYLON {
  67971. /**
  67972. * Post process which applies a refractin texture
  67973. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  67974. */
  67975. export class RefractionPostProcess extends PostProcess {
  67976. /** the base color of the refraction (used to taint the rendering) */
  67977. color: Color3;
  67978. /** simulated refraction depth */
  67979. depth: number;
  67980. /** the coefficient of the base color (0 to remove base color tainting) */
  67981. colorLevel: number;
  67982. private _refTexture;
  67983. private _ownRefractionTexture;
  67984. /**
  67985. * Gets or sets the refraction texture
  67986. * Please note that you are responsible for disposing the texture if you set it manually
  67987. */
  67988. get refractionTexture(): Texture;
  67989. set refractionTexture(value: Texture);
  67990. /**
  67991. * Initializes the RefractionPostProcess
  67992. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  67993. * @param name The name of the effect.
  67994. * @param refractionTextureUrl Url of the refraction texture to use
  67995. * @param color the base color of the refraction (used to taint the rendering)
  67996. * @param depth simulated refraction depth
  67997. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  67998. * @param camera The camera to apply the render pass to.
  67999. * @param options The required width/height ratio to downsize to before computing the render pass.
  68000. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68001. * @param engine The engine which the post process will be applied. (default: current engine)
  68002. * @param reusable If the post process can be reused on the same frame. (default: false)
  68003. */
  68004. constructor(name: string, refractionTextureUrl: string,
  68005. /** the base color of the refraction (used to taint the rendering) */
  68006. color: Color3,
  68007. /** simulated refraction depth */
  68008. depth: number,
  68009. /** the coefficient of the base color (0 to remove base color tainting) */
  68010. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68011. /**
  68012. * Disposes of the post process
  68013. * @param camera Camera to dispose post process on
  68014. */
  68015. dispose(camera: Camera): void;
  68016. }
  68017. }
  68018. declare module BABYLON {
  68019. /** @hidden */
  68020. export var sharpenPixelShader: {
  68021. name: string;
  68022. shader: string;
  68023. };
  68024. }
  68025. declare module BABYLON {
  68026. /**
  68027. * The SharpenPostProcess applies a sharpen kernel to every pixel
  68028. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  68029. */
  68030. export class SharpenPostProcess extends PostProcess {
  68031. /**
  68032. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  68033. */
  68034. colorAmount: number;
  68035. /**
  68036. * How much sharpness should be applied (default: 0.3)
  68037. */
  68038. edgeAmount: number;
  68039. /**
  68040. * Creates a new instance ConvolutionPostProcess
  68041. * @param name The name of the effect.
  68042. * @param options The required width/height ratio to downsize to before computing the render pass.
  68043. * @param camera The camera to apply the render pass to.
  68044. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68045. * @param engine The engine which the post process will be applied. (default: current engine)
  68046. * @param reusable If the post process can be reused on the same frame. (default: false)
  68047. * @param textureType Type of textures used when performing the post process. (default: 0)
  68048. * @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)
  68049. */
  68050. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68051. }
  68052. }
  68053. declare module BABYLON {
  68054. /**
  68055. * PostProcessRenderPipeline
  68056. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68057. */
  68058. export class PostProcessRenderPipeline {
  68059. private engine;
  68060. private _renderEffects;
  68061. private _renderEffectsForIsolatedPass;
  68062. /**
  68063. * List of inspectable custom properties (used by the Inspector)
  68064. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  68065. */
  68066. inspectableCustomProperties: IInspectable[];
  68067. /**
  68068. * @hidden
  68069. */
  68070. protected _cameras: Camera[];
  68071. /** @hidden */
  68072. _name: string;
  68073. /**
  68074. * Gets pipeline name
  68075. */
  68076. get name(): string;
  68077. /** Gets the list of attached cameras */
  68078. get cameras(): Camera[];
  68079. /**
  68080. * Initializes a PostProcessRenderPipeline
  68081. * @param engine engine to add the pipeline to
  68082. * @param name name of the pipeline
  68083. */
  68084. constructor(engine: Engine, name: string);
  68085. /**
  68086. * Gets the class name
  68087. * @returns "PostProcessRenderPipeline"
  68088. */
  68089. getClassName(): string;
  68090. /**
  68091. * If all the render effects in the pipeline are supported
  68092. */
  68093. get isSupported(): boolean;
  68094. /**
  68095. * Adds an effect to the pipeline
  68096. * @param renderEffect the effect to add
  68097. */
  68098. addEffect(renderEffect: PostProcessRenderEffect): void;
  68099. /** @hidden */
  68100. _rebuild(): void;
  68101. /** @hidden */
  68102. _enableEffect(renderEffectName: string, cameras: Camera): void;
  68103. /** @hidden */
  68104. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  68105. /** @hidden */
  68106. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68107. /** @hidden */
  68108. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68109. /** @hidden */
  68110. _attachCameras(cameras: Camera, unique: boolean): void;
  68111. /** @hidden */
  68112. _attachCameras(cameras: Camera[], unique: boolean): void;
  68113. /** @hidden */
  68114. _detachCameras(cameras: Camera): void;
  68115. /** @hidden */
  68116. _detachCameras(cameras: Nullable<Camera[]>): void;
  68117. /** @hidden */
  68118. _update(): void;
  68119. /** @hidden */
  68120. _reset(): void;
  68121. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  68122. /**
  68123. * Disposes of the pipeline
  68124. */
  68125. dispose(): void;
  68126. }
  68127. }
  68128. declare module BABYLON {
  68129. /**
  68130. * PostProcessRenderPipelineManager class
  68131. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68132. */
  68133. export class PostProcessRenderPipelineManager {
  68134. private _renderPipelines;
  68135. /**
  68136. * Initializes a PostProcessRenderPipelineManager
  68137. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68138. */
  68139. constructor();
  68140. /**
  68141. * Gets the list of supported render pipelines
  68142. */
  68143. get supportedPipelines(): PostProcessRenderPipeline[];
  68144. /**
  68145. * Adds a pipeline to the manager
  68146. * @param renderPipeline The pipeline to add
  68147. */
  68148. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  68149. /**
  68150. * Attaches a camera to the pipeline
  68151. * @param renderPipelineName The name of the pipeline to attach to
  68152. * @param cameras the camera to attach
  68153. * @param unique if the camera can be attached multiple times to the pipeline
  68154. */
  68155. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  68156. /**
  68157. * Detaches a camera from the pipeline
  68158. * @param renderPipelineName The name of the pipeline to detach from
  68159. * @param cameras the camera to detach
  68160. */
  68161. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  68162. /**
  68163. * Enables an effect by name on a pipeline
  68164. * @param renderPipelineName the name of the pipeline to enable the effect in
  68165. * @param renderEffectName the name of the effect to enable
  68166. * @param cameras the cameras that the effect should be enabled on
  68167. */
  68168. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68169. /**
  68170. * Disables an effect by name on a pipeline
  68171. * @param renderPipelineName the name of the pipeline to disable the effect in
  68172. * @param renderEffectName the name of the effect to disable
  68173. * @param cameras the cameras that the effect should be disabled on
  68174. */
  68175. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68176. /**
  68177. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  68178. */
  68179. update(): void;
  68180. /** @hidden */
  68181. _rebuild(): void;
  68182. /**
  68183. * Disposes of the manager and pipelines
  68184. */
  68185. dispose(): void;
  68186. }
  68187. }
  68188. declare module BABYLON {
  68189. interface Scene {
  68190. /** @hidden (Backing field) */
  68191. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68192. /**
  68193. * Gets the postprocess render pipeline manager
  68194. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68195. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68196. */
  68197. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68198. }
  68199. /**
  68200. * Defines the Render Pipeline scene component responsible to rendering pipelines
  68201. */
  68202. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  68203. /**
  68204. * The component name helpfull to identify the component in the list of scene components.
  68205. */
  68206. readonly name: string;
  68207. /**
  68208. * The scene the component belongs to.
  68209. */
  68210. scene: Scene;
  68211. /**
  68212. * Creates a new instance of the component for the given scene
  68213. * @param scene Defines the scene to register the component in
  68214. */
  68215. constructor(scene: Scene);
  68216. /**
  68217. * Registers the component in a given scene
  68218. */
  68219. register(): void;
  68220. /**
  68221. * Rebuilds the elements related to this component in case of
  68222. * context lost for instance.
  68223. */
  68224. rebuild(): void;
  68225. /**
  68226. * Disposes the component and the associated ressources
  68227. */
  68228. dispose(): void;
  68229. private _gatherRenderTargets;
  68230. }
  68231. }
  68232. declare module BABYLON {
  68233. /**
  68234. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  68235. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68236. */
  68237. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  68238. private _scene;
  68239. private _camerasToBeAttached;
  68240. /**
  68241. * ID of the sharpen post process,
  68242. */
  68243. private readonly SharpenPostProcessId;
  68244. /**
  68245. * @ignore
  68246. * ID of the image processing post process;
  68247. */
  68248. readonly ImageProcessingPostProcessId: string;
  68249. /**
  68250. * @ignore
  68251. * ID of the Fast Approximate Anti-Aliasing post process;
  68252. */
  68253. readonly FxaaPostProcessId: string;
  68254. /**
  68255. * ID of the chromatic aberration post process,
  68256. */
  68257. private readonly ChromaticAberrationPostProcessId;
  68258. /**
  68259. * ID of the grain post process
  68260. */
  68261. private readonly GrainPostProcessId;
  68262. /**
  68263. * Sharpen post process which will apply a sharpen convolution to enhance edges
  68264. */
  68265. sharpen: SharpenPostProcess;
  68266. private _sharpenEffect;
  68267. private bloom;
  68268. /**
  68269. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  68270. */
  68271. depthOfField: DepthOfFieldEffect;
  68272. /**
  68273. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  68274. */
  68275. fxaa: FxaaPostProcess;
  68276. /**
  68277. * Image post processing pass used to perform operations such as tone mapping or color grading.
  68278. */
  68279. imageProcessing: ImageProcessingPostProcess;
  68280. /**
  68281. * Chromatic aberration post process which will shift rgb colors in the image
  68282. */
  68283. chromaticAberration: ChromaticAberrationPostProcess;
  68284. private _chromaticAberrationEffect;
  68285. /**
  68286. * Grain post process which add noise to the image
  68287. */
  68288. grain: GrainPostProcess;
  68289. private _grainEffect;
  68290. /**
  68291. * Glow post process which adds a glow to emissive areas of the image
  68292. */
  68293. private _glowLayer;
  68294. /**
  68295. * Animations which can be used to tweak settings over a period of time
  68296. */
  68297. animations: Animation[];
  68298. private _imageProcessingConfigurationObserver;
  68299. private _sharpenEnabled;
  68300. private _bloomEnabled;
  68301. private _depthOfFieldEnabled;
  68302. private _depthOfFieldBlurLevel;
  68303. private _fxaaEnabled;
  68304. private _imageProcessingEnabled;
  68305. private _defaultPipelineTextureType;
  68306. private _bloomScale;
  68307. private _chromaticAberrationEnabled;
  68308. private _grainEnabled;
  68309. private _buildAllowed;
  68310. /**
  68311. * Gets active scene
  68312. */
  68313. get scene(): Scene;
  68314. /**
  68315. * Enable or disable the sharpen process from the pipeline
  68316. */
  68317. set sharpenEnabled(enabled: boolean);
  68318. get sharpenEnabled(): boolean;
  68319. private _resizeObserver;
  68320. private _hardwareScaleLevel;
  68321. private _bloomKernel;
  68322. /**
  68323. * Specifies the size of the bloom blur kernel, relative to the final output size
  68324. */
  68325. get bloomKernel(): number;
  68326. set bloomKernel(value: number);
  68327. /**
  68328. * Specifies the weight of the bloom in the final rendering
  68329. */
  68330. private _bloomWeight;
  68331. /**
  68332. * Specifies the luma threshold for the area that will be blurred by the bloom
  68333. */
  68334. private _bloomThreshold;
  68335. private _hdr;
  68336. /**
  68337. * The strength of the bloom.
  68338. */
  68339. set bloomWeight(value: number);
  68340. get bloomWeight(): number;
  68341. /**
  68342. * The strength of the bloom.
  68343. */
  68344. set bloomThreshold(value: number);
  68345. get bloomThreshold(): number;
  68346. /**
  68347. * The scale of the bloom, lower value will provide better performance.
  68348. */
  68349. set bloomScale(value: number);
  68350. get bloomScale(): number;
  68351. /**
  68352. * Enable or disable the bloom from the pipeline
  68353. */
  68354. set bloomEnabled(enabled: boolean);
  68355. get bloomEnabled(): boolean;
  68356. private _rebuildBloom;
  68357. /**
  68358. * If the depth of field is enabled.
  68359. */
  68360. get depthOfFieldEnabled(): boolean;
  68361. set depthOfFieldEnabled(enabled: boolean);
  68362. /**
  68363. * Blur level of the depth of field effect. (Higher blur will effect performance)
  68364. */
  68365. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  68366. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  68367. /**
  68368. * If the anti aliasing is enabled.
  68369. */
  68370. set fxaaEnabled(enabled: boolean);
  68371. get fxaaEnabled(): boolean;
  68372. private _samples;
  68373. /**
  68374. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  68375. */
  68376. set samples(sampleCount: number);
  68377. get samples(): number;
  68378. /**
  68379. * If image processing is enabled.
  68380. */
  68381. set imageProcessingEnabled(enabled: boolean);
  68382. get imageProcessingEnabled(): boolean;
  68383. /**
  68384. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  68385. */
  68386. set glowLayerEnabled(enabled: boolean);
  68387. get glowLayerEnabled(): boolean;
  68388. /**
  68389. * Gets the glow layer (or null if not defined)
  68390. */
  68391. get glowLayer(): Nullable<GlowLayer>;
  68392. /**
  68393. * Enable or disable the chromaticAberration process from the pipeline
  68394. */
  68395. set chromaticAberrationEnabled(enabled: boolean);
  68396. get chromaticAberrationEnabled(): boolean;
  68397. /**
  68398. * Enable or disable the grain process from the pipeline
  68399. */
  68400. set grainEnabled(enabled: boolean);
  68401. get grainEnabled(): boolean;
  68402. /**
  68403. * @constructor
  68404. * @param name - The rendering pipeline name (default: "")
  68405. * @param hdr - If high dynamic range textures should be used (default: true)
  68406. * @param scene - The scene linked to this pipeline (default: the last created scene)
  68407. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  68408. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  68409. */
  68410. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  68411. /**
  68412. * Get the class name
  68413. * @returns "DefaultRenderingPipeline"
  68414. */
  68415. getClassName(): string;
  68416. /**
  68417. * Force the compilation of the entire pipeline.
  68418. */
  68419. prepare(): void;
  68420. private _hasCleared;
  68421. private _prevPostProcess;
  68422. private _prevPrevPostProcess;
  68423. private _setAutoClearAndTextureSharing;
  68424. private _depthOfFieldSceneObserver;
  68425. private _buildPipeline;
  68426. private _disposePostProcesses;
  68427. /**
  68428. * Adds a camera to the pipeline
  68429. * @param camera the camera to be added
  68430. */
  68431. addCamera(camera: Camera): void;
  68432. /**
  68433. * Removes a camera from the pipeline
  68434. * @param camera the camera to remove
  68435. */
  68436. removeCamera(camera: Camera): void;
  68437. /**
  68438. * Dispose of the pipeline and stop all post processes
  68439. */
  68440. dispose(): void;
  68441. /**
  68442. * Serialize the rendering pipeline (Used when exporting)
  68443. * @returns the serialized object
  68444. */
  68445. serialize(): any;
  68446. /**
  68447. * Parse the serialized pipeline
  68448. * @param source Source pipeline.
  68449. * @param scene The scene to load the pipeline to.
  68450. * @param rootUrl The URL of the serialized pipeline.
  68451. * @returns An instantiated pipeline from the serialized object.
  68452. */
  68453. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  68454. }
  68455. }
  68456. declare module BABYLON {
  68457. /** @hidden */
  68458. export var lensHighlightsPixelShader: {
  68459. name: string;
  68460. shader: string;
  68461. };
  68462. }
  68463. declare module BABYLON {
  68464. /** @hidden */
  68465. export var depthOfFieldPixelShader: {
  68466. name: string;
  68467. shader: string;
  68468. };
  68469. }
  68470. declare module BABYLON {
  68471. /**
  68472. * BABYLON.JS Chromatic Aberration GLSL Shader
  68473. * Author: Olivier Guyot
  68474. * Separates very slightly R, G and B colors on the edges of the screen
  68475. * Inspired by Francois Tarlier & Martins Upitis
  68476. */
  68477. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  68478. /**
  68479. * @ignore
  68480. * The chromatic aberration PostProcess id in the pipeline
  68481. */
  68482. LensChromaticAberrationEffect: string;
  68483. /**
  68484. * @ignore
  68485. * The highlights enhancing PostProcess id in the pipeline
  68486. */
  68487. HighlightsEnhancingEffect: string;
  68488. /**
  68489. * @ignore
  68490. * The depth-of-field PostProcess id in the pipeline
  68491. */
  68492. LensDepthOfFieldEffect: string;
  68493. private _scene;
  68494. private _depthTexture;
  68495. private _grainTexture;
  68496. private _chromaticAberrationPostProcess;
  68497. private _highlightsPostProcess;
  68498. private _depthOfFieldPostProcess;
  68499. private _edgeBlur;
  68500. private _grainAmount;
  68501. private _chromaticAberration;
  68502. private _distortion;
  68503. private _highlightsGain;
  68504. private _highlightsThreshold;
  68505. private _dofDistance;
  68506. private _dofAperture;
  68507. private _dofDarken;
  68508. private _dofPentagon;
  68509. private _blurNoise;
  68510. /**
  68511. * @constructor
  68512. *
  68513. * Effect parameters are as follow:
  68514. * {
  68515. * chromatic_aberration: number; // from 0 to x (1 for realism)
  68516. * edge_blur: number; // from 0 to x (1 for realism)
  68517. * distortion: number; // from 0 to x (1 for realism)
  68518. * grain_amount: number; // from 0 to 1
  68519. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  68520. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  68521. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  68522. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  68523. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  68524. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  68525. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  68526. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  68527. * }
  68528. * Note: if an effect parameter is unset, effect is disabled
  68529. *
  68530. * @param name The rendering pipeline name
  68531. * @param parameters - An object containing all parameters (see above)
  68532. * @param scene The scene linked to this pipeline
  68533. * @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)
  68534. * @param cameras The array of cameras that the rendering pipeline will be attached to
  68535. */
  68536. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  68537. /**
  68538. * Get the class name
  68539. * @returns "LensRenderingPipeline"
  68540. */
  68541. getClassName(): string;
  68542. /**
  68543. * Gets associated scene
  68544. */
  68545. get scene(): Scene;
  68546. /**
  68547. * Gets or sets the edge blur
  68548. */
  68549. get edgeBlur(): number;
  68550. set edgeBlur(value: number);
  68551. /**
  68552. * Gets or sets the grain amount
  68553. */
  68554. get grainAmount(): number;
  68555. set grainAmount(value: number);
  68556. /**
  68557. * Gets or sets the chromatic aberration amount
  68558. */
  68559. get chromaticAberration(): number;
  68560. set chromaticAberration(value: number);
  68561. /**
  68562. * Gets or sets the depth of field aperture
  68563. */
  68564. get dofAperture(): number;
  68565. set dofAperture(value: number);
  68566. /**
  68567. * Gets or sets the edge distortion
  68568. */
  68569. get edgeDistortion(): number;
  68570. set edgeDistortion(value: number);
  68571. /**
  68572. * Gets or sets the depth of field distortion
  68573. */
  68574. get dofDistortion(): number;
  68575. set dofDistortion(value: number);
  68576. /**
  68577. * Gets or sets the darken out of focus amount
  68578. */
  68579. get darkenOutOfFocus(): number;
  68580. set darkenOutOfFocus(value: number);
  68581. /**
  68582. * Gets or sets a boolean indicating if blur noise is enabled
  68583. */
  68584. get blurNoise(): boolean;
  68585. set blurNoise(value: boolean);
  68586. /**
  68587. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  68588. */
  68589. get pentagonBokeh(): boolean;
  68590. set pentagonBokeh(value: boolean);
  68591. /**
  68592. * Gets or sets the highlight grain amount
  68593. */
  68594. get highlightsGain(): number;
  68595. set highlightsGain(value: number);
  68596. /**
  68597. * Gets or sets the highlight threshold
  68598. */
  68599. get highlightsThreshold(): number;
  68600. set highlightsThreshold(value: number);
  68601. /**
  68602. * Sets the amount of blur at the edges
  68603. * @param amount blur amount
  68604. */
  68605. setEdgeBlur(amount: number): void;
  68606. /**
  68607. * Sets edge blur to 0
  68608. */
  68609. disableEdgeBlur(): void;
  68610. /**
  68611. * Sets the amout of grain
  68612. * @param amount Amount of grain
  68613. */
  68614. setGrainAmount(amount: number): void;
  68615. /**
  68616. * Set grain amount to 0
  68617. */
  68618. disableGrain(): void;
  68619. /**
  68620. * Sets the chromatic aberration amount
  68621. * @param amount amount of chromatic aberration
  68622. */
  68623. setChromaticAberration(amount: number): void;
  68624. /**
  68625. * Sets chromatic aberration amount to 0
  68626. */
  68627. disableChromaticAberration(): void;
  68628. /**
  68629. * Sets the EdgeDistortion amount
  68630. * @param amount amount of EdgeDistortion
  68631. */
  68632. setEdgeDistortion(amount: number): void;
  68633. /**
  68634. * Sets edge distortion to 0
  68635. */
  68636. disableEdgeDistortion(): void;
  68637. /**
  68638. * Sets the FocusDistance amount
  68639. * @param amount amount of FocusDistance
  68640. */
  68641. setFocusDistance(amount: number): void;
  68642. /**
  68643. * Disables depth of field
  68644. */
  68645. disableDepthOfField(): void;
  68646. /**
  68647. * Sets the Aperture amount
  68648. * @param amount amount of Aperture
  68649. */
  68650. setAperture(amount: number): void;
  68651. /**
  68652. * Sets the DarkenOutOfFocus amount
  68653. * @param amount amount of DarkenOutOfFocus
  68654. */
  68655. setDarkenOutOfFocus(amount: number): void;
  68656. private _pentagonBokehIsEnabled;
  68657. /**
  68658. * Creates a pentagon bokeh effect
  68659. */
  68660. enablePentagonBokeh(): void;
  68661. /**
  68662. * Disables the pentagon bokeh effect
  68663. */
  68664. disablePentagonBokeh(): void;
  68665. /**
  68666. * Enables noise blur
  68667. */
  68668. enableNoiseBlur(): void;
  68669. /**
  68670. * Disables noise blur
  68671. */
  68672. disableNoiseBlur(): void;
  68673. /**
  68674. * Sets the HighlightsGain amount
  68675. * @param amount amount of HighlightsGain
  68676. */
  68677. setHighlightsGain(amount: number): void;
  68678. /**
  68679. * Sets the HighlightsThreshold amount
  68680. * @param amount amount of HighlightsThreshold
  68681. */
  68682. setHighlightsThreshold(amount: number): void;
  68683. /**
  68684. * Disables highlights
  68685. */
  68686. disableHighlights(): void;
  68687. /**
  68688. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  68689. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  68690. */
  68691. dispose(disableDepthRender?: boolean): void;
  68692. private _createChromaticAberrationPostProcess;
  68693. private _createHighlightsPostProcess;
  68694. private _createDepthOfFieldPostProcess;
  68695. private _createGrainTexture;
  68696. }
  68697. }
  68698. declare module BABYLON {
  68699. /** @hidden */
  68700. export var ssao2PixelShader: {
  68701. name: string;
  68702. shader: string;
  68703. };
  68704. }
  68705. declare module BABYLON {
  68706. /** @hidden */
  68707. export var ssaoCombinePixelShader: {
  68708. name: string;
  68709. shader: string;
  68710. };
  68711. }
  68712. declare module BABYLON {
  68713. /**
  68714. * Render pipeline to produce ssao effect
  68715. */
  68716. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  68717. /**
  68718. * @ignore
  68719. * The PassPostProcess id in the pipeline that contains the original scene color
  68720. */
  68721. SSAOOriginalSceneColorEffect: string;
  68722. /**
  68723. * @ignore
  68724. * The SSAO PostProcess id in the pipeline
  68725. */
  68726. SSAORenderEffect: string;
  68727. /**
  68728. * @ignore
  68729. * The horizontal blur PostProcess id in the pipeline
  68730. */
  68731. SSAOBlurHRenderEffect: string;
  68732. /**
  68733. * @ignore
  68734. * The vertical blur PostProcess id in the pipeline
  68735. */
  68736. SSAOBlurVRenderEffect: string;
  68737. /**
  68738. * @ignore
  68739. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  68740. */
  68741. SSAOCombineRenderEffect: string;
  68742. /**
  68743. * The output strength of the SSAO post-process. Default value is 1.0.
  68744. */
  68745. totalStrength: number;
  68746. /**
  68747. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  68748. */
  68749. maxZ: number;
  68750. /**
  68751. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  68752. */
  68753. minZAspect: number;
  68754. private _samples;
  68755. /**
  68756. * Number of samples used for the SSAO calculations. Default value is 8
  68757. */
  68758. set samples(n: number);
  68759. get samples(): number;
  68760. private _textureSamples;
  68761. /**
  68762. * Number of samples to use for antialiasing
  68763. */
  68764. set textureSamples(n: number);
  68765. get textureSamples(): number;
  68766. /**
  68767. * Ratio object used for SSAO ratio and blur ratio
  68768. */
  68769. private _ratio;
  68770. /**
  68771. * Dynamically generated sphere sampler.
  68772. */
  68773. private _sampleSphere;
  68774. /**
  68775. * Blur filter offsets
  68776. */
  68777. private _samplerOffsets;
  68778. private _expensiveBlur;
  68779. /**
  68780. * If bilateral blur should be used
  68781. */
  68782. set expensiveBlur(b: boolean);
  68783. get expensiveBlur(): boolean;
  68784. /**
  68785. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  68786. */
  68787. radius: number;
  68788. /**
  68789. * The base color of the SSAO post-process
  68790. * The final result is "base + ssao" between [0, 1]
  68791. */
  68792. base: number;
  68793. /**
  68794. * Support test.
  68795. */
  68796. static get IsSupported(): boolean;
  68797. private _scene;
  68798. private _depthTexture;
  68799. private _normalTexture;
  68800. private _randomTexture;
  68801. private _originalColorPostProcess;
  68802. private _ssaoPostProcess;
  68803. private _blurHPostProcess;
  68804. private _blurVPostProcess;
  68805. private _ssaoCombinePostProcess;
  68806. /**
  68807. * Gets active scene
  68808. */
  68809. get scene(): Scene;
  68810. /**
  68811. * @constructor
  68812. * @param name The rendering pipeline name
  68813. * @param scene The scene linked to this pipeline
  68814. * @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 }
  68815. * @param cameras The array of cameras that the rendering pipeline will be attached to
  68816. */
  68817. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  68818. /**
  68819. * Get the class name
  68820. * @returns "SSAO2RenderingPipeline"
  68821. */
  68822. getClassName(): string;
  68823. /**
  68824. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  68825. */
  68826. dispose(disableGeometryBufferRenderer?: boolean): void;
  68827. private _createBlurPostProcess;
  68828. /** @hidden */
  68829. _rebuild(): void;
  68830. private _bits;
  68831. private _radicalInverse_VdC;
  68832. private _hammersley;
  68833. private _hemisphereSample_uniform;
  68834. private _generateHemisphere;
  68835. private _createSSAOPostProcess;
  68836. private _createSSAOCombinePostProcess;
  68837. private _createRandomTexture;
  68838. /**
  68839. * Serialize the rendering pipeline (Used when exporting)
  68840. * @returns the serialized object
  68841. */
  68842. serialize(): any;
  68843. /**
  68844. * Parse the serialized pipeline
  68845. * @param source Source pipeline.
  68846. * @param scene The scene to load the pipeline to.
  68847. * @param rootUrl The URL of the serialized pipeline.
  68848. * @returns An instantiated pipeline from the serialized object.
  68849. */
  68850. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  68851. }
  68852. }
  68853. declare module BABYLON {
  68854. /** @hidden */
  68855. export var ssaoPixelShader: {
  68856. name: string;
  68857. shader: string;
  68858. };
  68859. }
  68860. declare module BABYLON {
  68861. /**
  68862. * Render pipeline to produce ssao effect
  68863. */
  68864. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  68865. /**
  68866. * @ignore
  68867. * The PassPostProcess id in the pipeline that contains the original scene color
  68868. */
  68869. SSAOOriginalSceneColorEffect: string;
  68870. /**
  68871. * @ignore
  68872. * The SSAO PostProcess id in the pipeline
  68873. */
  68874. SSAORenderEffect: string;
  68875. /**
  68876. * @ignore
  68877. * The horizontal blur PostProcess id in the pipeline
  68878. */
  68879. SSAOBlurHRenderEffect: string;
  68880. /**
  68881. * @ignore
  68882. * The vertical blur PostProcess id in the pipeline
  68883. */
  68884. SSAOBlurVRenderEffect: string;
  68885. /**
  68886. * @ignore
  68887. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  68888. */
  68889. SSAOCombineRenderEffect: string;
  68890. /**
  68891. * The output strength of the SSAO post-process. Default value is 1.0.
  68892. */
  68893. totalStrength: number;
  68894. /**
  68895. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  68896. */
  68897. radius: number;
  68898. /**
  68899. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  68900. * Must not be equal to fallOff and superior to fallOff.
  68901. * Default value is 0.0075
  68902. */
  68903. area: number;
  68904. /**
  68905. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  68906. * Must not be equal to area and inferior to area.
  68907. * Default value is 0.000001
  68908. */
  68909. fallOff: number;
  68910. /**
  68911. * The base color of the SSAO post-process
  68912. * The final result is "base + ssao" between [0, 1]
  68913. */
  68914. base: number;
  68915. private _scene;
  68916. private _depthTexture;
  68917. private _randomTexture;
  68918. private _originalColorPostProcess;
  68919. private _ssaoPostProcess;
  68920. private _blurHPostProcess;
  68921. private _blurVPostProcess;
  68922. private _ssaoCombinePostProcess;
  68923. private _firstUpdate;
  68924. /**
  68925. * Gets active scene
  68926. */
  68927. get scene(): Scene;
  68928. /**
  68929. * @constructor
  68930. * @param name - The rendering pipeline name
  68931. * @param scene - The scene linked to this pipeline
  68932. * @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 }
  68933. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  68934. */
  68935. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  68936. /**
  68937. * Get the class name
  68938. * @returns "SSAORenderingPipeline"
  68939. */
  68940. getClassName(): string;
  68941. /**
  68942. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  68943. */
  68944. dispose(disableDepthRender?: boolean): void;
  68945. private _createBlurPostProcess;
  68946. /** @hidden */
  68947. _rebuild(): void;
  68948. private _createSSAOPostProcess;
  68949. private _createSSAOCombinePostProcess;
  68950. private _createRandomTexture;
  68951. }
  68952. }
  68953. declare module BABYLON {
  68954. /** @hidden */
  68955. export var screenSpaceReflectionPixelShader: {
  68956. name: string;
  68957. shader: string;
  68958. };
  68959. }
  68960. declare module BABYLON {
  68961. /**
  68962. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  68963. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  68964. */
  68965. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  68966. /**
  68967. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  68968. */
  68969. threshold: number;
  68970. /**
  68971. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  68972. */
  68973. strength: number;
  68974. /**
  68975. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  68976. */
  68977. reflectionSpecularFalloffExponent: number;
  68978. /**
  68979. * Gets or sets the step size used to iterate until the effect finds the color of the reflection's pixel. Typically in interval [0.1, 1.0]
  68980. */
  68981. step: number;
  68982. /**
  68983. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  68984. */
  68985. roughnessFactor: number;
  68986. private _geometryBufferRenderer;
  68987. private _enableSmoothReflections;
  68988. private _reflectionSamples;
  68989. private _smoothSteps;
  68990. /**
  68991. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  68992. * @param name The name of the effect.
  68993. * @param scene The scene containing the objects to calculate reflections.
  68994. * @param options The required width/height ratio to downsize to before computing the render pass.
  68995. * @param camera The camera to apply the render pass to.
  68996. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68997. * @param engine The engine which the post process will be applied. (default: current engine)
  68998. * @param reusable If the post process can be reused on the same frame. (default: false)
  68999. * @param textureType Type of textures used when performing the post process. (default: 0)
  69000. * @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)
  69001. */
  69002. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69003. /**
  69004. * Gets wether or not smoothing reflections is enabled.
  69005. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69006. */
  69007. get enableSmoothReflections(): boolean;
  69008. /**
  69009. * Sets wether or not smoothing reflections is enabled.
  69010. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69011. */
  69012. set enableSmoothReflections(enabled: boolean);
  69013. /**
  69014. * Gets the number of samples taken while computing reflections. More samples count is high,
  69015. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69016. */
  69017. get reflectionSamples(): number;
  69018. /**
  69019. * Sets the number of samples taken while computing reflections. More samples count is high,
  69020. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69021. */
  69022. set reflectionSamples(samples: number);
  69023. /**
  69024. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  69025. * more the post-process will require GPU power and can generate a drop in FPS.
  69026. * Default value (5.0) work pretty well in all cases but can be adjusted.
  69027. */
  69028. get smoothSteps(): number;
  69029. set smoothSteps(steps: number);
  69030. private _updateEffectDefines;
  69031. }
  69032. }
  69033. declare module BABYLON {
  69034. /** @hidden */
  69035. export var standardPixelShader: {
  69036. name: string;
  69037. shader: string;
  69038. };
  69039. }
  69040. declare module BABYLON {
  69041. /**
  69042. * Standard rendering pipeline
  69043. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69044. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  69045. */
  69046. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  69047. /**
  69048. * Public members
  69049. */
  69050. /**
  69051. * Post-process which contains the original scene color before the pipeline applies all the effects
  69052. */
  69053. originalPostProcess: Nullable<PostProcess>;
  69054. /**
  69055. * Post-process used to down scale an image x4
  69056. */
  69057. downSampleX4PostProcess: Nullable<PostProcess>;
  69058. /**
  69059. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  69060. */
  69061. brightPassPostProcess: Nullable<PostProcess>;
  69062. /**
  69063. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  69064. */
  69065. blurHPostProcesses: PostProcess[];
  69066. /**
  69067. * Post-process array storing all the vertical blur post-processes used by the pipeline
  69068. */
  69069. blurVPostProcesses: PostProcess[];
  69070. /**
  69071. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  69072. */
  69073. textureAdderPostProcess: Nullable<PostProcess>;
  69074. /**
  69075. * Post-process used to create volumetric lighting effect
  69076. */
  69077. volumetricLightPostProcess: Nullable<PostProcess>;
  69078. /**
  69079. * Post-process used to smooth the previous volumetric light post-process on the X axis
  69080. */
  69081. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  69082. /**
  69083. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  69084. */
  69085. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  69086. /**
  69087. * Post-process used to merge the volumetric light effect and the real scene color
  69088. */
  69089. volumetricLightMergePostProces: Nullable<PostProcess>;
  69090. /**
  69091. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  69092. */
  69093. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  69094. /**
  69095. * Base post-process used to calculate the average luminance of the final image for HDR
  69096. */
  69097. luminancePostProcess: Nullable<PostProcess>;
  69098. /**
  69099. * Post-processes used to create down sample post-processes in order to get
  69100. * the average luminance of the final image for HDR
  69101. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  69102. */
  69103. luminanceDownSamplePostProcesses: PostProcess[];
  69104. /**
  69105. * Post-process used to create a HDR effect (light adaptation)
  69106. */
  69107. hdrPostProcess: Nullable<PostProcess>;
  69108. /**
  69109. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  69110. */
  69111. textureAdderFinalPostProcess: Nullable<PostProcess>;
  69112. /**
  69113. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  69114. */
  69115. lensFlareFinalPostProcess: Nullable<PostProcess>;
  69116. /**
  69117. * Post-process used to merge the final HDR post-process and the real scene color
  69118. */
  69119. hdrFinalPostProcess: Nullable<PostProcess>;
  69120. /**
  69121. * Post-process used to create a lens flare effect
  69122. */
  69123. lensFlarePostProcess: Nullable<PostProcess>;
  69124. /**
  69125. * Post-process that merges the result of the lens flare post-process and the real scene color
  69126. */
  69127. lensFlareComposePostProcess: Nullable<PostProcess>;
  69128. /**
  69129. * Post-process used to create a motion blur effect
  69130. */
  69131. motionBlurPostProcess: Nullable<PostProcess>;
  69132. /**
  69133. * Post-process used to create a depth of field effect
  69134. */
  69135. depthOfFieldPostProcess: Nullable<PostProcess>;
  69136. /**
  69137. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  69138. */
  69139. fxaaPostProcess: Nullable<FxaaPostProcess>;
  69140. /**
  69141. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  69142. */
  69143. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  69144. /**
  69145. * Represents the brightness threshold in order to configure the illuminated surfaces
  69146. */
  69147. brightThreshold: number;
  69148. /**
  69149. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  69150. */
  69151. blurWidth: number;
  69152. /**
  69153. * Sets if the blur for highlighted surfaces must be only horizontal
  69154. */
  69155. horizontalBlur: boolean;
  69156. /**
  69157. * Gets the overall exposure used by the pipeline
  69158. */
  69159. get exposure(): number;
  69160. /**
  69161. * Sets the overall exposure used by the pipeline
  69162. */
  69163. set exposure(value: number);
  69164. /**
  69165. * Texture used typically to simulate "dirty" on camera lens
  69166. */
  69167. lensTexture: Nullable<Texture>;
  69168. /**
  69169. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  69170. */
  69171. volumetricLightCoefficient: number;
  69172. /**
  69173. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  69174. */
  69175. volumetricLightPower: number;
  69176. /**
  69177. * Used the set the blur intensity to smooth the volumetric lights
  69178. */
  69179. volumetricLightBlurScale: number;
  69180. /**
  69181. * Light (spot or directional) used to generate the volumetric lights rays
  69182. * The source light must have a shadow generate so the pipeline can get its
  69183. * depth map
  69184. */
  69185. sourceLight: Nullable<SpotLight | DirectionalLight>;
  69186. /**
  69187. * For eye adaptation, represents the minimum luminance the eye can see
  69188. */
  69189. hdrMinimumLuminance: number;
  69190. /**
  69191. * For eye adaptation, represents the decrease luminance speed
  69192. */
  69193. hdrDecreaseRate: number;
  69194. /**
  69195. * For eye adaptation, represents the increase luminance speed
  69196. */
  69197. hdrIncreaseRate: number;
  69198. /**
  69199. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69200. */
  69201. get hdrAutoExposure(): boolean;
  69202. /**
  69203. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69204. */
  69205. set hdrAutoExposure(value: boolean);
  69206. /**
  69207. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  69208. */
  69209. lensColorTexture: Nullable<Texture>;
  69210. /**
  69211. * The overall strengh for the lens flare effect
  69212. */
  69213. lensFlareStrength: number;
  69214. /**
  69215. * Dispersion coefficient for lens flare ghosts
  69216. */
  69217. lensFlareGhostDispersal: number;
  69218. /**
  69219. * Main lens flare halo width
  69220. */
  69221. lensFlareHaloWidth: number;
  69222. /**
  69223. * Based on the lens distortion effect, defines how much the lens flare result
  69224. * is distorted
  69225. */
  69226. lensFlareDistortionStrength: number;
  69227. /**
  69228. * Configures the blur intensity used for for lens flare (halo)
  69229. */
  69230. lensFlareBlurWidth: number;
  69231. /**
  69232. * Lens star texture must be used to simulate rays on the flares and is available
  69233. * in the documentation
  69234. */
  69235. lensStarTexture: Nullable<Texture>;
  69236. /**
  69237. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  69238. * flare effect by taking account of the dirt texture
  69239. */
  69240. lensFlareDirtTexture: Nullable<Texture>;
  69241. /**
  69242. * Represents the focal length for the depth of field effect
  69243. */
  69244. depthOfFieldDistance: number;
  69245. /**
  69246. * Represents the blur intensity for the blurred part of the depth of field effect
  69247. */
  69248. depthOfFieldBlurWidth: number;
  69249. /**
  69250. * Gets how much the image is blurred by the movement while using the motion blur post-process
  69251. */
  69252. get motionStrength(): number;
  69253. /**
  69254. * Sets how much the image is blurred by the movement while using the motion blur post-process
  69255. */
  69256. set motionStrength(strength: number);
  69257. /**
  69258. * Gets wether or not the motion blur post-process is object based or screen based.
  69259. */
  69260. get objectBasedMotionBlur(): boolean;
  69261. /**
  69262. * Sets wether or not the motion blur post-process should be object based or screen based
  69263. */
  69264. set objectBasedMotionBlur(value: boolean);
  69265. /**
  69266. * List of animations for the pipeline (IAnimatable implementation)
  69267. */
  69268. animations: Animation[];
  69269. /**
  69270. * Private members
  69271. */
  69272. private _scene;
  69273. private _currentDepthOfFieldSource;
  69274. private _basePostProcess;
  69275. private _fixedExposure;
  69276. private _currentExposure;
  69277. private _hdrAutoExposure;
  69278. private _hdrCurrentLuminance;
  69279. private _motionStrength;
  69280. private _isObjectBasedMotionBlur;
  69281. private _floatTextureType;
  69282. private _camerasToBeAttached;
  69283. private _ratio;
  69284. private _bloomEnabled;
  69285. private _depthOfFieldEnabled;
  69286. private _vlsEnabled;
  69287. private _lensFlareEnabled;
  69288. private _hdrEnabled;
  69289. private _motionBlurEnabled;
  69290. private _fxaaEnabled;
  69291. private _screenSpaceReflectionsEnabled;
  69292. private _motionBlurSamples;
  69293. private _volumetricLightStepsCount;
  69294. private _samples;
  69295. /**
  69296. * @ignore
  69297. * Specifies if the bloom pipeline is enabled
  69298. */
  69299. get BloomEnabled(): boolean;
  69300. set BloomEnabled(enabled: boolean);
  69301. /**
  69302. * @ignore
  69303. * Specifies if the depth of field pipeline is enabed
  69304. */
  69305. get DepthOfFieldEnabled(): boolean;
  69306. set DepthOfFieldEnabled(enabled: boolean);
  69307. /**
  69308. * @ignore
  69309. * Specifies if the lens flare pipeline is enabed
  69310. */
  69311. get LensFlareEnabled(): boolean;
  69312. set LensFlareEnabled(enabled: boolean);
  69313. /**
  69314. * @ignore
  69315. * Specifies if the HDR pipeline is enabled
  69316. */
  69317. get HDREnabled(): boolean;
  69318. set HDREnabled(enabled: boolean);
  69319. /**
  69320. * @ignore
  69321. * Specifies if the volumetric lights scattering effect is enabled
  69322. */
  69323. get VLSEnabled(): boolean;
  69324. set VLSEnabled(enabled: boolean);
  69325. /**
  69326. * @ignore
  69327. * Specifies if the motion blur effect is enabled
  69328. */
  69329. get MotionBlurEnabled(): boolean;
  69330. set MotionBlurEnabled(enabled: boolean);
  69331. /**
  69332. * Specifies if anti-aliasing is enabled
  69333. */
  69334. get fxaaEnabled(): boolean;
  69335. set fxaaEnabled(enabled: boolean);
  69336. /**
  69337. * Specifies if screen space reflections are enabled.
  69338. */
  69339. get screenSpaceReflectionsEnabled(): boolean;
  69340. set screenSpaceReflectionsEnabled(enabled: boolean);
  69341. /**
  69342. * Specifies the number of steps used to calculate the volumetric lights
  69343. * Typically in interval [50, 200]
  69344. */
  69345. get volumetricLightStepsCount(): number;
  69346. set volumetricLightStepsCount(count: number);
  69347. /**
  69348. * Specifies the number of samples used for the motion blur effect
  69349. * Typically in interval [16, 64]
  69350. */
  69351. get motionBlurSamples(): number;
  69352. set motionBlurSamples(samples: number);
  69353. /**
  69354. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  69355. */
  69356. get samples(): number;
  69357. set samples(sampleCount: number);
  69358. /**
  69359. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69360. * @constructor
  69361. * @param name The rendering pipeline name
  69362. * @param scene The scene linked to this pipeline
  69363. * @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)
  69364. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  69365. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69366. */
  69367. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  69368. private _buildPipeline;
  69369. private _createDownSampleX4PostProcess;
  69370. private _createBrightPassPostProcess;
  69371. private _createBlurPostProcesses;
  69372. private _createTextureAdderPostProcess;
  69373. private _createVolumetricLightPostProcess;
  69374. private _createLuminancePostProcesses;
  69375. private _createHdrPostProcess;
  69376. private _createLensFlarePostProcess;
  69377. private _createDepthOfFieldPostProcess;
  69378. private _createMotionBlurPostProcess;
  69379. private _getDepthTexture;
  69380. private _disposePostProcesses;
  69381. /**
  69382. * Dispose of the pipeline and stop all post processes
  69383. */
  69384. dispose(): void;
  69385. /**
  69386. * Serialize the rendering pipeline (Used when exporting)
  69387. * @returns the serialized object
  69388. */
  69389. serialize(): any;
  69390. /**
  69391. * Parse the serialized pipeline
  69392. * @param source Source pipeline.
  69393. * @param scene The scene to load the pipeline to.
  69394. * @param rootUrl The URL of the serialized pipeline.
  69395. * @returns An instantiated pipeline from the serialized object.
  69396. */
  69397. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  69398. /**
  69399. * Luminance steps
  69400. */
  69401. static LuminanceSteps: number;
  69402. }
  69403. }
  69404. declare module BABYLON {
  69405. /** @hidden */
  69406. export var stereoscopicInterlacePixelShader: {
  69407. name: string;
  69408. shader: string;
  69409. };
  69410. }
  69411. declare module BABYLON {
  69412. /**
  69413. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  69414. */
  69415. export class StereoscopicInterlacePostProcessI extends PostProcess {
  69416. private _stepSize;
  69417. private _passedProcess;
  69418. /**
  69419. * Initializes a StereoscopicInterlacePostProcessI
  69420. * @param name The name of the effect.
  69421. * @param rigCameras The rig cameras to be appled to the post process
  69422. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  69423. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  69424. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69425. * @param engine The engine which the post process will be applied. (default: current engine)
  69426. * @param reusable If the post process can be reused on the same frame. (default: false)
  69427. */
  69428. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69429. }
  69430. /**
  69431. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  69432. */
  69433. export class StereoscopicInterlacePostProcess extends PostProcess {
  69434. private _stepSize;
  69435. private _passedProcess;
  69436. /**
  69437. * Initializes a StereoscopicInterlacePostProcess
  69438. * @param name The name of the effect.
  69439. * @param rigCameras The rig cameras to be appled to the post process
  69440. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  69441. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69442. * @param engine The engine which the post process will be applied. (default: current engine)
  69443. * @param reusable If the post process can be reused on the same frame. (default: false)
  69444. */
  69445. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69446. }
  69447. }
  69448. declare module BABYLON {
  69449. /** @hidden */
  69450. export var tonemapPixelShader: {
  69451. name: string;
  69452. shader: string;
  69453. };
  69454. }
  69455. declare module BABYLON {
  69456. /** Defines operator used for tonemapping */
  69457. export enum TonemappingOperator {
  69458. /** Hable */
  69459. Hable = 0,
  69460. /** Reinhard */
  69461. Reinhard = 1,
  69462. /** HejiDawson */
  69463. HejiDawson = 2,
  69464. /** Photographic */
  69465. Photographic = 3
  69466. }
  69467. /**
  69468. * Defines a post process to apply tone mapping
  69469. */
  69470. export class TonemapPostProcess extends PostProcess {
  69471. private _operator;
  69472. /** Defines the required exposure adjustement */
  69473. exposureAdjustment: number;
  69474. /**
  69475. * Creates a new TonemapPostProcess
  69476. * @param name defines the name of the postprocess
  69477. * @param _operator defines the operator to use
  69478. * @param exposureAdjustment defines the required exposure adjustement
  69479. * @param camera defines the camera to use (can be null)
  69480. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  69481. * @param engine defines the hosting engine (can be ignore if camera is set)
  69482. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  69483. */
  69484. constructor(name: string, _operator: TonemappingOperator,
  69485. /** Defines the required exposure adjustement */
  69486. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  69487. }
  69488. }
  69489. declare module BABYLON {
  69490. /** @hidden */
  69491. export var volumetricLightScatteringPixelShader: {
  69492. name: string;
  69493. shader: string;
  69494. };
  69495. }
  69496. declare module BABYLON {
  69497. /** @hidden */
  69498. export var volumetricLightScatteringPassVertexShader: {
  69499. name: string;
  69500. shader: string;
  69501. };
  69502. }
  69503. declare module BABYLON {
  69504. /** @hidden */
  69505. export var volumetricLightScatteringPassPixelShader: {
  69506. name: string;
  69507. shader: string;
  69508. };
  69509. }
  69510. declare module BABYLON {
  69511. /**
  69512. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  69513. */
  69514. export class VolumetricLightScatteringPostProcess extends PostProcess {
  69515. private _volumetricLightScatteringPass;
  69516. private _volumetricLightScatteringRTT;
  69517. private _viewPort;
  69518. private _screenCoordinates;
  69519. private _cachedDefines;
  69520. /**
  69521. * If not undefined, the mesh position is computed from the attached node position
  69522. */
  69523. attachedNode: {
  69524. position: Vector3;
  69525. };
  69526. /**
  69527. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  69528. */
  69529. customMeshPosition: Vector3;
  69530. /**
  69531. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  69532. */
  69533. useCustomMeshPosition: boolean;
  69534. /**
  69535. * If the post-process should inverse the light scattering direction
  69536. */
  69537. invert: boolean;
  69538. /**
  69539. * The internal mesh used by the post-process
  69540. */
  69541. mesh: Mesh;
  69542. /**
  69543. * @hidden
  69544. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  69545. */
  69546. get useDiffuseColor(): boolean;
  69547. set useDiffuseColor(useDiffuseColor: boolean);
  69548. /**
  69549. * Array containing the excluded meshes not rendered in the internal pass
  69550. */
  69551. excludedMeshes: AbstractMesh[];
  69552. /**
  69553. * Controls the overall intensity of the post-process
  69554. */
  69555. exposure: number;
  69556. /**
  69557. * Dissipates each sample's contribution in range [0, 1]
  69558. */
  69559. decay: number;
  69560. /**
  69561. * Controls the overall intensity of each sample
  69562. */
  69563. weight: number;
  69564. /**
  69565. * Controls the density of each sample
  69566. */
  69567. density: number;
  69568. /**
  69569. * @constructor
  69570. * @param name The post-process name
  69571. * @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)
  69572. * @param camera The camera that the post-process will be attached to
  69573. * @param mesh The mesh used to create the light scattering
  69574. * @param samples The post-process quality, default 100
  69575. * @param samplingModeThe post-process filtering mode
  69576. * @param engine The babylon engine
  69577. * @param reusable If the post-process is reusable
  69578. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  69579. */
  69580. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  69581. /**
  69582. * Returns the string "VolumetricLightScatteringPostProcess"
  69583. * @returns "VolumetricLightScatteringPostProcess"
  69584. */
  69585. getClassName(): string;
  69586. private _isReady;
  69587. /**
  69588. * Sets the new light position for light scattering effect
  69589. * @param position The new custom light position
  69590. */
  69591. setCustomMeshPosition(position: Vector3): void;
  69592. /**
  69593. * Returns the light position for light scattering effect
  69594. * @return Vector3 The custom light position
  69595. */
  69596. getCustomMeshPosition(): Vector3;
  69597. /**
  69598. * Disposes the internal assets and detaches the post-process from the camera
  69599. */
  69600. dispose(camera: Camera): void;
  69601. /**
  69602. * Returns the render target texture used by the post-process
  69603. * @return the render target texture used by the post-process
  69604. */
  69605. getPass(): RenderTargetTexture;
  69606. private _meshExcluded;
  69607. private _createPass;
  69608. private _updateMeshScreenCoordinates;
  69609. /**
  69610. * Creates a default mesh for the Volumeric Light Scattering post-process
  69611. * @param name The mesh name
  69612. * @param scene The scene where to create the mesh
  69613. * @return the default mesh
  69614. */
  69615. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  69616. }
  69617. }
  69618. declare module BABYLON {
  69619. interface Scene {
  69620. /** @hidden (Backing field) */
  69621. _boundingBoxRenderer: BoundingBoxRenderer;
  69622. /** @hidden (Backing field) */
  69623. _forceShowBoundingBoxes: boolean;
  69624. /**
  69625. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  69626. */
  69627. forceShowBoundingBoxes: boolean;
  69628. /**
  69629. * Gets the bounding box renderer associated with the scene
  69630. * @returns a BoundingBoxRenderer
  69631. */
  69632. getBoundingBoxRenderer(): BoundingBoxRenderer;
  69633. }
  69634. interface AbstractMesh {
  69635. /** @hidden (Backing field) */
  69636. _showBoundingBox: boolean;
  69637. /**
  69638. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  69639. */
  69640. showBoundingBox: boolean;
  69641. }
  69642. /**
  69643. * Component responsible of rendering the bounding box of the meshes in a scene.
  69644. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  69645. */
  69646. export class BoundingBoxRenderer implements ISceneComponent {
  69647. /**
  69648. * The component name helpfull to identify the component in the list of scene components.
  69649. */
  69650. readonly name: string;
  69651. /**
  69652. * The scene the component belongs to.
  69653. */
  69654. scene: Scene;
  69655. /**
  69656. * Color of the bounding box lines placed in front of an object
  69657. */
  69658. frontColor: Color3;
  69659. /**
  69660. * Color of the bounding box lines placed behind an object
  69661. */
  69662. backColor: Color3;
  69663. /**
  69664. * Defines if the renderer should show the back lines or not
  69665. */
  69666. showBackLines: boolean;
  69667. /**
  69668. * Observable raised before rendering a bounding box
  69669. */
  69670. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  69671. /**
  69672. * Observable raised after rendering a bounding box
  69673. */
  69674. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  69675. /**
  69676. * @hidden
  69677. */
  69678. renderList: SmartArray<BoundingBox>;
  69679. private _colorShader;
  69680. private _vertexBuffers;
  69681. private _indexBuffer;
  69682. private _fillIndexBuffer;
  69683. private _fillIndexData;
  69684. /**
  69685. * Instantiates a new bounding box renderer in a scene.
  69686. * @param scene the scene the renderer renders in
  69687. */
  69688. constructor(scene: Scene);
  69689. /**
  69690. * Registers the component in a given scene
  69691. */
  69692. register(): void;
  69693. private _evaluateSubMesh;
  69694. private _activeMesh;
  69695. private _prepareRessources;
  69696. private _createIndexBuffer;
  69697. /**
  69698. * Rebuilds the elements related to this component in case of
  69699. * context lost for instance.
  69700. */
  69701. rebuild(): void;
  69702. /**
  69703. * @hidden
  69704. */
  69705. reset(): void;
  69706. /**
  69707. * Render the bounding boxes of a specific rendering group
  69708. * @param renderingGroupId defines the rendering group to render
  69709. */
  69710. render(renderingGroupId: number): void;
  69711. /**
  69712. * In case of occlusion queries, we can render the occlusion bounding box through this method
  69713. * @param mesh Define the mesh to render the occlusion bounding box for
  69714. */
  69715. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  69716. /**
  69717. * Dispose and release the resources attached to this renderer.
  69718. */
  69719. dispose(): void;
  69720. }
  69721. }
  69722. declare module BABYLON {
  69723. interface Scene {
  69724. /** @hidden (Backing field) */
  69725. _depthRenderer: {
  69726. [id: string]: DepthRenderer;
  69727. };
  69728. /**
  69729. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  69730. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  69731. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  69732. * @returns the created depth renderer
  69733. */
  69734. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  69735. /**
  69736. * Disables a depth renderer for a given camera
  69737. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  69738. */
  69739. disableDepthRenderer(camera?: Nullable<Camera>): void;
  69740. }
  69741. /**
  69742. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  69743. * in several rendering techniques.
  69744. */
  69745. export class DepthRendererSceneComponent implements ISceneComponent {
  69746. /**
  69747. * The component name helpfull to identify the component in the list of scene components.
  69748. */
  69749. readonly name: string;
  69750. /**
  69751. * The scene the component belongs to.
  69752. */
  69753. scene: Scene;
  69754. /**
  69755. * Creates a new instance of the component for the given scene
  69756. * @param scene Defines the scene to register the component in
  69757. */
  69758. constructor(scene: Scene);
  69759. /**
  69760. * Registers the component in a given scene
  69761. */
  69762. register(): void;
  69763. /**
  69764. * Rebuilds the elements related to this component in case of
  69765. * context lost for instance.
  69766. */
  69767. rebuild(): void;
  69768. /**
  69769. * Disposes the component and the associated ressources
  69770. */
  69771. dispose(): void;
  69772. private _gatherRenderTargets;
  69773. private _gatherActiveCameraRenderTargets;
  69774. }
  69775. }
  69776. declare module BABYLON {
  69777. /** @hidden */
  69778. export var outlinePixelShader: {
  69779. name: string;
  69780. shader: string;
  69781. };
  69782. }
  69783. declare module BABYLON {
  69784. /** @hidden */
  69785. export var outlineVertexShader: {
  69786. name: string;
  69787. shader: string;
  69788. };
  69789. }
  69790. declare module BABYLON {
  69791. interface Scene {
  69792. /** @hidden */
  69793. _outlineRenderer: OutlineRenderer;
  69794. /**
  69795. * Gets the outline renderer associated with the scene
  69796. * @returns a OutlineRenderer
  69797. */
  69798. getOutlineRenderer(): OutlineRenderer;
  69799. }
  69800. interface AbstractMesh {
  69801. /** @hidden (Backing field) */
  69802. _renderOutline: boolean;
  69803. /**
  69804. * Gets or sets a boolean indicating if the outline must be rendered as well
  69805. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  69806. */
  69807. renderOutline: boolean;
  69808. /** @hidden (Backing field) */
  69809. _renderOverlay: boolean;
  69810. /**
  69811. * Gets or sets a boolean indicating if the overlay must be rendered as well
  69812. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  69813. */
  69814. renderOverlay: boolean;
  69815. }
  69816. /**
  69817. * This class is responsible to draw bothe outline/overlay of meshes.
  69818. * It should not be used directly but through the available method on mesh.
  69819. */
  69820. export class OutlineRenderer implements ISceneComponent {
  69821. /**
  69822. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  69823. */
  69824. private static _StencilReference;
  69825. /**
  69826. * The name of the component. Each component must have a unique name.
  69827. */
  69828. name: string;
  69829. /**
  69830. * The scene the component belongs to.
  69831. */
  69832. scene: Scene;
  69833. /**
  69834. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  69835. */
  69836. zOffset: number;
  69837. private _engine;
  69838. private _effect;
  69839. private _cachedDefines;
  69840. private _savedDepthWrite;
  69841. /**
  69842. * Instantiates a new outline renderer. (There could be only one per scene).
  69843. * @param scene Defines the scene it belongs to
  69844. */
  69845. constructor(scene: Scene);
  69846. /**
  69847. * Register the component to one instance of a scene.
  69848. */
  69849. register(): void;
  69850. /**
  69851. * Rebuilds the elements related to this component in case of
  69852. * context lost for instance.
  69853. */
  69854. rebuild(): void;
  69855. /**
  69856. * Disposes the component and the associated ressources.
  69857. */
  69858. dispose(): void;
  69859. /**
  69860. * Renders the outline in the canvas.
  69861. * @param subMesh Defines the sumesh to render
  69862. * @param batch Defines the batch of meshes in case of instances
  69863. * @param useOverlay Defines if the rendering is for the overlay or the outline
  69864. */
  69865. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  69866. /**
  69867. * Returns whether or not the outline renderer is ready for a given submesh.
  69868. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  69869. * @param subMesh Defines the submesh to check readyness for
  69870. * @param useInstances Defines wheter wee are trying to render instances or not
  69871. * @returns true if ready otherwise false
  69872. */
  69873. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  69874. private _beforeRenderingMesh;
  69875. private _afterRenderingMesh;
  69876. }
  69877. }
  69878. declare module BABYLON {
  69879. /**
  69880. * Defines the basic options interface of a Sprite Frame Source Size.
  69881. */
  69882. export interface ISpriteJSONSpriteSourceSize {
  69883. /**
  69884. * number of the original width of the Frame
  69885. */
  69886. w: number;
  69887. /**
  69888. * number of the original height of the Frame
  69889. */
  69890. h: number;
  69891. }
  69892. /**
  69893. * Defines the basic options interface of a Sprite Frame Data.
  69894. */
  69895. export interface ISpriteJSONSpriteFrameData {
  69896. /**
  69897. * number of the x offset of the Frame
  69898. */
  69899. x: number;
  69900. /**
  69901. * number of the y offset of the Frame
  69902. */
  69903. y: number;
  69904. /**
  69905. * number of the width of the Frame
  69906. */
  69907. w: number;
  69908. /**
  69909. * number of the height of the Frame
  69910. */
  69911. h: number;
  69912. }
  69913. /**
  69914. * Defines the basic options interface of a JSON Sprite.
  69915. */
  69916. export interface ISpriteJSONSprite {
  69917. /**
  69918. * string name of the Frame
  69919. */
  69920. filename: string;
  69921. /**
  69922. * ISpriteJSONSpriteFrame basic object of the frame data
  69923. */
  69924. frame: ISpriteJSONSpriteFrameData;
  69925. /**
  69926. * boolean to flag is the frame was rotated.
  69927. */
  69928. rotated: boolean;
  69929. /**
  69930. * boolean to flag is the frame was trimmed.
  69931. */
  69932. trimmed: boolean;
  69933. /**
  69934. * ISpriteJSONSpriteFrame basic object of the source data
  69935. */
  69936. spriteSourceSize: ISpriteJSONSpriteFrameData;
  69937. /**
  69938. * ISpriteJSONSpriteFrame basic object of the source data
  69939. */
  69940. sourceSize: ISpriteJSONSpriteSourceSize;
  69941. }
  69942. /**
  69943. * Defines the basic options interface of a JSON atlas.
  69944. */
  69945. export interface ISpriteJSONAtlas {
  69946. /**
  69947. * Array of objects that contain the frame data.
  69948. */
  69949. frames: Array<ISpriteJSONSprite>;
  69950. /**
  69951. * object basic object containing the sprite meta data.
  69952. */
  69953. meta?: object;
  69954. }
  69955. }
  69956. declare module BABYLON {
  69957. /** @hidden */
  69958. export var spriteMapPixelShader: {
  69959. name: string;
  69960. shader: string;
  69961. };
  69962. }
  69963. declare module BABYLON {
  69964. /** @hidden */
  69965. export var spriteMapVertexShader: {
  69966. name: string;
  69967. shader: string;
  69968. };
  69969. }
  69970. declare module BABYLON {
  69971. /**
  69972. * Defines the basic options interface of a SpriteMap
  69973. */
  69974. export interface ISpriteMapOptions {
  69975. /**
  69976. * Vector2 of the number of cells in the grid.
  69977. */
  69978. stageSize?: Vector2;
  69979. /**
  69980. * Vector2 of the size of the output plane in World Units.
  69981. */
  69982. outputSize?: Vector2;
  69983. /**
  69984. * Vector3 of the position of the output plane in World Units.
  69985. */
  69986. outputPosition?: Vector3;
  69987. /**
  69988. * Vector3 of the rotation of the output plane.
  69989. */
  69990. outputRotation?: Vector3;
  69991. /**
  69992. * number of layers that the system will reserve in resources.
  69993. */
  69994. layerCount?: number;
  69995. /**
  69996. * number of max animation frames a single cell will reserve in resources.
  69997. */
  69998. maxAnimationFrames?: number;
  69999. /**
  70000. * number cell index of the base tile when the system compiles.
  70001. */
  70002. baseTile?: number;
  70003. /**
  70004. * boolean flip the sprite after its been repositioned by the framing data.
  70005. */
  70006. flipU?: boolean;
  70007. /**
  70008. * Vector3 scalar of the global RGB values of the SpriteMap.
  70009. */
  70010. colorMultiply?: Vector3;
  70011. }
  70012. /**
  70013. * Defines the IDisposable interface in order to be cleanable from resources.
  70014. */
  70015. export interface ISpriteMap extends IDisposable {
  70016. /**
  70017. * String name of the SpriteMap.
  70018. */
  70019. name: string;
  70020. /**
  70021. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  70022. */
  70023. atlasJSON: ISpriteJSONAtlas;
  70024. /**
  70025. * Texture of the SpriteMap.
  70026. */
  70027. spriteSheet: Texture;
  70028. /**
  70029. * The parameters to initialize the SpriteMap with.
  70030. */
  70031. options: ISpriteMapOptions;
  70032. }
  70033. /**
  70034. * Class used to manage a grid restricted sprite deployment on an Output plane.
  70035. */
  70036. export class SpriteMap implements ISpriteMap {
  70037. /** The Name of the spriteMap */
  70038. name: string;
  70039. /** The JSON file with the frame and meta data */
  70040. atlasJSON: ISpriteJSONAtlas;
  70041. /** The systems Sprite Sheet Texture */
  70042. spriteSheet: Texture;
  70043. /** Arguments passed with the Constructor */
  70044. options: ISpriteMapOptions;
  70045. /** Public Sprite Storage array, parsed from atlasJSON */
  70046. sprites: Array<ISpriteJSONSprite>;
  70047. /** Returns the Number of Sprites in the System */
  70048. get spriteCount(): number;
  70049. /** Returns the Position of Output Plane*/
  70050. get position(): Vector3;
  70051. /** Returns the Position of Output Plane*/
  70052. set position(v: Vector3);
  70053. /** Returns the Rotation of Output Plane*/
  70054. get rotation(): Vector3;
  70055. /** Returns the Rotation of Output Plane*/
  70056. set rotation(v: Vector3);
  70057. /** Sets the AnimationMap*/
  70058. get animationMap(): RawTexture;
  70059. /** Sets the AnimationMap*/
  70060. set animationMap(v: RawTexture);
  70061. /** Scene that the SpriteMap was created in */
  70062. private _scene;
  70063. /** Texture Buffer of Float32 that holds tile frame data*/
  70064. private _frameMap;
  70065. /** Texture Buffers of Float32 that holds tileMap data*/
  70066. private _tileMaps;
  70067. /** Texture Buffer of Float32 that holds Animation Data*/
  70068. private _animationMap;
  70069. /** Custom ShaderMaterial Central to the System*/
  70070. private _material;
  70071. /** Custom ShaderMaterial Central to the System*/
  70072. private _output;
  70073. /** Systems Time Ticker*/
  70074. private _time;
  70075. /**
  70076. * Creates a new SpriteMap
  70077. * @param name defines the SpriteMaps Name
  70078. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  70079. * @param spriteSheet is the Texture that the Sprites are on.
  70080. * @param options a basic deployment configuration
  70081. * @param scene The Scene that the map is deployed on
  70082. */
  70083. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  70084. /**
  70085. * Returns tileID location
  70086. * @returns Vector2 the cell position ID
  70087. */
  70088. getTileID(): Vector2;
  70089. /**
  70090. * Gets the UV location of the mouse over the SpriteMap.
  70091. * @returns Vector2 the UV position of the mouse interaction
  70092. */
  70093. getMousePosition(): Vector2;
  70094. /**
  70095. * Creates the "frame" texture Buffer
  70096. * -------------------------------------
  70097. * Structure of frames
  70098. * "filename": "Falling-Water-2.png",
  70099. * "frame": {"x":69,"y":103,"w":24,"h":32},
  70100. * "rotated": true,
  70101. * "trimmed": true,
  70102. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  70103. * "sourceSize": {"w":32,"h":32}
  70104. * @returns RawTexture of the frameMap
  70105. */
  70106. private _createFrameBuffer;
  70107. /**
  70108. * Creates the tileMap texture Buffer
  70109. * @param buffer normally and array of numbers, or a false to generate from scratch
  70110. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  70111. * @returns RawTexture of the tileMap
  70112. */
  70113. private _createTileBuffer;
  70114. /**
  70115. * Modifies the data of the tileMaps
  70116. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  70117. * @param pos is the iVector2 Coordinates of the Tile
  70118. * @param tile The SpriteIndex of the new Tile
  70119. */
  70120. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  70121. /**
  70122. * Creates the animationMap texture Buffer
  70123. * @param buffer normally and array of numbers, or a false to generate from scratch
  70124. * @returns RawTexture of the animationMap
  70125. */
  70126. private _createTileAnimationBuffer;
  70127. /**
  70128. * Modifies the data of the animationMap
  70129. * @param cellID is the Index of the Sprite
  70130. * @param _frame is the target Animation frame
  70131. * @param toCell is the Target Index of the next frame of the animation
  70132. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  70133. * @param speed is a global scalar of the time variable on the map.
  70134. */
  70135. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  70136. /**
  70137. * Exports the .tilemaps file
  70138. */
  70139. saveTileMaps(): void;
  70140. /**
  70141. * Imports the .tilemaps file
  70142. * @param url of the .tilemaps file
  70143. */
  70144. loadTileMaps(url: string): void;
  70145. /**
  70146. * Release associated resources
  70147. */
  70148. dispose(): void;
  70149. }
  70150. }
  70151. declare module BABYLON {
  70152. /**
  70153. * Class used to manage multiple sprites of different sizes on the same spritesheet
  70154. * @see http://doc.babylonjs.com/babylon101/sprites
  70155. */
  70156. export class SpritePackedManager extends SpriteManager {
  70157. /** defines the packed manager's name */
  70158. name: string;
  70159. /**
  70160. * Creates a new sprite manager from a packed sprite sheet
  70161. * @param name defines the manager's name
  70162. * @param imgUrl defines the sprite sheet url
  70163. * @param capacity defines the maximum allowed number of sprites
  70164. * @param scene defines the hosting scene
  70165. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  70166. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  70167. * @param samplingMode defines the smapling mode to use with spritesheet
  70168. * @param fromPacked set to true; do not alter
  70169. */
  70170. constructor(
  70171. /** defines the packed manager's name */
  70172. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  70173. }
  70174. }
  70175. declare module BABYLON {
  70176. /**
  70177. * Defines the list of states available for a task inside a AssetsManager
  70178. */
  70179. export enum AssetTaskState {
  70180. /**
  70181. * Initialization
  70182. */
  70183. INIT = 0,
  70184. /**
  70185. * Running
  70186. */
  70187. RUNNING = 1,
  70188. /**
  70189. * Done
  70190. */
  70191. DONE = 2,
  70192. /**
  70193. * Error
  70194. */
  70195. ERROR = 3
  70196. }
  70197. /**
  70198. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  70199. */
  70200. export abstract class AbstractAssetTask {
  70201. /**
  70202. * Task name
  70203. */ name: string;
  70204. /**
  70205. * Callback called when the task is successful
  70206. */
  70207. onSuccess: (task: any) => void;
  70208. /**
  70209. * Callback called when the task is not successful
  70210. */
  70211. onError: (task: any, message?: string, exception?: any) => void;
  70212. /**
  70213. * Creates a new AssetsManager
  70214. * @param name defines the name of the task
  70215. */
  70216. constructor(
  70217. /**
  70218. * Task name
  70219. */ name: string);
  70220. private _isCompleted;
  70221. private _taskState;
  70222. private _errorObject;
  70223. /**
  70224. * Get if the task is completed
  70225. */
  70226. get isCompleted(): boolean;
  70227. /**
  70228. * Gets the current state of the task
  70229. */
  70230. get taskState(): AssetTaskState;
  70231. /**
  70232. * Gets the current error object (if task is in error)
  70233. */
  70234. get errorObject(): {
  70235. message?: string;
  70236. exception?: any;
  70237. };
  70238. /**
  70239. * Internal only
  70240. * @hidden
  70241. */
  70242. _setErrorObject(message?: string, exception?: any): void;
  70243. /**
  70244. * Execute the current task
  70245. * @param scene defines the scene where you want your assets to be loaded
  70246. * @param onSuccess is a callback called when the task is successfully executed
  70247. * @param onError is a callback called if an error occurs
  70248. */
  70249. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70250. /**
  70251. * Execute the current task
  70252. * @param scene defines the scene where you want your assets to be loaded
  70253. * @param onSuccess is a callback called when the task is successfully executed
  70254. * @param onError is a callback called if an error occurs
  70255. */
  70256. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70257. /**
  70258. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  70259. * This can be used with failed tasks that have the reason for failure fixed.
  70260. */
  70261. reset(): void;
  70262. private onErrorCallback;
  70263. private onDoneCallback;
  70264. }
  70265. /**
  70266. * Define the interface used by progress events raised during assets loading
  70267. */
  70268. export interface IAssetsProgressEvent {
  70269. /**
  70270. * Defines the number of remaining tasks to process
  70271. */
  70272. remainingCount: number;
  70273. /**
  70274. * Defines the total number of tasks
  70275. */
  70276. totalCount: number;
  70277. /**
  70278. * Defines the task that was just processed
  70279. */
  70280. task: AbstractAssetTask;
  70281. }
  70282. /**
  70283. * Class used to share progress information about assets loading
  70284. */
  70285. export class AssetsProgressEvent implements IAssetsProgressEvent {
  70286. /**
  70287. * Defines the number of remaining tasks to process
  70288. */
  70289. remainingCount: number;
  70290. /**
  70291. * Defines the total number of tasks
  70292. */
  70293. totalCount: number;
  70294. /**
  70295. * Defines the task that was just processed
  70296. */
  70297. task: AbstractAssetTask;
  70298. /**
  70299. * Creates a AssetsProgressEvent
  70300. * @param remainingCount defines the number of remaining tasks to process
  70301. * @param totalCount defines the total number of tasks
  70302. * @param task defines the task that was just processed
  70303. */
  70304. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  70305. }
  70306. /**
  70307. * Define a task used by AssetsManager to load meshes
  70308. */
  70309. export class MeshAssetTask extends AbstractAssetTask {
  70310. /**
  70311. * Defines the name of the task
  70312. */
  70313. name: string;
  70314. /**
  70315. * Defines the list of mesh's names you want to load
  70316. */
  70317. meshesNames: any;
  70318. /**
  70319. * Defines the root url to use as a base to load your meshes and associated resources
  70320. */
  70321. rootUrl: string;
  70322. /**
  70323. * Defines the filename or File of the scene to load from
  70324. */
  70325. sceneFilename: string | File;
  70326. /**
  70327. * Gets the list of loaded meshes
  70328. */
  70329. loadedMeshes: Array<AbstractMesh>;
  70330. /**
  70331. * Gets the list of loaded particle systems
  70332. */
  70333. loadedParticleSystems: Array<IParticleSystem>;
  70334. /**
  70335. * Gets the list of loaded skeletons
  70336. */
  70337. loadedSkeletons: Array<Skeleton>;
  70338. /**
  70339. * Gets the list of loaded animation groups
  70340. */
  70341. loadedAnimationGroups: Array<AnimationGroup>;
  70342. /**
  70343. * Callback called when the task is successful
  70344. */
  70345. onSuccess: (task: MeshAssetTask) => void;
  70346. /**
  70347. * Callback called when the task is successful
  70348. */
  70349. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  70350. /**
  70351. * Creates a new MeshAssetTask
  70352. * @param name defines the name of the task
  70353. * @param meshesNames defines the list of mesh's names you want to load
  70354. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  70355. * @param sceneFilename defines the filename or File of the scene to load from
  70356. */
  70357. constructor(
  70358. /**
  70359. * Defines the name of the task
  70360. */
  70361. name: string,
  70362. /**
  70363. * Defines the list of mesh's names you want to load
  70364. */
  70365. meshesNames: any,
  70366. /**
  70367. * Defines the root url to use as a base to load your meshes and associated resources
  70368. */
  70369. rootUrl: string,
  70370. /**
  70371. * Defines the filename or File of the scene to load from
  70372. */
  70373. sceneFilename: string | File);
  70374. /**
  70375. * Execute the current task
  70376. * @param scene defines the scene where you want your assets to be loaded
  70377. * @param onSuccess is a callback called when the task is successfully executed
  70378. * @param onError is a callback called if an error occurs
  70379. */
  70380. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70381. }
  70382. /**
  70383. * Define a task used by AssetsManager to load text content
  70384. */
  70385. export class TextFileAssetTask extends AbstractAssetTask {
  70386. /**
  70387. * Defines the name of the task
  70388. */
  70389. name: string;
  70390. /**
  70391. * Defines the location of the file to load
  70392. */
  70393. url: string;
  70394. /**
  70395. * Gets the loaded text string
  70396. */
  70397. text: string;
  70398. /**
  70399. * Callback called when the task is successful
  70400. */
  70401. onSuccess: (task: TextFileAssetTask) => void;
  70402. /**
  70403. * Callback called when the task is successful
  70404. */
  70405. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  70406. /**
  70407. * Creates a new TextFileAssetTask object
  70408. * @param name defines the name of the task
  70409. * @param url defines the location of the file to load
  70410. */
  70411. constructor(
  70412. /**
  70413. * Defines the name of the task
  70414. */
  70415. name: string,
  70416. /**
  70417. * Defines the location of the file to load
  70418. */
  70419. url: string);
  70420. /**
  70421. * Execute the current task
  70422. * @param scene defines the scene where you want your assets to be loaded
  70423. * @param onSuccess is a callback called when the task is successfully executed
  70424. * @param onError is a callback called if an error occurs
  70425. */
  70426. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70427. }
  70428. /**
  70429. * Define a task used by AssetsManager to load binary data
  70430. */
  70431. export class BinaryFileAssetTask extends AbstractAssetTask {
  70432. /**
  70433. * Defines the name of the task
  70434. */
  70435. name: string;
  70436. /**
  70437. * Defines the location of the file to load
  70438. */
  70439. url: string;
  70440. /**
  70441. * Gets the lodaded data (as an array buffer)
  70442. */
  70443. data: ArrayBuffer;
  70444. /**
  70445. * Callback called when the task is successful
  70446. */
  70447. onSuccess: (task: BinaryFileAssetTask) => void;
  70448. /**
  70449. * Callback called when the task is successful
  70450. */
  70451. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  70452. /**
  70453. * Creates a new BinaryFileAssetTask object
  70454. * @param name defines the name of the new task
  70455. * @param url defines the location of the file to load
  70456. */
  70457. constructor(
  70458. /**
  70459. * Defines the name of the task
  70460. */
  70461. name: string,
  70462. /**
  70463. * Defines the location of the file to load
  70464. */
  70465. url: string);
  70466. /**
  70467. * Execute the current task
  70468. * @param scene defines the scene where you want your assets to be loaded
  70469. * @param onSuccess is a callback called when the task is successfully executed
  70470. * @param onError is a callback called if an error occurs
  70471. */
  70472. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70473. }
  70474. /**
  70475. * Define a task used by AssetsManager to load images
  70476. */
  70477. export class ImageAssetTask extends AbstractAssetTask {
  70478. /**
  70479. * Defines the name of the task
  70480. */
  70481. name: string;
  70482. /**
  70483. * Defines the location of the image to load
  70484. */
  70485. url: string;
  70486. /**
  70487. * Gets the loaded images
  70488. */
  70489. image: HTMLImageElement;
  70490. /**
  70491. * Callback called when the task is successful
  70492. */
  70493. onSuccess: (task: ImageAssetTask) => void;
  70494. /**
  70495. * Callback called when the task is successful
  70496. */
  70497. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  70498. /**
  70499. * Creates a new ImageAssetTask
  70500. * @param name defines the name of the task
  70501. * @param url defines the location of the image to load
  70502. */
  70503. constructor(
  70504. /**
  70505. * Defines the name of the task
  70506. */
  70507. name: string,
  70508. /**
  70509. * Defines the location of the image to load
  70510. */
  70511. url: string);
  70512. /**
  70513. * Execute the current task
  70514. * @param scene defines the scene where you want your assets to be loaded
  70515. * @param onSuccess is a callback called when the task is successfully executed
  70516. * @param onError is a callback called if an error occurs
  70517. */
  70518. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70519. }
  70520. /**
  70521. * Defines the interface used by texture loading tasks
  70522. */
  70523. export interface ITextureAssetTask<TEX extends BaseTexture> {
  70524. /**
  70525. * Gets the loaded texture
  70526. */
  70527. texture: TEX;
  70528. }
  70529. /**
  70530. * Define a task used by AssetsManager to load 2D textures
  70531. */
  70532. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  70533. /**
  70534. * Defines the name of the task
  70535. */
  70536. name: string;
  70537. /**
  70538. * Defines the location of the file to load
  70539. */
  70540. url: string;
  70541. /**
  70542. * Defines if mipmap should not be generated (default is false)
  70543. */
  70544. noMipmap?: boolean | undefined;
  70545. /**
  70546. * Defines if texture must be inverted on Y axis (default is true)
  70547. */
  70548. invertY: boolean;
  70549. /**
  70550. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  70551. */
  70552. samplingMode: number;
  70553. /**
  70554. * Gets the loaded texture
  70555. */
  70556. texture: Texture;
  70557. /**
  70558. * Callback called when the task is successful
  70559. */
  70560. onSuccess: (task: TextureAssetTask) => void;
  70561. /**
  70562. * Callback called when the task is successful
  70563. */
  70564. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  70565. /**
  70566. * Creates a new TextureAssetTask object
  70567. * @param name defines the name of the task
  70568. * @param url defines the location of the file to load
  70569. * @param noMipmap defines if mipmap should not be generated (default is false)
  70570. * @param invertY defines if texture must be inverted on Y axis (default is true)
  70571. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  70572. */
  70573. constructor(
  70574. /**
  70575. * Defines the name of the task
  70576. */
  70577. name: string,
  70578. /**
  70579. * Defines the location of the file to load
  70580. */
  70581. url: string,
  70582. /**
  70583. * Defines if mipmap should not be generated (default is false)
  70584. */
  70585. noMipmap?: boolean | undefined,
  70586. /**
  70587. * Defines if texture must be inverted on Y axis (default is true)
  70588. */
  70589. invertY?: boolean,
  70590. /**
  70591. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  70592. */
  70593. samplingMode?: number);
  70594. /**
  70595. * Execute the current task
  70596. * @param scene defines the scene where you want your assets to be loaded
  70597. * @param onSuccess is a callback called when the task is successfully executed
  70598. * @param onError is a callback called if an error occurs
  70599. */
  70600. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70601. }
  70602. /**
  70603. * Define a task used by AssetsManager to load cube textures
  70604. */
  70605. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  70606. /**
  70607. * Defines the name of the task
  70608. */
  70609. name: string;
  70610. /**
  70611. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  70612. */
  70613. url: string;
  70614. /**
  70615. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  70616. */
  70617. extensions?: string[] | undefined;
  70618. /**
  70619. * Defines if mipmaps should not be generated (default is false)
  70620. */
  70621. noMipmap?: boolean | undefined;
  70622. /**
  70623. * Defines the explicit list of files (undefined by default)
  70624. */
  70625. files?: string[] | undefined;
  70626. /**
  70627. * Gets the loaded texture
  70628. */
  70629. texture: CubeTexture;
  70630. /**
  70631. * Callback called when the task is successful
  70632. */
  70633. onSuccess: (task: CubeTextureAssetTask) => void;
  70634. /**
  70635. * Callback called when the task is successful
  70636. */
  70637. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  70638. /**
  70639. * Creates a new CubeTextureAssetTask
  70640. * @param name defines the name of the task
  70641. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  70642. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  70643. * @param noMipmap defines if mipmaps should not be generated (default is false)
  70644. * @param files defines the explicit list of files (undefined by default)
  70645. */
  70646. constructor(
  70647. /**
  70648. * Defines the name of the task
  70649. */
  70650. name: string,
  70651. /**
  70652. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  70653. */
  70654. url: string,
  70655. /**
  70656. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  70657. */
  70658. extensions?: string[] | undefined,
  70659. /**
  70660. * Defines if mipmaps should not be generated (default is false)
  70661. */
  70662. noMipmap?: boolean | undefined,
  70663. /**
  70664. * Defines the explicit list of files (undefined by default)
  70665. */
  70666. files?: string[] | undefined);
  70667. /**
  70668. * Execute the current task
  70669. * @param scene defines the scene where you want your assets to be loaded
  70670. * @param onSuccess is a callback called when the task is successfully executed
  70671. * @param onError is a callback called if an error occurs
  70672. */
  70673. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70674. }
  70675. /**
  70676. * Define a task used by AssetsManager to load HDR cube textures
  70677. */
  70678. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  70679. /**
  70680. * Defines the name of the task
  70681. */
  70682. name: string;
  70683. /**
  70684. * Defines the location of the file to load
  70685. */
  70686. url: string;
  70687. /**
  70688. * Defines the desired size (the more it increases the longer the generation will be)
  70689. */
  70690. size: number;
  70691. /**
  70692. * Defines if mipmaps should not be generated (default is false)
  70693. */
  70694. noMipmap: boolean;
  70695. /**
  70696. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  70697. */
  70698. generateHarmonics: boolean;
  70699. /**
  70700. * 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)
  70701. */
  70702. gammaSpace: boolean;
  70703. /**
  70704. * Internal Use Only
  70705. */
  70706. reserved: boolean;
  70707. /**
  70708. * Gets the loaded texture
  70709. */
  70710. texture: HDRCubeTexture;
  70711. /**
  70712. * Callback called when the task is successful
  70713. */
  70714. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  70715. /**
  70716. * Callback called when the task is successful
  70717. */
  70718. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  70719. /**
  70720. * Creates a new HDRCubeTextureAssetTask object
  70721. * @param name defines the name of the task
  70722. * @param url defines the location of the file to load
  70723. * @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.
  70724. * @param noMipmap defines if mipmaps should not be generated (default is false)
  70725. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  70726. * @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)
  70727. * @param reserved Internal use only
  70728. */
  70729. constructor(
  70730. /**
  70731. * Defines the name of the task
  70732. */
  70733. name: string,
  70734. /**
  70735. * Defines the location of the file to load
  70736. */
  70737. url: string,
  70738. /**
  70739. * Defines the desired size (the more it increases the longer the generation will be)
  70740. */
  70741. size: number,
  70742. /**
  70743. * Defines if mipmaps should not be generated (default is false)
  70744. */
  70745. noMipmap?: boolean,
  70746. /**
  70747. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  70748. */
  70749. generateHarmonics?: boolean,
  70750. /**
  70751. * 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)
  70752. */
  70753. gammaSpace?: boolean,
  70754. /**
  70755. * Internal Use Only
  70756. */
  70757. reserved?: boolean);
  70758. /**
  70759. * Execute the current task
  70760. * @param scene defines the scene where you want your assets to be loaded
  70761. * @param onSuccess is a callback called when the task is successfully executed
  70762. * @param onError is a callback called if an error occurs
  70763. */
  70764. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70765. }
  70766. /**
  70767. * Define a task used by AssetsManager to load Equirectangular cube textures
  70768. */
  70769. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  70770. /**
  70771. * Defines the name of the task
  70772. */
  70773. name: string;
  70774. /**
  70775. * Defines the location of the file to load
  70776. */
  70777. url: string;
  70778. /**
  70779. * Defines the desired size (the more it increases the longer the generation will be)
  70780. */
  70781. size: number;
  70782. /**
  70783. * Defines if mipmaps should not be generated (default is false)
  70784. */
  70785. noMipmap: boolean;
  70786. /**
  70787. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  70788. * but the standard material would require them in Gamma space) (default is true)
  70789. */
  70790. gammaSpace: boolean;
  70791. /**
  70792. * Gets the loaded texture
  70793. */
  70794. texture: EquiRectangularCubeTexture;
  70795. /**
  70796. * Callback called when the task is successful
  70797. */
  70798. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  70799. /**
  70800. * Callback called when the task is successful
  70801. */
  70802. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  70803. /**
  70804. * Creates a new EquiRectangularCubeTextureAssetTask object
  70805. * @param name defines the name of the task
  70806. * @param url defines the location of the file to load
  70807. * @param size defines the desired size (the more it increases the longer the generation will be)
  70808. * If the size is omitted this implies you are using a preprocessed cubemap.
  70809. * @param noMipmap defines if mipmaps should not be generated (default is false)
  70810. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  70811. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  70812. * (default is true)
  70813. */
  70814. constructor(
  70815. /**
  70816. * Defines the name of the task
  70817. */
  70818. name: string,
  70819. /**
  70820. * Defines the location of the file to load
  70821. */
  70822. url: string,
  70823. /**
  70824. * Defines the desired size (the more it increases the longer the generation will be)
  70825. */
  70826. size: number,
  70827. /**
  70828. * Defines if mipmaps should not be generated (default is false)
  70829. */
  70830. noMipmap?: boolean,
  70831. /**
  70832. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  70833. * but the standard material would require them in Gamma space) (default is true)
  70834. */
  70835. gammaSpace?: boolean);
  70836. /**
  70837. * Execute the current task
  70838. * @param scene defines the scene where you want your assets to be loaded
  70839. * @param onSuccess is a callback called when the task is successfully executed
  70840. * @param onError is a callback called if an error occurs
  70841. */
  70842. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70843. }
  70844. /**
  70845. * This class can be used to easily import assets into a scene
  70846. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  70847. */
  70848. export class AssetsManager {
  70849. private _scene;
  70850. private _isLoading;
  70851. protected _tasks: AbstractAssetTask[];
  70852. protected _waitingTasksCount: number;
  70853. protected _totalTasksCount: number;
  70854. /**
  70855. * Callback called when all tasks are processed
  70856. */
  70857. onFinish: (tasks: AbstractAssetTask[]) => void;
  70858. /**
  70859. * Callback called when a task is successful
  70860. */
  70861. onTaskSuccess: (task: AbstractAssetTask) => void;
  70862. /**
  70863. * Callback called when a task had an error
  70864. */
  70865. onTaskError: (task: AbstractAssetTask) => void;
  70866. /**
  70867. * Callback called when a task is done (whatever the result is)
  70868. */
  70869. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  70870. /**
  70871. * Observable called when all tasks are processed
  70872. */
  70873. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  70874. /**
  70875. * Observable called when a task had an error
  70876. */
  70877. onTaskErrorObservable: Observable<AbstractAssetTask>;
  70878. /**
  70879. * Observable called when all tasks were executed
  70880. */
  70881. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  70882. /**
  70883. * Observable called when a task is done (whatever the result is)
  70884. */
  70885. onProgressObservable: Observable<IAssetsProgressEvent>;
  70886. /**
  70887. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  70888. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  70889. */
  70890. useDefaultLoadingScreen: boolean;
  70891. /**
  70892. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  70893. * when all assets have been downloaded.
  70894. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  70895. */
  70896. autoHideLoadingUI: boolean;
  70897. /**
  70898. * Creates a new AssetsManager
  70899. * @param scene defines the scene to work on
  70900. */
  70901. constructor(scene: Scene);
  70902. /**
  70903. * Add a MeshAssetTask to the list of active tasks
  70904. * @param taskName defines the name of the new task
  70905. * @param meshesNames defines the name of meshes to load
  70906. * @param rootUrl defines the root url to use to locate files
  70907. * @param sceneFilename defines the filename of the scene file
  70908. * @returns a new MeshAssetTask object
  70909. */
  70910. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  70911. /**
  70912. * Add a TextFileAssetTask to the list of active tasks
  70913. * @param taskName defines the name of the new task
  70914. * @param url defines the url of the file to load
  70915. * @returns a new TextFileAssetTask object
  70916. */
  70917. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  70918. /**
  70919. * Add a BinaryFileAssetTask to the list of active tasks
  70920. * @param taskName defines the name of the new task
  70921. * @param url defines the url of the file to load
  70922. * @returns a new BinaryFileAssetTask object
  70923. */
  70924. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  70925. /**
  70926. * Add a ImageAssetTask to the list of active tasks
  70927. * @param taskName defines the name of the new task
  70928. * @param url defines the url of the file to load
  70929. * @returns a new ImageAssetTask object
  70930. */
  70931. addImageTask(taskName: string, url: string): ImageAssetTask;
  70932. /**
  70933. * Add a TextureAssetTask to the list of active tasks
  70934. * @param taskName defines the name of the new task
  70935. * @param url defines the url of the file to load
  70936. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  70937. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  70938. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  70939. * @returns a new TextureAssetTask object
  70940. */
  70941. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  70942. /**
  70943. * Add a CubeTextureAssetTask to the list of active tasks
  70944. * @param taskName defines the name of the new task
  70945. * @param url defines the url of the file to load
  70946. * @param extensions defines the extension to use to load the cube map (can be null)
  70947. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  70948. * @param files defines the list of files to load (can be null)
  70949. * @returns a new CubeTextureAssetTask object
  70950. */
  70951. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  70952. /**
  70953. *
  70954. * Add a HDRCubeTextureAssetTask to the list of active tasks
  70955. * @param taskName defines the name of the new task
  70956. * @param url defines the url of the file to load
  70957. * @param size defines the size you want for the cubemap (can be null)
  70958. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  70959. * @param generateHarmonics defines if you want to automatically generate (true by default)
  70960. * @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)
  70961. * @param reserved Internal use only
  70962. * @returns a new HDRCubeTextureAssetTask object
  70963. */
  70964. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  70965. /**
  70966. *
  70967. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  70968. * @param taskName defines the name of the new task
  70969. * @param url defines the url of the file to load
  70970. * @param size defines the size you want for the cubemap (can be null)
  70971. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  70972. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  70973. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  70974. * @returns a new EquiRectangularCubeTextureAssetTask object
  70975. */
  70976. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  70977. /**
  70978. * Remove a task from the assets manager.
  70979. * @param task the task to remove
  70980. */
  70981. removeTask(task: AbstractAssetTask): void;
  70982. private _decreaseWaitingTasksCount;
  70983. private _runTask;
  70984. /**
  70985. * Reset the AssetsManager and remove all tasks
  70986. * @return the current instance of the AssetsManager
  70987. */
  70988. reset(): AssetsManager;
  70989. /**
  70990. * Start the loading process
  70991. * @return the current instance of the AssetsManager
  70992. */
  70993. load(): AssetsManager;
  70994. /**
  70995. * Start the loading process as an async operation
  70996. * @return a promise returning the list of failed tasks
  70997. */
  70998. loadAsync(): Promise<void>;
  70999. }
  71000. }
  71001. declare module BABYLON {
  71002. /**
  71003. * Wrapper class for promise with external resolve and reject.
  71004. */
  71005. export class Deferred<T> {
  71006. /**
  71007. * The promise associated with this deferred object.
  71008. */
  71009. readonly promise: Promise<T>;
  71010. private _resolve;
  71011. private _reject;
  71012. /**
  71013. * The resolve method of the promise associated with this deferred object.
  71014. */
  71015. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  71016. /**
  71017. * The reject method of the promise associated with this deferred object.
  71018. */
  71019. get reject(): (reason?: any) => void;
  71020. /**
  71021. * Constructor for this deferred object.
  71022. */
  71023. constructor();
  71024. }
  71025. }
  71026. declare module BABYLON {
  71027. /**
  71028. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  71029. */
  71030. export class MeshExploder {
  71031. private _centerMesh;
  71032. private _meshes;
  71033. private _meshesOrigins;
  71034. private _toCenterVectors;
  71035. private _scaledDirection;
  71036. private _newPosition;
  71037. private _centerPosition;
  71038. /**
  71039. * Explodes meshes from a center mesh.
  71040. * @param meshes The meshes to explode.
  71041. * @param centerMesh The mesh to be center of explosion.
  71042. */
  71043. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  71044. private _setCenterMesh;
  71045. /**
  71046. * Get class name
  71047. * @returns "MeshExploder"
  71048. */
  71049. getClassName(): string;
  71050. /**
  71051. * "Exploded meshes"
  71052. * @returns Array of meshes with the centerMesh at index 0.
  71053. */
  71054. getMeshes(): Array<Mesh>;
  71055. /**
  71056. * Explodes meshes giving a specific direction
  71057. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  71058. */
  71059. explode(direction?: number): void;
  71060. }
  71061. }
  71062. declare module BABYLON {
  71063. /**
  71064. * Class used to help managing file picking and drag'n'drop
  71065. */
  71066. export class FilesInput {
  71067. /**
  71068. * List of files ready to be loaded
  71069. */
  71070. static get FilesToLoad(): {
  71071. [key: string]: File;
  71072. };
  71073. /**
  71074. * Callback called when a file is processed
  71075. */
  71076. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  71077. private _engine;
  71078. private _currentScene;
  71079. private _sceneLoadedCallback;
  71080. private _progressCallback;
  71081. private _additionalRenderLoopLogicCallback;
  71082. private _textureLoadingCallback;
  71083. private _startingProcessingFilesCallback;
  71084. private _onReloadCallback;
  71085. private _errorCallback;
  71086. private _elementToMonitor;
  71087. private _sceneFileToLoad;
  71088. private _filesToLoad;
  71089. /**
  71090. * Creates a new FilesInput
  71091. * @param engine defines the rendering engine
  71092. * @param scene defines the hosting scene
  71093. * @param sceneLoadedCallback callback called when scene is loaded
  71094. * @param progressCallback callback called to track progress
  71095. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  71096. * @param textureLoadingCallback callback called when a texture is loading
  71097. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  71098. * @param onReloadCallback callback called when a reload is requested
  71099. * @param errorCallback callback call if an error occurs
  71100. */
  71101. 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);
  71102. private _dragEnterHandler;
  71103. private _dragOverHandler;
  71104. private _dropHandler;
  71105. /**
  71106. * Calls this function to listen to drag'n'drop events on a specific DOM element
  71107. * @param elementToMonitor defines the DOM element to track
  71108. */
  71109. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  71110. /**
  71111. * Release all associated resources
  71112. */
  71113. dispose(): void;
  71114. private renderFunction;
  71115. private drag;
  71116. private drop;
  71117. private _traverseFolder;
  71118. private _processFiles;
  71119. /**
  71120. * Load files from a drop event
  71121. * @param event defines the drop event to use as source
  71122. */
  71123. loadFiles(event: any): void;
  71124. private _processReload;
  71125. /**
  71126. * Reload the current scene from the loaded files
  71127. */
  71128. reload(): void;
  71129. }
  71130. }
  71131. declare module BABYLON {
  71132. /**
  71133. * Defines the root class used to create scene optimization to use with SceneOptimizer
  71134. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71135. */
  71136. export class SceneOptimization {
  71137. /**
  71138. * Defines the priority of this optimization (0 by default which means first in the list)
  71139. */
  71140. priority: number;
  71141. /**
  71142. * Gets a string describing the action executed by the current optimization
  71143. * @returns description string
  71144. */
  71145. getDescription(): string;
  71146. /**
  71147. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71148. * @param scene defines the current scene where to apply this optimization
  71149. * @param optimizer defines the current optimizer
  71150. * @returns true if everything that can be done was applied
  71151. */
  71152. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71153. /**
  71154. * Creates the SceneOptimization object
  71155. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71156. * @param desc defines the description associated with the optimization
  71157. */
  71158. constructor(
  71159. /**
  71160. * Defines the priority of this optimization (0 by default which means first in the list)
  71161. */
  71162. priority?: number);
  71163. }
  71164. /**
  71165. * Defines an optimization used to reduce the size of render target textures
  71166. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71167. */
  71168. export class TextureOptimization extends SceneOptimization {
  71169. /**
  71170. * Defines the priority of this optimization (0 by default which means first in the list)
  71171. */
  71172. priority: number;
  71173. /**
  71174. * 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
  71175. */
  71176. maximumSize: number;
  71177. /**
  71178. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71179. */
  71180. step: number;
  71181. /**
  71182. * Gets a string describing the action executed by the current optimization
  71183. * @returns description string
  71184. */
  71185. getDescription(): string;
  71186. /**
  71187. * Creates the TextureOptimization object
  71188. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71189. * @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
  71190. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71191. */
  71192. constructor(
  71193. /**
  71194. * Defines the priority of this optimization (0 by default which means first in the list)
  71195. */
  71196. priority?: number,
  71197. /**
  71198. * 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
  71199. */
  71200. maximumSize?: number,
  71201. /**
  71202. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71203. */
  71204. step?: number);
  71205. /**
  71206. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71207. * @param scene defines the current scene where to apply this optimization
  71208. * @param optimizer defines the current optimizer
  71209. * @returns true if everything that can be done was applied
  71210. */
  71211. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71212. }
  71213. /**
  71214. * Defines an optimization used to increase or decrease the rendering resolution
  71215. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71216. */
  71217. export class HardwareScalingOptimization extends SceneOptimization {
  71218. /**
  71219. * Defines the priority of this optimization (0 by default which means first in the list)
  71220. */
  71221. priority: number;
  71222. /**
  71223. * Defines the maximum scale to use (2 by default)
  71224. */
  71225. maximumScale: number;
  71226. /**
  71227. * Defines the step to use between two passes (0.5 by default)
  71228. */
  71229. step: number;
  71230. private _currentScale;
  71231. private _directionOffset;
  71232. /**
  71233. * Gets a string describing the action executed by the current optimization
  71234. * @return description string
  71235. */
  71236. getDescription(): string;
  71237. /**
  71238. * Creates the HardwareScalingOptimization object
  71239. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71240. * @param maximumScale defines the maximum scale to use (2 by default)
  71241. * @param step defines the step to use between two passes (0.5 by default)
  71242. */
  71243. constructor(
  71244. /**
  71245. * Defines the priority of this optimization (0 by default which means first in the list)
  71246. */
  71247. priority?: number,
  71248. /**
  71249. * Defines the maximum scale to use (2 by default)
  71250. */
  71251. maximumScale?: number,
  71252. /**
  71253. * Defines the step to use between two passes (0.5 by default)
  71254. */
  71255. step?: number);
  71256. /**
  71257. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71258. * @param scene defines the current scene where to apply this optimization
  71259. * @param optimizer defines the current optimizer
  71260. * @returns true if everything that can be done was applied
  71261. */
  71262. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71263. }
  71264. /**
  71265. * Defines an optimization used to remove shadows
  71266. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71267. */
  71268. export class ShadowsOptimization extends SceneOptimization {
  71269. /**
  71270. * Gets a string describing the action executed by the current optimization
  71271. * @return description string
  71272. */
  71273. getDescription(): string;
  71274. /**
  71275. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71276. * @param scene defines the current scene where to apply this optimization
  71277. * @param optimizer defines the current optimizer
  71278. * @returns true if everything that can be done was applied
  71279. */
  71280. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71281. }
  71282. /**
  71283. * Defines an optimization used to turn post-processes off
  71284. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71285. */
  71286. export class PostProcessesOptimization extends SceneOptimization {
  71287. /**
  71288. * Gets a string describing the action executed by the current optimization
  71289. * @return description string
  71290. */
  71291. getDescription(): string;
  71292. /**
  71293. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71294. * @param scene defines the current scene where to apply this optimization
  71295. * @param optimizer defines the current optimizer
  71296. * @returns true if everything that can be done was applied
  71297. */
  71298. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71299. }
  71300. /**
  71301. * Defines an optimization used to turn lens flares off
  71302. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71303. */
  71304. export class LensFlaresOptimization extends SceneOptimization {
  71305. /**
  71306. * Gets a string describing the action executed by the current optimization
  71307. * @return description string
  71308. */
  71309. getDescription(): string;
  71310. /**
  71311. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71312. * @param scene defines the current scene where to apply this optimization
  71313. * @param optimizer defines the current optimizer
  71314. * @returns true if everything that can be done was applied
  71315. */
  71316. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71317. }
  71318. /**
  71319. * Defines an optimization based on user defined callback.
  71320. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71321. */
  71322. export class CustomOptimization extends SceneOptimization {
  71323. /**
  71324. * Callback called to apply the custom optimization.
  71325. */
  71326. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  71327. /**
  71328. * Callback called to get custom description
  71329. */
  71330. onGetDescription: () => string;
  71331. /**
  71332. * Gets a string describing the action executed by the current optimization
  71333. * @returns description string
  71334. */
  71335. getDescription(): string;
  71336. /**
  71337. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71338. * @param scene defines the current scene where to apply this optimization
  71339. * @param optimizer defines the current optimizer
  71340. * @returns true if everything that can be done was applied
  71341. */
  71342. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71343. }
  71344. /**
  71345. * Defines an optimization used to turn particles off
  71346. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71347. */
  71348. export class ParticlesOptimization extends SceneOptimization {
  71349. /**
  71350. * Gets a string describing the action executed by the current optimization
  71351. * @return description string
  71352. */
  71353. getDescription(): string;
  71354. /**
  71355. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71356. * @param scene defines the current scene where to apply this optimization
  71357. * @param optimizer defines the current optimizer
  71358. * @returns true if everything that can be done was applied
  71359. */
  71360. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71361. }
  71362. /**
  71363. * Defines an optimization used to turn render targets off
  71364. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71365. */
  71366. export class RenderTargetsOptimization extends SceneOptimization {
  71367. /**
  71368. * Gets a string describing the action executed by the current optimization
  71369. * @return description string
  71370. */
  71371. getDescription(): string;
  71372. /**
  71373. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71374. * @param scene defines the current scene where to apply this optimization
  71375. * @param optimizer defines the current optimizer
  71376. * @returns true if everything that can be done was applied
  71377. */
  71378. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71379. }
  71380. /**
  71381. * Defines an optimization used to merge meshes with compatible materials
  71382. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71383. */
  71384. export class MergeMeshesOptimization extends SceneOptimization {
  71385. private static _UpdateSelectionTree;
  71386. /**
  71387. * Gets or sets a boolean which defines if optimization octree has to be updated
  71388. */
  71389. static get UpdateSelectionTree(): boolean;
  71390. /**
  71391. * Gets or sets a boolean which defines if optimization octree has to be updated
  71392. */
  71393. static set UpdateSelectionTree(value: boolean);
  71394. /**
  71395. * Gets a string describing the action executed by the current optimization
  71396. * @return description string
  71397. */
  71398. getDescription(): string;
  71399. private _canBeMerged;
  71400. /**
  71401. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71402. * @param scene defines the current scene where to apply this optimization
  71403. * @param optimizer defines the current optimizer
  71404. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  71405. * @returns true if everything that can be done was applied
  71406. */
  71407. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  71408. }
  71409. /**
  71410. * Defines a list of options used by SceneOptimizer
  71411. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71412. */
  71413. export class SceneOptimizerOptions {
  71414. /**
  71415. * Defines the target frame rate to reach (60 by default)
  71416. */
  71417. targetFrameRate: number;
  71418. /**
  71419. * Defines the interval between two checkes (2000ms by default)
  71420. */
  71421. trackerDuration: number;
  71422. /**
  71423. * Gets the list of optimizations to apply
  71424. */
  71425. optimizations: SceneOptimization[];
  71426. /**
  71427. * Creates a new list of options used by SceneOptimizer
  71428. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  71429. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  71430. */
  71431. constructor(
  71432. /**
  71433. * Defines the target frame rate to reach (60 by default)
  71434. */
  71435. targetFrameRate?: number,
  71436. /**
  71437. * Defines the interval between two checkes (2000ms by default)
  71438. */
  71439. trackerDuration?: number);
  71440. /**
  71441. * Add a new optimization
  71442. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  71443. * @returns the current SceneOptimizerOptions
  71444. */
  71445. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  71446. /**
  71447. * Add a new custom optimization
  71448. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  71449. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  71450. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71451. * @returns the current SceneOptimizerOptions
  71452. */
  71453. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  71454. /**
  71455. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  71456. * @param targetFrameRate defines the target frame rate (60 by default)
  71457. * @returns a SceneOptimizerOptions object
  71458. */
  71459. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71460. /**
  71461. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  71462. * @param targetFrameRate defines the target frame rate (60 by default)
  71463. * @returns a SceneOptimizerOptions object
  71464. */
  71465. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71466. /**
  71467. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  71468. * @param targetFrameRate defines the target frame rate (60 by default)
  71469. * @returns a SceneOptimizerOptions object
  71470. */
  71471. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71472. }
  71473. /**
  71474. * Class used to run optimizations in order to reach a target frame rate
  71475. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71476. */
  71477. export class SceneOptimizer implements IDisposable {
  71478. private _isRunning;
  71479. private _options;
  71480. private _scene;
  71481. private _currentPriorityLevel;
  71482. private _targetFrameRate;
  71483. private _trackerDuration;
  71484. private _currentFrameRate;
  71485. private _sceneDisposeObserver;
  71486. private _improvementMode;
  71487. /**
  71488. * Defines an observable called when the optimizer reaches the target frame rate
  71489. */
  71490. onSuccessObservable: Observable<SceneOptimizer>;
  71491. /**
  71492. * Defines an observable called when the optimizer enables an optimization
  71493. */
  71494. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  71495. /**
  71496. * Defines an observable called when the optimizer is not able to reach the target frame rate
  71497. */
  71498. onFailureObservable: Observable<SceneOptimizer>;
  71499. /**
  71500. * Gets a boolean indicating if the optimizer is in improvement mode
  71501. */
  71502. get isInImprovementMode(): boolean;
  71503. /**
  71504. * Gets the current priority level (0 at start)
  71505. */
  71506. get currentPriorityLevel(): number;
  71507. /**
  71508. * Gets the current frame rate checked by the SceneOptimizer
  71509. */
  71510. get currentFrameRate(): number;
  71511. /**
  71512. * Gets or sets the current target frame rate (60 by default)
  71513. */
  71514. get targetFrameRate(): number;
  71515. /**
  71516. * Gets or sets the current target frame rate (60 by default)
  71517. */
  71518. set targetFrameRate(value: number);
  71519. /**
  71520. * Gets or sets the current interval between two checks (every 2000ms by default)
  71521. */
  71522. get trackerDuration(): number;
  71523. /**
  71524. * Gets or sets the current interval between two checks (every 2000ms by default)
  71525. */
  71526. set trackerDuration(value: number);
  71527. /**
  71528. * Gets the list of active optimizations
  71529. */
  71530. get optimizations(): SceneOptimization[];
  71531. /**
  71532. * Creates a new SceneOptimizer
  71533. * @param scene defines the scene to work on
  71534. * @param options defines the options to use with the SceneOptimizer
  71535. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  71536. * @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)
  71537. */
  71538. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  71539. /**
  71540. * Stops the current optimizer
  71541. */
  71542. stop(): void;
  71543. /**
  71544. * Reset the optimizer to initial step (current priority level = 0)
  71545. */
  71546. reset(): void;
  71547. /**
  71548. * Start the optimizer. By default it will try to reach a specific framerate
  71549. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  71550. */
  71551. start(): void;
  71552. private _checkCurrentState;
  71553. /**
  71554. * Release all resources
  71555. */
  71556. dispose(): void;
  71557. /**
  71558. * Helper function to create a SceneOptimizer with one single line of code
  71559. * @param scene defines the scene to work on
  71560. * @param options defines the options to use with the SceneOptimizer
  71561. * @param onSuccess defines a callback to call on success
  71562. * @param onFailure defines a callback to call on failure
  71563. * @returns the new SceneOptimizer object
  71564. */
  71565. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  71566. }
  71567. }
  71568. declare module BABYLON {
  71569. /**
  71570. * Class used to serialize a scene into a string
  71571. */
  71572. export class SceneSerializer {
  71573. /**
  71574. * Clear cache used by a previous serialization
  71575. */
  71576. static ClearCache(): void;
  71577. /**
  71578. * Serialize a scene into a JSON compatible object
  71579. * @param scene defines the scene to serialize
  71580. * @returns a JSON compatible object
  71581. */
  71582. static Serialize(scene: Scene): any;
  71583. /**
  71584. * Serialize a mesh into a JSON compatible object
  71585. * @param toSerialize defines the mesh to serialize
  71586. * @param withParents defines if parents must be serialized as well
  71587. * @param withChildren defines if children must be serialized as well
  71588. * @returns a JSON compatible object
  71589. */
  71590. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  71591. }
  71592. }
  71593. declare module BABYLON {
  71594. /**
  71595. * Class used to host texture specific utilities
  71596. */
  71597. export class TextureTools {
  71598. /**
  71599. * Uses the GPU to create a copy texture rescaled at a given size
  71600. * @param texture Texture to copy from
  71601. * @param width defines the desired width
  71602. * @param height defines the desired height
  71603. * @param useBilinearMode defines if bilinear mode has to be used
  71604. * @return the generated texture
  71605. */
  71606. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  71607. }
  71608. }
  71609. declare module BABYLON {
  71610. /**
  71611. * This represents the different options available for the video capture.
  71612. */
  71613. export interface VideoRecorderOptions {
  71614. /** Defines the mime type of the video. */
  71615. mimeType: string;
  71616. /** Defines the FPS the video should be recorded at. */
  71617. fps: number;
  71618. /** Defines the chunk size for the recording data. */
  71619. recordChunckSize: number;
  71620. /** The audio tracks to attach to the recording. */
  71621. audioTracks?: MediaStreamTrack[];
  71622. }
  71623. /**
  71624. * This can help with recording videos from BabylonJS.
  71625. * This is based on the available WebRTC functionalities of the browser.
  71626. *
  71627. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  71628. */
  71629. export class VideoRecorder {
  71630. private static readonly _defaultOptions;
  71631. /**
  71632. * Returns whether or not the VideoRecorder is available in your browser.
  71633. * @param engine Defines the Babylon Engine.
  71634. * @returns true if supported otherwise false.
  71635. */
  71636. static IsSupported(engine: Engine): boolean;
  71637. private readonly _options;
  71638. private _canvas;
  71639. private _mediaRecorder;
  71640. private _recordedChunks;
  71641. private _fileName;
  71642. private _resolve;
  71643. private _reject;
  71644. /**
  71645. * True when a recording is already in progress.
  71646. */
  71647. get isRecording(): boolean;
  71648. /**
  71649. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  71650. * @param engine Defines the BabylonJS Engine you wish to record.
  71651. * @param options Defines options that can be used to customize the capture.
  71652. */
  71653. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  71654. /**
  71655. * Stops the current recording before the default capture timeout passed in the startRecording function.
  71656. */
  71657. stopRecording(): void;
  71658. /**
  71659. * Starts recording the canvas for a max duration specified in parameters.
  71660. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  71661. * If null no automatic download will start and you can rely on the promise to get the data back.
  71662. * @param maxDuration Defines the maximum recording time in seconds.
  71663. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  71664. * @return A promise callback at the end of the recording with the video data in Blob.
  71665. */
  71666. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  71667. /**
  71668. * Releases internal resources used during the recording.
  71669. */
  71670. dispose(): void;
  71671. private _handleDataAvailable;
  71672. private _handleError;
  71673. private _handleStop;
  71674. }
  71675. }
  71676. declare module BABYLON {
  71677. /**
  71678. * Class containing a set of static utilities functions for screenshots
  71679. */
  71680. export class ScreenshotTools {
  71681. /**
  71682. * Captures a screenshot of the current rendering
  71683. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  71684. * @param engine defines the rendering engine
  71685. * @param camera defines the source camera
  71686. * @param size This parameter can be set to a single number or to an object with the
  71687. * following (optional) properties: precision, width, height. If a single number is passed,
  71688. * it will be used for both width and height. If an object is passed, the screenshot size
  71689. * will be derived from the parameters. The precision property is a multiplier allowing
  71690. * rendering at a higher or lower resolution
  71691. * @param successCallback defines the callback receives a single parameter which contains the
  71692. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  71693. * src parameter of an <img> to display it
  71694. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  71695. * Check your browser for supported MIME types
  71696. */
  71697. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  71698. /**
  71699. * Captures a screenshot of the current rendering
  71700. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  71701. * @param engine defines the rendering engine
  71702. * @param camera defines the source camera
  71703. * @param size This parameter can be set to a single number or to an object with the
  71704. * following (optional) properties: precision, width, height. If a single number is passed,
  71705. * it will be used for both width and height. If an object is passed, the screenshot size
  71706. * will be derived from the parameters. The precision property is a multiplier allowing
  71707. * rendering at a higher or lower resolution
  71708. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  71709. * Check your browser for supported MIME types
  71710. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  71711. * to the src parameter of an <img> to display it
  71712. */
  71713. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  71714. /**
  71715. * Generates an image screenshot from the specified camera.
  71716. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  71717. * @param engine The engine to use for rendering
  71718. * @param camera The camera to use for rendering
  71719. * @param size This parameter can be set to a single number or to an object with the
  71720. * following (optional) properties: precision, width, height. If a single number is passed,
  71721. * it will be used for both width and height. If an object is passed, the screenshot size
  71722. * will be derived from the parameters. The precision property is a multiplier allowing
  71723. * rendering at a higher or lower resolution
  71724. * @param successCallback The callback receives a single parameter which contains the
  71725. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  71726. * src parameter of an <img> to display it
  71727. * @param mimeType The MIME type of the screenshot image (default: image/png).
  71728. * Check your browser for supported MIME types
  71729. * @param samples Texture samples (default: 1)
  71730. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  71731. * @param fileName A name for for the downloaded file.
  71732. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  71733. */
  71734. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  71735. /**
  71736. * Generates an image screenshot from the specified camera.
  71737. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  71738. * @param engine The engine to use for rendering
  71739. * @param camera The camera to use for rendering
  71740. * @param size This parameter can be set to a single number or to an object with the
  71741. * following (optional) properties: precision, width, height. If a single number is passed,
  71742. * it will be used for both width and height. If an object is passed, the screenshot size
  71743. * will be derived from the parameters. The precision property is a multiplier allowing
  71744. * rendering at a higher or lower resolution
  71745. * @param mimeType The MIME type of the screenshot image (default: image/png).
  71746. * Check your browser for supported MIME types
  71747. * @param samples Texture samples (default: 1)
  71748. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  71749. * @param fileName A name for for the downloaded file.
  71750. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  71751. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  71752. * to the src parameter of an <img> to display it
  71753. */
  71754. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  71755. /**
  71756. * Gets height and width for screenshot size
  71757. * @private
  71758. */
  71759. private static _getScreenshotSize;
  71760. }
  71761. }
  71762. declare module BABYLON {
  71763. /**
  71764. * Interface for a data buffer
  71765. */
  71766. export interface IDataBuffer {
  71767. /**
  71768. * Reads bytes from the data buffer.
  71769. * @param byteOffset The byte offset to read
  71770. * @param byteLength The byte length to read
  71771. * @returns A promise that resolves when the bytes are read
  71772. */
  71773. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  71774. /**
  71775. * The byte length of the buffer.
  71776. */
  71777. readonly byteLength: number;
  71778. }
  71779. /**
  71780. * Utility class for reading from a data buffer
  71781. */
  71782. export class DataReader {
  71783. /**
  71784. * The data buffer associated with this data reader.
  71785. */
  71786. readonly buffer: IDataBuffer;
  71787. /**
  71788. * The current byte offset from the beginning of the data buffer.
  71789. */
  71790. byteOffset: number;
  71791. private _dataView;
  71792. private _dataByteOffset;
  71793. /**
  71794. * Constructor
  71795. * @param buffer The buffer to read
  71796. */
  71797. constructor(buffer: IDataBuffer);
  71798. /**
  71799. * Loads the given byte length.
  71800. * @param byteLength The byte length to load
  71801. * @returns A promise that resolves when the load is complete
  71802. */
  71803. loadAsync(byteLength: number): Promise<void>;
  71804. /**
  71805. * Read a unsigned 32-bit integer from the currently loaded data range.
  71806. * @returns The 32-bit integer read
  71807. */
  71808. readUint32(): number;
  71809. /**
  71810. * Read a byte array from the currently loaded data range.
  71811. * @param byteLength The byte length to read
  71812. * @returns The byte array read
  71813. */
  71814. readUint8Array(byteLength: number): Uint8Array;
  71815. /**
  71816. * Read a string from the currently loaded data range.
  71817. * @param byteLength The byte length to read
  71818. * @returns The string read
  71819. */
  71820. readString(byteLength: number): string;
  71821. /**
  71822. * Skips the given byte length the currently loaded data range.
  71823. * @param byteLength The byte length to skip
  71824. */
  71825. skipBytes(byteLength: number): void;
  71826. }
  71827. }
  71828. declare module BABYLON {
  71829. /**
  71830. * Class for storing data to local storage if available or in-memory storage otherwise
  71831. */
  71832. export class DataStorage {
  71833. private static _Storage;
  71834. private static _GetStorage;
  71835. /**
  71836. * Reads a string from the data storage
  71837. * @param key The key to read
  71838. * @param defaultValue The value if the key doesn't exist
  71839. * @returns The string value
  71840. */
  71841. static ReadString(key: string, defaultValue: string): string;
  71842. /**
  71843. * Writes a string to the data storage
  71844. * @param key The key to write
  71845. * @param value The value to write
  71846. */
  71847. static WriteString(key: string, value: string): void;
  71848. /**
  71849. * Reads a boolean from the data storage
  71850. * @param key The key to read
  71851. * @param defaultValue The value if the key doesn't exist
  71852. * @returns The boolean value
  71853. */
  71854. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  71855. /**
  71856. * Writes a boolean to the data storage
  71857. * @param key The key to write
  71858. * @param value The value to write
  71859. */
  71860. static WriteBoolean(key: string, value: boolean): void;
  71861. /**
  71862. * Reads a number from the data storage
  71863. * @param key The key to read
  71864. * @param defaultValue The value if the key doesn't exist
  71865. * @returns The number value
  71866. */
  71867. static ReadNumber(key: string, defaultValue: number): number;
  71868. /**
  71869. * Writes a number to the data storage
  71870. * @param key The key to write
  71871. * @param value The value to write
  71872. */
  71873. static WriteNumber(key: string, value: number): void;
  71874. }
  71875. }
  71876. declare module BABYLON {
  71877. /**
  71878. * Options used for hit testing
  71879. */
  71880. export interface IWebXRLegacyHitTestOptions {
  71881. /**
  71882. * Only test when user interacted with the scene. Default - hit test every frame
  71883. */
  71884. testOnPointerDownOnly?: boolean;
  71885. /**
  71886. * The node to use to transform the local results to world coordinates
  71887. */
  71888. worldParentNode?: TransformNode;
  71889. }
  71890. /**
  71891. * Interface defining the babylon result of raycasting/hit-test
  71892. */
  71893. export interface IWebXRLegacyHitResult {
  71894. /**
  71895. * Transformation matrix that can be applied to a node that will put it in the hit point location
  71896. */
  71897. transformationMatrix: Matrix;
  71898. /**
  71899. * The native hit test result
  71900. */
  71901. xrHitResult: XRHitResult | XRHitTestResult;
  71902. }
  71903. /**
  71904. * The currently-working hit-test module.
  71905. * Hit test (or Ray-casting) is used to interact with the real world.
  71906. * For further information read here - https://github.com/immersive-web/hit-test
  71907. */
  71908. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  71909. /**
  71910. * options to use when constructing this feature
  71911. */
  71912. readonly options: IWebXRLegacyHitTestOptions;
  71913. private _direction;
  71914. private _mat;
  71915. private _onSelectEnabled;
  71916. private _origin;
  71917. /**
  71918. * The module's name
  71919. */
  71920. static readonly Name: string;
  71921. /**
  71922. * The (Babylon) version of this module.
  71923. * This is an integer representing the implementation version.
  71924. * This number does not correspond to the WebXR specs version
  71925. */
  71926. static readonly Version: number;
  71927. /**
  71928. * Populated with the last native XR Hit Results
  71929. */
  71930. lastNativeXRHitResults: XRHitResult[];
  71931. /**
  71932. * Triggered when new babylon (transformed) hit test results are available
  71933. */
  71934. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  71935. /**
  71936. * Creates a new instance of the (legacy version) hit test feature
  71937. * @param _xrSessionManager an instance of WebXRSessionManager
  71938. * @param options options to use when constructing this feature
  71939. */
  71940. constructor(_xrSessionManager: WebXRSessionManager,
  71941. /**
  71942. * options to use when constructing this feature
  71943. */
  71944. options?: IWebXRLegacyHitTestOptions);
  71945. /**
  71946. * execute a hit test with an XR Ray
  71947. *
  71948. * @param xrSession a native xrSession that will execute this hit test
  71949. * @param xrRay the ray (position and direction) to use for ray-casting
  71950. * @param referenceSpace native XR reference space to use for the hit-test
  71951. * @param filter filter function that will filter the results
  71952. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  71953. */
  71954. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  71955. /**
  71956. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  71957. * @param event the (select) event to use to select with
  71958. * @param referenceSpace the reference space to use for this hit test
  71959. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  71960. */
  71961. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  71962. /**
  71963. * attach this feature
  71964. * Will usually be called by the features manager
  71965. *
  71966. * @returns true if successful.
  71967. */
  71968. attach(): boolean;
  71969. /**
  71970. * detach this feature.
  71971. * Will usually be called by the features manager
  71972. *
  71973. * @returns true if successful.
  71974. */
  71975. detach(): boolean;
  71976. /**
  71977. * Dispose this feature and all of the resources attached
  71978. */
  71979. dispose(): void;
  71980. protected _onXRFrame(frame: XRFrame): void;
  71981. private _onHitTestResults;
  71982. private _onSelect;
  71983. }
  71984. }
  71985. declare module BABYLON {
  71986. /**
  71987. * Options used in the plane detector module
  71988. */
  71989. export interface IWebXRPlaneDetectorOptions {
  71990. /**
  71991. * The node to use to transform the local results to world coordinates
  71992. */
  71993. worldParentNode?: TransformNode;
  71994. }
  71995. /**
  71996. * A babylon interface for a WebXR plane.
  71997. * A Plane is actually a polygon, built from N points in space
  71998. *
  71999. * Supported in chrome 79, not supported in canary 81 ATM
  72000. */
  72001. export interface IWebXRPlane {
  72002. /**
  72003. * a babylon-assigned ID for this polygon
  72004. */
  72005. id: number;
  72006. /**
  72007. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  72008. */
  72009. polygonDefinition: Array<Vector3>;
  72010. /**
  72011. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  72012. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  72013. */
  72014. transformationMatrix: Matrix;
  72015. /**
  72016. * the native xr-plane object
  72017. */
  72018. xrPlane: XRPlane;
  72019. }
  72020. /**
  72021. * The plane detector is used to detect planes in the real world when in AR
  72022. * For more information see https://github.com/immersive-web/real-world-geometry/
  72023. */
  72024. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  72025. private _options;
  72026. private _detectedPlanes;
  72027. private _enabled;
  72028. private _lastFrameDetected;
  72029. /**
  72030. * The module's name
  72031. */
  72032. static readonly Name: string;
  72033. /**
  72034. * The (Babylon) version of this module.
  72035. * This is an integer representing the implementation version.
  72036. * This number does not correspond to the WebXR specs version
  72037. */
  72038. static readonly Version: number;
  72039. /**
  72040. * Observers registered here will be executed when a new plane was added to the session
  72041. */
  72042. onPlaneAddedObservable: Observable<IWebXRPlane>;
  72043. /**
  72044. * Observers registered here will be executed when a plane is no longer detected in the session
  72045. */
  72046. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  72047. /**
  72048. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  72049. * This can execute N times every frame
  72050. */
  72051. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  72052. /**
  72053. * construct a new Plane Detector
  72054. * @param _xrSessionManager an instance of xr Session manager
  72055. * @param _options configuration to use when constructing this feature
  72056. */
  72057. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  72058. /**
  72059. * Dispose this feature and all of the resources attached
  72060. */
  72061. dispose(): void;
  72062. protected _onXRFrame(frame: XRFrame): void;
  72063. private _init;
  72064. private _updatePlaneWithXRPlane;
  72065. /**
  72066. * avoiding using Array.find for global support.
  72067. * @param xrPlane the plane to find in the array
  72068. */
  72069. private findIndexInPlaneArray;
  72070. }
  72071. }
  72072. declare module BABYLON {
  72073. /**
  72074. * Configuration options of the anchor system
  72075. */
  72076. export interface IWebXRAnchorSystemOptions {
  72077. /**
  72078. * Should a new anchor be added every time a select event is triggered
  72079. */
  72080. addAnchorOnSelect?: boolean;
  72081. /**
  72082. * should the anchor system use plane detection.
  72083. * If set to true, the plane-detection feature should be set using setPlaneDetector
  72084. */
  72085. usePlaneDetection?: boolean;
  72086. /**
  72087. * a node that will be used to convert local to world coordinates
  72088. */
  72089. worldParentNode?: TransformNode;
  72090. }
  72091. /**
  72092. * A babylon container for an XR Anchor
  72093. */
  72094. export interface IWebXRAnchor {
  72095. /**
  72096. * A babylon-assigned ID for this anchor
  72097. */
  72098. id: number;
  72099. /**
  72100. * Transformation matrix to apply to an object attached to this anchor
  72101. */
  72102. transformationMatrix: Matrix;
  72103. /**
  72104. * The native anchor object
  72105. */
  72106. xrAnchor: XRAnchor;
  72107. }
  72108. /**
  72109. * An implementation of the anchor system of WebXR.
  72110. * Note that the current documented implementation is not available in any browser. Future implementations
  72111. * will use the frame to create an anchor and not the session or a detected plane
  72112. * For further information see https://github.com/immersive-web/anchors/
  72113. */
  72114. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  72115. private _options;
  72116. private _enabled;
  72117. private _hitTestModule;
  72118. private _lastFrameDetected;
  72119. private _onSelect;
  72120. private _planeDetector;
  72121. private _trackedAnchors;
  72122. /**
  72123. * The module's name
  72124. */
  72125. static readonly Name: string;
  72126. /**
  72127. * The (Babylon) version of this module.
  72128. * This is an integer representing the implementation version.
  72129. * This number does not correspond to the WebXR specs version
  72130. */
  72131. static readonly Version: number;
  72132. /**
  72133. * Observers registered here will be executed when a new anchor was added to the session
  72134. */
  72135. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  72136. /**
  72137. * Observers registered here will be executed when an anchor was removed from the session
  72138. */
  72139. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  72140. /**
  72141. * Observers registered here will be executed when an existing anchor updates
  72142. * This can execute N times every frame
  72143. */
  72144. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  72145. /**
  72146. * constructs a new anchor system
  72147. * @param _xrSessionManager an instance of WebXRSessionManager
  72148. * @param _options configuration object for this feature
  72149. */
  72150. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  72151. /**
  72152. * Add anchor at a specific XR point.
  72153. *
  72154. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  72155. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  72156. * @returns a promise the fulfills when the anchor was created
  72157. */
  72158. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  72159. /**
  72160. * attach this feature
  72161. * Will usually be called by the features manager
  72162. *
  72163. * @returns true if successful.
  72164. */
  72165. attach(): boolean;
  72166. /**
  72167. * detach this feature.
  72168. * Will usually be called by the features manager
  72169. *
  72170. * @returns true if successful.
  72171. */
  72172. detach(): boolean;
  72173. /**
  72174. * Dispose this feature and all of the resources attached
  72175. */
  72176. dispose(): void;
  72177. /**
  72178. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  72179. * @param hitTestModule the hit-test module to use.
  72180. */
  72181. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  72182. /**
  72183. * set the plane detector to use in order to create anchors from frames
  72184. * @param planeDetector the plane-detector module to use
  72185. * @param enable enable plane-anchors. default is true
  72186. */
  72187. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  72188. protected _onXRFrame(frame: XRFrame): void;
  72189. /**
  72190. * avoiding using Array.find for global support.
  72191. * @param xrAnchor the plane to find in the array
  72192. */
  72193. private _findIndexInAnchorArray;
  72194. private _updateAnchorWithXRFrame;
  72195. }
  72196. }
  72197. declare module BABYLON {
  72198. /**
  72199. * Options interface for the background remover plugin
  72200. */
  72201. export interface IWebXRBackgroundRemoverOptions {
  72202. /**
  72203. * Further background meshes to disable when entering AR
  72204. */
  72205. backgroundMeshes?: AbstractMesh[];
  72206. /**
  72207. * flags to configure the removal of the environment helper.
  72208. * If not set, the entire background will be removed. If set, flags should be set as well.
  72209. */
  72210. environmentHelperRemovalFlags?: {
  72211. /**
  72212. * Should the skybox be removed (default false)
  72213. */
  72214. skyBox?: boolean;
  72215. /**
  72216. * Should the ground be removed (default false)
  72217. */
  72218. ground?: boolean;
  72219. };
  72220. /**
  72221. * don't disable the environment helper
  72222. */
  72223. ignoreEnvironmentHelper?: boolean;
  72224. }
  72225. /**
  72226. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  72227. */
  72228. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  72229. /**
  72230. * read-only options to be used in this module
  72231. */
  72232. readonly options: IWebXRBackgroundRemoverOptions;
  72233. /**
  72234. * The module's name
  72235. */
  72236. static readonly Name: string;
  72237. /**
  72238. * The (Babylon) version of this module.
  72239. * This is an integer representing the implementation version.
  72240. * This number does not correspond to the WebXR specs version
  72241. */
  72242. static readonly Version: number;
  72243. /**
  72244. * registered observers will be triggered when the background state changes
  72245. */
  72246. onBackgroundStateChangedObservable: Observable<boolean>;
  72247. /**
  72248. * constructs a new background remover module
  72249. * @param _xrSessionManager the session manager for this module
  72250. * @param options read-only options to be used in this module
  72251. */
  72252. constructor(_xrSessionManager: WebXRSessionManager,
  72253. /**
  72254. * read-only options to be used in this module
  72255. */
  72256. options?: IWebXRBackgroundRemoverOptions);
  72257. /**
  72258. * attach this feature
  72259. * Will usually be called by the features manager
  72260. *
  72261. * @returns true if successful.
  72262. */
  72263. attach(): boolean;
  72264. /**
  72265. * detach this feature.
  72266. * Will usually be called by the features manager
  72267. *
  72268. * @returns true if successful.
  72269. */
  72270. detach(): boolean;
  72271. /**
  72272. * Dispose this feature and all of the resources attached
  72273. */
  72274. dispose(): void;
  72275. protected _onXRFrame(_xrFrame: XRFrame): void;
  72276. private _setBackgroundState;
  72277. }
  72278. }
  72279. declare module BABYLON {
  72280. /**
  72281. * Options for the controller physics feature
  72282. */
  72283. export class IWebXRControllerPhysicsOptions {
  72284. /**
  72285. * Should the headset get its own impostor
  72286. */
  72287. enableHeadsetImpostor?: boolean;
  72288. /**
  72289. * Optional parameters for the headset impostor
  72290. */
  72291. headsetImpostorParams?: {
  72292. /**
  72293. * The type of impostor to create. Default is sphere
  72294. */
  72295. impostorType: number;
  72296. /**
  72297. * the size of the impostor. Defaults to 10cm
  72298. */
  72299. impostorSize?: number | {
  72300. width: number;
  72301. height: number;
  72302. depth: number;
  72303. };
  72304. /**
  72305. * Friction definitions
  72306. */
  72307. friction?: number;
  72308. /**
  72309. * Restitution
  72310. */
  72311. restitution?: number;
  72312. };
  72313. /**
  72314. * The physics properties of the future impostors
  72315. */
  72316. physicsProperties?: {
  72317. /**
  72318. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  72319. * Note that this requires a physics engine that supports mesh impostors!
  72320. */
  72321. useControllerMesh?: boolean;
  72322. /**
  72323. * The type of impostor to create. Default is sphere
  72324. */
  72325. impostorType?: number;
  72326. /**
  72327. * the size of the impostor. Defaults to 10cm
  72328. */
  72329. impostorSize?: number | {
  72330. width: number;
  72331. height: number;
  72332. depth: number;
  72333. };
  72334. /**
  72335. * Friction definitions
  72336. */
  72337. friction?: number;
  72338. /**
  72339. * Restitution
  72340. */
  72341. restitution?: number;
  72342. };
  72343. /**
  72344. * the xr input to use with this pointer selection
  72345. */
  72346. xrInput: WebXRInput;
  72347. }
  72348. /**
  72349. * Add physics impostor to your webxr controllers,
  72350. * including naive calculation of their linear and angular velocity
  72351. */
  72352. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  72353. private readonly _options;
  72354. private _attachController;
  72355. private _controllers;
  72356. private _debugMode;
  72357. private _delta;
  72358. private _headsetImpostor?;
  72359. private _headsetMesh?;
  72360. private _lastTimestamp;
  72361. private _tmpQuaternion;
  72362. private _tmpVector;
  72363. /**
  72364. * The module's name
  72365. */
  72366. static readonly Name: string;
  72367. /**
  72368. * The (Babylon) version of this module.
  72369. * This is an integer representing the implementation version.
  72370. * This number does not correspond to the webxr specs version
  72371. */
  72372. static readonly Version: number;
  72373. /**
  72374. * Construct a new Controller Physics Feature
  72375. * @param _xrSessionManager the corresponding xr session manager
  72376. * @param _options options to create this feature with
  72377. */
  72378. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  72379. /**
  72380. * @hidden
  72381. * enable debugging - will show console outputs and the impostor mesh
  72382. */
  72383. _enablePhysicsDebug(): void;
  72384. /**
  72385. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  72386. * @param xrController the controller to add
  72387. */
  72388. addController(xrController: WebXRInputSource): void;
  72389. /**
  72390. * attach this feature
  72391. * Will usually be called by the features manager
  72392. *
  72393. * @returns true if successful.
  72394. */
  72395. attach(): boolean;
  72396. /**
  72397. * detach this feature.
  72398. * Will usually be called by the features manager
  72399. *
  72400. * @returns true if successful.
  72401. */
  72402. detach(): boolean;
  72403. /**
  72404. * Get the headset impostor, if enabled
  72405. * @returns the impostor
  72406. */
  72407. getHeadsetImpostor(): PhysicsImpostor | undefined;
  72408. /**
  72409. * Get the physics impostor of a specific controller.
  72410. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  72411. * @param controller the controller or the controller id of which to get the impostor
  72412. * @returns the impostor or null
  72413. */
  72414. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  72415. /**
  72416. * Update the physics properties provided in the constructor
  72417. * @param newProperties the new properties object
  72418. */
  72419. setPhysicsProperties(newProperties: {
  72420. impostorType?: number;
  72421. impostorSize?: number | {
  72422. width: number;
  72423. height: number;
  72424. depth: number;
  72425. };
  72426. friction?: number;
  72427. restitution?: number;
  72428. }): void;
  72429. protected _onXRFrame(_xrFrame: any): void;
  72430. private _detachController;
  72431. }
  72432. }
  72433. declare module BABYLON {
  72434. /**
  72435. * Options used for hit testing (version 2)
  72436. */
  72437. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  72438. /**
  72439. * Do not create a permanent hit test. Will usually be used when only
  72440. * transient inputs are needed.
  72441. */
  72442. disablePermanentHitTest?: boolean;
  72443. /**
  72444. * Enable transient (for example touch-based) hit test inspections
  72445. */
  72446. enableTransientHitTest?: boolean;
  72447. /**
  72448. * Offset ray for the permanent hit test
  72449. */
  72450. offsetRay?: Vector3;
  72451. /**
  72452. * Offset ray for the transient hit test
  72453. */
  72454. transientOffsetRay?: Vector3;
  72455. /**
  72456. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  72457. */
  72458. useReferenceSpace?: boolean;
  72459. }
  72460. /**
  72461. * Interface defining the babylon result of hit-test
  72462. */
  72463. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  72464. /**
  72465. * The input source that generated this hit test (if transient)
  72466. */
  72467. inputSource?: XRInputSource;
  72468. /**
  72469. * Is this a transient hit test
  72470. */
  72471. isTransient?: boolean;
  72472. /**
  72473. * Position of the hit test result
  72474. */
  72475. position: Vector3;
  72476. /**
  72477. * Rotation of the hit test result
  72478. */
  72479. rotationQuaternion: Quaternion;
  72480. }
  72481. /**
  72482. * The currently-working hit-test module.
  72483. * Hit test (or Ray-casting) is used to interact with the real world.
  72484. * For further information read here - https://github.com/immersive-web/hit-test
  72485. *
  72486. * Tested on chrome (mobile) 80.
  72487. */
  72488. export class WebXRHitTest extends WebXRAbstractFeature {
  72489. /**
  72490. * options to use when constructing this feature
  72491. */
  72492. readonly options: IWebXRHitTestOptions;
  72493. private _tmpMat;
  72494. private _tmpPos;
  72495. private _tmpQuat;
  72496. private _transientXrHitTestSource;
  72497. private _xrHitTestSource;
  72498. private initHitTestSource;
  72499. /**
  72500. * The module's name
  72501. */
  72502. static readonly Name: string;
  72503. /**
  72504. * The (Babylon) version of this module.
  72505. * This is an integer representing the implementation version.
  72506. * This number does not correspond to the WebXR specs version
  72507. */
  72508. static readonly Version: number;
  72509. /**
  72510. * When set to true, each hit test will have its own position/rotation objects
  72511. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  72512. * the developers will clone them or copy them as they see fit.
  72513. */
  72514. autoCloneTransformation: boolean;
  72515. /**
  72516. * Populated with the last native XR Hit Results
  72517. */
  72518. lastNativeXRHitResults: XRHitResult[];
  72519. /**
  72520. * Triggered when new babylon (transformed) hit test results are available
  72521. */
  72522. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  72523. /**
  72524. * Use this to temporarily pause hit test checks.
  72525. */
  72526. paused: boolean;
  72527. /**
  72528. * Creates a new instance of the hit test feature
  72529. * @param _xrSessionManager an instance of WebXRSessionManager
  72530. * @param options options to use when constructing this feature
  72531. */
  72532. constructor(_xrSessionManager: WebXRSessionManager,
  72533. /**
  72534. * options to use when constructing this feature
  72535. */
  72536. options?: IWebXRHitTestOptions);
  72537. /**
  72538. * attach this feature
  72539. * Will usually be called by the features manager
  72540. *
  72541. * @returns true if successful.
  72542. */
  72543. attach(): boolean;
  72544. /**
  72545. * detach this feature.
  72546. * Will usually be called by the features manager
  72547. *
  72548. * @returns true if successful.
  72549. */
  72550. detach(): boolean;
  72551. /**
  72552. * Dispose this feature and all of the resources attached
  72553. */
  72554. dispose(): void;
  72555. protected _onXRFrame(frame: XRFrame): void;
  72556. private _processWebXRHitTestResult;
  72557. }
  72558. }
  72559. declare module BABYLON {
  72560. /**
  72561. * The motion controller class for all microsoft mixed reality controllers
  72562. */
  72563. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  72564. protected readonly _mapping: {
  72565. defaultButton: {
  72566. valueNodeName: string;
  72567. unpressedNodeName: string;
  72568. pressedNodeName: string;
  72569. };
  72570. defaultAxis: {
  72571. valueNodeName: string;
  72572. minNodeName: string;
  72573. maxNodeName: string;
  72574. };
  72575. buttons: {
  72576. "xr-standard-trigger": {
  72577. rootNodeName: string;
  72578. componentProperty: string;
  72579. states: string[];
  72580. };
  72581. "xr-standard-squeeze": {
  72582. rootNodeName: string;
  72583. componentProperty: string;
  72584. states: string[];
  72585. };
  72586. "xr-standard-touchpad": {
  72587. rootNodeName: string;
  72588. labelAnchorNodeName: string;
  72589. touchPointNodeName: string;
  72590. };
  72591. "xr-standard-thumbstick": {
  72592. rootNodeName: string;
  72593. componentProperty: string;
  72594. states: string[];
  72595. };
  72596. };
  72597. axes: {
  72598. "xr-standard-touchpad": {
  72599. "x-axis": {
  72600. rootNodeName: string;
  72601. };
  72602. "y-axis": {
  72603. rootNodeName: string;
  72604. };
  72605. };
  72606. "xr-standard-thumbstick": {
  72607. "x-axis": {
  72608. rootNodeName: string;
  72609. };
  72610. "y-axis": {
  72611. rootNodeName: string;
  72612. };
  72613. };
  72614. };
  72615. };
  72616. /**
  72617. * The base url used to load the left and right controller models
  72618. */
  72619. static MODEL_BASE_URL: string;
  72620. /**
  72621. * The name of the left controller model file
  72622. */
  72623. static MODEL_LEFT_FILENAME: string;
  72624. /**
  72625. * The name of the right controller model file
  72626. */
  72627. static MODEL_RIGHT_FILENAME: string;
  72628. profileId: string;
  72629. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  72630. protected _getFilenameAndPath(): {
  72631. filename: string;
  72632. path: string;
  72633. };
  72634. protected _getModelLoadingConstraints(): boolean;
  72635. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  72636. protected _setRootMesh(meshes: AbstractMesh[]): void;
  72637. protected _updateModel(): void;
  72638. }
  72639. }
  72640. declare module BABYLON {
  72641. /**
  72642. * The motion controller class for oculus touch (quest, rift).
  72643. * This class supports legacy mapping as well the standard xr mapping
  72644. */
  72645. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  72646. private _forceLegacyControllers;
  72647. private _modelRootNode;
  72648. /**
  72649. * The base url used to load the left and right controller models
  72650. */
  72651. static MODEL_BASE_URL: string;
  72652. /**
  72653. * The name of the left controller model file
  72654. */
  72655. static MODEL_LEFT_FILENAME: string;
  72656. /**
  72657. * The name of the right controller model file
  72658. */
  72659. static MODEL_RIGHT_FILENAME: string;
  72660. /**
  72661. * Base Url for the Quest controller model.
  72662. */
  72663. static QUEST_MODEL_BASE_URL: string;
  72664. profileId: string;
  72665. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  72666. protected _getFilenameAndPath(): {
  72667. filename: string;
  72668. path: string;
  72669. };
  72670. protected _getModelLoadingConstraints(): boolean;
  72671. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  72672. protected _setRootMesh(meshes: AbstractMesh[]): void;
  72673. protected _updateModel(): void;
  72674. /**
  72675. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  72676. * between the touch and touch 2.
  72677. */
  72678. private _isQuest;
  72679. }
  72680. }
  72681. declare module BABYLON {
  72682. /**
  72683. * The motion controller class for the standard HTC-Vive controllers
  72684. */
  72685. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  72686. private _modelRootNode;
  72687. /**
  72688. * The base url used to load the left and right controller models
  72689. */
  72690. static MODEL_BASE_URL: string;
  72691. /**
  72692. * File name for the controller model.
  72693. */
  72694. static MODEL_FILENAME: string;
  72695. profileId: string;
  72696. /**
  72697. * Create a new Vive motion controller object
  72698. * @param scene the scene to use to create this controller
  72699. * @param gamepadObject the corresponding gamepad object
  72700. * @param handedness the handedness of the controller
  72701. */
  72702. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  72703. protected _getFilenameAndPath(): {
  72704. filename: string;
  72705. path: string;
  72706. };
  72707. protected _getModelLoadingConstraints(): boolean;
  72708. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  72709. protected _setRootMesh(meshes: AbstractMesh[]): void;
  72710. protected _updateModel(): void;
  72711. }
  72712. }
  72713. declare module BABYLON {
  72714. /**
  72715. * A cursor which tracks a point on a path
  72716. */
  72717. export class PathCursor {
  72718. private path;
  72719. /**
  72720. * Stores path cursor callbacks for when an onchange event is triggered
  72721. */
  72722. private _onchange;
  72723. /**
  72724. * The value of the path cursor
  72725. */
  72726. value: number;
  72727. /**
  72728. * The animation array of the path cursor
  72729. */
  72730. animations: Animation[];
  72731. /**
  72732. * Initializes the path cursor
  72733. * @param path The path to track
  72734. */
  72735. constructor(path: Path2);
  72736. /**
  72737. * Gets the cursor point on the path
  72738. * @returns A point on the path cursor at the cursor location
  72739. */
  72740. getPoint(): Vector3;
  72741. /**
  72742. * Moves the cursor ahead by the step amount
  72743. * @param step The amount to move the cursor forward
  72744. * @returns This path cursor
  72745. */
  72746. moveAhead(step?: number): PathCursor;
  72747. /**
  72748. * Moves the cursor behind by the step amount
  72749. * @param step The amount to move the cursor back
  72750. * @returns This path cursor
  72751. */
  72752. moveBack(step?: number): PathCursor;
  72753. /**
  72754. * Moves the cursor by the step amount
  72755. * If the step amount is greater than one, an exception is thrown
  72756. * @param step The amount to move the cursor
  72757. * @returns This path cursor
  72758. */
  72759. move(step: number): PathCursor;
  72760. /**
  72761. * Ensures that the value is limited between zero and one
  72762. * @returns This path cursor
  72763. */
  72764. private ensureLimits;
  72765. /**
  72766. * Runs onchange callbacks on change (used by the animation engine)
  72767. * @returns This path cursor
  72768. */
  72769. private raiseOnChange;
  72770. /**
  72771. * Executes a function on change
  72772. * @param f A path cursor onchange callback
  72773. * @returns This path cursor
  72774. */
  72775. onchange(f: (cursor: PathCursor) => void): PathCursor;
  72776. }
  72777. }
  72778. declare module BABYLON {
  72779. /** @hidden */
  72780. export var blurPixelShader: {
  72781. name: string;
  72782. shader: string;
  72783. };
  72784. }
  72785. declare module BABYLON {
  72786. /** @hidden */
  72787. export var pointCloudVertexDeclaration: {
  72788. name: string;
  72789. shader: string;
  72790. };
  72791. }
  72792. // Mixins
  72793. interface Window {
  72794. mozIndexedDB: IDBFactory;
  72795. webkitIndexedDB: IDBFactory;
  72796. msIndexedDB: IDBFactory;
  72797. webkitURL: typeof URL;
  72798. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  72799. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  72800. WebGLRenderingContext: WebGLRenderingContext;
  72801. MSGesture: MSGesture;
  72802. CANNON: any;
  72803. AudioContext: AudioContext;
  72804. webkitAudioContext: AudioContext;
  72805. PointerEvent: any;
  72806. Math: Math;
  72807. Uint8Array: Uint8ArrayConstructor;
  72808. Float32Array: Float32ArrayConstructor;
  72809. mozURL: typeof URL;
  72810. msURL: typeof URL;
  72811. VRFrameData: any; // WebVR, from specs 1.1
  72812. DracoDecoderModule: any;
  72813. setImmediate(handler: (...args: any[]) => void): number;
  72814. }
  72815. interface HTMLCanvasElement {
  72816. requestPointerLock(): void;
  72817. msRequestPointerLock?(): void;
  72818. mozRequestPointerLock?(): void;
  72819. webkitRequestPointerLock?(): void;
  72820. /** Track wether a record is in progress */
  72821. isRecording: boolean;
  72822. /** Capture Stream method defined by some browsers */
  72823. captureStream(fps?: number): MediaStream;
  72824. }
  72825. interface CanvasRenderingContext2D {
  72826. msImageSmoothingEnabled: boolean;
  72827. }
  72828. interface MouseEvent {
  72829. mozMovementX: number;
  72830. mozMovementY: number;
  72831. webkitMovementX: number;
  72832. webkitMovementY: number;
  72833. msMovementX: number;
  72834. msMovementY: number;
  72835. }
  72836. interface Navigator {
  72837. mozGetVRDevices: (any: any) => any;
  72838. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  72839. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  72840. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  72841. webkitGetGamepads(): Gamepad[];
  72842. msGetGamepads(): Gamepad[];
  72843. webkitGamepads(): Gamepad[];
  72844. }
  72845. interface HTMLVideoElement {
  72846. mozSrcObject: any;
  72847. }
  72848. interface Math {
  72849. fround(x: number): number;
  72850. imul(a: number, b: number): number;
  72851. }
  72852. interface WebGLRenderingContext {
  72853. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  72854. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  72855. vertexAttribDivisor(index: number, divisor: number): void;
  72856. createVertexArray(): any;
  72857. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  72858. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  72859. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  72860. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  72861. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  72862. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  72863. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  72864. // Queries
  72865. createQuery(): WebGLQuery;
  72866. deleteQuery(query: WebGLQuery): void;
  72867. beginQuery(target: number, query: WebGLQuery): void;
  72868. endQuery(target: number): void;
  72869. getQueryParameter(query: WebGLQuery, pname: number): any;
  72870. getQuery(target: number, pname: number): any;
  72871. MAX_SAMPLES: number;
  72872. RGBA8: number;
  72873. READ_FRAMEBUFFER: number;
  72874. DRAW_FRAMEBUFFER: number;
  72875. UNIFORM_BUFFER: number;
  72876. HALF_FLOAT_OES: number;
  72877. RGBA16F: number;
  72878. RGBA32F: number;
  72879. R32F: number;
  72880. RG32F: number;
  72881. RGB32F: number;
  72882. R16F: number;
  72883. RG16F: number;
  72884. RGB16F: number;
  72885. RED: number;
  72886. RG: number;
  72887. R8: number;
  72888. RG8: number;
  72889. UNSIGNED_INT_24_8: number;
  72890. DEPTH24_STENCIL8: number;
  72891. MIN: number;
  72892. MAX: number;
  72893. /* Multiple Render Targets */
  72894. drawBuffers(buffers: number[]): void;
  72895. readBuffer(src: number): void;
  72896. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  72897. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  72898. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  72899. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  72900. // Occlusion Query
  72901. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  72902. ANY_SAMPLES_PASSED: number;
  72903. QUERY_RESULT_AVAILABLE: number;
  72904. QUERY_RESULT: number;
  72905. }
  72906. interface WebGLProgram {
  72907. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  72908. }
  72909. interface EXT_disjoint_timer_query {
  72910. QUERY_COUNTER_BITS_EXT: number;
  72911. TIME_ELAPSED_EXT: number;
  72912. TIMESTAMP_EXT: number;
  72913. GPU_DISJOINT_EXT: number;
  72914. QUERY_RESULT_EXT: number;
  72915. QUERY_RESULT_AVAILABLE_EXT: number;
  72916. queryCounterEXT(query: WebGLQuery, target: number): void;
  72917. createQueryEXT(): WebGLQuery;
  72918. beginQueryEXT(target: number, query: WebGLQuery): void;
  72919. endQueryEXT(target: number): void;
  72920. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  72921. deleteQueryEXT(query: WebGLQuery): void;
  72922. }
  72923. interface WebGLUniformLocation {
  72924. _currentState: any;
  72925. }
  72926. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  72927. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  72928. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  72929. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  72930. interface WebGLRenderingContext {
  72931. readonly RASTERIZER_DISCARD: number;
  72932. readonly DEPTH_COMPONENT24: number;
  72933. readonly TEXTURE_3D: number;
  72934. readonly TEXTURE_2D_ARRAY: number;
  72935. readonly TEXTURE_COMPARE_FUNC: number;
  72936. readonly TEXTURE_COMPARE_MODE: number;
  72937. readonly COMPARE_REF_TO_TEXTURE: number;
  72938. readonly TEXTURE_WRAP_R: number;
  72939. readonly HALF_FLOAT: number;
  72940. readonly RGB8: number;
  72941. readonly RED_INTEGER: number;
  72942. readonly RG_INTEGER: number;
  72943. readonly RGB_INTEGER: number;
  72944. readonly RGBA_INTEGER: number;
  72945. readonly R8_SNORM: number;
  72946. readonly RG8_SNORM: number;
  72947. readonly RGB8_SNORM: number;
  72948. readonly RGBA8_SNORM: number;
  72949. readonly R8I: number;
  72950. readonly RG8I: number;
  72951. readonly RGB8I: number;
  72952. readonly RGBA8I: number;
  72953. readonly R8UI: number;
  72954. readonly RG8UI: number;
  72955. readonly RGB8UI: number;
  72956. readonly RGBA8UI: number;
  72957. readonly R16I: number;
  72958. readonly RG16I: number;
  72959. readonly RGB16I: number;
  72960. readonly RGBA16I: number;
  72961. readonly R16UI: number;
  72962. readonly RG16UI: number;
  72963. readonly RGB16UI: number;
  72964. readonly RGBA16UI: number;
  72965. readonly R32I: number;
  72966. readonly RG32I: number;
  72967. readonly RGB32I: number;
  72968. readonly RGBA32I: number;
  72969. readonly R32UI: number;
  72970. readonly RG32UI: number;
  72971. readonly RGB32UI: number;
  72972. readonly RGBA32UI: number;
  72973. readonly RGB10_A2UI: number;
  72974. readonly R11F_G11F_B10F: number;
  72975. readonly RGB9_E5: number;
  72976. readonly RGB10_A2: number;
  72977. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  72978. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  72979. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  72980. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  72981. readonly DEPTH_COMPONENT32F: number;
  72982. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  72983. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  72984. 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;
  72985. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  72986. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  72987. readonly TRANSFORM_FEEDBACK: number;
  72988. readonly INTERLEAVED_ATTRIBS: number;
  72989. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  72990. createTransformFeedback(): WebGLTransformFeedback;
  72991. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  72992. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  72993. beginTransformFeedback(primitiveMode: number): void;
  72994. endTransformFeedback(): void;
  72995. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  72996. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  72997. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  72998. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  72999. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  73000. }
  73001. interface ImageBitmap {
  73002. readonly width: number;
  73003. readonly height: number;
  73004. close(): void;
  73005. }
  73006. interface WebGLQuery extends WebGLObject {
  73007. }
  73008. declare var WebGLQuery: {
  73009. prototype: WebGLQuery;
  73010. new(): WebGLQuery;
  73011. };
  73012. interface WebGLSampler extends WebGLObject {
  73013. }
  73014. declare var WebGLSampler: {
  73015. prototype: WebGLSampler;
  73016. new(): WebGLSampler;
  73017. };
  73018. interface WebGLSync extends WebGLObject {
  73019. }
  73020. declare var WebGLSync: {
  73021. prototype: WebGLSync;
  73022. new(): WebGLSync;
  73023. };
  73024. interface WebGLTransformFeedback extends WebGLObject {
  73025. }
  73026. declare var WebGLTransformFeedback: {
  73027. prototype: WebGLTransformFeedback;
  73028. new(): WebGLTransformFeedback;
  73029. };
  73030. interface WebGLVertexArrayObject extends WebGLObject {
  73031. }
  73032. declare var WebGLVertexArrayObject: {
  73033. prototype: WebGLVertexArrayObject;
  73034. new(): WebGLVertexArrayObject;
  73035. };
  73036. // Type definitions for WebVR API
  73037. // Project: https://w3c.github.io/webvr/
  73038. // Definitions by: six a <https://github.com/lostfictions>
  73039. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  73040. interface VRDisplay extends EventTarget {
  73041. /**
  73042. * Dictionary of capabilities describing the VRDisplay.
  73043. */
  73044. readonly capabilities: VRDisplayCapabilities;
  73045. /**
  73046. * z-depth defining the far plane of the eye view frustum
  73047. * enables mapping of values in the render target depth
  73048. * attachment to scene coordinates. Initially set to 10000.0.
  73049. */
  73050. depthFar: number;
  73051. /**
  73052. * z-depth defining the near plane of the eye view frustum
  73053. * enables mapping of values in the render target depth
  73054. * attachment to scene coordinates. Initially set to 0.01.
  73055. */
  73056. depthNear: number;
  73057. /**
  73058. * An identifier for this distinct VRDisplay. Used as an
  73059. * association point in the Gamepad API.
  73060. */
  73061. readonly displayId: number;
  73062. /**
  73063. * A display name, a user-readable name identifying it.
  73064. */
  73065. readonly displayName: string;
  73066. readonly isConnected: boolean;
  73067. readonly isPresenting: boolean;
  73068. /**
  73069. * If this VRDisplay supports room-scale experiences, the optional
  73070. * stage attribute contains details on the room-scale parameters.
  73071. */
  73072. readonly stageParameters: VRStageParameters | null;
  73073. /**
  73074. * Passing the value returned by `requestAnimationFrame` to
  73075. * `cancelAnimationFrame` will unregister the callback.
  73076. * @param handle Define the hanle of the request to cancel
  73077. */
  73078. cancelAnimationFrame(handle: number): void;
  73079. /**
  73080. * Stops presenting to the VRDisplay.
  73081. * @returns a promise to know when it stopped
  73082. */
  73083. exitPresent(): Promise<void>;
  73084. /**
  73085. * Return the current VREyeParameters for the given eye.
  73086. * @param whichEye Define the eye we want the parameter for
  73087. * @returns the eye parameters
  73088. */
  73089. getEyeParameters(whichEye: string): VREyeParameters;
  73090. /**
  73091. * Populates the passed VRFrameData with the information required to render
  73092. * the current frame.
  73093. * @param frameData Define the data structure to populate
  73094. * @returns true if ok otherwise false
  73095. */
  73096. getFrameData(frameData: VRFrameData): boolean;
  73097. /**
  73098. * Get the layers currently being presented.
  73099. * @returns the list of VR layers
  73100. */
  73101. getLayers(): VRLayer[];
  73102. /**
  73103. * Return a VRPose containing the future predicted pose of the VRDisplay
  73104. * when the current frame will be presented. The value returned will not
  73105. * change until JavaScript has returned control to the browser.
  73106. *
  73107. * The VRPose will contain the position, orientation, velocity,
  73108. * and acceleration of each of these properties.
  73109. * @returns the pose object
  73110. */
  73111. getPose(): VRPose;
  73112. /**
  73113. * Return the current instantaneous pose of the VRDisplay, with no
  73114. * prediction applied.
  73115. * @returns the current instantaneous pose
  73116. */
  73117. getImmediatePose(): VRPose;
  73118. /**
  73119. * The callback passed to `requestAnimationFrame` will be called
  73120. * any time a new frame should be rendered. When the VRDisplay is
  73121. * presenting the callback will be called at the native refresh
  73122. * rate of the HMD. When not presenting this function acts
  73123. * identically to how window.requestAnimationFrame acts. Content should
  73124. * make no assumptions of frame rate or vsync behavior as the HMD runs
  73125. * asynchronously from other displays and at differing refresh rates.
  73126. * @param callback Define the eaction to run next frame
  73127. * @returns the request handle it
  73128. */
  73129. requestAnimationFrame(callback: FrameRequestCallback): number;
  73130. /**
  73131. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  73132. * Repeat calls while already presenting will update the VRLayers being displayed.
  73133. * @param layers Define the list of layer to present
  73134. * @returns a promise to know when the request has been fulfilled
  73135. */
  73136. requestPresent(layers: VRLayer[]): Promise<void>;
  73137. /**
  73138. * Reset the pose for this display, treating its current position and
  73139. * orientation as the "origin/zero" values. VRPose.position,
  73140. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  73141. * updated when calling resetPose(). This should be called in only
  73142. * sitting-space experiences.
  73143. */
  73144. resetPose(): void;
  73145. /**
  73146. * The VRLayer provided to the VRDisplay will be captured and presented
  73147. * in the HMD. Calling this function has the same effect on the source
  73148. * canvas as any other operation that uses its source image, and canvases
  73149. * created without preserveDrawingBuffer set to true will be cleared.
  73150. * @param pose Define the pose to submit
  73151. */
  73152. submitFrame(pose?: VRPose): void;
  73153. }
  73154. declare var VRDisplay: {
  73155. prototype: VRDisplay;
  73156. new(): VRDisplay;
  73157. };
  73158. interface VRLayer {
  73159. leftBounds?: number[] | Float32Array | null;
  73160. rightBounds?: number[] | Float32Array | null;
  73161. source?: HTMLCanvasElement | null;
  73162. }
  73163. interface VRDisplayCapabilities {
  73164. readonly canPresent: boolean;
  73165. readonly hasExternalDisplay: boolean;
  73166. readonly hasOrientation: boolean;
  73167. readonly hasPosition: boolean;
  73168. readonly maxLayers: number;
  73169. }
  73170. interface VREyeParameters {
  73171. /** @deprecated */
  73172. readonly fieldOfView: VRFieldOfView;
  73173. readonly offset: Float32Array;
  73174. readonly renderHeight: number;
  73175. readonly renderWidth: number;
  73176. }
  73177. interface VRFieldOfView {
  73178. readonly downDegrees: number;
  73179. readonly leftDegrees: number;
  73180. readonly rightDegrees: number;
  73181. readonly upDegrees: number;
  73182. }
  73183. interface VRFrameData {
  73184. readonly leftProjectionMatrix: Float32Array;
  73185. readonly leftViewMatrix: Float32Array;
  73186. readonly pose: VRPose;
  73187. readonly rightProjectionMatrix: Float32Array;
  73188. readonly rightViewMatrix: Float32Array;
  73189. readonly timestamp: number;
  73190. }
  73191. interface VRPose {
  73192. readonly angularAcceleration: Float32Array | null;
  73193. readonly angularVelocity: Float32Array | null;
  73194. readonly linearAcceleration: Float32Array | null;
  73195. readonly linearVelocity: Float32Array | null;
  73196. readonly orientation: Float32Array | null;
  73197. readonly position: Float32Array | null;
  73198. readonly timestamp: number;
  73199. }
  73200. interface VRStageParameters {
  73201. sittingToStandingTransform?: Float32Array;
  73202. sizeX?: number;
  73203. sizeY?: number;
  73204. }
  73205. interface Navigator {
  73206. getVRDisplays(): Promise<VRDisplay[]>;
  73207. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  73208. }
  73209. interface Window {
  73210. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  73211. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  73212. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  73213. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  73214. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  73215. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  73216. }
  73217. interface Gamepad {
  73218. readonly displayId: number;
  73219. }
  73220. type XRSessionMode =
  73221. | "inline"
  73222. | "immersive-vr"
  73223. | "immersive-ar";
  73224. type XRReferenceSpaceType =
  73225. | "viewer"
  73226. | "local"
  73227. | "local-floor"
  73228. | "bounded-floor"
  73229. | "unbounded";
  73230. type XREnvironmentBlendMode =
  73231. | "opaque"
  73232. | "additive"
  73233. | "alpha-blend";
  73234. type XRVisibilityState =
  73235. | "visible"
  73236. | "visible-blurred"
  73237. | "hidden";
  73238. type XRHandedness =
  73239. | "none"
  73240. | "left"
  73241. | "right";
  73242. type XRTargetRayMode =
  73243. | "gaze"
  73244. | "tracked-pointer"
  73245. | "screen";
  73246. type XREye =
  73247. | "none"
  73248. | "left"
  73249. | "right";
  73250. type XREventType =
  73251. | "devicechange"
  73252. | "visibilitychange"
  73253. | "end"
  73254. | "inputsourceschange"
  73255. | "select"
  73256. | "selectstart"
  73257. | "selectend"
  73258. | "squeeze"
  73259. | "squeezestart"
  73260. | "squeezeend"
  73261. | "reset";
  73262. interface XRSpace extends EventTarget {
  73263. }
  73264. interface XRRenderState {
  73265. depthNear?: number;
  73266. depthFar?: number;
  73267. inlineVerticalFieldOfView?: number;
  73268. baseLayer?: XRWebGLLayer;
  73269. }
  73270. interface XRInputSource {
  73271. handedness: XRHandedness;
  73272. targetRayMode: XRTargetRayMode;
  73273. targetRaySpace: XRSpace;
  73274. gripSpace: XRSpace | undefined;
  73275. gamepad: Gamepad | undefined;
  73276. profiles: Array<string>;
  73277. }
  73278. interface XRSessionInit {
  73279. optionalFeatures?: string[];
  73280. requiredFeatures?: string[];
  73281. }
  73282. interface XRSession extends XRAnchorCreator {
  73283. addEventListener: Function;
  73284. removeEventListener: Function;
  73285. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  73286. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  73287. requestAnimationFrame: Function;
  73288. end(): Promise<void>;
  73289. renderState: XRRenderState;
  73290. inputSources: Array<XRInputSource>;
  73291. // hit test
  73292. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  73293. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  73294. // legacy AR hit test
  73295. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  73296. // legacy plane detection
  73297. updateWorldTrackingState(options: {
  73298. planeDetectionState?: { enabled: boolean; }
  73299. }): void;
  73300. }
  73301. interface XRReferenceSpace extends XRSpace {
  73302. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  73303. onreset: any;
  73304. }
  73305. type XRPlaneSet = Set<XRPlane>;
  73306. type XRAnchorSet = Set<XRAnchor>;
  73307. interface XRFrame {
  73308. session: XRSession;
  73309. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  73310. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  73311. // AR
  73312. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  73313. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  73314. // Anchors
  73315. trackedAnchors?: XRAnchorSet;
  73316. // Planes
  73317. worldInformation: {
  73318. detectedPlanes?: XRPlaneSet;
  73319. };
  73320. }
  73321. interface XRViewerPose extends XRPose {
  73322. views: Array<XRView>;
  73323. }
  73324. interface XRPose {
  73325. transform: XRRigidTransform;
  73326. emulatedPosition: boolean;
  73327. }
  73328. interface XRWebGLLayerOptions {
  73329. antialias?: boolean;
  73330. depth?: boolean;
  73331. stencil?: boolean;
  73332. alpha?: boolean;
  73333. multiview?: boolean;
  73334. framebufferScaleFactor?: number;
  73335. }
  73336. declare var XRWebGLLayer: {
  73337. prototype: XRWebGLLayer;
  73338. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  73339. };
  73340. interface XRWebGLLayer {
  73341. framebuffer: WebGLFramebuffer;
  73342. framebufferWidth: number;
  73343. framebufferHeight: number;
  73344. getViewport: Function;
  73345. }
  73346. declare class XRRigidTransform {
  73347. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  73348. position: DOMPointReadOnly;
  73349. orientation: DOMPointReadOnly;
  73350. matrix: Float32Array;
  73351. inverse: XRRigidTransform;
  73352. }
  73353. interface XRView {
  73354. eye: XREye;
  73355. projectionMatrix: Float32Array;
  73356. transform: XRRigidTransform;
  73357. }
  73358. interface XRInputSourceChangeEvent {
  73359. session: XRSession;
  73360. removed: Array<XRInputSource>;
  73361. added: Array<XRInputSource>;
  73362. }
  73363. interface XRInputSourceEvent extends Event {
  73364. readonly frame: XRFrame;
  73365. readonly inputSource: XRInputSource;
  73366. }
  73367. // Experimental(er) features
  73368. declare class XRRay {
  73369. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  73370. origin: DOMPointReadOnly;
  73371. direction: DOMPointReadOnly;
  73372. matrix: Float32Array;
  73373. }
  73374. declare enum XRHitTestTrackableType {
  73375. "point",
  73376. "plane"
  73377. }
  73378. interface XRHitResult {
  73379. hitMatrix: Float32Array;
  73380. }
  73381. interface XRTransientInputHitTestResult {
  73382. readonly inputSource: XRInputSource;
  73383. readonly results: Array<XRHitTestResult>;
  73384. }
  73385. interface XRHitTestResult {
  73386. getPose(baseSpace: XRSpace): XRPose | undefined;
  73387. }
  73388. interface XRHitTestSource {
  73389. cancel(): void;
  73390. }
  73391. interface XRTransientInputHitTestSource {
  73392. cancel(): void;
  73393. }
  73394. interface XRHitTestOptionsInit {
  73395. space: XRSpace;
  73396. entityTypes?: Array<XRHitTestTrackableType>;
  73397. offsetRay?: XRRay;
  73398. }
  73399. interface XRTransientInputHitTestOptionsInit {
  73400. profile: string;
  73401. entityTypes?: Array<XRHitTestTrackableType>;
  73402. offsetRay?: XRRay;
  73403. }
  73404. interface XRAnchor {
  73405. // remove?
  73406. id?: string;
  73407. anchorSpace: XRSpace;
  73408. lastChangedTime: number;
  73409. detach(): void;
  73410. }
  73411. interface XRPlane extends XRAnchorCreator {
  73412. orientation: "Horizontal" | "Vertical";
  73413. planeSpace: XRSpace;
  73414. polygon: Array<DOMPointReadOnly>;
  73415. lastChangedTime: number;
  73416. }
  73417. interface XRAnchorCreator {
  73418. // AR Anchors
  73419. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  73420. }
  73421. /**
  73422. * @ignore
  73423. */
  73424. declare module BABYLON.GLTF2.Exporter {
  73425. }
  73426. /**
  73427. * @ignore
  73428. */
  73429. declare module BABYLON.GLTF1 {
  73430. }
  73431. declare module BABYLON.GUI {
  73432. /**
  73433. * Class used to specific a value and its associated unit
  73434. */
  73435. export class ValueAndUnit {
  73436. /** defines the unit to store */
  73437. unit: number;
  73438. /** defines a boolean indicating if the value can be negative */
  73439. negativeValueAllowed: boolean;
  73440. private _value;
  73441. private _originalUnit;
  73442. /**
  73443. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  73444. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  73445. */
  73446. ignoreAdaptiveScaling: boolean;
  73447. /**
  73448. * Creates a new ValueAndUnit
  73449. * @param value defines the value to store
  73450. * @param unit defines the unit to store
  73451. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  73452. */
  73453. constructor(value: number,
  73454. /** defines the unit to store */
  73455. unit?: number,
  73456. /** defines a boolean indicating if the value can be negative */
  73457. negativeValueAllowed?: boolean);
  73458. /** Gets a boolean indicating if the value is a percentage */
  73459. get isPercentage(): boolean;
  73460. /** Gets a boolean indicating if the value is store as pixel */
  73461. get isPixel(): boolean;
  73462. /** Gets direct internal value */
  73463. get internalValue(): number;
  73464. /**
  73465. * Gets value as pixel
  73466. * @param host defines the root host
  73467. * @param refValue defines the reference value for percentages
  73468. * @returns the value as pixel
  73469. */
  73470. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  73471. /**
  73472. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  73473. * @param value defines the value to store
  73474. * @param unit defines the unit to store
  73475. * @returns the current ValueAndUnit
  73476. */
  73477. updateInPlace(value: number, unit?: number): ValueAndUnit;
  73478. /**
  73479. * Gets the value accordingly to its unit
  73480. * @param host defines the root host
  73481. * @returns the value
  73482. */
  73483. getValue(host: AdvancedDynamicTexture): number;
  73484. /**
  73485. * Gets a string representation of the value
  73486. * @param host defines the root host
  73487. * @param decimals defines an optional number of decimals to display
  73488. * @returns a string
  73489. */
  73490. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  73491. /**
  73492. * Store a value parsed from a string
  73493. * @param source defines the source string
  73494. * @returns true if the value was successfully parsed
  73495. */
  73496. fromString(source: string | number): boolean;
  73497. private static _Regex;
  73498. private static _UNITMODE_PERCENTAGE;
  73499. private static _UNITMODE_PIXEL;
  73500. /** UNITMODE_PERCENTAGE */
  73501. static get UNITMODE_PERCENTAGE(): number;
  73502. /** UNITMODE_PIXEL */
  73503. static get UNITMODE_PIXEL(): number;
  73504. }
  73505. }
  73506. declare module BABYLON.GUI {
  73507. /**
  73508. * Define a style used by control to automatically setup properties based on a template.
  73509. * Only support font related properties so far
  73510. */
  73511. export class Style implements BABYLON.IDisposable {
  73512. private _fontFamily;
  73513. private _fontStyle;
  73514. private _fontWeight;
  73515. /** @hidden */
  73516. _host: AdvancedDynamicTexture;
  73517. /** @hidden */
  73518. _fontSize: ValueAndUnit;
  73519. /**
  73520. * BABYLON.Observable raised when the style values are changed
  73521. */
  73522. onChangedObservable: BABYLON.Observable<Style>;
  73523. /**
  73524. * Creates a new style object
  73525. * @param host defines the AdvancedDynamicTexture which hosts this style
  73526. */
  73527. constructor(host: AdvancedDynamicTexture);
  73528. /**
  73529. * Gets or sets the font size
  73530. */
  73531. get fontSize(): string | number;
  73532. set fontSize(value: string | number);
  73533. /**
  73534. * Gets or sets the font family
  73535. */
  73536. get fontFamily(): string;
  73537. set fontFamily(value: string);
  73538. /**
  73539. * Gets or sets the font style
  73540. */
  73541. get fontStyle(): string;
  73542. set fontStyle(value: string);
  73543. /** Gets or sets font weight */
  73544. get fontWeight(): string;
  73545. set fontWeight(value: string);
  73546. /** Dispose all associated resources */
  73547. dispose(): void;
  73548. }
  73549. }
  73550. declare module BABYLON.GUI {
  73551. /**
  73552. * Class used to transport BABYLON.Vector2 information for pointer events
  73553. */
  73554. export class Vector2WithInfo extends BABYLON.Vector2 {
  73555. /** defines the current mouse button index */
  73556. buttonIndex: number;
  73557. /**
  73558. * Creates a new Vector2WithInfo
  73559. * @param source defines the vector2 data to transport
  73560. * @param buttonIndex defines the current mouse button index
  73561. */
  73562. constructor(source: BABYLON.Vector2,
  73563. /** defines the current mouse button index */
  73564. buttonIndex?: number);
  73565. }
  73566. /** Class used to provide 2D matrix features */
  73567. export class Matrix2D {
  73568. /** Gets the internal array of 6 floats used to store matrix data */
  73569. m: Float32Array;
  73570. /**
  73571. * Creates a new matrix
  73572. * @param m00 defines value for (0, 0)
  73573. * @param m01 defines value for (0, 1)
  73574. * @param m10 defines value for (1, 0)
  73575. * @param m11 defines value for (1, 1)
  73576. * @param m20 defines value for (2, 0)
  73577. * @param m21 defines value for (2, 1)
  73578. */
  73579. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  73580. /**
  73581. * Fills the matrix from direct values
  73582. * @param m00 defines value for (0, 0)
  73583. * @param m01 defines value for (0, 1)
  73584. * @param m10 defines value for (1, 0)
  73585. * @param m11 defines value for (1, 1)
  73586. * @param m20 defines value for (2, 0)
  73587. * @param m21 defines value for (2, 1)
  73588. * @returns the current modified matrix
  73589. */
  73590. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  73591. /**
  73592. * Gets matrix determinant
  73593. * @returns the determinant
  73594. */
  73595. determinant(): number;
  73596. /**
  73597. * Inverses the matrix and stores it in a target matrix
  73598. * @param result defines the target matrix
  73599. * @returns the current matrix
  73600. */
  73601. invertToRef(result: Matrix2D): Matrix2D;
  73602. /**
  73603. * Multiplies the current matrix with another one
  73604. * @param other defines the second operand
  73605. * @param result defines the target matrix
  73606. * @returns the current matrix
  73607. */
  73608. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  73609. /**
  73610. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  73611. * @param x defines the x coordinate to transform
  73612. * @param y defines the x coordinate to transform
  73613. * @param result defines the target vector2
  73614. * @returns the current matrix
  73615. */
  73616. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  73617. /**
  73618. * Creates an identity matrix
  73619. * @returns a new matrix
  73620. */
  73621. static Identity(): Matrix2D;
  73622. /**
  73623. * Creates a translation matrix and stores it in a target matrix
  73624. * @param x defines the x coordinate of the translation
  73625. * @param y defines the y coordinate of the translation
  73626. * @param result defines the target matrix
  73627. */
  73628. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  73629. /**
  73630. * Creates a scaling matrix and stores it in a target matrix
  73631. * @param x defines the x coordinate of the scaling
  73632. * @param y defines the y coordinate of the scaling
  73633. * @param result defines the target matrix
  73634. */
  73635. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  73636. /**
  73637. * Creates a rotation matrix and stores it in a target matrix
  73638. * @param angle defines the rotation angle
  73639. * @param result defines the target matrix
  73640. */
  73641. static RotationToRef(angle: number, result: Matrix2D): void;
  73642. private static _TempPreTranslationMatrix;
  73643. private static _TempPostTranslationMatrix;
  73644. private static _TempRotationMatrix;
  73645. private static _TempScalingMatrix;
  73646. private static _TempCompose0;
  73647. private static _TempCompose1;
  73648. private static _TempCompose2;
  73649. /**
  73650. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  73651. * @param tx defines the x coordinate of the translation
  73652. * @param ty defines the y coordinate of the translation
  73653. * @param angle defines the rotation angle
  73654. * @param scaleX defines the x coordinate of the scaling
  73655. * @param scaleY defines the y coordinate of the scaling
  73656. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  73657. * @param result defines the target matrix
  73658. */
  73659. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  73660. }
  73661. }
  73662. declare module BABYLON.GUI {
  73663. /**
  73664. * Class used to store 2D control sizes
  73665. */
  73666. export class Measure {
  73667. /** defines left coordinate */
  73668. left: number;
  73669. /** defines top coordinate */
  73670. top: number;
  73671. /** defines width dimension */
  73672. width: number;
  73673. /** defines height dimension */
  73674. height: number;
  73675. /**
  73676. * Creates a new measure
  73677. * @param left defines left coordinate
  73678. * @param top defines top coordinate
  73679. * @param width defines width dimension
  73680. * @param height defines height dimension
  73681. */
  73682. constructor(
  73683. /** defines left coordinate */
  73684. left: number,
  73685. /** defines top coordinate */
  73686. top: number,
  73687. /** defines width dimension */
  73688. width: number,
  73689. /** defines height dimension */
  73690. height: number);
  73691. /**
  73692. * Copy from another measure
  73693. * @param other defines the other measure to copy from
  73694. */
  73695. copyFrom(other: Measure): void;
  73696. /**
  73697. * Copy from a group of 4 floats
  73698. * @param left defines left coordinate
  73699. * @param top defines top coordinate
  73700. * @param width defines width dimension
  73701. * @param height defines height dimension
  73702. */
  73703. copyFromFloats(left: number, top: number, width: number, height: number): void;
  73704. /**
  73705. * Computes the axis aligned bounding box measure for two given measures
  73706. * @param a Input measure
  73707. * @param b Input measure
  73708. * @param result the resulting bounding measure
  73709. */
  73710. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  73711. /**
  73712. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  73713. * @param transform the matrix to transform the measure before computing the AABB
  73714. * @param result the resulting AABB
  73715. */
  73716. transformToRef(transform: Matrix2D, result: Measure): void;
  73717. /**
  73718. * Check equality between this measure and another one
  73719. * @param other defines the other measures
  73720. * @returns true if both measures are equals
  73721. */
  73722. isEqualsTo(other: Measure): boolean;
  73723. /**
  73724. * Creates an empty measure
  73725. * @returns a new measure
  73726. */
  73727. static Empty(): Measure;
  73728. }
  73729. }
  73730. declare module BABYLON.GUI {
  73731. /**
  73732. * Interface used to define a control that can receive focus
  73733. */
  73734. export interface IFocusableControl {
  73735. /**
  73736. * Function called when the control receives the focus
  73737. */
  73738. onFocus(): void;
  73739. /**
  73740. * Function called when the control loses the focus
  73741. */
  73742. onBlur(): void;
  73743. /**
  73744. * Function called to let the control handle keyboard events
  73745. * @param evt defines the current keyboard event
  73746. */
  73747. processKeyboard(evt: KeyboardEvent): void;
  73748. /**
  73749. * Function called to get the list of controls that should not steal the focus from this control
  73750. * @returns an array of controls
  73751. */
  73752. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  73753. }
  73754. /**
  73755. * Class used to create texture to support 2D GUI elements
  73756. * @see http://doc.babylonjs.com/how_to/gui
  73757. */
  73758. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  73759. private _isDirty;
  73760. private _renderObserver;
  73761. private _resizeObserver;
  73762. private _preKeyboardObserver;
  73763. private _pointerMoveObserver;
  73764. private _pointerObserver;
  73765. private _canvasPointerOutObserver;
  73766. private _background;
  73767. /** @hidden */
  73768. _rootContainer: Container;
  73769. /** @hidden */
  73770. _lastPickedControl: Control;
  73771. /** @hidden */
  73772. _lastControlOver: {
  73773. [pointerId: number]: Control;
  73774. };
  73775. /** @hidden */
  73776. _lastControlDown: {
  73777. [pointerId: number]: Control;
  73778. };
  73779. /** @hidden */
  73780. _capturingControl: {
  73781. [pointerId: number]: Control;
  73782. };
  73783. /** @hidden */
  73784. _shouldBlockPointer: boolean;
  73785. /** @hidden */
  73786. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  73787. /** @hidden */
  73788. _linkedControls: Control[];
  73789. private _isFullscreen;
  73790. private _fullscreenViewport;
  73791. private _idealWidth;
  73792. private _idealHeight;
  73793. private _useSmallestIdeal;
  73794. private _renderAtIdealSize;
  73795. private _focusedControl;
  73796. private _blockNextFocusCheck;
  73797. private _renderScale;
  73798. private _rootElement;
  73799. private _cursorChanged;
  73800. private _defaultMousePointerId;
  73801. /** @hidden */
  73802. _numLayoutCalls: number;
  73803. /** Gets the number of layout calls made the last time the ADT has been rendered */
  73804. get numLayoutCalls(): number;
  73805. /** @hidden */
  73806. _numRenderCalls: number;
  73807. /** Gets the number of render calls made the last time the ADT has been rendered */
  73808. get numRenderCalls(): number;
  73809. /**
  73810. * Define type to string to ensure compatibility across browsers
  73811. * Safari doesn't support DataTransfer constructor
  73812. */
  73813. private _clipboardData;
  73814. /**
  73815. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  73816. */
  73817. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  73818. /**
  73819. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  73820. */
  73821. onControlPickedObservable: BABYLON.Observable<Control>;
  73822. /**
  73823. * BABYLON.Observable event triggered before layout is evaluated
  73824. */
  73825. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  73826. /**
  73827. * BABYLON.Observable event triggered after the layout was evaluated
  73828. */
  73829. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  73830. /**
  73831. * BABYLON.Observable event triggered before the texture is rendered
  73832. */
  73833. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  73834. /**
  73835. * BABYLON.Observable event triggered after the texture was rendered
  73836. */
  73837. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  73838. /**
  73839. * Gets or sets a boolean defining if alpha is stored as premultiplied
  73840. */
  73841. premulAlpha: boolean;
  73842. /**
  73843. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  73844. * Useful when you want more antialiasing
  73845. */
  73846. get renderScale(): number;
  73847. set renderScale(value: number);
  73848. /** Gets or sets the background color */
  73849. get background(): string;
  73850. set background(value: string);
  73851. /**
  73852. * Gets or sets the ideal width used to design controls.
  73853. * The GUI will then rescale everything accordingly
  73854. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  73855. */
  73856. get idealWidth(): number;
  73857. set idealWidth(value: number);
  73858. /**
  73859. * Gets or sets the ideal height used to design controls.
  73860. * The GUI will then rescale everything accordingly
  73861. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  73862. */
  73863. get idealHeight(): number;
  73864. set idealHeight(value: number);
  73865. /**
  73866. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  73867. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  73868. */
  73869. get useSmallestIdeal(): boolean;
  73870. set useSmallestIdeal(value: boolean);
  73871. /**
  73872. * Gets or sets a boolean indicating if adaptive scaling must be used
  73873. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  73874. */
  73875. get renderAtIdealSize(): boolean;
  73876. set renderAtIdealSize(value: boolean);
  73877. /**
  73878. * Gets the ratio used when in "ideal mode"
  73879. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  73880. * */
  73881. get idealRatio(): number;
  73882. /**
  73883. * Gets the underlying layer used to render the texture when in fullscreen mode
  73884. */
  73885. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  73886. /**
  73887. * Gets the root container control
  73888. */
  73889. get rootContainer(): Container;
  73890. /**
  73891. * Returns an array containing the root container.
  73892. * This is mostly used to let the Inspector introspects the ADT
  73893. * @returns an array containing the rootContainer
  73894. */
  73895. getChildren(): Array<Container>;
  73896. /**
  73897. * Will return all controls that are inside this texture
  73898. * @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
  73899. * @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
  73900. * @return all child controls
  73901. */
  73902. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  73903. /**
  73904. * Gets or sets the current focused control
  73905. */
  73906. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  73907. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  73908. /**
  73909. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  73910. */
  73911. get isForeground(): boolean;
  73912. set isForeground(value: boolean);
  73913. /**
  73914. * Gets or set information about clipboardData
  73915. */
  73916. get clipboardData(): string;
  73917. set clipboardData(value: string);
  73918. /**
  73919. * Creates a new AdvancedDynamicTexture
  73920. * @param name defines the name of the texture
  73921. * @param width defines the width of the texture
  73922. * @param height defines the height of the texture
  73923. * @param scene defines the hosting scene
  73924. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  73925. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  73926. */
  73927. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  73928. /**
  73929. * Get the current class name of the texture useful for serialization or dynamic coding.
  73930. * @returns "AdvancedDynamicTexture"
  73931. */
  73932. getClassName(): string;
  73933. /**
  73934. * Function used to execute a function on all controls
  73935. * @param func defines the function to execute
  73936. * @param container defines the container where controls belong. If null the root container will be used
  73937. */
  73938. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  73939. private _useInvalidateRectOptimization;
  73940. /**
  73941. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  73942. */
  73943. get useInvalidateRectOptimization(): boolean;
  73944. set useInvalidateRectOptimization(value: boolean);
  73945. private _invalidatedRectangle;
  73946. /**
  73947. * Invalidates a rectangle area on the gui texture
  73948. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  73949. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  73950. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  73951. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  73952. */
  73953. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  73954. /**
  73955. * Marks the texture as dirty forcing a complete update
  73956. */
  73957. markAsDirty(): void;
  73958. /**
  73959. * Helper function used to create a new style
  73960. * @returns a new style
  73961. * @see http://doc.babylonjs.com/how_to/gui#styles
  73962. */
  73963. createStyle(): Style;
  73964. /**
  73965. * Adds a new control to the root container
  73966. * @param control defines the control to add
  73967. * @returns the current texture
  73968. */
  73969. addControl(control: Control): AdvancedDynamicTexture;
  73970. /**
  73971. * Removes a control from the root container
  73972. * @param control defines the control to remove
  73973. * @returns the current texture
  73974. */
  73975. removeControl(control: Control): AdvancedDynamicTexture;
  73976. /**
  73977. * Release all resources
  73978. */
  73979. dispose(): void;
  73980. private _onResize;
  73981. /** @hidden */
  73982. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  73983. /**
  73984. * Get screen coordinates for a vector3
  73985. * @param position defines the position to project
  73986. * @param worldMatrix defines the world matrix to use
  73987. * @returns the projected position
  73988. */
  73989. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  73990. private _checkUpdate;
  73991. private _clearMeasure;
  73992. private _render;
  73993. /** @hidden */
  73994. _changeCursor(cursor: string): void;
  73995. /** @hidden */
  73996. _registerLastControlDown(control: Control, pointerId: number): void;
  73997. private _doPicking;
  73998. /** @hidden */
  73999. _cleanControlAfterRemovalFromList(list: {
  74000. [pointerId: number]: Control;
  74001. }, control: Control): void;
  74002. /** @hidden */
  74003. _cleanControlAfterRemoval(control: Control): void;
  74004. /** Attach to all scene events required to support pointer events */
  74005. attach(): void;
  74006. /** @hidden */
  74007. private onClipboardCopy;
  74008. /** @hidden */
  74009. private onClipboardCut;
  74010. /** @hidden */
  74011. private onClipboardPaste;
  74012. /**
  74013. * Register the clipboard Events onto the canvas
  74014. */
  74015. registerClipboardEvents(): void;
  74016. /**
  74017. * Unregister the clipboard Events from the canvas
  74018. */
  74019. unRegisterClipboardEvents(): void;
  74020. /**
  74021. * Connect the texture to a hosting mesh to enable interactions
  74022. * @param mesh defines the mesh to attach to
  74023. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  74024. */
  74025. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  74026. /**
  74027. * Move the focus to a specific control
  74028. * @param control defines the control which will receive the focus
  74029. */
  74030. moveFocusToControl(control: IFocusableControl): void;
  74031. private _manageFocus;
  74032. private _attachToOnPointerOut;
  74033. /**
  74034. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  74035. * @param mesh defines the mesh which will receive the texture
  74036. * @param width defines the texture width (1024 by default)
  74037. * @param height defines the texture height (1024 by default)
  74038. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  74039. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  74040. * @returns a new AdvancedDynamicTexture
  74041. */
  74042. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  74043. /**
  74044. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  74045. * In this mode the texture will rely on a layer for its rendering.
  74046. * This allows it to be treated like any other layer.
  74047. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  74048. * LayerMask is set through advancedTexture.layer.layerMask
  74049. * @param name defines name for the texture
  74050. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  74051. * @param scene defines the hsoting scene
  74052. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  74053. * @returns a new AdvancedDynamicTexture
  74054. */
  74055. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  74056. }
  74057. }
  74058. declare module BABYLON.GUI {
  74059. /**
  74060. * Root class used for all 2D controls
  74061. * @see http://doc.babylonjs.com/how_to/gui#controls
  74062. */
  74063. export class Control {
  74064. /** defines the name of the control */
  74065. name?: string | undefined;
  74066. /**
  74067. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  74068. */
  74069. static AllowAlphaInheritance: boolean;
  74070. private _alpha;
  74071. private _alphaSet;
  74072. private _zIndex;
  74073. /** @hidden */
  74074. _host: AdvancedDynamicTexture;
  74075. /** Gets or sets the control parent */
  74076. parent: BABYLON.Nullable<Container>;
  74077. /** @hidden */
  74078. _currentMeasure: Measure;
  74079. private _fontFamily;
  74080. private _fontStyle;
  74081. private _fontWeight;
  74082. private _fontSize;
  74083. private _font;
  74084. /** @hidden */
  74085. _width: ValueAndUnit;
  74086. /** @hidden */
  74087. _height: ValueAndUnit;
  74088. /** @hidden */
  74089. protected _fontOffset: {
  74090. ascent: number;
  74091. height: number;
  74092. descent: number;
  74093. };
  74094. private _color;
  74095. private _style;
  74096. private _styleObserver;
  74097. /** @hidden */
  74098. protected _horizontalAlignment: number;
  74099. /** @hidden */
  74100. protected _verticalAlignment: number;
  74101. /** @hidden */
  74102. protected _isDirty: boolean;
  74103. /** @hidden */
  74104. protected _wasDirty: boolean;
  74105. /** @hidden */
  74106. _tempParentMeasure: Measure;
  74107. /** @hidden */
  74108. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  74109. /** @hidden */
  74110. protected _cachedParentMeasure: Measure;
  74111. private _paddingLeft;
  74112. private _paddingRight;
  74113. private _paddingTop;
  74114. private _paddingBottom;
  74115. /** @hidden */
  74116. _left: ValueAndUnit;
  74117. /** @hidden */
  74118. _top: ValueAndUnit;
  74119. private _scaleX;
  74120. private _scaleY;
  74121. private _rotation;
  74122. private _transformCenterX;
  74123. private _transformCenterY;
  74124. /** @hidden */
  74125. _transformMatrix: Matrix2D;
  74126. /** @hidden */
  74127. protected _invertTransformMatrix: Matrix2D;
  74128. /** @hidden */
  74129. protected _transformedPosition: BABYLON.Vector2;
  74130. private _isMatrixDirty;
  74131. private _cachedOffsetX;
  74132. private _cachedOffsetY;
  74133. private _isVisible;
  74134. private _isHighlighted;
  74135. /** @hidden */
  74136. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  74137. private _fontSet;
  74138. private _dummyVector2;
  74139. private _downCount;
  74140. private _enterCount;
  74141. private _doNotRender;
  74142. private _downPointerIds;
  74143. protected _isEnabled: boolean;
  74144. protected _disabledColor: string;
  74145. protected _disabledColorItem: string;
  74146. /** @hidden */
  74147. protected _rebuildLayout: boolean;
  74148. /** @hidden */
  74149. _customData: any;
  74150. /** @hidden */
  74151. _isClipped: boolean;
  74152. /** @hidden */
  74153. _automaticSize: boolean;
  74154. /** @hidden */
  74155. _tag: any;
  74156. /**
  74157. * 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
  74158. */
  74159. uniqueId: number;
  74160. /**
  74161. * Gets or sets an object used to store user defined information for the node
  74162. */
  74163. metadata: any;
  74164. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  74165. isHitTestVisible: boolean;
  74166. /** Gets or sets a boolean indicating if the control can block pointer events */
  74167. isPointerBlocker: boolean;
  74168. /** Gets or sets a boolean indicating if the control can be focusable */
  74169. isFocusInvisible: boolean;
  74170. /**
  74171. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  74172. * 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
  74173. */
  74174. clipChildren: boolean;
  74175. /**
  74176. * Gets or sets a boolean indicating that control content must be clipped
  74177. * 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
  74178. */
  74179. clipContent: boolean;
  74180. /**
  74181. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  74182. */
  74183. useBitmapCache: boolean;
  74184. private _cacheData;
  74185. private _shadowOffsetX;
  74186. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  74187. get shadowOffsetX(): number;
  74188. set shadowOffsetX(value: number);
  74189. private _shadowOffsetY;
  74190. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  74191. get shadowOffsetY(): number;
  74192. set shadowOffsetY(value: number);
  74193. private _shadowBlur;
  74194. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  74195. get shadowBlur(): number;
  74196. set shadowBlur(value: number);
  74197. private _shadowColor;
  74198. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  74199. get shadowColor(): string;
  74200. set shadowColor(value: string);
  74201. /** Gets or sets the cursor to use when the control is hovered */
  74202. hoverCursor: string;
  74203. /** @hidden */
  74204. protected _linkOffsetX: ValueAndUnit;
  74205. /** @hidden */
  74206. protected _linkOffsetY: ValueAndUnit;
  74207. /** Gets the control type name */
  74208. get typeName(): string;
  74209. /**
  74210. * Get the current class name of the control.
  74211. * @returns current class name
  74212. */
  74213. getClassName(): string;
  74214. /**
  74215. * An event triggered when pointer wheel is scrolled
  74216. */
  74217. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  74218. /**
  74219. * An event triggered when the pointer move over the control.
  74220. */
  74221. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  74222. /**
  74223. * An event triggered when the pointer move out of the control.
  74224. */
  74225. onPointerOutObservable: BABYLON.Observable<Control>;
  74226. /**
  74227. * An event triggered when the pointer taps the control
  74228. */
  74229. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  74230. /**
  74231. * An event triggered when pointer up
  74232. */
  74233. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  74234. /**
  74235. * An event triggered when a control is clicked on
  74236. */
  74237. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  74238. /**
  74239. * An event triggered when pointer enters the control
  74240. */
  74241. onPointerEnterObservable: BABYLON.Observable<Control>;
  74242. /**
  74243. * An event triggered when the control is marked as dirty
  74244. */
  74245. onDirtyObservable: BABYLON.Observable<Control>;
  74246. /**
  74247. * An event triggered before drawing the control
  74248. */
  74249. onBeforeDrawObservable: BABYLON.Observable<Control>;
  74250. /**
  74251. * An event triggered after the control was drawn
  74252. */
  74253. onAfterDrawObservable: BABYLON.Observable<Control>;
  74254. /**
  74255. * An event triggered when the control has been disposed
  74256. */
  74257. onDisposeObservable: BABYLON.Observable<Control>;
  74258. /**
  74259. * Get the hosting AdvancedDynamicTexture
  74260. */
  74261. get host(): AdvancedDynamicTexture;
  74262. /** Gets or set information about font offsets (used to render and align text) */
  74263. get fontOffset(): {
  74264. ascent: number;
  74265. height: number;
  74266. descent: number;
  74267. };
  74268. set fontOffset(offset: {
  74269. ascent: number;
  74270. height: number;
  74271. descent: number;
  74272. });
  74273. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  74274. get alpha(): number;
  74275. set alpha(value: number);
  74276. /**
  74277. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  74278. */
  74279. get isHighlighted(): boolean;
  74280. set isHighlighted(value: boolean);
  74281. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  74282. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  74283. */
  74284. get scaleX(): number;
  74285. set scaleX(value: number);
  74286. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  74287. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  74288. */
  74289. get scaleY(): number;
  74290. set scaleY(value: number);
  74291. /** Gets or sets the rotation angle (0 by default)
  74292. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  74293. */
  74294. get rotation(): number;
  74295. set rotation(value: number);
  74296. /** Gets or sets the transformation center on Y axis (0 by default)
  74297. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  74298. */
  74299. get transformCenterY(): number;
  74300. set transformCenterY(value: number);
  74301. /** Gets or sets the transformation center on X axis (0 by default)
  74302. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  74303. */
  74304. get transformCenterX(): number;
  74305. set transformCenterX(value: number);
  74306. /**
  74307. * Gets or sets the horizontal alignment
  74308. * @see http://doc.babylonjs.com/how_to/gui#alignments
  74309. */
  74310. get horizontalAlignment(): number;
  74311. set horizontalAlignment(value: number);
  74312. /**
  74313. * Gets or sets the vertical alignment
  74314. * @see http://doc.babylonjs.com/how_to/gui#alignments
  74315. */
  74316. get verticalAlignment(): number;
  74317. set verticalAlignment(value: number);
  74318. /**
  74319. * Gets or sets control width
  74320. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74321. */
  74322. get width(): string | number;
  74323. set width(value: string | number);
  74324. /**
  74325. * Gets or sets the control width in pixel
  74326. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74327. */
  74328. get widthInPixels(): number;
  74329. set widthInPixels(value: number);
  74330. /**
  74331. * Gets or sets control height
  74332. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74333. */
  74334. get height(): string | number;
  74335. set height(value: string | number);
  74336. /**
  74337. * Gets or sets control height in pixel
  74338. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74339. */
  74340. get heightInPixels(): number;
  74341. set heightInPixels(value: number);
  74342. /** Gets or set font family */
  74343. get fontFamily(): string;
  74344. set fontFamily(value: string);
  74345. /** Gets or sets font style */
  74346. get fontStyle(): string;
  74347. set fontStyle(value: string);
  74348. /** Gets or sets font weight */
  74349. get fontWeight(): string;
  74350. set fontWeight(value: string);
  74351. /**
  74352. * Gets or sets style
  74353. * @see http://doc.babylonjs.com/how_to/gui#styles
  74354. */
  74355. get style(): BABYLON.Nullable<Style>;
  74356. set style(value: BABYLON.Nullable<Style>);
  74357. /** @hidden */
  74358. get _isFontSizeInPercentage(): boolean;
  74359. /** Gets or sets font size in pixels */
  74360. get fontSizeInPixels(): number;
  74361. set fontSizeInPixels(value: number);
  74362. /** Gets or sets font size */
  74363. get fontSize(): string | number;
  74364. set fontSize(value: string | number);
  74365. /** Gets or sets foreground color */
  74366. get color(): string;
  74367. set color(value: string);
  74368. /** Gets or sets z index which is used to reorder controls on the z axis */
  74369. get zIndex(): number;
  74370. set zIndex(value: number);
  74371. /** Gets or sets a boolean indicating if the control can be rendered */
  74372. get notRenderable(): boolean;
  74373. set notRenderable(value: boolean);
  74374. /** Gets or sets a boolean indicating if the control is visible */
  74375. get isVisible(): boolean;
  74376. set isVisible(value: boolean);
  74377. /** Gets a boolean indicating that the control needs to update its rendering */
  74378. get isDirty(): boolean;
  74379. /**
  74380. * Gets the current linked mesh (or null if none)
  74381. */
  74382. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  74383. /**
  74384. * Gets or sets a value indicating the padding to use on the left of the control
  74385. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74386. */
  74387. get paddingLeft(): string | number;
  74388. set paddingLeft(value: string | number);
  74389. /**
  74390. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  74391. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74392. */
  74393. get paddingLeftInPixels(): number;
  74394. set paddingLeftInPixels(value: number);
  74395. /**
  74396. * Gets or sets a value indicating the padding to use on the right of the control
  74397. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74398. */
  74399. get paddingRight(): string | number;
  74400. set paddingRight(value: string | number);
  74401. /**
  74402. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  74403. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74404. */
  74405. get paddingRightInPixels(): number;
  74406. set paddingRightInPixels(value: number);
  74407. /**
  74408. * Gets or sets a value indicating the padding to use on the top of the control
  74409. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74410. */
  74411. get paddingTop(): string | number;
  74412. set paddingTop(value: string | number);
  74413. /**
  74414. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  74415. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74416. */
  74417. get paddingTopInPixels(): number;
  74418. set paddingTopInPixels(value: number);
  74419. /**
  74420. * Gets or sets a value indicating the padding to use on the bottom of the control
  74421. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74422. */
  74423. get paddingBottom(): string | number;
  74424. set paddingBottom(value: string | number);
  74425. /**
  74426. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  74427. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74428. */
  74429. get paddingBottomInPixels(): number;
  74430. set paddingBottomInPixels(value: number);
  74431. /**
  74432. * Gets or sets a value indicating the left coordinate of the control
  74433. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74434. */
  74435. get left(): string | number;
  74436. set left(value: string | number);
  74437. /**
  74438. * Gets or sets a value indicating the left coordinate in pixels of the control
  74439. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74440. */
  74441. get leftInPixels(): number;
  74442. set leftInPixels(value: number);
  74443. /**
  74444. * Gets or sets a value indicating the top coordinate of the control
  74445. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74446. */
  74447. get top(): string | number;
  74448. set top(value: string | number);
  74449. /**
  74450. * Gets or sets a value indicating the top coordinate in pixels of the control
  74451. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74452. */
  74453. get topInPixels(): number;
  74454. set topInPixels(value: number);
  74455. /**
  74456. * Gets or sets a value indicating the offset on X axis to the linked mesh
  74457. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  74458. */
  74459. get linkOffsetX(): string | number;
  74460. set linkOffsetX(value: string | number);
  74461. /**
  74462. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  74463. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  74464. */
  74465. get linkOffsetXInPixels(): number;
  74466. set linkOffsetXInPixels(value: number);
  74467. /**
  74468. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  74469. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  74470. */
  74471. get linkOffsetY(): string | number;
  74472. set linkOffsetY(value: string | number);
  74473. /**
  74474. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  74475. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  74476. */
  74477. get linkOffsetYInPixels(): number;
  74478. set linkOffsetYInPixels(value: number);
  74479. /** Gets the center coordinate on X axis */
  74480. get centerX(): number;
  74481. /** Gets the center coordinate on Y axis */
  74482. get centerY(): number;
  74483. /** Gets or sets if control is Enabled*/
  74484. get isEnabled(): boolean;
  74485. set isEnabled(value: boolean);
  74486. /** Gets or sets background color of control if it's disabled*/
  74487. get disabledColor(): string;
  74488. set disabledColor(value: string);
  74489. /** Gets or sets front color of control if it's disabled*/
  74490. get disabledColorItem(): string;
  74491. set disabledColorItem(value: string);
  74492. /**
  74493. * Creates a new control
  74494. * @param name defines the name of the control
  74495. */
  74496. constructor(
  74497. /** defines the name of the control */
  74498. name?: string | undefined);
  74499. /** @hidden */
  74500. protected _getTypeName(): string;
  74501. /**
  74502. * Gets the first ascendant in the hierarchy of the given type
  74503. * @param className defines the required type
  74504. * @returns the ascendant or null if not found
  74505. */
  74506. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  74507. /** @hidden */
  74508. _resetFontCache(): void;
  74509. /**
  74510. * Determines if a container is an ascendant of the current control
  74511. * @param container defines the container to look for
  74512. * @returns true if the container is one of the ascendant of the control
  74513. */
  74514. isAscendant(container: Control): boolean;
  74515. /**
  74516. * Gets coordinates in local control space
  74517. * @param globalCoordinates defines the coordinates to transform
  74518. * @returns the new coordinates in local space
  74519. */
  74520. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  74521. /**
  74522. * Gets coordinates in local control space
  74523. * @param globalCoordinates defines the coordinates to transform
  74524. * @param result defines the target vector2 where to store the result
  74525. * @returns the current control
  74526. */
  74527. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  74528. /**
  74529. * Gets coordinates in parent local control space
  74530. * @param globalCoordinates defines the coordinates to transform
  74531. * @returns the new coordinates in parent local space
  74532. */
  74533. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  74534. /**
  74535. * Move the current control to a vector3 position projected onto the screen.
  74536. * @param position defines the target position
  74537. * @param scene defines the hosting scene
  74538. */
  74539. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  74540. /**
  74541. * Will store all controls that have this control as ascendant in a given array
  74542. * @param results defines the array where to store the descendants
  74543. * @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
  74544. * @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
  74545. */
  74546. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  74547. /**
  74548. * Will return all controls that have this control as ascendant
  74549. * @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
  74550. * @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
  74551. * @return all child controls
  74552. */
  74553. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  74554. /**
  74555. * Link current control with a target mesh
  74556. * @param mesh defines the mesh to link with
  74557. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  74558. */
  74559. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  74560. /** @hidden */
  74561. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  74562. /** @hidden */
  74563. _offsetLeft(offset: number): void;
  74564. /** @hidden */
  74565. _offsetTop(offset: number): void;
  74566. /** @hidden */
  74567. _markMatrixAsDirty(): void;
  74568. /** @hidden */
  74569. _flagDescendantsAsMatrixDirty(): void;
  74570. /** @hidden */
  74571. _intersectsRect(rect: Measure): boolean;
  74572. /** @hidden */
  74573. protected invalidateRect(): void;
  74574. /** @hidden */
  74575. _markAsDirty(force?: boolean): void;
  74576. /** @hidden */
  74577. _markAllAsDirty(): void;
  74578. /** @hidden */
  74579. _link(host: AdvancedDynamicTexture): void;
  74580. /** @hidden */
  74581. protected _transform(context?: CanvasRenderingContext2D): void;
  74582. /** @hidden */
  74583. _renderHighlight(context: CanvasRenderingContext2D): void;
  74584. /** @hidden */
  74585. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  74586. /** @hidden */
  74587. protected _applyStates(context: CanvasRenderingContext2D): void;
  74588. /** @hidden */
  74589. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  74590. /** @hidden */
  74591. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74592. protected _evaluateClippingState(parentMeasure: Measure): void;
  74593. /** @hidden */
  74594. _measure(): void;
  74595. /** @hidden */
  74596. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74597. /** @hidden */
  74598. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74599. /** @hidden */
  74600. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74601. /** @hidden */
  74602. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  74603. private static _ClipMeasure;
  74604. private _tmpMeasureA;
  74605. private _clip;
  74606. /** @hidden */
  74607. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  74608. /** @hidden */
  74609. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  74610. /**
  74611. * Tests if a given coordinates belong to the current control
  74612. * @param x defines x coordinate to test
  74613. * @param y defines y coordinate to test
  74614. * @returns true if the coordinates are inside the control
  74615. */
  74616. contains(x: number, y: number): boolean;
  74617. /** @hidden */
  74618. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  74619. /** @hidden */
  74620. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  74621. /** @hidden */
  74622. _onPointerEnter(target: Control): boolean;
  74623. /** @hidden */
  74624. _onPointerOut(target: Control, force?: boolean): void;
  74625. /** @hidden */
  74626. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  74627. /** @hidden */
  74628. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  74629. /** @hidden */
  74630. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  74631. /** @hidden */
  74632. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  74633. /** @hidden */
  74634. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  74635. private _prepareFont;
  74636. /** Releases associated resources */
  74637. dispose(): void;
  74638. private static _HORIZONTAL_ALIGNMENT_LEFT;
  74639. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  74640. private static _HORIZONTAL_ALIGNMENT_CENTER;
  74641. private static _VERTICAL_ALIGNMENT_TOP;
  74642. private static _VERTICAL_ALIGNMENT_BOTTOM;
  74643. private static _VERTICAL_ALIGNMENT_CENTER;
  74644. /** HORIZONTAL_ALIGNMENT_LEFT */
  74645. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  74646. /** HORIZONTAL_ALIGNMENT_RIGHT */
  74647. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  74648. /** HORIZONTAL_ALIGNMENT_CENTER */
  74649. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  74650. /** VERTICAL_ALIGNMENT_TOP */
  74651. static get VERTICAL_ALIGNMENT_TOP(): number;
  74652. /** VERTICAL_ALIGNMENT_BOTTOM */
  74653. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  74654. /** VERTICAL_ALIGNMENT_CENTER */
  74655. static get VERTICAL_ALIGNMENT_CENTER(): number;
  74656. private static _FontHeightSizes;
  74657. /** @hidden */
  74658. static _GetFontOffset(font: string): {
  74659. ascent: number;
  74660. height: number;
  74661. descent: number;
  74662. };
  74663. /**
  74664. * Creates a stack panel that can be used to render headers
  74665. * @param control defines the control to associate with the header
  74666. * @param text defines the text of the header
  74667. * @param size defines the size of the header
  74668. * @param options defines options used to configure the header
  74669. * @returns a new StackPanel
  74670. * @ignore
  74671. * @hidden
  74672. */
  74673. static AddHeader: (control: Control, text: string, size: string | number, options: {
  74674. isHorizontal: boolean;
  74675. controlFirst: boolean;
  74676. }) => any;
  74677. /** @hidden */
  74678. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  74679. }
  74680. }
  74681. declare module BABYLON.GUI {
  74682. /**
  74683. * Root class for 2D containers
  74684. * @see http://doc.babylonjs.com/how_to/gui#containers
  74685. */
  74686. export class Container extends Control {
  74687. name?: string | undefined;
  74688. /** @hidden */
  74689. _children: Control[];
  74690. /** @hidden */
  74691. protected _measureForChildren: Measure;
  74692. /** @hidden */
  74693. protected _background: string;
  74694. /** @hidden */
  74695. protected _adaptWidthToChildren: boolean;
  74696. /** @hidden */
  74697. protected _adaptHeightToChildren: boolean;
  74698. /**
  74699. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  74700. */
  74701. logLayoutCycleErrors: boolean;
  74702. /**
  74703. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  74704. */
  74705. maxLayoutCycle: number;
  74706. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  74707. get adaptHeightToChildren(): boolean;
  74708. set adaptHeightToChildren(value: boolean);
  74709. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  74710. get adaptWidthToChildren(): boolean;
  74711. set adaptWidthToChildren(value: boolean);
  74712. /** Gets or sets background color */
  74713. get background(): string;
  74714. set background(value: string);
  74715. /** Gets the list of children */
  74716. get children(): Control[];
  74717. /**
  74718. * Creates a new Container
  74719. * @param name defines the name of the container
  74720. */
  74721. constructor(name?: string | undefined);
  74722. protected _getTypeName(): string;
  74723. _flagDescendantsAsMatrixDirty(): void;
  74724. /**
  74725. * Gets a child using its name
  74726. * @param name defines the child name to look for
  74727. * @returns the child control if found
  74728. */
  74729. getChildByName(name: string): BABYLON.Nullable<Control>;
  74730. /**
  74731. * Gets a child using its type and its name
  74732. * @param name defines the child name to look for
  74733. * @param type defines the child type to look for
  74734. * @returns the child control if found
  74735. */
  74736. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  74737. /**
  74738. * Search for a specific control in children
  74739. * @param control defines the control to look for
  74740. * @returns true if the control is in child list
  74741. */
  74742. containsControl(control: Control): boolean;
  74743. /**
  74744. * Adds a new control to the current container
  74745. * @param control defines the control to add
  74746. * @returns the current container
  74747. */
  74748. addControl(control: BABYLON.Nullable<Control>): Container;
  74749. /**
  74750. * Removes all controls from the current container
  74751. * @returns the current container
  74752. */
  74753. clearControls(): Container;
  74754. /**
  74755. * Removes a control from the current container
  74756. * @param control defines the control to remove
  74757. * @returns the current container
  74758. */
  74759. removeControl(control: Control): Container;
  74760. /** @hidden */
  74761. _reOrderControl(control: Control): void;
  74762. /** @hidden */
  74763. _offsetLeft(offset: number): void;
  74764. /** @hidden */
  74765. _offsetTop(offset: number): void;
  74766. /** @hidden */
  74767. _markAllAsDirty(): void;
  74768. /** @hidden */
  74769. protected _localDraw(context: CanvasRenderingContext2D): void;
  74770. /** @hidden */
  74771. _link(host: AdvancedDynamicTexture): void;
  74772. /** @hidden */
  74773. protected _beforeLayout(): void;
  74774. /** @hidden */
  74775. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74776. /** @hidden */
  74777. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  74778. protected _postMeasure(): void;
  74779. /** @hidden */
  74780. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  74781. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  74782. /** @hidden */
  74783. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  74784. /** @hidden */
  74785. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74786. /** Releases associated resources */
  74787. dispose(): void;
  74788. }
  74789. }
  74790. declare module BABYLON.GUI {
  74791. /** Class used to create rectangle container */
  74792. export class Rectangle extends Container {
  74793. name?: string | undefined;
  74794. private _thickness;
  74795. private _cornerRadius;
  74796. /** Gets or sets border thickness */
  74797. get thickness(): number;
  74798. set thickness(value: number);
  74799. /** Gets or sets the corner radius angle */
  74800. get cornerRadius(): number;
  74801. set cornerRadius(value: number);
  74802. /**
  74803. * Creates a new Rectangle
  74804. * @param name defines the control name
  74805. */
  74806. constructor(name?: string | undefined);
  74807. protected _getTypeName(): string;
  74808. protected _localDraw(context: CanvasRenderingContext2D): void;
  74809. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74810. private _drawRoundedRect;
  74811. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  74812. }
  74813. }
  74814. declare module BABYLON.GUI {
  74815. /**
  74816. * Enum that determines the text-wrapping mode to use.
  74817. */
  74818. export enum TextWrapping {
  74819. /**
  74820. * Clip the text when it's larger than Control.width; this is the default mode.
  74821. */
  74822. Clip = 0,
  74823. /**
  74824. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  74825. */
  74826. WordWrap = 1,
  74827. /**
  74828. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  74829. */
  74830. Ellipsis = 2
  74831. }
  74832. /**
  74833. * Class used to create text block control
  74834. */
  74835. export class TextBlock extends Control {
  74836. /**
  74837. * Defines the name of the control
  74838. */
  74839. name?: string | undefined;
  74840. private _text;
  74841. private _textWrapping;
  74842. private _textHorizontalAlignment;
  74843. private _textVerticalAlignment;
  74844. private _lines;
  74845. private _resizeToFit;
  74846. private _lineSpacing;
  74847. private _outlineWidth;
  74848. private _outlineColor;
  74849. /**
  74850. * An event triggered after the text is changed
  74851. */
  74852. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  74853. /**
  74854. * An event triggered after the text was broken up into lines
  74855. */
  74856. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  74857. /**
  74858. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  74859. */
  74860. get lines(): any[];
  74861. /**
  74862. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  74863. */
  74864. get resizeToFit(): boolean;
  74865. /**
  74866. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  74867. */
  74868. set resizeToFit(value: boolean);
  74869. /**
  74870. * Gets or sets a boolean indicating if text must be wrapped
  74871. */
  74872. get textWrapping(): TextWrapping | boolean;
  74873. /**
  74874. * Gets or sets a boolean indicating if text must be wrapped
  74875. */
  74876. set textWrapping(value: TextWrapping | boolean);
  74877. /**
  74878. * Gets or sets text to display
  74879. */
  74880. get text(): string;
  74881. /**
  74882. * Gets or sets text to display
  74883. */
  74884. set text(value: string);
  74885. /**
  74886. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  74887. */
  74888. get textHorizontalAlignment(): number;
  74889. /**
  74890. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  74891. */
  74892. set textHorizontalAlignment(value: number);
  74893. /**
  74894. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  74895. */
  74896. get textVerticalAlignment(): number;
  74897. /**
  74898. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  74899. */
  74900. set textVerticalAlignment(value: number);
  74901. /**
  74902. * Gets or sets line spacing value
  74903. */
  74904. set lineSpacing(value: string | number);
  74905. /**
  74906. * Gets or sets line spacing value
  74907. */
  74908. get lineSpacing(): string | number;
  74909. /**
  74910. * Gets or sets outlineWidth of the text to display
  74911. */
  74912. get outlineWidth(): number;
  74913. /**
  74914. * Gets or sets outlineWidth of the text to display
  74915. */
  74916. set outlineWidth(value: number);
  74917. /**
  74918. * Gets or sets outlineColor of the text to display
  74919. */
  74920. get outlineColor(): string;
  74921. /**
  74922. * Gets or sets outlineColor of the text to display
  74923. */
  74924. set outlineColor(value: string);
  74925. /**
  74926. * Creates a new TextBlock object
  74927. * @param name defines the name of the control
  74928. * @param text defines the text to display (emptry string by default)
  74929. */
  74930. constructor(
  74931. /**
  74932. * Defines the name of the control
  74933. */
  74934. name?: string | undefined, text?: string);
  74935. protected _getTypeName(): string;
  74936. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74937. private _drawText;
  74938. /** @hidden */
  74939. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  74940. protected _applyStates(context: CanvasRenderingContext2D): void;
  74941. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  74942. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  74943. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  74944. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  74945. protected _renderLines(context: CanvasRenderingContext2D): void;
  74946. /**
  74947. * Given a width constraint applied on the text block, find the expected height
  74948. * @returns expected height
  74949. */
  74950. computeExpectedHeight(): number;
  74951. dispose(): void;
  74952. }
  74953. }
  74954. declare module BABYLON.GUI {
  74955. /**
  74956. * Class used to create 2D images
  74957. */
  74958. export class Image extends Control {
  74959. name?: string | undefined;
  74960. private _workingCanvas;
  74961. private _domImage;
  74962. private _imageWidth;
  74963. private _imageHeight;
  74964. private _loaded;
  74965. private _stretch;
  74966. private _source;
  74967. private _autoScale;
  74968. private _sourceLeft;
  74969. private _sourceTop;
  74970. private _sourceWidth;
  74971. private _sourceHeight;
  74972. private _svgAttributesComputationCompleted;
  74973. private _isSVG;
  74974. private _cellWidth;
  74975. private _cellHeight;
  74976. private _cellId;
  74977. private _populateNinePatchSlicesFromImage;
  74978. private _sliceLeft;
  74979. private _sliceRight;
  74980. private _sliceTop;
  74981. private _sliceBottom;
  74982. private _detectPointerOnOpaqueOnly;
  74983. /**
  74984. * BABYLON.Observable notified when the content is loaded
  74985. */
  74986. onImageLoadedObservable: BABYLON.Observable<Image>;
  74987. /**
  74988. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  74989. */
  74990. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  74991. /**
  74992. * Gets a boolean indicating that the content is loaded
  74993. */
  74994. get isLoaded(): boolean;
  74995. /**
  74996. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  74997. */
  74998. get populateNinePatchSlicesFromImage(): boolean;
  74999. set populateNinePatchSlicesFromImage(value: boolean);
  75000. /**
  75001. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  75002. * Beware using this as this will comsume more memory as the image has to be stored twice
  75003. */
  75004. get detectPointerOnOpaqueOnly(): boolean;
  75005. set detectPointerOnOpaqueOnly(value: boolean);
  75006. /**
  75007. * Gets or sets the left value for slicing (9-patch)
  75008. */
  75009. get sliceLeft(): number;
  75010. set sliceLeft(value: number);
  75011. /**
  75012. * Gets or sets the right value for slicing (9-patch)
  75013. */
  75014. get sliceRight(): number;
  75015. set sliceRight(value: number);
  75016. /**
  75017. * Gets or sets the top value for slicing (9-patch)
  75018. */
  75019. get sliceTop(): number;
  75020. set sliceTop(value: number);
  75021. /**
  75022. * Gets or sets the bottom value for slicing (9-patch)
  75023. */
  75024. get sliceBottom(): number;
  75025. set sliceBottom(value: number);
  75026. /**
  75027. * Gets or sets the left coordinate in the source image
  75028. */
  75029. get sourceLeft(): number;
  75030. set sourceLeft(value: number);
  75031. /**
  75032. * Gets or sets the top coordinate in the source image
  75033. */
  75034. get sourceTop(): number;
  75035. set sourceTop(value: number);
  75036. /**
  75037. * Gets or sets the width to capture in the source image
  75038. */
  75039. get sourceWidth(): number;
  75040. set sourceWidth(value: number);
  75041. /**
  75042. * Gets or sets the height to capture in the source image
  75043. */
  75044. get sourceHeight(): number;
  75045. set sourceHeight(value: number);
  75046. /** Indicates if the format of the image is SVG */
  75047. get isSVG(): boolean;
  75048. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  75049. get svgAttributesComputationCompleted(): boolean;
  75050. /**
  75051. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  75052. * @see http://doc.babylonjs.com/how_to/gui#image
  75053. */
  75054. get autoScale(): boolean;
  75055. set autoScale(value: boolean);
  75056. /** Gets or sets the streching mode used by the image */
  75057. get stretch(): number;
  75058. set stretch(value: number);
  75059. /** @hidden */
  75060. _rotate90(n: number, preserveProperties?: boolean): Image;
  75061. private _handleRotationForSVGImage;
  75062. private _rotate90SourceProperties;
  75063. /**
  75064. * Gets or sets the internal DOM image used to render the control
  75065. */
  75066. set domImage(value: HTMLImageElement);
  75067. get domImage(): HTMLImageElement;
  75068. private _onImageLoaded;
  75069. private _extractNinePatchSliceDataFromImage;
  75070. /**
  75071. * Gets or sets image source url
  75072. */
  75073. set source(value: BABYLON.Nullable<string>);
  75074. /**
  75075. * Checks for svg document with icon id present
  75076. */
  75077. private _svgCheck;
  75078. /**
  75079. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  75080. * given external svg file and icon id
  75081. */
  75082. private _getSVGAttribs;
  75083. /**
  75084. * Gets or sets the cell width to use when animation sheet is enabled
  75085. * @see http://doc.babylonjs.com/how_to/gui#image
  75086. */
  75087. get cellWidth(): number;
  75088. set cellWidth(value: number);
  75089. /**
  75090. * Gets or sets the cell height to use when animation sheet is enabled
  75091. * @see http://doc.babylonjs.com/how_to/gui#image
  75092. */
  75093. get cellHeight(): number;
  75094. set cellHeight(value: number);
  75095. /**
  75096. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  75097. * @see http://doc.babylonjs.com/how_to/gui#image
  75098. */
  75099. get cellId(): number;
  75100. set cellId(value: number);
  75101. /**
  75102. * Creates a new Image
  75103. * @param name defines the control name
  75104. * @param url defines the image url
  75105. */
  75106. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  75107. /**
  75108. * Tests if a given coordinates belong to the current control
  75109. * @param x defines x coordinate to test
  75110. * @param y defines y coordinate to test
  75111. * @returns true if the coordinates are inside the control
  75112. */
  75113. contains(x: number, y: number): boolean;
  75114. protected _getTypeName(): string;
  75115. /** Force the control to synchronize with its content */
  75116. synchronizeSizeWithContent(): void;
  75117. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75118. private _prepareWorkingCanvasForOpaqueDetection;
  75119. private _drawImage;
  75120. _draw(context: CanvasRenderingContext2D): void;
  75121. private _renderCornerPatch;
  75122. private _renderNinePatch;
  75123. dispose(): void;
  75124. /** STRETCH_NONE */
  75125. static readonly STRETCH_NONE: number;
  75126. /** STRETCH_FILL */
  75127. static readonly STRETCH_FILL: number;
  75128. /** STRETCH_UNIFORM */
  75129. static readonly STRETCH_UNIFORM: number;
  75130. /** STRETCH_EXTEND */
  75131. static readonly STRETCH_EXTEND: number;
  75132. /** NINE_PATCH */
  75133. static readonly STRETCH_NINE_PATCH: number;
  75134. }
  75135. }
  75136. declare module BABYLON.GUI {
  75137. /**
  75138. * Class used to create 2D buttons
  75139. */
  75140. export class Button extends Rectangle {
  75141. name?: string | undefined;
  75142. /**
  75143. * Function called to generate a pointer enter animation
  75144. */
  75145. pointerEnterAnimation: () => void;
  75146. /**
  75147. * Function called to generate a pointer out animation
  75148. */
  75149. pointerOutAnimation: () => void;
  75150. /**
  75151. * Function called to generate a pointer down animation
  75152. */
  75153. pointerDownAnimation: () => void;
  75154. /**
  75155. * Function called to generate a pointer up animation
  75156. */
  75157. pointerUpAnimation: () => void;
  75158. /**
  75159. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  75160. */
  75161. delegatePickingToChildren: boolean;
  75162. private _image;
  75163. /**
  75164. * Returns the image part of the button (if any)
  75165. */
  75166. get image(): BABYLON.Nullable<Image>;
  75167. private _textBlock;
  75168. /**
  75169. * Returns the image part of the button (if any)
  75170. */
  75171. get textBlock(): BABYLON.Nullable<TextBlock>;
  75172. /**
  75173. * Creates a new Button
  75174. * @param name defines the name of the button
  75175. */
  75176. constructor(name?: string | undefined);
  75177. protected _getTypeName(): string;
  75178. /** @hidden */
  75179. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  75180. /** @hidden */
  75181. _onPointerEnter(target: Control): boolean;
  75182. /** @hidden */
  75183. _onPointerOut(target: Control, force?: boolean): void;
  75184. /** @hidden */
  75185. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  75186. /** @hidden */
  75187. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  75188. /**
  75189. * Creates a new button made with an image and a text
  75190. * @param name defines the name of the button
  75191. * @param text defines the text of the button
  75192. * @param imageUrl defines the url of the image
  75193. * @returns a new Button
  75194. */
  75195. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  75196. /**
  75197. * Creates a new button made with an image
  75198. * @param name defines the name of the button
  75199. * @param imageUrl defines the url of the image
  75200. * @returns a new Button
  75201. */
  75202. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  75203. /**
  75204. * Creates a new button made with a text
  75205. * @param name defines the name of the button
  75206. * @param text defines the text of the button
  75207. * @returns a new Button
  75208. */
  75209. static CreateSimpleButton(name: string, text: string): Button;
  75210. /**
  75211. * Creates a new button made with an image and a centered text
  75212. * @param name defines the name of the button
  75213. * @param text defines the text of the button
  75214. * @param imageUrl defines the url of the image
  75215. * @returns a new Button
  75216. */
  75217. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  75218. }
  75219. }
  75220. declare module BABYLON.GUI {
  75221. /**
  75222. * Class used to create a 2D stack panel container
  75223. */
  75224. export class StackPanel extends Container {
  75225. name?: string | undefined;
  75226. private _isVertical;
  75227. private _manualWidth;
  75228. private _manualHeight;
  75229. private _doNotTrackManualChanges;
  75230. /**
  75231. * Gets or sets a boolean indicating that layou warnings should be ignored
  75232. */
  75233. ignoreLayoutWarnings: boolean;
  75234. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  75235. get isVertical(): boolean;
  75236. set isVertical(value: boolean);
  75237. /**
  75238. * Gets or sets panel width.
  75239. * This value should not be set when in horizontal mode as it will be computed automatically
  75240. */
  75241. set width(value: string | number);
  75242. get width(): string | number;
  75243. /**
  75244. * Gets or sets panel height.
  75245. * This value should not be set when in vertical mode as it will be computed automatically
  75246. */
  75247. set height(value: string | number);
  75248. get height(): string | number;
  75249. /**
  75250. * Creates a new StackPanel
  75251. * @param name defines control name
  75252. */
  75253. constructor(name?: string | undefined);
  75254. protected _getTypeName(): string;
  75255. /** @hidden */
  75256. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75257. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75258. protected _postMeasure(): void;
  75259. }
  75260. }
  75261. declare module BABYLON.GUI {
  75262. /**
  75263. * Class used to represent a 2D checkbox
  75264. */
  75265. export class Checkbox extends Control {
  75266. name?: string | undefined;
  75267. private _isChecked;
  75268. private _background;
  75269. private _checkSizeRatio;
  75270. private _thickness;
  75271. /** Gets or sets border thickness */
  75272. get thickness(): number;
  75273. set thickness(value: number);
  75274. /**
  75275. * BABYLON.Observable raised when isChecked property changes
  75276. */
  75277. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  75278. /** Gets or sets a value indicating the ratio between overall size and check size */
  75279. get checkSizeRatio(): number;
  75280. set checkSizeRatio(value: number);
  75281. /** Gets or sets background color */
  75282. get background(): string;
  75283. set background(value: string);
  75284. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  75285. get isChecked(): boolean;
  75286. set isChecked(value: boolean);
  75287. /**
  75288. * Creates a new CheckBox
  75289. * @param name defines the control name
  75290. */
  75291. constructor(name?: string | undefined);
  75292. protected _getTypeName(): string;
  75293. /** @hidden */
  75294. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  75295. /** @hidden */
  75296. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  75297. /**
  75298. * Utility function to easily create a checkbox with a header
  75299. * @param title defines the label to use for the header
  75300. * @param onValueChanged defines the callback to call when value changes
  75301. * @returns a StackPanel containing the checkbox and a textBlock
  75302. */
  75303. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  75304. }
  75305. }
  75306. declare module BABYLON.GUI {
  75307. /**
  75308. * Class used to store key control properties
  75309. */
  75310. export class KeyPropertySet {
  75311. /** Width */
  75312. width?: string;
  75313. /** Height */
  75314. height?: string;
  75315. /** Left padding */
  75316. paddingLeft?: string;
  75317. /** Right padding */
  75318. paddingRight?: string;
  75319. /** Top padding */
  75320. paddingTop?: string;
  75321. /** Bottom padding */
  75322. paddingBottom?: string;
  75323. /** Foreground color */
  75324. color?: string;
  75325. /** Background color */
  75326. background?: string;
  75327. }
  75328. /**
  75329. * Class used to create virtual keyboard
  75330. */
  75331. export class VirtualKeyboard extends StackPanel {
  75332. /** BABYLON.Observable raised when a key is pressed */
  75333. onKeyPressObservable: BABYLON.Observable<string>;
  75334. /** Gets or sets default key button width */
  75335. defaultButtonWidth: string;
  75336. /** Gets or sets default key button height */
  75337. defaultButtonHeight: string;
  75338. /** Gets or sets default key button left padding */
  75339. defaultButtonPaddingLeft: string;
  75340. /** Gets or sets default key button right padding */
  75341. defaultButtonPaddingRight: string;
  75342. /** Gets or sets default key button top padding */
  75343. defaultButtonPaddingTop: string;
  75344. /** Gets or sets default key button bottom padding */
  75345. defaultButtonPaddingBottom: string;
  75346. /** Gets or sets default key button foreground color */
  75347. defaultButtonColor: string;
  75348. /** Gets or sets default key button background color */
  75349. defaultButtonBackground: string;
  75350. /** Gets or sets shift button foreground color */
  75351. shiftButtonColor: string;
  75352. /** Gets or sets shift button thickness*/
  75353. selectedShiftThickness: number;
  75354. /** Gets shift key state */
  75355. shiftState: number;
  75356. protected _getTypeName(): string;
  75357. private _createKey;
  75358. /**
  75359. * Adds a new row of keys
  75360. * @param keys defines the list of keys to add
  75361. * @param propertySets defines the associated property sets
  75362. */
  75363. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  75364. /**
  75365. * Set the shift key to a specific state
  75366. * @param shiftState defines the new shift state
  75367. */
  75368. applyShiftState(shiftState: number): void;
  75369. private _currentlyConnectedInputText;
  75370. private _connectedInputTexts;
  75371. private _onKeyPressObserver;
  75372. /** Gets the input text control currently attached to the keyboard */
  75373. get connectedInputText(): BABYLON.Nullable<InputText>;
  75374. /**
  75375. * Connects the keyboard with an input text control
  75376. *
  75377. * @param input defines the target control
  75378. */
  75379. connect(input: InputText): void;
  75380. /**
  75381. * Disconnects the keyboard from connected InputText controls
  75382. *
  75383. * @param input optionally defines a target control, otherwise all are disconnected
  75384. */
  75385. disconnect(input?: InputText): void;
  75386. private _removeConnectedInputObservables;
  75387. /**
  75388. * Release all resources
  75389. */
  75390. dispose(): void;
  75391. /**
  75392. * Creates a new keyboard using a default layout
  75393. *
  75394. * @param name defines control name
  75395. * @returns a new VirtualKeyboard
  75396. */
  75397. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  75398. }
  75399. }
  75400. declare module BABYLON.GUI {
  75401. /**
  75402. * Class used to create input text control
  75403. */
  75404. export class InputText extends Control implements IFocusableControl {
  75405. name?: string | undefined;
  75406. private _text;
  75407. private _placeholderText;
  75408. private _background;
  75409. private _focusedBackground;
  75410. private _focusedColor;
  75411. private _placeholderColor;
  75412. private _thickness;
  75413. private _margin;
  75414. private _autoStretchWidth;
  75415. private _maxWidth;
  75416. private _isFocused;
  75417. private _blinkTimeout;
  75418. private _blinkIsEven;
  75419. private _cursorOffset;
  75420. private _scrollLeft;
  75421. private _textWidth;
  75422. private _clickedCoordinate;
  75423. private _deadKey;
  75424. private _addKey;
  75425. private _currentKey;
  75426. private _isTextHighlightOn;
  75427. private _textHighlightColor;
  75428. private _highligherOpacity;
  75429. private _highlightedText;
  75430. private _startHighlightIndex;
  75431. private _endHighlightIndex;
  75432. private _cursorIndex;
  75433. private _onFocusSelectAll;
  75434. private _isPointerDown;
  75435. private _onClipboardObserver;
  75436. private _onPointerDblTapObserver;
  75437. /** @hidden */
  75438. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  75439. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  75440. promptMessage: string;
  75441. /** Force disable prompt on mobile device */
  75442. disableMobilePrompt: boolean;
  75443. /** BABYLON.Observable raised when the text changes */
  75444. onTextChangedObservable: BABYLON.Observable<InputText>;
  75445. /** BABYLON.Observable raised just before an entered character is to be added */
  75446. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  75447. /** BABYLON.Observable raised when the control gets the focus */
  75448. onFocusObservable: BABYLON.Observable<InputText>;
  75449. /** BABYLON.Observable raised when the control loses the focus */
  75450. onBlurObservable: BABYLON.Observable<InputText>;
  75451. /**Observable raised when the text is highlighted */
  75452. onTextHighlightObservable: BABYLON.Observable<InputText>;
  75453. /**Observable raised when copy event is triggered */
  75454. onTextCopyObservable: BABYLON.Observable<InputText>;
  75455. /** BABYLON.Observable raised when cut event is triggered */
  75456. onTextCutObservable: BABYLON.Observable<InputText>;
  75457. /** BABYLON.Observable raised when paste event is triggered */
  75458. onTextPasteObservable: BABYLON.Observable<InputText>;
  75459. /** BABYLON.Observable raised when a key event was processed */
  75460. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  75461. /** Gets or sets the maximum width allowed by the control */
  75462. get maxWidth(): string | number;
  75463. /** Gets the maximum width allowed by the control in pixels */
  75464. get maxWidthInPixels(): number;
  75465. set maxWidth(value: string | number);
  75466. /** Gets or sets the text highlighter transparency; default: 0.4 */
  75467. get highligherOpacity(): number;
  75468. set highligherOpacity(value: number);
  75469. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  75470. get onFocusSelectAll(): boolean;
  75471. set onFocusSelectAll(value: boolean);
  75472. /** Gets or sets the text hightlight color */
  75473. get textHighlightColor(): string;
  75474. set textHighlightColor(value: string);
  75475. /** Gets or sets control margin */
  75476. get margin(): string;
  75477. /** Gets control margin in pixels */
  75478. get marginInPixels(): number;
  75479. set margin(value: string);
  75480. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  75481. get autoStretchWidth(): boolean;
  75482. set autoStretchWidth(value: boolean);
  75483. /** Gets or sets border thickness */
  75484. get thickness(): number;
  75485. set thickness(value: number);
  75486. /** Gets or sets the background color when focused */
  75487. get focusedBackground(): string;
  75488. set focusedBackground(value: string);
  75489. /** Gets or sets the background color when focused */
  75490. get focusedColor(): string;
  75491. set focusedColor(value: string);
  75492. /** Gets or sets the background color */
  75493. get background(): string;
  75494. set background(value: string);
  75495. /** Gets or sets the placeholder color */
  75496. get placeholderColor(): string;
  75497. set placeholderColor(value: string);
  75498. /** Gets or sets the text displayed when the control is empty */
  75499. get placeholderText(): string;
  75500. set placeholderText(value: string);
  75501. /** Gets or sets the dead key flag */
  75502. get deadKey(): boolean;
  75503. set deadKey(flag: boolean);
  75504. /** Gets or sets the highlight text */
  75505. get highlightedText(): string;
  75506. set highlightedText(text: string);
  75507. /** Gets or sets if the current key should be added */
  75508. get addKey(): boolean;
  75509. set addKey(flag: boolean);
  75510. /** Gets or sets the value of the current key being entered */
  75511. get currentKey(): string;
  75512. set currentKey(key: string);
  75513. /** Gets or sets the text displayed in the control */
  75514. get text(): string;
  75515. set text(value: string);
  75516. /** Gets or sets control width */
  75517. get width(): string | number;
  75518. set width(value: string | number);
  75519. /**
  75520. * Creates a new InputText
  75521. * @param name defines the control name
  75522. * @param text defines the text of the control
  75523. */
  75524. constructor(name?: string | undefined, text?: string);
  75525. /** @hidden */
  75526. onBlur(): void;
  75527. /** @hidden */
  75528. onFocus(): void;
  75529. protected _getTypeName(): string;
  75530. /**
  75531. * Function called to get the list of controls that should not steal the focus from this control
  75532. * @returns an array of controls
  75533. */
  75534. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  75535. /** @hidden */
  75536. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  75537. /** @hidden */
  75538. private _updateValueFromCursorIndex;
  75539. /** @hidden */
  75540. private _processDblClick;
  75541. /** @hidden */
  75542. private _selectAllText;
  75543. /**
  75544. * Handles the keyboard event
  75545. * @param evt Defines the KeyboardEvent
  75546. */
  75547. processKeyboard(evt: KeyboardEvent): void;
  75548. /** @hidden */
  75549. private _onCopyText;
  75550. /** @hidden */
  75551. private _onCutText;
  75552. /** @hidden */
  75553. private _onPasteText;
  75554. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  75555. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  75556. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  75557. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  75558. protected _beforeRenderText(text: string): string;
  75559. dispose(): void;
  75560. }
  75561. }
  75562. declare module BABYLON.GUI {
  75563. /**
  75564. * Class used to create a 2D grid container
  75565. */
  75566. export class Grid extends Container {
  75567. name?: string | undefined;
  75568. private _rowDefinitions;
  75569. private _columnDefinitions;
  75570. private _cells;
  75571. private _childControls;
  75572. /**
  75573. * Gets the number of columns
  75574. */
  75575. get columnCount(): number;
  75576. /**
  75577. * Gets the number of rows
  75578. */
  75579. get rowCount(): number;
  75580. /** Gets the list of children */
  75581. get children(): Control[];
  75582. /** Gets the list of cells (e.g. the containers) */
  75583. get cells(): {
  75584. [key: string]: Container;
  75585. };
  75586. /**
  75587. * Gets the definition of a specific row
  75588. * @param index defines the index of the row
  75589. * @returns the row definition
  75590. */
  75591. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  75592. /**
  75593. * Gets the definition of a specific column
  75594. * @param index defines the index of the column
  75595. * @returns the column definition
  75596. */
  75597. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  75598. /**
  75599. * Adds a new row to the grid
  75600. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  75601. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  75602. * @returns the current grid
  75603. */
  75604. addRowDefinition(height: number, isPixel?: boolean): Grid;
  75605. /**
  75606. * Adds a new column to the grid
  75607. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  75608. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  75609. * @returns the current grid
  75610. */
  75611. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  75612. /**
  75613. * Update a row definition
  75614. * @param index defines the index of the row to update
  75615. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  75616. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  75617. * @returns the current grid
  75618. */
  75619. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  75620. /**
  75621. * Update a column definition
  75622. * @param index defines the index of the column to update
  75623. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  75624. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  75625. * @returns the current grid
  75626. */
  75627. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  75628. /**
  75629. * Gets the list of children stored in a specific cell
  75630. * @param row defines the row to check
  75631. * @param column defines the column to check
  75632. * @returns the list of controls
  75633. */
  75634. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  75635. /**
  75636. * Gets a string representing the child cell info (row x column)
  75637. * @param child defines the control to get info from
  75638. * @returns a string containing the child cell info (row x column)
  75639. */
  75640. getChildCellInfo(child: Control): string;
  75641. private _removeCell;
  75642. private _offsetCell;
  75643. /**
  75644. * Remove a column definition at specified index
  75645. * @param index defines the index of the column to remove
  75646. * @returns the current grid
  75647. */
  75648. removeColumnDefinition(index: number): Grid;
  75649. /**
  75650. * Remove a row definition at specified index
  75651. * @param index defines the index of the row to remove
  75652. * @returns the current grid
  75653. */
  75654. removeRowDefinition(index: number): Grid;
  75655. /**
  75656. * Adds a new control to the current grid
  75657. * @param control defines the control to add
  75658. * @param row defines the row where to add the control (0 by default)
  75659. * @param column defines the column where to add the control (0 by default)
  75660. * @returns the current grid
  75661. */
  75662. addControl(control: Control, row?: number, column?: number): Grid;
  75663. /**
  75664. * Removes a control from the current container
  75665. * @param control defines the control to remove
  75666. * @returns the current container
  75667. */
  75668. removeControl(control: Control): Container;
  75669. /**
  75670. * Creates a new Grid
  75671. * @param name defines control name
  75672. */
  75673. constructor(name?: string | undefined);
  75674. protected _getTypeName(): string;
  75675. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  75676. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75677. _flagDescendantsAsMatrixDirty(): void;
  75678. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  75679. /** Releases associated resources */
  75680. dispose(): void;
  75681. }
  75682. }
  75683. declare module BABYLON.GUI {
  75684. /** Class used to create color pickers */
  75685. export class ColorPicker extends Control {
  75686. name?: string | undefined;
  75687. private static _Epsilon;
  75688. private _colorWheelCanvas;
  75689. private _value;
  75690. private _tmpColor;
  75691. private _pointerStartedOnSquare;
  75692. private _pointerStartedOnWheel;
  75693. private _squareLeft;
  75694. private _squareTop;
  75695. private _squareSize;
  75696. private _h;
  75697. private _s;
  75698. private _v;
  75699. private _lastPointerDownID;
  75700. /**
  75701. * BABYLON.Observable raised when the value changes
  75702. */
  75703. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  75704. /** Gets or sets the color of the color picker */
  75705. get value(): BABYLON.Color3;
  75706. set value(value: BABYLON.Color3);
  75707. /**
  75708. * Gets or sets control width
  75709. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75710. */
  75711. get width(): string | number;
  75712. set width(value: string | number);
  75713. /**
  75714. * Gets or sets control height
  75715. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75716. */
  75717. get height(): string | number;
  75718. /** Gets or sets control height */
  75719. set height(value: string | number);
  75720. /** Gets or sets control size */
  75721. get size(): string | number;
  75722. set size(value: string | number);
  75723. /**
  75724. * Creates a new ColorPicker
  75725. * @param name defines the control name
  75726. */
  75727. constructor(name?: string | undefined);
  75728. protected _getTypeName(): string;
  75729. /** @hidden */
  75730. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75731. private _updateSquareProps;
  75732. private _drawGradientSquare;
  75733. private _drawCircle;
  75734. private _createColorWheelCanvas;
  75735. /** @hidden */
  75736. _draw(context: CanvasRenderingContext2D): void;
  75737. private _pointerIsDown;
  75738. private _updateValueFromPointer;
  75739. private _isPointOnSquare;
  75740. private _isPointOnWheel;
  75741. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  75742. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  75743. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  75744. /**
  75745. * This function expands the color picker by creating a color picker dialog with manual
  75746. * color value input and the ability to save colors into an array to be used later in
  75747. * subsequent launches of the dialogue.
  75748. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  75749. * @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.
  75750. * @returns picked color as a hex string and the saved colors array as hex strings.
  75751. */
  75752. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  75753. pickerWidth?: string;
  75754. pickerHeight?: string;
  75755. headerHeight?: string;
  75756. lastColor?: string;
  75757. swatchLimit?: number;
  75758. numSwatchesPerLine?: number;
  75759. savedColors?: Array<string>;
  75760. }): Promise<{
  75761. savedColors?: string[];
  75762. pickedColor: string;
  75763. }>;
  75764. }
  75765. }
  75766. declare module BABYLON.GUI {
  75767. /** Class used to create 2D ellipse containers */
  75768. export class Ellipse extends Container {
  75769. name?: string | undefined;
  75770. private _thickness;
  75771. /** Gets or sets border thickness */
  75772. get thickness(): number;
  75773. set thickness(value: number);
  75774. /**
  75775. * Creates a new Ellipse
  75776. * @param name defines the control name
  75777. */
  75778. constructor(name?: string | undefined);
  75779. protected _getTypeName(): string;
  75780. protected _localDraw(context: CanvasRenderingContext2D): void;
  75781. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75782. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  75783. }
  75784. }
  75785. declare module BABYLON.GUI {
  75786. /**
  75787. * Class used to create a password control
  75788. */
  75789. export class InputPassword extends InputText {
  75790. protected _beforeRenderText(text: string): string;
  75791. }
  75792. }
  75793. declare module BABYLON.GUI {
  75794. /** Class used to render 2D lines */
  75795. export class Line extends Control {
  75796. name?: string | undefined;
  75797. private _lineWidth;
  75798. private _x1;
  75799. private _y1;
  75800. private _x2;
  75801. private _y2;
  75802. private _dash;
  75803. private _connectedControl;
  75804. private _connectedControlDirtyObserver;
  75805. /** Gets or sets the dash pattern */
  75806. get dash(): Array<number>;
  75807. set dash(value: Array<number>);
  75808. /** Gets or sets the control connected with the line end */
  75809. get connectedControl(): Control;
  75810. set connectedControl(value: Control);
  75811. /** Gets or sets start coordinates on X axis */
  75812. get x1(): string | number;
  75813. set x1(value: string | number);
  75814. /** Gets or sets start coordinates on Y axis */
  75815. get y1(): string | number;
  75816. set y1(value: string | number);
  75817. /** Gets or sets end coordinates on X axis */
  75818. get x2(): string | number;
  75819. set x2(value: string | number);
  75820. /** Gets or sets end coordinates on Y axis */
  75821. get y2(): string | number;
  75822. set y2(value: string | number);
  75823. /** Gets or sets line width */
  75824. get lineWidth(): number;
  75825. set lineWidth(value: number);
  75826. /** Gets or sets horizontal alignment */
  75827. set horizontalAlignment(value: number);
  75828. /** Gets or sets vertical alignment */
  75829. set verticalAlignment(value: number);
  75830. private get _effectiveX2();
  75831. private get _effectiveY2();
  75832. /**
  75833. * Creates a new Line
  75834. * @param name defines the control name
  75835. */
  75836. constructor(name?: string | undefined);
  75837. protected _getTypeName(): string;
  75838. _draw(context: CanvasRenderingContext2D): void;
  75839. _measure(): void;
  75840. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75841. /**
  75842. * Move one end of the line given 3D cartesian coordinates.
  75843. * @param position Targeted world position
  75844. * @param scene BABYLON.Scene
  75845. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  75846. */
  75847. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  75848. /**
  75849. * Move one end of the line to a position in screen absolute space.
  75850. * @param projectedPosition Position in screen absolute space (X, Y)
  75851. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  75852. */
  75853. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  75854. }
  75855. }
  75856. declare module BABYLON.GUI {
  75857. /**
  75858. * Class used to store a point for a MultiLine object.
  75859. * The point can be pure 2D coordinates, a mesh or a control
  75860. */
  75861. export class MultiLinePoint {
  75862. private _multiLine;
  75863. private _x;
  75864. private _y;
  75865. private _control;
  75866. private _mesh;
  75867. private _controlObserver;
  75868. private _meshObserver;
  75869. /** @hidden */
  75870. _point: BABYLON.Vector2;
  75871. /**
  75872. * Creates a new MultiLinePoint
  75873. * @param multiLine defines the source MultiLine object
  75874. */
  75875. constructor(multiLine: MultiLine);
  75876. /** Gets or sets x coordinate */
  75877. get x(): string | number;
  75878. set x(value: string | number);
  75879. /** Gets or sets y coordinate */
  75880. get y(): string | number;
  75881. set y(value: string | number);
  75882. /** Gets or sets the control associated with this point */
  75883. get control(): BABYLON.Nullable<Control>;
  75884. set control(value: BABYLON.Nullable<Control>);
  75885. /** Gets or sets the mesh associated with this point */
  75886. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  75887. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  75888. /** Resets links */
  75889. resetLinks(): void;
  75890. /**
  75891. * Gets a translation vector
  75892. * @returns the translation vector
  75893. */
  75894. translate(): BABYLON.Vector2;
  75895. private _translatePoint;
  75896. /** Release associated resources */
  75897. dispose(): void;
  75898. }
  75899. }
  75900. declare module BABYLON.GUI {
  75901. /**
  75902. * Class used to create multi line control
  75903. */
  75904. export class MultiLine extends Control {
  75905. name?: string | undefined;
  75906. private _lineWidth;
  75907. private _dash;
  75908. private _points;
  75909. private _minX;
  75910. private _minY;
  75911. private _maxX;
  75912. private _maxY;
  75913. /**
  75914. * Creates a new MultiLine
  75915. * @param name defines the control name
  75916. */
  75917. constructor(name?: string | undefined);
  75918. /** Gets or sets dash pattern */
  75919. get dash(): Array<number>;
  75920. set dash(value: Array<number>);
  75921. /**
  75922. * Gets point stored at specified index
  75923. * @param index defines the index to look for
  75924. * @returns the requested point if found
  75925. */
  75926. getAt(index: number): MultiLinePoint;
  75927. /** Function called when a point is updated */
  75928. onPointUpdate: () => void;
  75929. /**
  75930. * Adds new points to the point collection
  75931. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  75932. * @returns the list of created MultiLinePoint
  75933. */
  75934. add(...items: (AbstractMesh | Control | {
  75935. x: string | number;
  75936. y: string | number;
  75937. })[]): MultiLinePoint[];
  75938. /**
  75939. * Adds a new point to the point collection
  75940. * @param item defines the item (mesh, control or 2d coordiantes) to add
  75941. * @returns the created MultiLinePoint
  75942. */
  75943. push(item?: (AbstractMesh | Control | {
  75944. x: string | number;
  75945. y: string | number;
  75946. })): MultiLinePoint;
  75947. /**
  75948. * Remove a specific value or point from the active point collection
  75949. * @param value defines the value or point to remove
  75950. */
  75951. remove(value: number | MultiLinePoint): void;
  75952. /**
  75953. * Resets this object to initial state (no point)
  75954. */
  75955. reset(): void;
  75956. /**
  75957. * Resets all links
  75958. */
  75959. resetLinks(): void;
  75960. /** Gets or sets line width */
  75961. get lineWidth(): number;
  75962. set lineWidth(value: number);
  75963. set horizontalAlignment(value: number);
  75964. set verticalAlignment(value: number);
  75965. protected _getTypeName(): string;
  75966. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  75967. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75968. _measure(): void;
  75969. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75970. dispose(): void;
  75971. }
  75972. }
  75973. declare module BABYLON.GUI {
  75974. /**
  75975. * Class used to create radio button controls
  75976. */
  75977. export class RadioButton extends Control {
  75978. name?: string | undefined;
  75979. private _isChecked;
  75980. private _background;
  75981. private _checkSizeRatio;
  75982. private _thickness;
  75983. /** Gets or sets border thickness */
  75984. get thickness(): number;
  75985. set thickness(value: number);
  75986. /** Gets or sets group name */
  75987. group: string;
  75988. /** BABYLON.Observable raised when isChecked is changed */
  75989. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  75990. /** Gets or sets a value indicating the ratio between overall size and check size */
  75991. get checkSizeRatio(): number;
  75992. set checkSizeRatio(value: number);
  75993. /** Gets or sets background color */
  75994. get background(): string;
  75995. set background(value: string);
  75996. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  75997. get isChecked(): boolean;
  75998. set isChecked(value: boolean);
  75999. /**
  76000. * Creates a new RadioButton
  76001. * @param name defines the control name
  76002. */
  76003. constructor(name?: string | undefined);
  76004. protected _getTypeName(): string;
  76005. _draw(context: CanvasRenderingContext2D): void;
  76006. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76007. /**
  76008. * Utility function to easily create a radio button with a header
  76009. * @param title defines the label to use for the header
  76010. * @param group defines the group to use for the radio button
  76011. * @param isChecked defines the initial state of the radio button
  76012. * @param onValueChanged defines the callback to call when value changes
  76013. * @returns a StackPanel containing the radio button and a textBlock
  76014. */
  76015. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  76016. }
  76017. }
  76018. declare module BABYLON.GUI {
  76019. /**
  76020. * Class used to create slider controls
  76021. */
  76022. export class BaseSlider extends Control {
  76023. name?: string | undefined;
  76024. protected _thumbWidth: ValueAndUnit;
  76025. private _minimum;
  76026. private _maximum;
  76027. private _value;
  76028. private _isVertical;
  76029. protected _barOffset: ValueAndUnit;
  76030. private _isThumbClamped;
  76031. protected _displayThumb: boolean;
  76032. private _step;
  76033. private _lastPointerDownID;
  76034. protected _effectiveBarOffset: number;
  76035. protected _renderLeft: number;
  76036. protected _renderTop: number;
  76037. protected _renderWidth: number;
  76038. protected _renderHeight: number;
  76039. protected _backgroundBoxLength: number;
  76040. protected _backgroundBoxThickness: number;
  76041. protected _effectiveThumbThickness: number;
  76042. /** BABYLON.Observable raised when the sldier value changes */
  76043. onValueChangedObservable: BABYLON.Observable<number>;
  76044. /** Gets or sets a boolean indicating if the thumb must be rendered */
  76045. get displayThumb(): boolean;
  76046. set displayThumb(value: boolean);
  76047. /** Gets or sets a step to apply to values (0 by default) */
  76048. get step(): number;
  76049. set step(value: number);
  76050. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  76051. get barOffset(): string | number;
  76052. /** Gets main bar offset in pixels*/
  76053. get barOffsetInPixels(): number;
  76054. set barOffset(value: string | number);
  76055. /** Gets or sets thumb width */
  76056. get thumbWidth(): string | number;
  76057. /** Gets thumb width in pixels */
  76058. get thumbWidthInPixels(): number;
  76059. set thumbWidth(value: string | number);
  76060. /** Gets or sets minimum value */
  76061. get minimum(): number;
  76062. set minimum(value: number);
  76063. /** Gets or sets maximum value */
  76064. get maximum(): number;
  76065. set maximum(value: number);
  76066. /** Gets or sets current value */
  76067. get value(): number;
  76068. set value(value: number);
  76069. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  76070. get isVertical(): boolean;
  76071. set isVertical(value: boolean);
  76072. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  76073. get isThumbClamped(): boolean;
  76074. set isThumbClamped(value: boolean);
  76075. /**
  76076. * Creates a new BaseSlider
  76077. * @param name defines the control name
  76078. */
  76079. constructor(name?: string | undefined);
  76080. protected _getTypeName(): string;
  76081. protected _getThumbPosition(): number;
  76082. protected _getThumbThickness(type: string): number;
  76083. protected _prepareRenderingData(type: string): void;
  76084. private _pointerIsDown;
  76085. /** @hidden */
  76086. protected _updateValueFromPointer(x: number, y: number): void;
  76087. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76088. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  76089. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  76090. }
  76091. }
  76092. declare module BABYLON.GUI {
  76093. /**
  76094. * Class used to create slider controls
  76095. */
  76096. export class Slider extends BaseSlider {
  76097. name?: string | undefined;
  76098. private _background;
  76099. private _borderColor;
  76100. private _isThumbCircle;
  76101. protected _displayValueBar: boolean;
  76102. /** Gets or sets a boolean indicating if the value bar must be rendered */
  76103. get displayValueBar(): boolean;
  76104. set displayValueBar(value: boolean);
  76105. /** Gets or sets border color */
  76106. get borderColor(): string;
  76107. set borderColor(value: string);
  76108. /** Gets or sets background color */
  76109. get background(): string;
  76110. set background(value: string);
  76111. /** Gets or sets a boolean indicating if the thumb should be round or square */
  76112. get isThumbCircle(): boolean;
  76113. set isThumbCircle(value: boolean);
  76114. /**
  76115. * Creates a new Slider
  76116. * @param name defines the control name
  76117. */
  76118. constructor(name?: string | undefined);
  76119. protected _getTypeName(): string;
  76120. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76121. }
  76122. }
  76123. declare module BABYLON.GUI {
  76124. /** Class used to create a RadioGroup
  76125. * which contains groups of radio buttons
  76126. */
  76127. export class SelectorGroup {
  76128. /** name of SelectorGroup */
  76129. name: string;
  76130. private _groupPanel;
  76131. private _selectors;
  76132. private _groupHeader;
  76133. /**
  76134. * Creates a new SelectorGroup
  76135. * @param name of group, used as a group heading
  76136. */
  76137. constructor(
  76138. /** name of SelectorGroup */
  76139. name: string);
  76140. /** Gets the groupPanel of the SelectorGroup */
  76141. get groupPanel(): StackPanel;
  76142. /** Gets the selectors array */
  76143. get selectors(): StackPanel[];
  76144. /** Gets and sets the group header */
  76145. get header(): string;
  76146. set header(label: string);
  76147. /** @hidden */
  76148. private _addGroupHeader;
  76149. /** @hidden*/
  76150. _getSelector(selectorNb: number): StackPanel | undefined;
  76151. /** Removes the selector at the given position
  76152. * @param selectorNb the position of the selector within the group
  76153. */
  76154. removeSelector(selectorNb: number): void;
  76155. }
  76156. /** Class used to create a CheckboxGroup
  76157. * which contains groups of checkbox buttons
  76158. */
  76159. export class CheckboxGroup extends SelectorGroup {
  76160. /** Adds a checkbox as a control
  76161. * @param text is the label for the selector
  76162. * @param func is the function called when the Selector is checked
  76163. * @param checked is true when Selector is checked
  76164. */
  76165. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  76166. /** @hidden */
  76167. _setSelectorLabel(selectorNb: number, label: string): void;
  76168. /** @hidden */
  76169. _setSelectorLabelColor(selectorNb: number, color: string): void;
  76170. /** @hidden */
  76171. _setSelectorButtonColor(selectorNb: number, color: string): void;
  76172. /** @hidden */
  76173. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  76174. }
  76175. /** Class used to create a RadioGroup
  76176. * which contains groups of radio buttons
  76177. */
  76178. export class RadioGroup extends SelectorGroup {
  76179. private _selectNb;
  76180. /** Adds a radio button as a control
  76181. * @param label is the label for the selector
  76182. * @param func is the function called when the Selector is checked
  76183. * @param checked is true when Selector is checked
  76184. */
  76185. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  76186. /** @hidden */
  76187. _setSelectorLabel(selectorNb: number, label: string): void;
  76188. /** @hidden */
  76189. _setSelectorLabelColor(selectorNb: number, color: string): void;
  76190. /** @hidden */
  76191. _setSelectorButtonColor(selectorNb: number, color: string): void;
  76192. /** @hidden */
  76193. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  76194. }
  76195. /** Class used to create a SliderGroup
  76196. * which contains groups of slider buttons
  76197. */
  76198. export class SliderGroup extends SelectorGroup {
  76199. /**
  76200. * Adds a slider to the SelectorGroup
  76201. * @param label is the label for the SliderBar
  76202. * @param func is the function called when the Slider moves
  76203. * @param unit is a string describing the units used, eg degrees or metres
  76204. * @param min is the minimum value for the Slider
  76205. * @param max is the maximum value for the Slider
  76206. * @param value is the start value for the Slider between min and max
  76207. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  76208. */
  76209. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  76210. /** @hidden */
  76211. _setSelectorLabel(selectorNb: number, label: string): void;
  76212. /** @hidden */
  76213. _setSelectorLabelColor(selectorNb: number, color: string): void;
  76214. /** @hidden */
  76215. _setSelectorButtonColor(selectorNb: number, color: string): void;
  76216. /** @hidden */
  76217. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  76218. }
  76219. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  76220. * @see http://doc.babylonjs.com/how_to/selector
  76221. */
  76222. export class SelectionPanel extends Rectangle {
  76223. /** name of SelectionPanel */
  76224. name: string;
  76225. /** an array of SelectionGroups */
  76226. groups: SelectorGroup[];
  76227. private _panel;
  76228. private _buttonColor;
  76229. private _buttonBackground;
  76230. private _headerColor;
  76231. private _barColor;
  76232. private _barHeight;
  76233. private _spacerHeight;
  76234. private _labelColor;
  76235. private _groups;
  76236. private _bars;
  76237. /**
  76238. * Creates a new SelectionPanel
  76239. * @param name of SelectionPanel
  76240. * @param groups is an array of SelectionGroups
  76241. */
  76242. constructor(
  76243. /** name of SelectionPanel */
  76244. name: string,
  76245. /** an array of SelectionGroups */
  76246. groups?: SelectorGroup[]);
  76247. protected _getTypeName(): string;
  76248. /** Gets or sets the headerColor */
  76249. get headerColor(): string;
  76250. set headerColor(color: string);
  76251. private _setHeaderColor;
  76252. /** Gets or sets the button color */
  76253. get buttonColor(): string;
  76254. set buttonColor(color: string);
  76255. private _setbuttonColor;
  76256. /** Gets or sets the label color */
  76257. get labelColor(): string;
  76258. set labelColor(color: string);
  76259. private _setLabelColor;
  76260. /** Gets or sets the button background */
  76261. get buttonBackground(): string;
  76262. set buttonBackground(color: string);
  76263. private _setButtonBackground;
  76264. /** Gets or sets the color of separator bar */
  76265. get barColor(): string;
  76266. set barColor(color: string);
  76267. private _setBarColor;
  76268. /** Gets or sets the height of separator bar */
  76269. get barHeight(): string;
  76270. set barHeight(value: string);
  76271. private _setBarHeight;
  76272. /** Gets or sets the height of spacers*/
  76273. get spacerHeight(): string;
  76274. set spacerHeight(value: string);
  76275. private _setSpacerHeight;
  76276. /** Adds a bar between groups */
  76277. private _addSpacer;
  76278. /** Add a group to the selection panel
  76279. * @param group is the selector group to add
  76280. */
  76281. addGroup(group: SelectorGroup): void;
  76282. /** Remove the group from the given position
  76283. * @param groupNb is the position of the group in the list
  76284. */
  76285. removeGroup(groupNb: number): void;
  76286. /** Change a group header label
  76287. * @param label is the new group header label
  76288. * @param groupNb is the number of the group to relabel
  76289. * */
  76290. setHeaderName(label: string, groupNb: number): void;
  76291. /** Change selector label to the one given
  76292. * @param label is the new selector label
  76293. * @param groupNb is the number of the groupcontaining the selector
  76294. * @param selectorNb is the number of the selector within a group to relabel
  76295. * */
  76296. relabel(label: string, groupNb: number, selectorNb: number): void;
  76297. /** For a given group position remove the selector at the given position
  76298. * @param groupNb is the number of the group to remove the selector from
  76299. * @param selectorNb is the number of the selector within the group
  76300. */
  76301. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  76302. /** For a given group position of correct type add a checkbox button
  76303. * @param groupNb is the number of the group to remove the selector from
  76304. * @param label is the label for the selector
  76305. * @param func is the function called when the Selector is checked
  76306. * @param checked is true when Selector is checked
  76307. */
  76308. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  76309. /** For a given group position of correct type add a radio button
  76310. * @param groupNb is the number of the group to remove the selector from
  76311. * @param label is the label for the selector
  76312. * @param func is the function called when the Selector is checked
  76313. * @param checked is true when Selector is checked
  76314. */
  76315. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  76316. /**
  76317. * For a given slider group add a slider
  76318. * @param groupNb is the number of the group to add the slider to
  76319. * @param label is the label for the Slider
  76320. * @param func is the function called when the Slider moves
  76321. * @param unit is a string describing the units used, eg degrees or metres
  76322. * @param min is the minimum value for the Slider
  76323. * @param max is the maximum value for the Slider
  76324. * @param value is the start value for the Slider between min and max
  76325. * @param onVal is the function used to format the value displayed, eg radians to degrees
  76326. */
  76327. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  76328. }
  76329. }
  76330. declare module BABYLON.GUI {
  76331. /**
  76332. * Class used to hold a the container for ScrollViewer
  76333. * @hidden
  76334. */
  76335. export class _ScrollViewerWindow extends Container {
  76336. parentClientWidth: number;
  76337. parentClientHeight: number;
  76338. private _freezeControls;
  76339. private _parentMeasure;
  76340. private _oldLeft;
  76341. private _oldTop;
  76342. get freezeControls(): boolean;
  76343. set freezeControls(value: boolean);
  76344. private _bucketWidth;
  76345. private _bucketHeight;
  76346. private _buckets;
  76347. private _bucketLen;
  76348. get bucketWidth(): number;
  76349. get bucketHeight(): number;
  76350. setBucketSizes(width: number, height: number): void;
  76351. private _useBuckets;
  76352. private _makeBuckets;
  76353. private _dispatchInBuckets;
  76354. private _updateMeasures;
  76355. private _updateChildrenMeasures;
  76356. private _restoreMeasures;
  76357. /**
  76358. * Creates a new ScrollViewerWindow
  76359. * @param name of ScrollViewerWindow
  76360. */
  76361. constructor(name?: string);
  76362. protected _getTypeName(): string;
  76363. /** @hidden */
  76364. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76365. /** @hidden */
  76366. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  76367. private _scrollChildren;
  76368. private _scrollChildrenWithBuckets;
  76369. /** @hidden */
  76370. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  76371. protected _postMeasure(): void;
  76372. }
  76373. }
  76374. declare module BABYLON.GUI {
  76375. /**
  76376. * Class used to create slider controls
  76377. */
  76378. export class ScrollBar extends BaseSlider {
  76379. name?: string | undefined;
  76380. private _background;
  76381. private _borderColor;
  76382. private _tempMeasure;
  76383. /** Gets or sets border color */
  76384. get borderColor(): string;
  76385. set borderColor(value: string);
  76386. /** Gets or sets background color */
  76387. get background(): string;
  76388. set background(value: string);
  76389. /**
  76390. * Creates a new Slider
  76391. * @param name defines the control name
  76392. */
  76393. constructor(name?: string | undefined);
  76394. protected _getTypeName(): string;
  76395. protected _getThumbThickness(): number;
  76396. _draw(context: CanvasRenderingContext2D): void;
  76397. private _first;
  76398. private _originX;
  76399. private _originY;
  76400. /** @hidden */
  76401. protected _updateValueFromPointer(x: number, y: number): void;
  76402. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76403. }
  76404. }
  76405. declare module BABYLON.GUI {
  76406. /**
  76407. * Class used to create slider controls
  76408. */
  76409. export class ImageScrollBar extends BaseSlider {
  76410. name?: string | undefined;
  76411. private _backgroundBaseImage;
  76412. private _backgroundImage;
  76413. private _thumbImage;
  76414. private _thumbBaseImage;
  76415. private _thumbLength;
  76416. private _thumbHeight;
  76417. private _barImageHeight;
  76418. private _tempMeasure;
  76419. /** Number of 90° rotation to apply on the images when in vertical mode */
  76420. num90RotationInVerticalMode: number;
  76421. /**
  76422. * Gets or sets the image used to render the background for horizontal bar
  76423. */
  76424. get backgroundImage(): Image;
  76425. set backgroundImage(value: Image);
  76426. /**
  76427. * Gets or sets the image used to render the thumb
  76428. */
  76429. get thumbImage(): Image;
  76430. set thumbImage(value: Image);
  76431. /**
  76432. * Gets or sets the length of the thumb
  76433. */
  76434. get thumbLength(): number;
  76435. set thumbLength(value: number);
  76436. /**
  76437. * Gets or sets the height of the thumb
  76438. */
  76439. get thumbHeight(): number;
  76440. set thumbHeight(value: number);
  76441. /**
  76442. * Gets or sets the height of the bar image
  76443. */
  76444. get barImageHeight(): number;
  76445. set barImageHeight(value: number);
  76446. /**
  76447. * Creates a new ImageScrollBar
  76448. * @param name defines the control name
  76449. */
  76450. constructor(name?: string | undefined);
  76451. protected _getTypeName(): string;
  76452. protected _getThumbThickness(): number;
  76453. _draw(context: CanvasRenderingContext2D): void;
  76454. private _first;
  76455. private _originX;
  76456. private _originY;
  76457. /** @hidden */
  76458. protected _updateValueFromPointer(x: number, y: number): void;
  76459. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76460. }
  76461. }
  76462. declare module BABYLON.GUI {
  76463. /**
  76464. * Class used to hold a viewer window and sliders in a grid
  76465. */
  76466. export class ScrollViewer extends Rectangle {
  76467. private _grid;
  76468. private _horizontalBarSpace;
  76469. private _verticalBarSpace;
  76470. private _dragSpace;
  76471. private _horizontalBar;
  76472. private _verticalBar;
  76473. private _barColor;
  76474. private _barBackground;
  76475. private _barImage;
  76476. private _horizontalBarImage;
  76477. private _verticalBarImage;
  76478. private _barBackgroundImage;
  76479. private _horizontalBarBackgroundImage;
  76480. private _verticalBarBackgroundImage;
  76481. private _barSize;
  76482. private _window;
  76483. private _pointerIsOver;
  76484. private _wheelPrecision;
  76485. private _onWheelObserver;
  76486. private _clientWidth;
  76487. private _clientHeight;
  76488. private _useImageBar;
  76489. private _thumbLength;
  76490. private _thumbHeight;
  76491. private _barImageHeight;
  76492. private _horizontalBarImageHeight;
  76493. private _verticalBarImageHeight;
  76494. private _oldWindowContentsWidth;
  76495. private _oldWindowContentsHeight;
  76496. /**
  76497. * Gets the horizontal scrollbar
  76498. */
  76499. get horizontalBar(): ScrollBar | ImageScrollBar;
  76500. /**
  76501. * Gets the vertical scrollbar
  76502. */
  76503. get verticalBar(): ScrollBar | ImageScrollBar;
  76504. /**
  76505. * Adds a new control to the current container
  76506. * @param control defines the control to add
  76507. * @returns the current container
  76508. */
  76509. addControl(control: BABYLON.Nullable<Control>): Container;
  76510. /**
  76511. * Removes a control from the current container
  76512. * @param control defines the control to remove
  76513. * @returns the current container
  76514. */
  76515. removeControl(control: Control): Container;
  76516. /** Gets the list of children */
  76517. get children(): Control[];
  76518. _flagDescendantsAsMatrixDirty(): void;
  76519. /**
  76520. * Freezes or unfreezes the controls in the window.
  76521. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  76522. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  76523. */
  76524. get freezeControls(): boolean;
  76525. set freezeControls(value: boolean);
  76526. /** Gets the bucket width */
  76527. get bucketWidth(): number;
  76528. /** Gets the bucket height */
  76529. get bucketHeight(): number;
  76530. /**
  76531. * Sets the bucket sizes.
  76532. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  76533. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  76534. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  76535. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  76536. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  76537. * used), that's why it is not enabled by default.
  76538. * @param width width of the bucket
  76539. * @param height height of the bucket
  76540. */
  76541. setBucketSizes(width: number, height: number): void;
  76542. private _forceHorizontalBar;
  76543. private _forceVerticalBar;
  76544. /**
  76545. * Forces the horizontal scroll bar to be displayed
  76546. */
  76547. get forceHorizontalBar(): boolean;
  76548. set forceHorizontalBar(value: boolean);
  76549. /**
  76550. * Forces the vertical scroll bar to be displayed
  76551. */
  76552. get forceVerticalBar(): boolean;
  76553. set forceVerticalBar(value: boolean);
  76554. /**
  76555. * Creates a new ScrollViewer
  76556. * @param name of ScrollViewer
  76557. */
  76558. constructor(name?: string, isImageBased?: boolean);
  76559. /** Reset the scroll viewer window to initial size */
  76560. resetWindow(): void;
  76561. protected _getTypeName(): string;
  76562. private _buildClientSizes;
  76563. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76564. protected _postMeasure(): void;
  76565. /**
  76566. * Gets or sets the mouse wheel precision
  76567. * from 0 to 1 with a default value of 0.05
  76568. * */
  76569. get wheelPrecision(): number;
  76570. set wheelPrecision(value: number);
  76571. /** Gets or sets the scroll bar container background color */
  76572. get scrollBackground(): string;
  76573. set scrollBackground(color: string);
  76574. /** Gets or sets the bar color */
  76575. get barColor(): string;
  76576. set barColor(color: string);
  76577. /** Gets or sets the bar image */
  76578. get thumbImage(): Image;
  76579. set thumbImage(value: Image);
  76580. /** Gets or sets the horizontal bar image */
  76581. get horizontalThumbImage(): Image;
  76582. set horizontalThumbImage(value: Image);
  76583. /** Gets or sets the vertical bar image */
  76584. get verticalThumbImage(): Image;
  76585. set verticalThumbImage(value: Image);
  76586. /** Gets or sets the size of the bar */
  76587. get barSize(): number;
  76588. set barSize(value: number);
  76589. /** Gets or sets the length of the thumb */
  76590. get thumbLength(): number;
  76591. set thumbLength(value: number);
  76592. /** Gets or sets the height of the thumb */
  76593. get thumbHeight(): number;
  76594. set thumbHeight(value: number);
  76595. /** Gets or sets the height of the bar image */
  76596. get barImageHeight(): number;
  76597. set barImageHeight(value: number);
  76598. /** Gets or sets the height of the horizontal bar image */
  76599. get horizontalBarImageHeight(): number;
  76600. set horizontalBarImageHeight(value: number);
  76601. /** Gets or sets the height of the vertical bar image */
  76602. get verticalBarImageHeight(): number;
  76603. set verticalBarImageHeight(value: number);
  76604. /** Gets or sets the bar background */
  76605. get barBackground(): string;
  76606. set barBackground(color: string);
  76607. /** Gets or sets the bar background image */
  76608. get barImage(): Image;
  76609. set barImage(value: Image);
  76610. /** Gets or sets the horizontal bar background image */
  76611. get horizontalBarImage(): Image;
  76612. set horizontalBarImage(value: Image);
  76613. /** Gets or sets the vertical bar background image */
  76614. get verticalBarImage(): Image;
  76615. set verticalBarImage(value: Image);
  76616. private _setWindowPosition;
  76617. /** @hidden */
  76618. private _updateScroller;
  76619. _link(host: AdvancedDynamicTexture): void;
  76620. /** @hidden */
  76621. private _addBar;
  76622. /** @hidden */
  76623. private _attachWheel;
  76624. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  76625. /** Releases associated resources */
  76626. dispose(): void;
  76627. }
  76628. }
  76629. declare module BABYLON.GUI {
  76630. /** Class used to render a grid */
  76631. export class DisplayGrid extends Control {
  76632. name?: string | undefined;
  76633. private _cellWidth;
  76634. private _cellHeight;
  76635. private _minorLineTickness;
  76636. private _minorLineColor;
  76637. private _majorLineTickness;
  76638. private _majorLineColor;
  76639. private _majorLineFrequency;
  76640. private _background;
  76641. private _displayMajorLines;
  76642. private _displayMinorLines;
  76643. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  76644. get displayMinorLines(): boolean;
  76645. set displayMinorLines(value: boolean);
  76646. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  76647. get displayMajorLines(): boolean;
  76648. set displayMajorLines(value: boolean);
  76649. /** Gets or sets background color (Black by default) */
  76650. get background(): string;
  76651. set background(value: string);
  76652. /** Gets or sets the width of each cell (20 by default) */
  76653. get cellWidth(): number;
  76654. set cellWidth(value: number);
  76655. /** Gets or sets the height of each cell (20 by default) */
  76656. get cellHeight(): number;
  76657. set cellHeight(value: number);
  76658. /** Gets or sets the tickness of minor lines (1 by default) */
  76659. get minorLineTickness(): number;
  76660. set minorLineTickness(value: number);
  76661. /** Gets or sets the color of minor lines (DarkGray by default) */
  76662. get minorLineColor(): string;
  76663. set minorLineColor(value: string);
  76664. /** Gets or sets the tickness of major lines (2 by default) */
  76665. get majorLineTickness(): number;
  76666. set majorLineTickness(value: number);
  76667. /** Gets or sets the color of major lines (White by default) */
  76668. get majorLineColor(): string;
  76669. set majorLineColor(value: string);
  76670. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  76671. get majorLineFrequency(): number;
  76672. set majorLineFrequency(value: number);
  76673. /**
  76674. * Creates a new GridDisplayRectangle
  76675. * @param name defines the control name
  76676. */
  76677. constructor(name?: string | undefined);
  76678. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76679. protected _getTypeName(): string;
  76680. }
  76681. }
  76682. declare module BABYLON.GUI {
  76683. /**
  76684. * Class used to create slider controls based on images
  76685. */
  76686. export class ImageBasedSlider extends BaseSlider {
  76687. name?: string | undefined;
  76688. private _backgroundImage;
  76689. private _thumbImage;
  76690. private _valueBarImage;
  76691. private _tempMeasure;
  76692. get displayThumb(): boolean;
  76693. set displayThumb(value: boolean);
  76694. /**
  76695. * Gets or sets the image used to render the background
  76696. */
  76697. get backgroundImage(): Image;
  76698. set backgroundImage(value: Image);
  76699. /**
  76700. * Gets or sets the image used to render the value bar
  76701. */
  76702. get valueBarImage(): Image;
  76703. set valueBarImage(value: Image);
  76704. /**
  76705. * Gets or sets the image used to render the thumb
  76706. */
  76707. get thumbImage(): Image;
  76708. set thumbImage(value: Image);
  76709. /**
  76710. * Creates a new ImageBasedSlider
  76711. * @param name defines the control name
  76712. */
  76713. constructor(name?: string | undefined);
  76714. protected _getTypeName(): string;
  76715. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76716. }
  76717. }
  76718. declare module BABYLON.GUI {
  76719. /**
  76720. * Forcing an export so that this code will execute
  76721. * @hidden
  76722. */
  76723. const name = "Statics";
  76724. }
  76725. declare module BABYLON.GUI {
  76726. /**
  76727. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  76728. */
  76729. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  76730. /**
  76731. * Define the instrumented AdvancedDynamicTexture.
  76732. */
  76733. texture: AdvancedDynamicTexture;
  76734. private _captureRenderTime;
  76735. private _renderTime;
  76736. private _captureLayoutTime;
  76737. private _layoutTime;
  76738. private _onBeginRenderObserver;
  76739. private _onEndRenderObserver;
  76740. private _onBeginLayoutObserver;
  76741. private _onEndLayoutObserver;
  76742. /**
  76743. * Gets the perf counter used to capture render time
  76744. */
  76745. get renderTimeCounter(): BABYLON.PerfCounter;
  76746. /**
  76747. * Gets the perf counter used to capture layout time
  76748. */
  76749. get layoutTimeCounter(): BABYLON.PerfCounter;
  76750. /**
  76751. * Enable or disable the render time capture
  76752. */
  76753. get captureRenderTime(): boolean;
  76754. set captureRenderTime(value: boolean);
  76755. /**
  76756. * Enable or disable the layout time capture
  76757. */
  76758. get captureLayoutTime(): boolean;
  76759. set captureLayoutTime(value: boolean);
  76760. /**
  76761. * Instantiates a new advanced dynamic texture instrumentation.
  76762. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  76763. * @param texture Defines the AdvancedDynamicTexture to instrument
  76764. */
  76765. constructor(
  76766. /**
  76767. * Define the instrumented AdvancedDynamicTexture.
  76768. */
  76769. texture: AdvancedDynamicTexture);
  76770. /**
  76771. * Dispose and release associated resources.
  76772. */
  76773. dispose(): void;
  76774. }
  76775. }
  76776. declare module BABYLON.GUI {
  76777. /**
  76778. * Class used to load GUI via XML.
  76779. */
  76780. export class XmlLoader {
  76781. private _nodes;
  76782. private _nodeTypes;
  76783. private _isLoaded;
  76784. private _objectAttributes;
  76785. private _parentClass;
  76786. /**
  76787. * Create a new xml loader
  76788. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  76789. */
  76790. constructor(parentClass?: null);
  76791. private _getChainElement;
  76792. private _getClassAttribute;
  76793. private _createGuiElement;
  76794. private _parseGrid;
  76795. private _parseElement;
  76796. private _prepareSourceElement;
  76797. private _parseElementsFromSource;
  76798. private _parseXml;
  76799. /**
  76800. * Gets if the loading has finished.
  76801. * @returns whether the loading has finished or not
  76802. */
  76803. isLoaded(): boolean;
  76804. /**
  76805. * Gets a loaded node / control by id.
  76806. * @param id the Controls id set in the xml
  76807. * @returns element of type Control
  76808. */
  76809. getNodeById(id: string): any;
  76810. /**
  76811. * Gets all loaded nodes / controls
  76812. * @returns Array of controls
  76813. */
  76814. getNodes(): any;
  76815. /**
  76816. * Initiates the xml layout loading
  76817. * @param xmlFile defines the xml layout to load
  76818. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  76819. * @param callback defines the callback called on layout load.
  76820. */
  76821. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  76822. }
  76823. }
  76824. declare module BABYLON.GUI {
  76825. /**
  76826. * Class used to create containers for controls
  76827. */
  76828. export class Container3D extends Control3D {
  76829. private _blockLayout;
  76830. /**
  76831. * Gets the list of child controls
  76832. */
  76833. protected _children: Control3D[];
  76834. /**
  76835. * Gets the list of child controls
  76836. */
  76837. get children(): Array<Control3D>;
  76838. /**
  76839. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  76840. * This is helpful to optimize layout operation when adding multiple children in a row
  76841. */
  76842. get blockLayout(): boolean;
  76843. set blockLayout(value: boolean);
  76844. /**
  76845. * Creates a new container
  76846. * @param name defines the container name
  76847. */
  76848. constructor(name?: string);
  76849. /**
  76850. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  76851. * @returns the current container
  76852. */
  76853. updateLayout(): Container3D;
  76854. /**
  76855. * Gets a boolean indicating if the given control is in the children of this control
  76856. * @param control defines the control to check
  76857. * @returns true if the control is in the child list
  76858. */
  76859. containsControl(control: Control3D): boolean;
  76860. /**
  76861. * Adds a control to the children of this control
  76862. * @param control defines the control to add
  76863. * @returns the current container
  76864. */
  76865. addControl(control: Control3D): Container3D;
  76866. /**
  76867. * This function will be called everytime a new control is added
  76868. */
  76869. protected _arrangeChildren(): void;
  76870. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  76871. /**
  76872. * Removes a control from the children of this control
  76873. * @param control defines the control to remove
  76874. * @returns the current container
  76875. */
  76876. removeControl(control: Control3D): Container3D;
  76877. protected _getTypeName(): string;
  76878. /**
  76879. * Releases all associated resources
  76880. */
  76881. dispose(): void;
  76882. /** Control rotation will remain unchanged */
  76883. static readonly UNSET_ORIENTATION: number;
  76884. /** Control will rotate to make it look at sphere central axis */
  76885. static readonly FACEORIGIN_ORIENTATION: number;
  76886. /** Control will rotate to make it look back at sphere central axis */
  76887. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  76888. /** Control will rotate to look at z axis (0, 0, 1) */
  76889. static readonly FACEFORWARD_ORIENTATION: number;
  76890. /** Control will rotate to look at negative z axis (0, 0, -1) */
  76891. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  76892. }
  76893. }
  76894. declare module BABYLON.GUI {
  76895. /**
  76896. * Class used to manage 3D user interface
  76897. * @see http://doc.babylonjs.com/how_to/gui3d
  76898. */
  76899. export class GUI3DManager implements BABYLON.IDisposable {
  76900. private _scene;
  76901. private _sceneDisposeObserver;
  76902. private _utilityLayer;
  76903. private _rootContainer;
  76904. private _pointerObserver;
  76905. private _pointerOutObserver;
  76906. /** @hidden */
  76907. _lastPickedControl: Control3D;
  76908. /** @hidden */
  76909. _lastControlOver: {
  76910. [pointerId: number]: Control3D;
  76911. };
  76912. /** @hidden */
  76913. _lastControlDown: {
  76914. [pointerId: number]: Control3D;
  76915. };
  76916. /**
  76917. * BABYLON.Observable raised when the point picked by the pointer events changed
  76918. */
  76919. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  76920. /** @hidden */
  76921. _sharedMaterials: {
  76922. [key: string]: BABYLON.Material;
  76923. };
  76924. /** Gets the hosting scene */
  76925. get scene(): BABYLON.Scene;
  76926. /** Gets associated utility layer */
  76927. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  76928. /**
  76929. * Creates a new GUI3DManager
  76930. * @param scene
  76931. */
  76932. constructor(scene?: BABYLON.Scene);
  76933. private _handlePointerOut;
  76934. private _doPicking;
  76935. /**
  76936. * Gets the root container
  76937. */
  76938. get rootContainer(): Container3D;
  76939. /**
  76940. * Gets a boolean indicating if the given control is in the root child list
  76941. * @param control defines the control to check
  76942. * @returns true if the control is in the root child list
  76943. */
  76944. containsControl(control: Control3D): boolean;
  76945. /**
  76946. * Adds a control to the root child list
  76947. * @param control defines the control to add
  76948. * @returns the current manager
  76949. */
  76950. addControl(control: Control3D): GUI3DManager;
  76951. /**
  76952. * Removes a control from the root child list
  76953. * @param control defines the control to remove
  76954. * @returns the current container
  76955. */
  76956. removeControl(control: Control3D): GUI3DManager;
  76957. /**
  76958. * Releases all associated resources
  76959. */
  76960. dispose(): void;
  76961. }
  76962. }
  76963. declare module BABYLON.GUI {
  76964. /**
  76965. * Class used to transport BABYLON.Vector3 information for pointer events
  76966. */
  76967. export class Vector3WithInfo extends BABYLON.Vector3 {
  76968. /** defines the current mouse button index */
  76969. buttonIndex: number;
  76970. /**
  76971. * Creates a new Vector3WithInfo
  76972. * @param source defines the vector3 data to transport
  76973. * @param buttonIndex defines the current mouse button index
  76974. */
  76975. constructor(source: BABYLON.Vector3,
  76976. /** defines the current mouse button index */
  76977. buttonIndex?: number);
  76978. }
  76979. }
  76980. declare module BABYLON.GUI {
  76981. /**
  76982. * Class used as base class for controls
  76983. */
  76984. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  76985. /** Defines the control name */
  76986. name?: string | undefined;
  76987. /** @hidden */
  76988. _host: GUI3DManager;
  76989. private _node;
  76990. private _downCount;
  76991. private _enterCount;
  76992. private _downPointerIds;
  76993. private _isVisible;
  76994. /** Gets or sets the control position in world space */
  76995. get position(): BABYLON.Vector3;
  76996. set position(value: BABYLON.Vector3);
  76997. /** Gets or sets the control scaling in world space */
  76998. get scaling(): BABYLON.Vector3;
  76999. set scaling(value: BABYLON.Vector3);
  77000. /** Callback used to start pointer enter animation */
  77001. pointerEnterAnimation: () => void;
  77002. /** Callback used to start pointer out animation */
  77003. pointerOutAnimation: () => void;
  77004. /** Callback used to start pointer down animation */
  77005. pointerDownAnimation: () => void;
  77006. /** Callback used to start pointer up animation */
  77007. pointerUpAnimation: () => void;
  77008. /**
  77009. * An event triggered when the pointer move over the control
  77010. */
  77011. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  77012. /**
  77013. * An event triggered when the pointer move out of the control
  77014. */
  77015. onPointerOutObservable: BABYLON.Observable<Control3D>;
  77016. /**
  77017. * An event triggered when the pointer taps the control
  77018. */
  77019. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  77020. /**
  77021. * An event triggered when pointer is up
  77022. */
  77023. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  77024. /**
  77025. * An event triggered when a control is clicked on (with a mouse)
  77026. */
  77027. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  77028. /**
  77029. * An event triggered when pointer enters the control
  77030. */
  77031. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  77032. /**
  77033. * Gets or sets the parent container
  77034. */
  77035. parent: BABYLON.Nullable<Container3D>;
  77036. private _behaviors;
  77037. /**
  77038. * Gets the list of attached behaviors
  77039. * @see http://doc.babylonjs.com/features/behaviour
  77040. */
  77041. get behaviors(): BABYLON.Behavior<Control3D>[];
  77042. /**
  77043. * Attach a behavior to the control
  77044. * @see http://doc.babylonjs.com/features/behaviour
  77045. * @param behavior defines the behavior to attach
  77046. * @returns the current control
  77047. */
  77048. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  77049. /**
  77050. * Remove an attached behavior
  77051. * @see http://doc.babylonjs.com/features/behaviour
  77052. * @param behavior defines the behavior to attach
  77053. * @returns the current control
  77054. */
  77055. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  77056. /**
  77057. * Gets an attached behavior by name
  77058. * @param name defines the name of the behavior to look for
  77059. * @see http://doc.babylonjs.com/features/behaviour
  77060. * @returns null if behavior was not found else the requested behavior
  77061. */
  77062. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  77063. /** Gets or sets a boolean indicating if the control is visible */
  77064. get isVisible(): boolean;
  77065. set isVisible(value: boolean);
  77066. /**
  77067. * Creates a new control
  77068. * @param name defines the control name
  77069. */
  77070. constructor(
  77071. /** Defines the control name */
  77072. name?: string | undefined);
  77073. /**
  77074. * Gets a string representing the class name
  77075. */
  77076. get typeName(): string;
  77077. /**
  77078. * Get the current class name of the control.
  77079. * @returns current class name
  77080. */
  77081. getClassName(): string;
  77082. protected _getTypeName(): string;
  77083. /**
  77084. * Gets the transform node used by this control
  77085. */
  77086. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  77087. /**
  77088. * Gets the mesh used to render this control
  77089. */
  77090. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  77091. /**
  77092. * Link the control as child of the given node
  77093. * @param node defines the node to link to. Use null to unlink the control
  77094. * @returns the current control
  77095. */
  77096. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  77097. /** @hidden **/
  77098. _prepareNode(scene: BABYLON.Scene): void;
  77099. /**
  77100. * Node creation.
  77101. * Can be overriden by children
  77102. * @param scene defines the scene where the node must be attached
  77103. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  77104. */
  77105. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  77106. /**
  77107. * Affect a material to the given mesh
  77108. * @param mesh defines the mesh which will represent the control
  77109. */
  77110. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  77111. /** @hidden */
  77112. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  77113. /** @hidden */
  77114. _onPointerEnter(target: Control3D): boolean;
  77115. /** @hidden */
  77116. _onPointerOut(target: Control3D): void;
  77117. /** @hidden */
  77118. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  77119. /** @hidden */
  77120. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  77121. /** @hidden */
  77122. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  77123. /** @hidden */
  77124. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  77125. /** @hidden */
  77126. _disposeNode(): void;
  77127. /**
  77128. * Releases all associated resources
  77129. */
  77130. dispose(): void;
  77131. }
  77132. }
  77133. declare module BABYLON.GUI {
  77134. /**
  77135. * Class used as a root to all buttons
  77136. */
  77137. export class AbstractButton3D extends Control3D {
  77138. /**
  77139. * Creates a new button
  77140. * @param name defines the control name
  77141. */
  77142. constructor(name?: string);
  77143. protected _getTypeName(): string;
  77144. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  77145. }
  77146. }
  77147. declare module BABYLON.GUI {
  77148. /**
  77149. * Class used to create a button in 3D
  77150. */
  77151. export class Button3D extends AbstractButton3D {
  77152. /** @hidden */
  77153. protected _currentMaterial: BABYLON.Material;
  77154. private _facadeTexture;
  77155. private _content;
  77156. private _contentResolution;
  77157. private _contentScaleRatio;
  77158. /**
  77159. * Gets or sets the texture resolution used to render content (512 by default)
  77160. */
  77161. get contentResolution(): BABYLON.int;
  77162. set contentResolution(value: BABYLON.int);
  77163. /**
  77164. * Gets or sets the texture scale ratio used to render content (2 by default)
  77165. */
  77166. get contentScaleRatio(): number;
  77167. set contentScaleRatio(value: number);
  77168. protected _disposeFacadeTexture(): void;
  77169. protected _resetContent(): void;
  77170. /**
  77171. * Creates a new button
  77172. * @param name defines the control name
  77173. */
  77174. constructor(name?: string);
  77175. /**
  77176. * Gets or sets the GUI 2D content used to display the button's facade
  77177. */
  77178. get content(): Control;
  77179. set content(value: Control);
  77180. /**
  77181. * Apply the facade texture (created from the content property).
  77182. * This function can be overloaded by child classes
  77183. * @param facadeTexture defines the AdvancedDynamicTexture to use
  77184. */
  77185. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  77186. protected _getTypeName(): string;
  77187. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  77188. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  77189. /**
  77190. * Releases all associated resources
  77191. */
  77192. dispose(): void;
  77193. }
  77194. }
  77195. declare module BABYLON.GUI {
  77196. /**
  77197. * Abstract class used to create a container panel deployed on the surface of a volume
  77198. */
  77199. export abstract class VolumeBasedPanel extends Container3D {
  77200. private _columns;
  77201. private _rows;
  77202. private _rowThenColum;
  77203. private _orientation;
  77204. protected _cellWidth: number;
  77205. protected _cellHeight: number;
  77206. /**
  77207. * Gets or sets the distance between elements
  77208. */
  77209. margin: number;
  77210. /**
  77211. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  77212. * | Value | Type | Description |
  77213. * | ----- | ----------------------------------- | ----------- |
  77214. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  77215. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  77216. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  77217. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  77218. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  77219. */
  77220. get orientation(): number;
  77221. set orientation(value: number);
  77222. /**
  77223. * Gets or sets the number of columns requested (10 by default).
  77224. * The panel will automatically compute the number of rows based on number of child controls.
  77225. */
  77226. get columns(): BABYLON.int;
  77227. set columns(value: BABYLON.int);
  77228. /**
  77229. * Gets or sets a the number of rows requested.
  77230. * The panel will automatically compute the number of columns based on number of child controls.
  77231. */
  77232. get rows(): BABYLON.int;
  77233. set rows(value: BABYLON.int);
  77234. /**
  77235. * Creates new VolumeBasedPanel
  77236. */
  77237. constructor();
  77238. protected _arrangeChildren(): void;
  77239. /** Child classes must implement this function to provide correct control positioning */
  77240. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  77241. /** Child classes can implement this function to provide additional processing */
  77242. protected _finalProcessing(): void;
  77243. }
  77244. }
  77245. declare module BABYLON.GUI {
  77246. /**
  77247. * Class used to create a container panel deployed on the surface of a cylinder
  77248. */
  77249. export class CylinderPanel extends VolumeBasedPanel {
  77250. private _radius;
  77251. /**
  77252. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  77253. */
  77254. get radius(): BABYLON.float;
  77255. set radius(value: BABYLON.float);
  77256. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  77257. private _cylindricalMapping;
  77258. }
  77259. }
  77260. declare module BABYLON.GUI {
  77261. /** @hidden */
  77262. export var fluentVertexShader: {
  77263. name: string;
  77264. shader: string;
  77265. };
  77266. }
  77267. declare module BABYLON.GUI {
  77268. /** @hidden */
  77269. export var fluentPixelShader: {
  77270. name: string;
  77271. shader: string;
  77272. };
  77273. }
  77274. declare module BABYLON.GUI {
  77275. /** @hidden */
  77276. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  77277. INNERGLOW: boolean;
  77278. BORDER: boolean;
  77279. HOVERLIGHT: boolean;
  77280. TEXTURE: boolean;
  77281. constructor();
  77282. }
  77283. /**
  77284. * Class used to render controls with fluent desgin
  77285. */
  77286. export class FluentMaterial extends BABYLON.PushMaterial {
  77287. /**
  77288. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  77289. */
  77290. innerGlowColorIntensity: number;
  77291. /**
  77292. * Gets or sets the inner glow color (white by default)
  77293. */
  77294. innerGlowColor: BABYLON.Color3;
  77295. /**
  77296. * Gets or sets alpha value (default is 1.0)
  77297. */
  77298. alpha: number;
  77299. /**
  77300. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  77301. */
  77302. albedoColor: BABYLON.Color3;
  77303. /**
  77304. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  77305. */
  77306. renderBorders: boolean;
  77307. /**
  77308. * Gets or sets border width (default is 0.5)
  77309. */
  77310. borderWidth: number;
  77311. /**
  77312. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  77313. */
  77314. edgeSmoothingValue: number;
  77315. /**
  77316. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  77317. */
  77318. borderMinValue: number;
  77319. /**
  77320. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  77321. */
  77322. renderHoverLight: boolean;
  77323. /**
  77324. * Gets or sets the radius used to render the hover light (default is 1.0)
  77325. */
  77326. hoverRadius: number;
  77327. /**
  77328. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  77329. */
  77330. hoverColor: BABYLON.Color4;
  77331. /**
  77332. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  77333. */
  77334. hoverPosition: BABYLON.Vector3;
  77335. private _albedoTexture;
  77336. /** Gets or sets the texture to use for albedo color */
  77337. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  77338. /**
  77339. * Creates a new Fluent material
  77340. * @param name defines the name of the material
  77341. * @param scene defines the hosting scene
  77342. */
  77343. constructor(name: string, scene: BABYLON.Scene);
  77344. needAlphaBlending(): boolean;
  77345. needAlphaTesting(): boolean;
  77346. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  77347. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  77348. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  77349. getActiveTextures(): BABYLON.BaseTexture[];
  77350. hasTexture(texture: BABYLON.BaseTexture): boolean;
  77351. dispose(forceDisposeEffect?: boolean): void;
  77352. clone(name: string): FluentMaterial;
  77353. serialize(): any;
  77354. getClassName(): string;
  77355. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  77356. }
  77357. }
  77358. declare module BABYLON.GUI {
  77359. /**
  77360. * Class used to create a holographic button in 3D
  77361. */
  77362. export class HolographicButton extends Button3D {
  77363. private _backPlate;
  77364. private _textPlate;
  77365. private _frontPlate;
  77366. private _text;
  77367. private _imageUrl;
  77368. private _shareMaterials;
  77369. private _frontMaterial;
  77370. private _backMaterial;
  77371. private _plateMaterial;
  77372. private _pickedPointObserver;
  77373. private _tooltipFade;
  77374. private _tooltipTextBlock;
  77375. private _tooltipTexture;
  77376. private _tooltipMesh;
  77377. private _tooltipHoverObserver;
  77378. private _tooltipOutObserver;
  77379. private _disposeTooltip;
  77380. /**
  77381. * Rendering ground id of all the mesh in the button
  77382. */
  77383. set renderingGroupId(id: number);
  77384. get renderingGroupId(): number;
  77385. /**
  77386. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  77387. */
  77388. set tooltipText(text: BABYLON.Nullable<string>);
  77389. get tooltipText(): BABYLON.Nullable<string>;
  77390. /**
  77391. * Gets or sets text for the button
  77392. */
  77393. get text(): string;
  77394. set text(value: string);
  77395. /**
  77396. * Gets or sets the image url for the button
  77397. */
  77398. get imageUrl(): string;
  77399. set imageUrl(value: string);
  77400. /**
  77401. * Gets the back material used by this button
  77402. */
  77403. get backMaterial(): FluentMaterial;
  77404. /**
  77405. * Gets the front material used by this button
  77406. */
  77407. get frontMaterial(): FluentMaterial;
  77408. /**
  77409. * Gets the plate material used by this button
  77410. */
  77411. get plateMaterial(): BABYLON.StandardMaterial;
  77412. /**
  77413. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  77414. */
  77415. get shareMaterials(): boolean;
  77416. /**
  77417. * Creates a new button
  77418. * @param name defines the control name
  77419. */
  77420. constructor(name?: string, shareMaterials?: boolean);
  77421. protected _getTypeName(): string;
  77422. private _rebuildContent;
  77423. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  77424. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  77425. private _createBackMaterial;
  77426. private _createFrontMaterial;
  77427. private _createPlateMaterial;
  77428. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  77429. /**
  77430. * Releases all associated resources
  77431. */
  77432. dispose(): void;
  77433. }
  77434. }
  77435. declare module BABYLON.GUI {
  77436. /**
  77437. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  77438. */
  77439. export class MeshButton3D extends Button3D {
  77440. /** @hidden */
  77441. protected _currentMesh: BABYLON.Mesh;
  77442. /**
  77443. * Creates a new 3D button based on a mesh
  77444. * @param mesh mesh to become a 3D button
  77445. * @param name defines the control name
  77446. */
  77447. constructor(mesh: BABYLON.Mesh, name?: string);
  77448. protected _getTypeName(): string;
  77449. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  77450. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  77451. }
  77452. }
  77453. declare module BABYLON.GUI {
  77454. /**
  77455. * Class used to create a container panel deployed on the surface of a plane
  77456. */
  77457. export class PlanePanel extends VolumeBasedPanel {
  77458. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  77459. }
  77460. }
  77461. declare module BABYLON.GUI {
  77462. /**
  77463. * Class used to create a container panel where items get randomized planar mapping
  77464. */
  77465. export class ScatterPanel extends VolumeBasedPanel {
  77466. private _iteration;
  77467. /**
  77468. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  77469. */
  77470. get iteration(): BABYLON.float;
  77471. set iteration(value: BABYLON.float);
  77472. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  77473. private _scatterMapping;
  77474. protected _finalProcessing(): void;
  77475. }
  77476. }
  77477. declare module BABYLON.GUI {
  77478. /**
  77479. * Class used to create a container panel deployed on the surface of a sphere
  77480. */
  77481. export class SpherePanel extends VolumeBasedPanel {
  77482. private _radius;
  77483. /**
  77484. * Gets or sets the radius of the sphere where to project controls (5 by default)
  77485. */
  77486. get radius(): BABYLON.float;
  77487. set radius(value: BABYLON.float);
  77488. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  77489. private _sphericalMapping;
  77490. }
  77491. }
  77492. declare module BABYLON.GUI {
  77493. /**
  77494. * Class used to create a stack panel in 3D on XY plane
  77495. */
  77496. export class StackPanel3D extends Container3D {
  77497. private _isVertical;
  77498. /**
  77499. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  77500. */
  77501. get isVertical(): boolean;
  77502. set isVertical(value: boolean);
  77503. /**
  77504. * Gets or sets the distance between elements
  77505. */
  77506. margin: number;
  77507. /**
  77508. * Creates new StackPanel
  77509. * @param isVertical
  77510. */
  77511. constructor(isVertical?: boolean);
  77512. protected _arrangeChildren(): void;
  77513. }
  77514. }
  77515. declare module BABYLON {
  77516. /**
  77517. * Configuration for glTF validation
  77518. */
  77519. export interface IGLTFValidationConfiguration {
  77520. /**
  77521. * The url of the glTF validator.
  77522. */
  77523. url: string;
  77524. }
  77525. /**
  77526. * glTF validation
  77527. */
  77528. export class GLTFValidation {
  77529. /**
  77530. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  77531. */
  77532. static Configuration: IGLTFValidationConfiguration;
  77533. private static _LoadScriptPromise;
  77534. /**
  77535. * Validate a glTF asset using the glTF-Validator.
  77536. * @param data The JSON of a glTF or the array buffer of a binary glTF
  77537. * @param rootUrl The root url for the glTF
  77538. * @param fileName The file name for the glTF
  77539. * @param getExternalResource The callback to get external resources for the glTF validator
  77540. * @returns A promise that resolves with the glTF validation results once complete
  77541. */
  77542. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  77543. }
  77544. }
  77545. declare module BABYLON {
  77546. /**
  77547. * Mode that determines the coordinate system to use.
  77548. */
  77549. export enum GLTFLoaderCoordinateSystemMode {
  77550. /**
  77551. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  77552. */
  77553. AUTO = 0,
  77554. /**
  77555. * Sets the useRightHandedSystem flag on the scene.
  77556. */
  77557. FORCE_RIGHT_HANDED = 1
  77558. }
  77559. /**
  77560. * Mode that determines what animations will start.
  77561. */
  77562. export enum GLTFLoaderAnimationStartMode {
  77563. /**
  77564. * No animation will start.
  77565. */
  77566. NONE = 0,
  77567. /**
  77568. * The first animation will start.
  77569. */
  77570. FIRST = 1,
  77571. /**
  77572. * All animations will start.
  77573. */
  77574. ALL = 2
  77575. }
  77576. /**
  77577. * Interface that contains the data for the glTF asset.
  77578. */
  77579. export interface IGLTFLoaderData {
  77580. /**
  77581. * The object that represents the glTF JSON.
  77582. */
  77583. json: Object;
  77584. /**
  77585. * The BIN chunk of a binary glTF.
  77586. */
  77587. bin: Nullable<IDataBuffer>;
  77588. }
  77589. /**
  77590. * Interface for extending the loader.
  77591. */
  77592. export interface IGLTFLoaderExtension {
  77593. /**
  77594. * The name of this extension.
  77595. */
  77596. readonly name: string;
  77597. /**
  77598. * Defines whether this extension is enabled.
  77599. */
  77600. enabled: boolean;
  77601. /**
  77602. * Defines the order of this extension.
  77603. * The loader sorts the extensions using these values when loading.
  77604. */
  77605. order?: number;
  77606. }
  77607. /**
  77608. * Loader state.
  77609. */
  77610. export enum GLTFLoaderState {
  77611. /**
  77612. * The asset is loading.
  77613. */
  77614. LOADING = 0,
  77615. /**
  77616. * The asset is ready for rendering.
  77617. */
  77618. READY = 1,
  77619. /**
  77620. * The asset is completely loaded.
  77621. */
  77622. COMPLETE = 2
  77623. }
  77624. /** @hidden */
  77625. export interface IImportMeshAsyncOutput {
  77626. meshes: AbstractMesh[];
  77627. particleSystems: IParticleSystem[];
  77628. skeletons: Skeleton[];
  77629. animationGroups: AnimationGroup[];
  77630. lights: Light[];
  77631. transformNodes: TransformNode[];
  77632. }
  77633. /** @hidden */
  77634. export interface IGLTFLoader extends IDisposable {
  77635. readonly state: Nullable<GLTFLoaderState>;
  77636. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  77637. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  77638. }
  77639. /**
  77640. * File loader for loading glTF files into a scene.
  77641. */
  77642. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  77643. /** @hidden */
  77644. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  77645. /** @hidden */
  77646. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  77647. /**
  77648. * Raised when the asset has been parsed
  77649. */
  77650. onParsedObservable: Observable<IGLTFLoaderData>;
  77651. private _onParsedObserver;
  77652. /**
  77653. * Raised when the asset has been parsed
  77654. */
  77655. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  77656. /**
  77657. * 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.
  77658. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  77659. * Defaults to true.
  77660. * @hidden
  77661. */
  77662. static IncrementalLoading: boolean;
  77663. /**
  77664. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  77665. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  77666. * @hidden
  77667. */
  77668. static HomogeneousCoordinates: boolean;
  77669. /**
  77670. * The coordinate system mode. Defaults to AUTO.
  77671. */
  77672. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  77673. /**
  77674. * The animation start mode. Defaults to FIRST.
  77675. */
  77676. animationStartMode: GLTFLoaderAnimationStartMode;
  77677. /**
  77678. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  77679. */
  77680. compileMaterials: boolean;
  77681. /**
  77682. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  77683. */
  77684. useClipPlane: boolean;
  77685. /**
  77686. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  77687. */
  77688. compileShadowGenerators: boolean;
  77689. /**
  77690. * Defines if the Alpha blended materials are only applied as coverage.
  77691. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  77692. * If true, no extra effects are applied to transparent pixels.
  77693. */
  77694. transparencyAsCoverage: boolean;
  77695. /**
  77696. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  77697. * Enabling will disable offline support and glTF validator.
  77698. * Defaults to false.
  77699. */
  77700. useRangeRequests: boolean;
  77701. /**
  77702. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  77703. */
  77704. createInstances: boolean;
  77705. /**
  77706. * Function called before loading a url referenced by the asset.
  77707. */
  77708. preprocessUrlAsync: (url: string) => Promise<string>;
  77709. /**
  77710. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  77711. */
  77712. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  77713. private _onMeshLoadedObserver;
  77714. /**
  77715. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  77716. */
  77717. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  77718. /**
  77719. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  77720. */
  77721. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  77722. private _onTextureLoadedObserver;
  77723. /**
  77724. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  77725. */
  77726. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  77727. /**
  77728. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  77729. */
  77730. readonly onMaterialLoadedObservable: Observable<Material>;
  77731. private _onMaterialLoadedObserver;
  77732. /**
  77733. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  77734. */
  77735. set onMaterialLoaded(callback: (material: Material) => void);
  77736. /**
  77737. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  77738. */
  77739. readonly onCameraLoadedObservable: Observable<Camera>;
  77740. private _onCameraLoadedObserver;
  77741. /**
  77742. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  77743. */
  77744. set onCameraLoaded(callback: (camera: Camera) => void);
  77745. /**
  77746. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  77747. * For assets with LODs, raised when all of the LODs are complete.
  77748. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  77749. */
  77750. readonly onCompleteObservable: Observable<void>;
  77751. private _onCompleteObserver;
  77752. /**
  77753. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  77754. * For assets with LODs, raised when all of the LODs are complete.
  77755. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  77756. */
  77757. set onComplete(callback: () => void);
  77758. /**
  77759. * Observable raised when an error occurs.
  77760. */
  77761. readonly onErrorObservable: Observable<any>;
  77762. private _onErrorObserver;
  77763. /**
  77764. * Callback raised when an error occurs.
  77765. */
  77766. set onError(callback: (reason: any) => void);
  77767. /**
  77768. * Observable raised after the loader is disposed.
  77769. */
  77770. readonly onDisposeObservable: Observable<void>;
  77771. private _onDisposeObserver;
  77772. /**
  77773. * Callback raised after the loader is disposed.
  77774. */
  77775. set onDispose(callback: () => void);
  77776. /**
  77777. * Observable raised after a loader extension is created.
  77778. * Set additional options for a loader extension in this event.
  77779. */
  77780. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  77781. private _onExtensionLoadedObserver;
  77782. /**
  77783. * Callback raised after a loader extension is created.
  77784. */
  77785. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  77786. /**
  77787. * Defines if the loader logging is enabled.
  77788. */
  77789. get loggingEnabled(): boolean;
  77790. set loggingEnabled(value: boolean);
  77791. /**
  77792. * Defines if the loader should capture performance counters.
  77793. */
  77794. get capturePerformanceCounters(): boolean;
  77795. set capturePerformanceCounters(value: boolean);
  77796. /**
  77797. * Defines if the loader should validate the asset.
  77798. */
  77799. validate: boolean;
  77800. /**
  77801. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  77802. */
  77803. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  77804. private _onValidatedObserver;
  77805. /**
  77806. * Callback raised after a loader extension is created.
  77807. */
  77808. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  77809. private _loader;
  77810. /**
  77811. * Name of the loader ("gltf")
  77812. */
  77813. name: string;
  77814. /** @hidden */
  77815. extensions: ISceneLoaderPluginExtensions;
  77816. /**
  77817. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  77818. */
  77819. dispose(): void;
  77820. /** @hidden */
  77821. _clear(): void;
  77822. /** @hidden */
  77823. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  77824. /** @hidden */
  77825. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  77826. /** @hidden */
  77827. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  77828. meshes: AbstractMesh[];
  77829. particleSystems: IParticleSystem[];
  77830. skeletons: Skeleton[];
  77831. animationGroups: AnimationGroup[];
  77832. }>;
  77833. /** @hidden */
  77834. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  77835. /** @hidden */
  77836. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  77837. /** @hidden */
  77838. canDirectLoad(data: string): boolean;
  77839. /** @hidden */
  77840. directLoad(scene: Scene, data: string): any;
  77841. /**
  77842. * The callback that allows custom handling of the root url based on the response url.
  77843. * @param rootUrl the original root url
  77844. * @param responseURL the response url if available
  77845. * @returns the new root url
  77846. */
  77847. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  77848. /** @hidden */
  77849. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  77850. /**
  77851. * The loader state or null if the loader is not active.
  77852. */
  77853. get loaderState(): Nullable<GLTFLoaderState>;
  77854. /**
  77855. * Returns a promise that resolves when the asset is completely loaded.
  77856. * @returns a promise that resolves when the asset is completely loaded.
  77857. */
  77858. whenCompleteAsync(): Promise<void>;
  77859. private _validate;
  77860. private _getLoader;
  77861. private _parseJson;
  77862. private _unpackBinaryAsync;
  77863. private _unpackBinaryV1Async;
  77864. private _unpackBinaryV2Async;
  77865. private static _parseVersion;
  77866. private static _compareVersion;
  77867. private static readonly _logSpaces;
  77868. private _logIndentLevel;
  77869. private _loggingEnabled;
  77870. /** @hidden */
  77871. _log: (message: string) => void;
  77872. /** @hidden */
  77873. _logOpen(message: string): void;
  77874. /** @hidden */
  77875. _logClose(): void;
  77876. private _logEnabled;
  77877. private _logDisabled;
  77878. private _capturePerformanceCounters;
  77879. /** @hidden */
  77880. _startPerformanceCounter: (counterName: string) => void;
  77881. /** @hidden */
  77882. _endPerformanceCounter: (counterName: string) => void;
  77883. private _startPerformanceCounterEnabled;
  77884. private _startPerformanceCounterDisabled;
  77885. private _endPerformanceCounterEnabled;
  77886. private _endPerformanceCounterDisabled;
  77887. }
  77888. }
  77889. declare module BABYLON.GLTF1 {
  77890. /**
  77891. * Enums
  77892. * @hidden
  77893. */
  77894. export enum EComponentType {
  77895. BYTE = 5120,
  77896. UNSIGNED_BYTE = 5121,
  77897. SHORT = 5122,
  77898. UNSIGNED_SHORT = 5123,
  77899. FLOAT = 5126
  77900. }
  77901. /** @hidden */
  77902. export enum EShaderType {
  77903. FRAGMENT = 35632,
  77904. VERTEX = 35633
  77905. }
  77906. /** @hidden */
  77907. export enum EParameterType {
  77908. BYTE = 5120,
  77909. UNSIGNED_BYTE = 5121,
  77910. SHORT = 5122,
  77911. UNSIGNED_SHORT = 5123,
  77912. INT = 5124,
  77913. UNSIGNED_INT = 5125,
  77914. FLOAT = 5126,
  77915. FLOAT_VEC2 = 35664,
  77916. FLOAT_VEC3 = 35665,
  77917. FLOAT_VEC4 = 35666,
  77918. INT_VEC2 = 35667,
  77919. INT_VEC3 = 35668,
  77920. INT_VEC4 = 35669,
  77921. BOOL = 35670,
  77922. BOOL_VEC2 = 35671,
  77923. BOOL_VEC3 = 35672,
  77924. BOOL_VEC4 = 35673,
  77925. FLOAT_MAT2 = 35674,
  77926. FLOAT_MAT3 = 35675,
  77927. FLOAT_MAT4 = 35676,
  77928. SAMPLER_2D = 35678
  77929. }
  77930. /** @hidden */
  77931. export enum ETextureWrapMode {
  77932. CLAMP_TO_EDGE = 33071,
  77933. MIRRORED_REPEAT = 33648,
  77934. REPEAT = 10497
  77935. }
  77936. /** @hidden */
  77937. export enum ETextureFilterType {
  77938. NEAREST = 9728,
  77939. LINEAR = 9728,
  77940. NEAREST_MIPMAP_NEAREST = 9984,
  77941. LINEAR_MIPMAP_NEAREST = 9985,
  77942. NEAREST_MIPMAP_LINEAR = 9986,
  77943. LINEAR_MIPMAP_LINEAR = 9987
  77944. }
  77945. /** @hidden */
  77946. export enum ETextureFormat {
  77947. ALPHA = 6406,
  77948. RGB = 6407,
  77949. RGBA = 6408,
  77950. LUMINANCE = 6409,
  77951. LUMINANCE_ALPHA = 6410
  77952. }
  77953. /** @hidden */
  77954. export enum ECullingType {
  77955. FRONT = 1028,
  77956. BACK = 1029,
  77957. FRONT_AND_BACK = 1032
  77958. }
  77959. /** @hidden */
  77960. export enum EBlendingFunction {
  77961. ZERO = 0,
  77962. ONE = 1,
  77963. SRC_COLOR = 768,
  77964. ONE_MINUS_SRC_COLOR = 769,
  77965. DST_COLOR = 774,
  77966. ONE_MINUS_DST_COLOR = 775,
  77967. SRC_ALPHA = 770,
  77968. ONE_MINUS_SRC_ALPHA = 771,
  77969. DST_ALPHA = 772,
  77970. ONE_MINUS_DST_ALPHA = 773,
  77971. CONSTANT_COLOR = 32769,
  77972. ONE_MINUS_CONSTANT_COLOR = 32770,
  77973. CONSTANT_ALPHA = 32771,
  77974. ONE_MINUS_CONSTANT_ALPHA = 32772,
  77975. SRC_ALPHA_SATURATE = 776
  77976. }
  77977. /** @hidden */
  77978. export interface IGLTFProperty {
  77979. extensions?: {
  77980. [key: string]: any;
  77981. };
  77982. extras?: Object;
  77983. }
  77984. /** @hidden */
  77985. export interface IGLTFChildRootProperty extends IGLTFProperty {
  77986. name?: string;
  77987. }
  77988. /** @hidden */
  77989. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  77990. bufferView: string;
  77991. byteOffset: number;
  77992. byteStride: number;
  77993. count: number;
  77994. type: string;
  77995. componentType: EComponentType;
  77996. max?: number[];
  77997. min?: number[];
  77998. name?: string;
  77999. }
  78000. /** @hidden */
  78001. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  78002. buffer: string;
  78003. byteOffset: number;
  78004. byteLength: number;
  78005. byteStride: number;
  78006. target?: number;
  78007. }
  78008. /** @hidden */
  78009. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  78010. uri: string;
  78011. byteLength?: number;
  78012. type?: string;
  78013. }
  78014. /** @hidden */
  78015. export interface IGLTFShader extends IGLTFChildRootProperty {
  78016. uri: string;
  78017. type: EShaderType;
  78018. }
  78019. /** @hidden */
  78020. export interface IGLTFProgram extends IGLTFChildRootProperty {
  78021. attributes: string[];
  78022. fragmentShader: string;
  78023. vertexShader: string;
  78024. }
  78025. /** @hidden */
  78026. export interface IGLTFTechniqueParameter {
  78027. type: number;
  78028. count?: number;
  78029. semantic?: string;
  78030. node?: string;
  78031. value?: number | boolean | string | Array<any>;
  78032. source?: string;
  78033. babylonValue?: any;
  78034. }
  78035. /** @hidden */
  78036. export interface IGLTFTechniqueCommonProfile {
  78037. lightingModel: string;
  78038. texcoordBindings: Object;
  78039. parameters?: Array<any>;
  78040. }
  78041. /** @hidden */
  78042. export interface IGLTFTechniqueStatesFunctions {
  78043. blendColor?: number[];
  78044. blendEquationSeparate?: number[];
  78045. blendFuncSeparate?: number[];
  78046. colorMask: boolean[];
  78047. cullFace: number[];
  78048. }
  78049. /** @hidden */
  78050. export interface IGLTFTechniqueStates {
  78051. enable: number[];
  78052. functions: IGLTFTechniqueStatesFunctions;
  78053. }
  78054. /** @hidden */
  78055. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  78056. parameters: {
  78057. [key: string]: IGLTFTechniqueParameter;
  78058. };
  78059. program: string;
  78060. attributes: {
  78061. [key: string]: string;
  78062. };
  78063. uniforms: {
  78064. [key: string]: string;
  78065. };
  78066. states: IGLTFTechniqueStates;
  78067. }
  78068. /** @hidden */
  78069. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  78070. technique?: string;
  78071. values: string[];
  78072. }
  78073. /** @hidden */
  78074. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  78075. attributes: {
  78076. [key: string]: string;
  78077. };
  78078. indices: string;
  78079. material: string;
  78080. mode?: number;
  78081. }
  78082. /** @hidden */
  78083. export interface IGLTFMesh extends IGLTFChildRootProperty {
  78084. primitives: IGLTFMeshPrimitive[];
  78085. }
  78086. /** @hidden */
  78087. export interface IGLTFImage extends IGLTFChildRootProperty {
  78088. uri: string;
  78089. }
  78090. /** @hidden */
  78091. export interface IGLTFSampler extends IGLTFChildRootProperty {
  78092. magFilter?: number;
  78093. minFilter?: number;
  78094. wrapS?: number;
  78095. wrapT?: number;
  78096. }
  78097. /** @hidden */
  78098. export interface IGLTFTexture extends IGLTFChildRootProperty {
  78099. sampler: string;
  78100. source: string;
  78101. format?: ETextureFormat;
  78102. internalFormat?: ETextureFormat;
  78103. target?: number;
  78104. type?: number;
  78105. babylonTexture?: Texture;
  78106. }
  78107. /** @hidden */
  78108. export interface IGLTFAmbienLight {
  78109. color?: number[];
  78110. }
  78111. /** @hidden */
  78112. export interface IGLTFDirectionalLight {
  78113. color?: number[];
  78114. }
  78115. /** @hidden */
  78116. export interface IGLTFPointLight {
  78117. color?: number[];
  78118. constantAttenuation?: number;
  78119. linearAttenuation?: number;
  78120. quadraticAttenuation?: number;
  78121. }
  78122. /** @hidden */
  78123. export interface IGLTFSpotLight {
  78124. color?: number[];
  78125. constantAttenuation?: number;
  78126. fallOfAngle?: number;
  78127. fallOffExponent?: number;
  78128. linearAttenuation?: number;
  78129. quadraticAttenuation?: number;
  78130. }
  78131. /** @hidden */
  78132. export interface IGLTFLight extends IGLTFChildRootProperty {
  78133. type: string;
  78134. }
  78135. /** @hidden */
  78136. export interface IGLTFCameraOrthographic {
  78137. xmag: number;
  78138. ymag: number;
  78139. zfar: number;
  78140. znear: number;
  78141. }
  78142. /** @hidden */
  78143. export interface IGLTFCameraPerspective {
  78144. aspectRatio: number;
  78145. yfov: number;
  78146. zfar: number;
  78147. znear: number;
  78148. }
  78149. /** @hidden */
  78150. export interface IGLTFCamera extends IGLTFChildRootProperty {
  78151. type: string;
  78152. }
  78153. /** @hidden */
  78154. export interface IGLTFAnimationChannelTarget {
  78155. id: string;
  78156. path: string;
  78157. }
  78158. /** @hidden */
  78159. export interface IGLTFAnimationChannel {
  78160. sampler: string;
  78161. target: IGLTFAnimationChannelTarget;
  78162. }
  78163. /** @hidden */
  78164. export interface IGLTFAnimationSampler {
  78165. input: string;
  78166. output: string;
  78167. interpolation?: string;
  78168. }
  78169. /** @hidden */
  78170. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  78171. channels?: IGLTFAnimationChannel[];
  78172. parameters?: {
  78173. [key: string]: string;
  78174. };
  78175. samplers?: {
  78176. [key: string]: IGLTFAnimationSampler;
  78177. };
  78178. }
  78179. /** @hidden */
  78180. export interface IGLTFNodeInstanceSkin {
  78181. skeletons: string[];
  78182. skin: string;
  78183. meshes: string[];
  78184. }
  78185. /** @hidden */
  78186. export interface IGLTFSkins extends IGLTFChildRootProperty {
  78187. bindShapeMatrix: number[];
  78188. inverseBindMatrices: string;
  78189. jointNames: string[];
  78190. babylonSkeleton?: Skeleton;
  78191. }
  78192. /** @hidden */
  78193. export interface IGLTFNode extends IGLTFChildRootProperty {
  78194. camera?: string;
  78195. children: string[];
  78196. skin?: string;
  78197. jointName?: string;
  78198. light?: string;
  78199. matrix: number[];
  78200. mesh?: string;
  78201. meshes?: string[];
  78202. rotation?: number[];
  78203. scale?: number[];
  78204. translation?: number[];
  78205. babylonNode?: Node;
  78206. }
  78207. /** @hidden */
  78208. export interface IGLTFScene extends IGLTFChildRootProperty {
  78209. nodes: string[];
  78210. }
  78211. /** @hidden */
  78212. export interface IGLTFRuntime {
  78213. extensions: {
  78214. [key: string]: any;
  78215. };
  78216. accessors: {
  78217. [key: string]: IGLTFAccessor;
  78218. };
  78219. buffers: {
  78220. [key: string]: IGLTFBuffer;
  78221. };
  78222. bufferViews: {
  78223. [key: string]: IGLTFBufferView;
  78224. };
  78225. meshes: {
  78226. [key: string]: IGLTFMesh;
  78227. };
  78228. lights: {
  78229. [key: string]: IGLTFLight;
  78230. };
  78231. cameras: {
  78232. [key: string]: IGLTFCamera;
  78233. };
  78234. nodes: {
  78235. [key: string]: IGLTFNode;
  78236. };
  78237. images: {
  78238. [key: string]: IGLTFImage;
  78239. };
  78240. textures: {
  78241. [key: string]: IGLTFTexture;
  78242. };
  78243. shaders: {
  78244. [key: string]: IGLTFShader;
  78245. };
  78246. programs: {
  78247. [key: string]: IGLTFProgram;
  78248. };
  78249. samplers: {
  78250. [key: string]: IGLTFSampler;
  78251. };
  78252. techniques: {
  78253. [key: string]: IGLTFTechnique;
  78254. };
  78255. materials: {
  78256. [key: string]: IGLTFMaterial;
  78257. };
  78258. animations: {
  78259. [key: string]: IGLTFAnimation;
  78260. };
  78261. skins: {
  78262. [key: string]: IGLTFSkins;
  78263. };
  78264. currentScene?: Object;
  78265. scenes: {
  78266. [key: string]: IGLTFScene;
  78267. };
  78268. extensionsUsed: string[];
  78269. extensionsRequired?: string[];
  78270. buffersCount: number;
  78271. shaderscount: number;
  78272. scene: Scene;
  78273. rootUrl: string;
  78274. loadedBufferCount: number;
  78275. loadedBufferViews: {
  78276. [name: string]: ArrayBufferView;
  78277. };
  78278. loadedShaderCount: number;
  78279. importOnlyMeshes: boolean;
  78280. importMeshesNames?: string[];
  78281. dummyNodes: Node[];
  78282. forAssetContainer: boolean;
  78283. }
  78284. /** @hidden */
  78285. export interface INodeToRoot {
  78286. bone: Bone;
  78287. node: IGLTFNode;
  78288. id: string;
  78289. }
  78290. /** @hidden */
  78291. export interface IJointNode {
  78292. node: IGLTFNode;
  78293. id: string;
  78294. }
  78295. }
  78296. declare module BABYLON.GLTF1 {
  78297. /**
  78298. * Utils functions for GLTF
  78299. * @hidden
  78300. */
  78301. export class GLTFUtils {
  78302. /**
  78303. * Sets the given "parameter" matrix
  78304. * @param scene: the Scene object
  78305. * @param source: the source node where to pick the matrix
  78306. * @param parameter: the GLTF technique parameter
  78307. * @param uniformName: the name of the shader's uniform
  78308. * @param shaderMaterial: the shader material
  78309. */
  78310. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  78311. /**
  78312. * Sets the given "parameter" matrix
  78313. * @param shaderMaterial: the shader material
  78314. * @param uniform: the name of the shader's uniform
  78315. * @param value: the value of the uniform
  78316. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  78317. */
  78318. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  78319. /**
  78320. * Returns the wrap mode of the texture
  78321. * @param mode: the mode value
  78322. */
  78323. static GetWrapMode(mode: number): number;
  78324. /**
  78325. * Returns the byte stride giving an accessor
  78326. * @param accessor: the GLTF accessor objet
  78327. */
  78328. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  78329. /**
  78330. * Returns the texture filter mode giving a mode value
  78331. * @param mode: the filter mode value
  78332. */
  78333. static GetTextureFilterMode(mode: number): ETextureFilterType;
  78334. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  78335. /**
  78336. * Returns a buffer from its accessor
  78337. * @param gltfRuntime: the GLTF runtime
  78338. * @param accessor: the GLTF accessor
  78339. */
  78340. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  78341. /**
  78342. * Decodes a buffer view into a string
  78343. * @param view: the buffer view
  78344. */
  78345. static DecodeBufferToText(view: ArrayBufferView): string;
  78346. /**
  78347. * Returns the default material of gltf. Related to
  78348. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  78349. * @param scene: the Babylon.js scene
  78350. */
  78351. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  78352. private static _DefaultMaterial;
  78353. }
  78354. }
  78355. declare module BABYLON.GLTF1 {
  78356. /**
  78357. * Implementation of the base glTF spec
  78358. * @hidden
  78359. */
  78360. export class GLTFLoaderBase {
  78361. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  78362. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  78363. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  78364. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  78365. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  78366. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  78367. }
  78368. /**
  78369. * glTF V1 Loader
  78370. * @hidden
  78371. */
  78372. export class GLTFLoader implements IGLTFLoader {
  78373. static Extensions: {
  78374. [name: string]: GLTFLoaderExtension;
  78375. };
  78376. static RegisterExtension(extension: GLTFLoaderExtension): void;
  78377. state: Nullable<GLTFLoaderState>;
  78378. dispose(): void;
  78379. private _importMeshAsync;
  78380. /**
  78381. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  78382. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  78383. * @param scene the scene the meshes should be added to
  78384. * @param forAssetContainer defines if the entities must be stored in the scene
  78385. * @param data gltf data containing information of the meshes in a loaded file
  78386. * @param rootUrl root url to load from
  78387. * @param onProgress event that fires when loading progress has occured
  78388. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  78389. */
  78390. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  78391. private _loadAsync;
  78392. /**
  78393. * Imports all objects from a loaded gltf file and adds them to the scene
  78394. * @param scene the scene the objects should be added to
  78395. * @param data gltf data containing information of the meshes in a loaded file
  78396. * @param rootUrl root url to load from
  78397. * @param onProgress event that fires when loading progress has occured
  78398. * @returns a promise which completes when objects have been loaded to the scene
  78399. */
  78400. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  78401. private _loadShadersAsync;
  78402. private _loadBuffersAsync;
  78403. private _createNodes;
  78404. }
  78405. /** @hidden */
  78406. export abstract class GLTFLoaderExtension {
  78407. private _name;
  78408. constructor(name: string);
  78409. get name(): string;
  78410. /**
  78411. * Defines an override for loading the runtime
  78412. * Return true to stop further extensions from loading the runtime
  78413. */
  78414. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  78415. /**
  78416. * Defines an onverride for creating gltf runtime
  78417. * Return true to stop further extensions from creating the runtime
  78418. */
  78419. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  78420. /**
  78421. * Defines an override for loading buffers
  78422. * Return true to stop further extensions from loading this buffer
  78423. */
  78424. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  78425. /**
  78426. * Defines an override for loading texture buffers
  78427. * Return true to stop further extensions from loading this texture data
  78428. */
  78429. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  78430. /**
  78431. * Defines an override for creating textures
  78432. * Return true to stop further extensions from loading this texture
  78433. */
  78434. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  78435. /**
  78436. * Defines an override for loading shader strings
  78437. * Return true to stop further extensions from loading this shader data
  78438. */
  78439. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  78440. /**
  78441. * Defines an override for loading materials
  78442. * Return true to stop further extensions from loading this material
  78443. */
  78444. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  78445. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  78446. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  78447. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  78448. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  78449. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  78450. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  78451. private static LoadTextureBufferAsync;
  78452. private static CreateTextureAsync;
  78453. private static ApplyExtensions;
  78454. }
  78455. }
  78456. declare module BABYLON.GLTF1 {
  78457. /** @hidden */
  78458. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  78459. private _bin;
  78460. constructor();
  78461. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  78462. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  78463. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  78464. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  78465. }
  78466. }
  78467. declare module BABYLON.GLTF1 {
  78468. /** @hidden */
  78469. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  78470. constructor();
  78471. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  78472. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  78473. private _loadTexture;
  78474. }
  78475. }
  78476. declare module BABYLON.GLTF2.Loader {
  78477. /**
  78478. * Loader interface with an index field.
  78479. */
  78480. export interface IArrayItem {
  78481. /**
  78482. * The index of this item in the array.
  78483. */
  78484. index: number;
  78485. }
  78486. /**
  78487. * Loader interface with additional members.
  78488. */
  78489. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  78490. /** @hidden */
  78491. _data?: Promise<ArrayBufferView>;
  78492. /** @hidden */
  78493. _babylonVertexBuffer?: Promise<VertexBuffer>;
  78494. }
  78495. /**
  78496. * Loader interface with additional members.
  78497. */
  78498. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  78499. }
  78500. /** @hidden */
  78501. export interface _IAnimationSamplerData {
  78502. input: Float32Array;
  78503. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  78504. output: Float32Array;
  78505. }
  78506. /**
  78507. * Loader interface with additional members.
  78508. */
  78509. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  78510. /** @hidden */
  78511. _data?: Promise<_IAnimationSamplerData>;
  78512. }
  78513. /**
  78514. * Loader interface with additional members.
  78515. */
  78516. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  78517. channels: IAnimationChannel[];
  78518. samplers: IAnimationSampler[];
  78519. /** @hidden */
  78520. _babylonAnimationGroup?: AnimationGroup;
  78521. }
  78522. /**
  78523. * Loader interface with additional members.
  78524. */
  78525. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  78526. /** @hidden */
  78527. _data?: Promise<ArrayBufferView>;
  78528. }
  78529. /**
  78530. * Loader interface with additional members.
  78531. */
  78532. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  78533. /** @hidden */
  78534. _data?: Promise<ArrayBufferView>;
  78535. /** @hidden */
  78536. _babylonBuffer?: Promise<Buffer>;
  78537. }
  78538. /**
  78539. * Loader interface with additional members.
  78540. */
  78541. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  78542. }
  78543. /**
  78544. * Loader interface with additional members.
  78545. */
  78546. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  78547. /** @hidden */
  78548. _data?: Promise<ArrayBufferView>;
  78549. }
  78550. /**
  78551. * Loader interface with additional members.
  78552. */
  78553. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  78554. }
  78555. /**
  78556. * Loader interface with additional members.
  78557. */
  78558. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  78559. }
  78560. /**
  78561. * Loader interface with additional members.
  78562. */
  78563. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  78564. baseColorTexture?: ITextureInfo;
  78565. metallicRoughnessTexture?: ITextureInfo;
  78566. }
  78567. /**
  78568. * Loader interface with additional members.
  78569. */
  78570. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  78571. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  78572. normalTexture?: IMaterialNormalTextureInfo;
  78573. occlusionTexture?: IMaterialOcclusionTextureInfo;
  78574. emissiveTexture?: ITextureInfo;
  78575. /** @hidden */
  78576. _data?: {
  78577. [babylonDrawMode: number]: {
  78578. babylonMaterial: Material;
  78579. babylonMeshes: AbstractMesh[];
  78580. promise: Promise<void>;
  78581. };
  78582. };
  78583. }
  78584. /**
  78585. * Loader interface with additional members.
  78586. */
  78587. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  78588. primitives: IMeshPrimitive[];
  78589. }
  78590. /**
  78591. * Loader interface with additional members.
  78592. */
  78593. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  78594. /** @hidden */
  78595. _instanceData?: {
  78596. babylonSourceMesh: Mesh;
  78597. promise: Promise<any>;
  78598. };
  78599. }
  78600. /**
  78601. * Loader interface with additional members.
  78602. */
  78603. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  78604. /**
  78605. * The parent glTF node.
  78606. */
  78607. parent?: INode;
  78608. /** @hidden */
  78609. _babylonTransformNode?: TransformNode;
  78610. /** @hidden */
  78611. _primitiveBabylonMeshes?: AbstractMesh[];
  78612. /** @hidden */
  78613. _babylonBones?: Bone[];
  78614. /** @hidden */
  78615. _numMorphTargets?: number;
  78616. }
  78617. /** @hidden */
  78618. export interface _ISamplerData {
  78619. noMipMaps: boolean;
  78620. samplingMode: number;
  78621. wrapU: number;
  78622. wrapV: number;
  78623. }
  78624. /**
  78625. * Loader interface with additional members.
  78626. */
  78627. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  78628. /** @hidden */
  78629. _data?: _ISamplerData;
  78630. }
  78631. /**
  78632. * Loader interface with additional members.
  78633. */
  78634. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  78635. }
  78636. /**
  78637. * Loader interface with additional members.
  78638. */
  78639. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  78640. /** @hidden */
  78641. _data?: {
  78642. babylonSkeleton: Skeleton;
  78643. promise: Promise<void>;
  78644. };
  78645. }
  78646. /**
  78647. * Loader interface with additional members.
  78648. */
  78649. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  78650. }
  78651. /**
  78652. * Loader interface with additional members.
  78653. */
  78654. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  78655. }
  78656. /**
  78657. * Loader interface with additional members.
  78658. */
  78659. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  78660. accessors?: IAccessor[];
  78661. animations?: IAnimation[];
  78662. buffers?: IBuffer[];
  78663. bufferViews?: IBufferView[];
  78664. cameras?: ICamera[];
  78665. images?: IImage[];
  78666. materials?: IMaterial[];
  78667. meshes?: IMesh[];
  78668. nodes?: INode[];
  78669. samplers?: ISampler[];
  78670. scenes?: IScene[];
  78671. skins?: ISkin[];
  78672. textures?: ITexture[];
  78673. }
  78674. }
  78675. declare module BABYLON.GLTF2 {
  78676. /**
  78677. * Interface for a glTF loader extension.
  78678. */
  78679. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  78680. /**
  78681. * Called after the loader state changes to LOADING.
  78682. */
  78683. onLoading?(): void;
  78684. /**
  78685. * Called after the loader state changes to READY.
  78686. */
  78687. onReady?(): void;
  78688. /**
  78689. * Define this method to modify the default behavior when loading scenes.
  78690. * @param context The context when loading the asset
  78691. * @param scene The glTF scene property
  78692. * @returns A promise that resolves when the load is complete or null if not handled
  78693. */
  78694. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  78695. /**
  78696. * Define this method to modify the default behavior when loading nodes.
  78697. * @param context The context when loading the asset
  78698. * @param node The glTF node property
  78699. * @param assign A function called synchronously after parsing the glTF properties
  78700. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  78701. */
  78702. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  78703. /**
  78704. * Define this method to modify the default behavior when loading cameras.
  78705. * @param context The context when loading the asset
  78706. * @param camera The glTF camera property
  78707. * @param assign A function called synchronously after parsing the glTF properties
  78708. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  78709. */
  78710. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  78711. /**
  78712. * @hidden
  78713. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  78714. * @param context The context when loading the asset
  78715. * @param primitive The glTF mesh primitive property
  78716. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  78717. */
  78718. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  78719. /**
  78720. * @hidden
  78721. * Define this method to modify the default behavior when loading data for mesh primitives.
  78722. * @param context The context when loading the asset
  78723. * @param name The mesh name when loading the asset
  78724. * @param node The glTF node when loading the asset
  78725. * @param mesh The glTF mesh when loading the asset
  78726. * @param primitive The glTF mesh primitive property
  78727. * @param assign A function called synchronously after parsing the glTF properties
  78728. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  78729. */
  78730. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  78731. /**
  78732. * @hidden
  78733. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  78734. * @param context The context when loading the asset
  78735. * @param material The glTF material property
  78736. * @param assign A function called synchronously after parsing the glTF properties
  78737. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  78738. */
  78739. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  78740. /**
  78741. * Define this method to modify the default behavior when creating materials.
  78742. * @param context The context when loading the asset
  78743. * @param material The glTF material property
  78744. * @param babylonDrawMode The draw mode for the Babylon material
  78745. * @returns The Babylon material or null if not handled
  78746. */
  78747. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  78748. /**
  78749. * Define this method to modify the default behavior when loading material properties.
  78750. * @param context The context when loading the asset
  78751. * @param material The glTF material property
  78752. * @param babylonMaterial The Babylon material
  78753. * @returns A promise that resolves when the load is complete or null if not handled
  78754. */
  78755. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  78756. /**
  78757. * Define this method to modify the default behavior when loading texture infos.
  78758. * @param context The context when loading the asset
  78759. * @param textureInfo The glTF texture info property
  78760. * @param assign A function called synchronously after parsing the glTF properties
  78761. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  78762. */
  78763. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  78764. /**
  78765. * @hidden
  78766. * Define this method to modify the default behavior when loading textures.
  78767. * @param context The context when loading the asset
  78768. * @param texture The glTF texture property
  78769. * @param assign A function called synchronously after parsing the glTF properties
  78770. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  78771. */
  78772. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  78773. /**
  78774. * Define this method to modify the default behavior when loading animations.
  78775. * @param context The context when loading the asset
  78776. * @param animation The glTF animation property
  78777. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  78778. */
  78779. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  78780. /**
  78781. * @hidden
  78782. * Define this method to modify the default behavior when loading skins.
  78783. * @param context The context when loading the asset
  78784. * @param node The glTF node property
  78785. * @param skin The glTF skin property
  78786. * @returns A promise that resolves when the load is complete or null if not handled
  78787. */
  78788. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  78789. /**
  78790. * @hidden
  78791. * Define this method to modify the default behavior when loading uris.
  78792. * @param context The context when loading the asset
  78793. * @param property The glTF property associated with the uri
  78794. * @param uri The uri to load
  78795. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  78796. */
  78797. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  78798. /**
  78799. * Define this method to modify the default behavior when loading buffer views.
  78800. * @param context The context when loading the asset
  78801. * @param bufferView The glTF buffer view property
  78802. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  78803. */
  78804. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  78805. /**
  78806. * Define this method to modify the default behavior when loading buffers.
  78807. * @param context The context when loading the asset
  78808. * @param buffer The glTF buffer property
  78809. * @param byteOffset The byte offset to load
  78810. * @param byteLength The byte length to load
  78811. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  78812. */
  78813. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  78814. }
  78815. }
  78816. declare module BABYLON.GLTF2 {
  78817. /**
  78818. * Helper class for working with arrays when loading the glTF asset
  78819. */
  78820. export class ArrayItem {
  78821. /**
  78822. * Gets an item from the given array.
  78823. * @param context The context when loading the asset
  78824. * @param array The array to get the item from
  78825. * @param index The index to the array
  78826. * @returns The array item
  78827. */
  78828. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  78829. /**
  78830. * Assign an `index` field to each item of the given array.
  78831. * @param array The array of items
  78832. */
  78833. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  78834. }
  78835. /**
  78836. * The glTF 2.0 loader
  78837. */
  78838. export class GLTFLoader implements IGLTFLoader {
  78839. /** @hidden */
  78840. _completePromises: Promise<any>[];
  78841. /** @hidden */
  78842. _forAssetContainer: boolean;
  78843. /** Storage */
  78844. _babylonLights: Light[];
  78845. private _disposed;
  78846. private _parent;
  78847. private _state;
  78848. private _extensions;
  78849. private _rootUrl;
  78850. private _fileName;
  78851. private _uniqueRootUrl;
  78852. private _gltf;
  78853. private _bin;
  78854. private _babylonScene;
  78855. private _rootBabylonMesh;
  78856. private _defaultBabylonMaterialData;
  78857. private _progressCallback?;
  78858. private _requests;
  78859. private static _RegisteredExtensions;
  78860. /**
  78861. * The default glTF sampler.
  78862. */
  78863. static readonly DefaultSampler: ISampler;
  78864. /**
  78865. * Registers a loader extension.
  78866. * @param name The name of the loader extension.
  78867. * @param factory The factory function that creates the loader extension.
  78868. */
  78869. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  78870. /**
  78871. * Unregisters a loader extension.
  78872. * @param name The name of the loader extension.
  78873. * @returns A boolean indicating whether the extension has been unregistered
  78874. */
  78875. static UnregisterExtension(name: string): boolean;
  78876. /**
  78877. * The loader state.
  78878. */
  78879. get state(): Nullable<GLTFLoaderState>;
  78880. /**
  78881. * The object that represents the glTF JSON.
  78882. */
  78883. get gltf(): IGLTF;
  78884. /**
  78885. * The BIN chunk of a binary glTF.
  78886. */
  78887. get bin(): Nullable<IDataBuffer>;
  78888. /**
  78889. * The parent file loader.
  78890. */
  78891. get parent(): GLTFFileLoader;
  78892. /**
  78893. * The Babylon scene when loading the asset.
  78894. */
  78895. get babylonScene(): Scene;
  78896. /**
  78897. * The root Babylon mesh when loading the asset.
  78898. */
  78899. get rootBabylonMesh(): Mesh;
  78900. /** @hidden */
  78901. constructor(parent: GLTFFileLoader);
  78902. /** @hidden */
  78903. dispose(): void;
  78904. /** @hidden */
  78905. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  78906. /** @hidden */
  78907. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  78908. private _loadAsync;
  78909. private _loadData;
  78910. private _setupData;
  78911. private _loadExtensions;
  78912. private _checkExtensions;
  78913. private _setState;
  78914. private _createRootNode;
  78915. /**
  78916. * Loads a glTF scene.
  78917. * @param context The context when loading the asset
  78918. * @param scene The glTF scene property
  78919. * @returns A promise that resolves when the load is complete
  78920. */
  78921. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  78922. private _forEachPrimitive;
  78923. private _getMeshes;
  78924. private _getTransformNodes;
  78925. private _getSkeletons;
  78926. private _getAnimationGroups;
  78927. private _startAnimations;
  78928. /**
  78929. * Loads a glTF node.
  78930. * @param context The context when loading the asset
  78931. * @param node The glTF node property
  78932. * @param assign A function called synchronously after parsing the glTF properties
  78933. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  78934. */
  78935. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  78936. private _loadMeshAsync;
  78937. /**
  78938. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  78939. * @param context The context when loading the asset
  78940. * @param name The mesh name when loading the asset
  78941. * @param node The glTF node when loading the asset
  78942. * @param mesh The glTF mesh when loading the asset
  78943. * @param primitive The glTF mesh primitive property
  78944. * @param assign A function called synchronously after parsing the glTF properties
  78945. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  78946. */
  78947. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  78948. private _loadVertexDataAsync;
  78949. private _createMorphTargets;
  78950. private _loadMorphTargetsAsync;
  78951. private _loadMorphTargetVertexDataAsync;
  78952. private static _LoadTransform;
  78953. private _loadSkinAsync;
  78954. private _loadBones;
  78955. private _loadBone;
  78956. private _loadSkinInverseBindMatricesDataAsync;
  78957. private _updateBoneMatrices;
  78958. private _getNodeMatrix;
  78959. /**
  78960. * Loads a glTF camera.
  78961. * @param context The context when loading the asset
  78962. * @param camera The glTF camera property
  78963. * @param assign A function called synchronously after parsing the glTF properties
  78964. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  78965. */
  78966. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  78967. private _loadAnimationsAsync;
  78968. /**
  78969. * Loads a glTF animation.
  78970. * @param context The context when loading the asset
  78971. * @param animation The glTF animation property
  78972. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  78973. */
  78974. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  78975. /**
  78976. * @hidden Loads a glTF animation channel.
  78977. * @param context The context when loading the asset
  78978. * @param animationContext The context of the animation when loading the asset
  78979. * @param animation The glTF animation property
  78980. * @param channel The glTF animation channel property
  78981. * @param babylonAnimationGroup The babylon animation group property
  78982. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  78983. * @returns A void promise when the channel load is complete
  78984. */
  78985. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  78986. private _loadAnimationSamplerAsync;
  78987. private _loadBufferAsync;
  78988. /**
  78989. * Loads a glTF buffer view.
  78990. * @param context The context when loading the asset
  78991. * @param bufferView The glTF buffer view property
  78992. * @returns A promise that resolves with the loaded data when the load is complete
  78993. */
  78994. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  78995. private _loadAccessorAsync;
  78996. /** @hidden */
  78997. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  78998. private _loadIndicesAccessorAsync;
  78999. private _loadVertexBufferViewAsync;
  79000. private _loadVertexAccessorAsync;
  79001. private _loadMaterialMetallicRoughnessPropertiesAsync;
  79002. /** @hidden */
  79003. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  79004. private _createDefaultMaterial;
  79005. /**
  79006. * Creates a Babylon material from a glTF material.
  79007. * @param context The context when loading the asset
  79008. * @param material The glTF material property
  79009. * @param babylonDrawMode The draw mode for the Babylon material
  79010. * @returns The Babylon material
  79011. */
  79012. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  79013. /**
  79014. * Loads properties from a glTF material into a Babylon material.
  79015. * @param context The context when loading the asset
  79016. * @param material The glTF material property
  79017. * @param babylonMaterial The Babylon material
  79018. * @returns A promise that resolves when the load is complete
  79019. */
  79020. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  79021. /**
  79022. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  79023. * @param context The context when loading the asset
  79024. * @param material The glTF material property
  79025. * @param babylonMaterial The Babylon material
  79026. * @returns A promise that resolves when the load is complete
  79027. */
  79028. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  79029. /**
  79030. * Loads the alpha properties from a glTF material into a Babylon material.
  79031. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  79032. * @param context The context when loading the asset
  79033. * @param material The glTF material property
  79034. * @param babylonMaterial The Babylon material
  79035. */
  79036. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  79037. /**
  79038. * Loads a glTF texture info.
  79039. * @param context The context when loading the asset
  79040. * @param textureInfo The glTF texture info property
  79041. * @param assign A function called synchronously after parsing the glTF properties
  79042. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  79043. */
  79044. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  79045. /** @hidden */
  79046. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  79047. /** @hidden */
  79048. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  79049. private _loadSampler;
  79050. /**
  79051. * Loads a glTF image.
  79052. * @param context The context when loading the asset
  79053. * @param image The glTF image property
  79054. * @returns A promise that resolves with the loaded data when the load is complete
  79055. */
  79056. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  79057. /**
  79058. * Loads a glTF uri.
  79059. * @param context The context when loading the asset
  79060. * @param property The glTF property associated with the uri
  79061. * @param uri The base64 or relative uri
  79062. * @returns A promise that resolves with the loaded data when the load is complete
  79063. */
  79064. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  79065. private _onProgress;
  79066. /**
  79067. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  79068. * @param babylonObject the Babylon object with metadata
  79069. * @param pointer the JSON pointer
  79070. */
  79071. static AddPointerMetadata(babylonObject: {
  79072. metadata: any;
  79073. }, pointer: string): void;
  79074. private static _GetTextureWrapMode;
  79075. private static _GetTextureSamplingMode;
  79076. private static _GetTypedArrayConstructor;
  79077. private static _GetTypedArray;
  79078. private static _GetNumComponents;
  79079. private static _ValidateUri;
  79080. private static _GetDrawMode;
  79081. private _compileMaterialsAsync;
  79082. private _compileShadowGeneratorsAsync;
  79083. private _forEachExtensions;
  79084. private _applyExtensions;
  79085. private _extensionsOnLoading;
  79086. private _extensionsOnReady;
  79087. private _extensionsLoadSceneAsync;
  79088. private _extensionsLoadNodeAsync;
  79089. private _extensionsLoadCameraAsync;
  79090. private _extensionsLoadVertexDataAsync;
  79091. private _extensionsLoadMeshPrimitiveAsync;
  79092. private _extensionsLoadMaterialAsync;
  79093. private _extensionsCreateMaterial;
  79094. private _extensionsLoadMaterialPropertiesAsync;
  79095. private _extensionsLoadTextureInfoAsync;
  79096. private _extensionsLoadTextureAsync;
  79097. private _extensionsLoadAnimationAsync;
  79098. private _extensionsLoadSkinAsync;
  79099. private _extensionsLoadUriAsync;
  79100. private _extensionsLoadBufferViewAsync;
  79101. private _extensionsLoadBufferAsync;
  79102. /**
  79103. * Helper method called by a loader extension to load an glTF extension.
  79104. * @param context The context when loading the asset
  79105. * @param property The glTF property to load the extension from
  79106. * @param extensionName The name of the extension to load
  79107. * @param actionAsync The action to run
  79108. * @returns The promise returned by actionAsync or null if the extension does not exist
  79109. */
  79110. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  79111. /**
  79112. * Helper method called by a loader extension to load a glTF extra.
  79113. * @param context The context when loading the asset
  79114. * @param property The glTF property to load the extra from
  79115. * @param extensionName The name of the extension to load
  79116. * @param actionAsync The action to run
  79117. * @returns The promise returned by actionAsync or null if the extra does not exist
  79118. */
  79119. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  79120. /**
  79121. * Checks for presence of an extension.
  79122. * @param name The name of the extension to check
  79123. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  79124. */
  79125. isExtensionUsed(name: string): boolean;
  79126. /**
  79127. * Increments the indentation level and logs a message.
  79128. * @param message The message to log
  79129. */
  79130. logOpen(message: string): void;
  79131. /**
  79132. * Decrements the indentation level.
  79133. */
  79134. logClose(): void;
  79135. /**
  79136. * Logs a message
  79137. * @param message The message to log
  79138. */
  79139. log(message: string): void;
  79140. /**
  79141. * Starts a performance counter.
  79142. * @param counterName The name of the performance counter
  79143. */
  79144. startPerformanceCounter(counterName: string): void;
  79145. /**
  79146. * Ends a performance counter.
  79147. * @param counterName The name of the performance counter
  79148. */
  79149. endPerformanceCounter(counterName: string): void;
  79150. }
  79151. }
  79152. declare module BABYLON.GLTF2.Loader.Extensions {
  79153. /**
  79154. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  79155. */
  79156. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  79157. /**
  79158. * The name of this extension.
  79159. */
  79160. readonly name: string;
  79161. /**
  79162. * Defines whether this extension is enabled.
  79163. */
  79164. enabled: boolean;
  79165. private _loader;
  79166. private _lights?;
  79167. /** @hidden */
  79168. constructor(loader: GLTFLoader);
  79169. /** @hidden */
  79170. dispose(): void;
  79171. /** @hidden */
  79172. onLoading(): void;
  79173. /** @hidden */
  79174. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  79175. private _loadLightAsync;
  79176. }
  79177. }
  79178. declare module BABYLON.GLTF2.Loader.Extensions {
  79179. /**
  79180. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  79181. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  79182. * !!! Experimental Extension Subject to Changes !!!
  79183. */
  79184. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  79185. /**
  79186. * The name of this extension.
  79187. */
  79188. readonly name: string;
  79189. /**
  79190. * Defines whether this extension is enabled.
  79191. */
  79192. enabled: boolean;
  79193. private _loader;
  79194. /** @hidden */
  79195. constructor(loader: GLTFLoader);
  79196. /** @hidden */
  79197. dispose(): void;
  79198. /** @hidden */
  79199. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  79200. }
  79201. }
  79202. declare module BABYLON.GLTF2.Loader.Extensions {
  79203. /**
  79204. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  79205. */
  79206. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  79207. /**
  79208. * The name of this extension.
  79209. */
  79210. readonly name: string;
  79211. /**
  79212. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  79213. */
  79214. dracoCompression?: DracoCompression;
  79215. /**
  79216. * Defines whether this extension is enabled.
  79217. */
  79218. enabled: boolean;
  79219. private _loader;
  79220. /** @hidden */
  79221. constructor(loader: GLTFLoader);
  79222. /** @hidden */
  79223. dispose(): void;
  79224. /** @hidden */
  79225. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  79226. }
  79227. }
  79228. declare module BABYLON.GLTF2.Loader.Extensions {
  79229. /**
  79230. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  79231. */
  79232. export class KHR_lights implements IGLTFLoaderExtension {
  79233. /**
  79234. * The name of this extension.
  79235. */
  79236. readonly name: string;
  79237. /**
  79238. * Defines whether this extension is enabled.
  79239. */
  79240. enabled: boolean;
  79241. private _loader;
  79242. private _lights?;
  79243. /** @hidden */
  79244. constructor(loader: GLTFLoader);
  79245. /** @hidden */
  79246. dispose(): void;
  79247. /** @hidden */
  79248. onLoading(): void;
  79249. /** @hidden */
  79250. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  79251. }
  79252. }
  79253. declare module BABYLON.GLTF2.Loader.Extensions {
  79254. /**
  79255. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  79256. */
  79257. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  79258. /**
  79259. * The name of this extension.
  79260. */
  79261. readonly name: string;
  79262. /**
  79263. * Defines whether this extension is enabled.
  79264. */
  79265. enabled: boolean;
  79266. /**
  79267. * Defines a number that determines the order the extensions are applied.
  79268. */
  79269. order: number;
  79270. private _loader;
  79271. /** @hidden */
  79272. constructor(loader: GLTFLoader);
  79273. /** @hidden */
  79274. dispose(): void;
  79275. /** @hidden */
  79276. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79277. private _loadSpecularGlossinessPropertiesAsync;
  79278. }
  79279. }
  79280. declare module BABYLON.GLTF2.Loader.Extensions {
  79281. /**
  79282. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  79283. */
  79284. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  79285. /**
  79286. * The name of this extension.
  79287. */
  79288. readonly name: string;
  79289. /**
  79290. * Defines whether this extension is enabled.
  79291. */
  79292. enabled: boolean;
  79293. /**
  79294. * Defines a number that determines the order the extensions are applied.
  79295. */
  79296. order: number;
  79297. private _loader;
  79298. /** @hidden */
  79299. constructor(loader: GLTFLoader);
  79300. /** @hidden */
  79301. dispose(): void;
  79302. /** @hidden */
  79303. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79304. private _loadUnlitPropertiesAsync;
  79305. }
  79306. }
  79307. declare module BABYLON.GLTF2.Loader.Extensions {
  79308. /**
  79309. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  79310. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  79311. * !!! Experimental Extension Subject to Changes !!!
  79312. */
  79313. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  79314. /**
  79315. * The name of this extension.
  79316. */
  79317. readonly name: string;
  79318. /**
  79319. * Defines whether this extension is enabled.
  79320. */
  79321. enabled: boolean;
  79322. /**
  79323. * Defines a number that determines the order the extensions are applied.
  79324. */
  79325. order: number;
  79326. private _loader;
  79327. /** @hidden */
  79328. constructor(loader: GLTFLoader);
  79329. /** @hidden */
  79330. dispose(): void;
  79331. /** @hidden */
  79332. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79333. private _loadClearCoatPropertiesAsync;
  79334. }
  79335. }
  79336. declare module BABYLON.GLTF2.Loader.Extensions {
  79337. /**
  79338. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  79339. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  79340. * !!! Experimental Extension Subject to Changes !!!
  79341. */
  79342. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  79343. /**
  79344. * The name of this extension.
  79345. */
  79346. readonly name: string;
  79347. /**
  79348. * Defines whether this extension is enabled.
  79349. */
  79350. enabled: boolean;
  79351. /**
  79352. * Defines a number that determines the order the extensions are applied.
  79353. */
  79354. order: number;
  79355. private _loader;
  79356. /** @hidden */
  79357. constructor(loader: GLTFLoader);
  79358. /** @hidden */
  79359. dispose(): void;
  79360. /** @hidden */
  79361. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79362. private _loadSheenPropertiesAsync;
  79363. }
  79364. }
  79365. declare module BABYLON.GLTF2.Loader.Extensions {
  79366. /**
  79367. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  79368. * !!! Experimental Extension Subject to Changes !!!
  79369. */
  79370. export class KHR_materials_specular implements IGLTFLoaderExtension {
  79371. /**
  79372. * The name of this extension.
  79373. */
  79374. readonly name: string;
  79375. /**
  79376. * Defines whether this extension is enabled.
  79377. */
  79378. enabled: boolean;
  79379. /**
  79380. * Defines a number that determines the order the extensions are applied.
  79381. */
  79382. order: number;
  79383. private _loader;
  79384. /** @hidden */
  79385. constructor(loader: GLTFLoader);
  79386. /** @hidden */
  79387. dispose(): void;
  79388. /** @hidden */
  79389. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79390. private _loadSpecularPropertiesAsync;
  79391. }
  79392. }
  79393. declare module BABYLON.GLTF2.Loader.Extensions {
  79394. /**
  79395. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  79396. * !!! Experimental Extension Subject to Changes !!!
  79397. */
  79398. export class KHR_materials_ior implements IGLTFLoaderExtension {
  79399. /**
  79400. * Default ior Value from the spec.
  79401. */
  79402. private static readonly _DEFAULT_IOR;
  79403. /**
  79404. * The name of this extension.
  79405. */
  79406. readonly name: string;
  79407. /**
  79408. * Defines whether this extension is enabled.
  79409. */
  79410. enabled: boolean;
  79411. /**
  79412. * Defines a number that determines the order the extensions are applied.
  79413. */
  79414. order: number;
  79415. private _loader;
  79416. /** @hidden */
  79417. constructor(loader: GLTFLoader);
  79418. /** @hidden */
  79419. dispose(): void;
  79420. /** @hidden */
  79421. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79422. private _loadIorPropertiesAsync;
  79423. }
  79424. }
  79425. declare module BABYLON.GLTF2.Loader.Extensions {
  79426. /**
  79427. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  79428. */
  79429. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  79430. /**
  79431. * The name of this extension.
  79432. */
  79433. readonly name: string;
  79434. /**
  79435. * Defines whether this extension is enabled.
  79436. */
  79437. enabled: boolean;
  79438. /** @hidden */
  79439. constructor(loader: GLTFLoader);
  79440. /** @hidden */
  79441. dispose(): void;
  79442. }
  79443. }
  79444. declare module BABYLON.GLTF2.Loader.Extensions {
  79445. /**
  79446. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  79447. * !!! Experimental Extension Subject to Changes !!!
  79448. */
  79449. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  79450. /** The name of this extension. */
  79451. readonly name: string;
  79452. /** Defines whether this extension is enabled. */
  79453. enabled: boolean;
  79454. private _loader;
  79455. /** @hidden */
  79456. constructor(loader: GLTFLoader);
  79457. /** @hidden */
  79458. dispose(): void;
  79459. /** @hidden */
  79460. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  79461. }
  79462. }
  79463. declare module BABYLON.GLTF2.Loader.Extensions {
  79464. /**
  79465. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  79466. */
  79467. export class KHR_texture_transform implements IGLTFLoaderExtension {
  79468. /**
  79469. * The name of this extension.
  79470. */
  79471. readonly name: string;
  79472. /**
  79473. * Defines whether this extension is enabled.
  79474. */
  79475. enabled: boolean;
  79476. private _loader;
  79477. /** @hidden */
  79478. constructor(loader: GLTFLoader);
  79479. /** @hidden */
  79480. dispose(): void;
  79481. /** @hidden */
  79482. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  79483. }
  79484. }
  79485. declare module BABYLON.GLTF2.Loader.Extensions {
  79486. /**
  79487. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  79488. */
  79489. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  79490. /**
  79491. * The name of this extension.
  79492. */
  79493. readonly name: string;
  79494. /**
  79495. * Defines whether this extension is enabled.
  79496. */
  79497. enabled: boolean;
  79498. private _loader;
  79499. private _clips;
  79500. private _emitters;
  79501. /** @hidden */
  79502. constructor(loader: GLTFLoader);
  79503. /** @hidden */
  79504. dispose(): void;
  79505. /** @hidden */
  79506. onLoading(): void;
  79507. /** @hidden */
  79508. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  79509. /** @hidden */
  79510. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  79511. /** @hidden */
  79512. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  79513. private _loadClipAsync;
  79514. private _loadEmitterAsync;
  79515. private _getEventAction;
  79516. private _loadAnimationEventAsync;
  79517. }
  79518. }
  79519. declare module BABYLON.GLTF2.Loader.Extensions {
  79520. /**
  79521. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  79522. */
  79523. export class MSFT_lod implements IGLTFLoaderExtension {
  79524. /**
  79525. * The name of this extension.
  79526. */
  79527. readonly name: string;
  79528. /**
  79529. * Defines whether this extension is enabled.
  79530. */
  79531. enabled: boolean;
  79532. /**
  79533. * Defines a number that determines the order the extensions are applied.
  79534. */
  79535. order: number;
  79536. /**
  79537. * Maximum number of LODs to load, starting from the lowest LOD.
  79538. */
  79539. maxLODsToLoad: number;
  79540. /**
  79541. * Observable raised when all node LODs of one level are loaded.
  79542. * The event data is the index of the loaded LOD starting from zero.
  79543. * Dispose the loader to cancel the loading of the next level of LODs.
  79544. */
  79545. onNodeLODsLoadedObservable: Observable<number>;
  79546. /**
  79547. * Observable raised when all material LODs of one level are loaded.
  79548. * The event data is the index of the loaded LOD starting from zero.
  79549. * Dispose the loader to cancel the loading of the next level of LODs.
  79550. */
  79551. onMaterialLODsLoadedObservable: Observable<number>;
  79552. private _loader;
  79553. private _nodeIndexLOD;
  79554. private _nodeSignalLODs;
  79555. private _nodePromiseLODs;
  79556. private _materialIndexLOD;
  79557. private _materialSignalLODs;
  79558. private _materialPromiseLODs;
  79559. private _indexLOD;
  79560. private _bufferLODs;
  79561. /** @hidden */
  79562. constructor(loader: GLTFLoader);
  79563. /** @hidden */
  79564. dispose(): void;
  79565. /** @hidden */
  79566. onReady(): void;
  79567. /** @hidden */
  79568. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  79569. /** @hidden */
  79570. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  79571. /** @hidden */
  79572. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  79573. /** @hidden */
  79574. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  79575. /** @hidden */
  79576. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  79577. private _loadBufferLOD;
  79578. /**
  79579. * Gets an array of LOD properties from lowest to highest.
  79580. */
  79581. private _getLODs;
  79582. private _disposeTransformNode;
  79583. private _disposeMaterials;
  79584. }
  79585. }
  79586. declare module BABYLON.GLTF2.Loader.Extensions {
  79587. /** @hidden */
  79588. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  79589. readonly name: string;
  79590. enabled: boolean;
  79591. private _loader;
  79592. constructor(loader: GLTFLoader);
  79593. dispose(): void;
  79594. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79595. }
  79596. }
  79597. declare module BABYLON.GLTF2.Loader.Extensions {
  79598. /** @hidden */
  79599. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  79600. readonly name: string;
  79601. enabled: boolean;
  79602. private _loader;
  79603. constructor(loader: GLTFLoader);
  79604. dispose(): void;
  79605. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79606. }
  79607. }
  79608. declare module BABYLON.GLTF2.Loader.Extensions {
  79609. /**
  79610. * Store glTF extras (if present) in BJS objects' metadata
  79611. */
  79612. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  79613. /**
  79614. * The name of this extension.
  79615. */
  79616. readonly name: string;
  79617. /**
  79618. * Defines whether this extension is enabled.
  79619. */
  79620. enabled: boolean;
  79621. private _loader;
  79622. private _assignExtras;
  79623. /** @hidden */
  79624. constructor(loader: GLTFLoader);
  79625. /** @hidden */
  79626. dispose(): void;
  79627. /** @hidden */
  79628. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  79629. /** @hidden */
  79630. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  79631. /** @hidden */
  79632. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  79633. }
  79634. }
  79635. declare module BABYLON {
  79636. /**
  79637. * Class reading and parsing the MTL file bundled with the obj file.
  79638. */
  79639. export class MTLFileLoader {
  79640. /**
  79641. * Invert Y-Axis of referenced textures on load
  79642. */
  79643. static INVERT_TEXTURE_Y: boolean;
  79644. /**
  79645. * All material loaded from the mtl will be set here
  79646. */
  79647. materials: StandardMaterial[];
  79648. /**
  79649. * This function will read the mtl file and create each material described inside
  79650. * This function could be improve by adding :
  79651. * -some component missing (Ni, Tf...)
  79652. * -including the specific options available
  79653. *
  79654. * @param scene defines the scene the material will be created in
  79655. * @param data defines the mtl data to parse
  79656. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  79657. * @param forAssetContainer defines if the material should be registered in the scene
  79658. */
  79659. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  79660. /**
  79661. * Gets the texture for the material.
  79662. *
  79663. * If the material is imported from input file,
  79664. * We sanitize the url to ensure it takes the textre from aside the material.
  79665. *
  79666. * @param rootUrl The root url to load from
  79667. * @param value The value stored in the mtl
  79668. * @return The Texture
  79669. */
  79670. private static _getTexture;
  79671. }
  79672. }
  79673. declare module BABYLON {
  79674. /**
  79675. * Options for loading OBJ/MTL files
  79676. */
  79677. type MeshLoadOptions = {
  79678. /**
  79679. * Defines if UVs are optimized by default during load.
  79680. */
  79681. OptimizeWithUV: boolean;
  79682. /**
  79683. * Defines custom scaling of UV coordinates of loaded meshes.
  79684. */
  79685. UVScaling: Vector2;
  79686. /**
  79687. * Invert model on y-axis (does a model scaling inversion)
  79688. */
  79689. InvertY: boolean;
  79690. /**
  79691. * Invert Y-Axis of referenced textures on load
  79692. */
  79693. InvertTextureY: boolean;
  79694. /**
  79695. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  79696. */
  79697. ImportVertexColors: boolean;
  79698. /**
  79699. * Compute the normals for the model, even if normals are present in the file.
  79700. */
  79701. ComputeNormals: boolean;
  79702. /**
  79703. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  79704. */
  79705. SkipMaterials: boolean;
  79706. /**
  79707. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  79708. */
  79709. MaterialLoadingFailsSilently: boolean;
  79710. };
  79711. /**
  79712. * OBJ file type loader.
  79713. * This is a babylon scene loader plugin.
  79714. */
  79715. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  79716. /**
  79717. * Defines if UVs are optimized by default during load.
  79718. */
  79719. static OPTIMIZE_WITH_UV: boolean;
  79720. /**
  79721. * Invert model on y-axis (does a model scaling inversion)
  79722. */
  79723. static INVERT_Y: boolean;
  79724. /**
  79725. * Invert Y-Axis of referenced textures on load
  79726. */
  79727. static get INVERT_TEXTURE_Y(): boolean;
  79728. static set INVERT_TEXTURE_Y(value: boolean);
  79729. /**
  79730. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  79731. */
  79732. static IMPORT_VERTEX_COLORS: boolean;
  79733. /**
  79734. * Compute the normals for the model, even if normals are present in the file.
  79735. */
  79736. static COMPUTE_NORMALS: boolean;
  79737. /**
  79738. * Defines custom scaling of UV coordinates of loaded meshes.
  79739. */
  79740. static UV_SCALING: Vector2;
  79741. /**
  79742. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  79743. */
  79744. static SKIP_MATERIALS: boolean;
  79745. /**
  79746. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  79747. *
  79748. * Defaults to true for backwards compatibility.
  79749. */
  79750. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  79751. /**
  79752. * Defines the name of the plugin.
  79753. */
  79754. name: string;
  79755. /**
  79756. * Defines the extension the plugin is able to load.
  79757. */
  79758. extensions: string;
  79759. /** @hidden */
  79760. obj: RegExp;
  79761. /** @hidden */
  79762. group: RegExp;
  79763. /** @hidden */
  79764. mtllib: RegExp;
  79765. /** @hidden */
  79766. usemtl: RegExp;
  79767. /** @hidden */
  79768. smooth: RegExp;
  79769. /** @hidden */
  79770. vertexPattern: RegExp;
  79771. /** @hidden */
  79772. normalPattern: RegExp;
  79773. /** @hidden */
  79774. uvPattern: RegExp;
  79775. /** @hidden */
  79776. facePattern1: RegExp;
  79777. /** @hidden */
  79778. facePattern2: RegExp;
  79779. /** @hidden */
  79780. facePattern3: RegExp;
  79781. /** @hidden */
  79782. facePattern4: RegExp;
  79783. /** @hidden */
  79784. facePattern5: RegExp;
  79785. private _forAssetContainer;
  79786. private _meshLoadOptions;
  79787. /**
  79788. * Creates loader for .OBJ files
  79789. *
  79790. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  79791. */
  79792. constructor(meshLoadOptions?: MeshLoadOptions);
  79793. private static get currentMeshLoadOptions();
  79794. /**
  79795. * Calls synchronously the MTL file attached to this obj.
  79796. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  79797. * Without this function materials are not displayed in the first frame (but displayed after).
  79798. * In consequence it is impossible to get material information in your HTML file
  79799. *
  79800. * @param url The URL of the MTL file
  79801. * @param rootUrl
  79802. * @param onSuccess Callback function to be called when the MTL file is loaded
  79803. * @private
  79804. */
  79805. private _loadMTL;
  79806. /**
  79807. * Instantiates a OBJ file loader plugin.
  79808. * @returns the created plugin
  79809. */
  79810. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  79811. /**
  79812. * If the data string can be loaded directly.
  79813. *
  79814. * @param data string containing the file data
  79815. * @returns if the data can be loaded directly
  79816. */
  79817. canDirectLoad(data: string): boolean;
  79818. /**
  79819. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  79820. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  79821. * @param scene the scene the meshes should be added to
  79822. * @param data the OBJ data to load
  79823. * @param rootUrl root url to load from
  79824. * @param onProgress event that fires when loading progress has occured
  79825. * @param fileName Defines the name of the file to load
  79826. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  79827. */
  79828. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  79829. meshes: AbstractMesh[];
  79830. particleSystems: IParticleSystem[];
  79831. skeletons: Skeleton[];
  79832. animationGroups: AnimationGroup[];
  79833. }>;
  79834. /**
  79835. * Imports all objects from the loaded OBJ data and adds them to the scene
  79836. * @param scene the scene the objects should be added to
  79837. * @param data the OBJ data to load
  79838. * @param rootUrl root url to load from
  79839. * @param onProgress event that fires when loading progress has occured
  79840. * @param fileName Defines the name of the file to load
  79841. * @returns a promise which completes when objects have been loaded to the scene
  79842. */
  79843. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  79844. /**
  79845. * Load into an asset container.
  79846. * @param scene The scene to load into
  79847. * @param data The data to import
  79848. * @param rootUrl The root url for scene and resources
  79849. * @param onProgress The callback when the load progresses
  79850. * @param fileName Defines the name of the file to load
  79851. * @returns The loaded asset container
  79852. */
  79853. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  79854. /**
  79855. * Read the OBJ file and create an Array of meshes.
  79856. * Each mesh contains all information given by the OBJ and the MTL file.
  79857. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  79858. *
  79859. * @param meshesNames
  79860. * @param scene Scene The scene where are displayed the data
  79861. * @param data String The content of the obj file
  79862. * @param rootUrl String The path to the folder
  79863. * @returns Array<AbstractMesh>
  79864. * @private
  79865. */
  79866. private _parseSolid;
  79867. }
  79868. }
  79869. declare module BABYLON {
  79870. /**
  79871. * STL file type loader.
  79872. * This is a babylon scene loader plugin.
  79873. */
  79874. export class STLFileLoader implements ISceneLoaderPlugin {
  79875. /** @hidden */
  79876. solidPattern: RegExp;
  79877. /** @hidden */
  79878. facetsPattern: RegExp;
  79879. /** @hidden */
  79880. normalPattern: RegExp;
  79881. /** @hidden */
  79882. vertexPattern: RegExp;
  79883. /**
  79884. * Defines the name of the plugin.
  79885. */
  79886. name: string;
  79887. /**
  79888. * Defines the extensions the stl loader is able to load.
  79889. * force data to come in as an ArrayBuffer
  79890. * we'll convert to string if it looks like it's an ASCII .stl
  79891. */
  79892. extensions: ISceneLoaderPluginExtensions;
  79893. /**
  79894. * Import meshes into a scene.
  79895. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  79896. * @param scene The scene to import into
  79897. * @param data The data to import
  79898. * @param rootUrl The root url for scene and resources
  79899. * @param meshes The meshes array to import into
  79900. * @param particleSystems The particle systems array to import into
  79901. * @param skeletons The skeletons array to import into
  79902. * @param onError The callback when import fails
  79903. * @returns True if successful or false otherwise
  79904. */
  79905. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  79906. /**
  79907. * Load into a scene.
  79908. * @param scene The scene to load into
  79909. * @param data The data to import
  79910. * @param rootUrl The root url for scene and resources
  79911. * @param onError The callback when import fails
  79912. * @returns true if successful or false otherwise
  79913. */
  79914. load(scene: Scene, data: any, rootUrl: string): boolean;
  79915. /**
  79916. * Load into an asset container.
  79917. * @param scene The scene to load into
  79918. * @param data The data to import
  79919. * @param rootUrl The root url for scene and resources
  79920. * @param onError The callback when import fails
  79921. * @returns The loaded asset container
  79922. */
  79923. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  79924. private _isBinary;
  79925. private _parseBinary;
  79926. private _parseASCII;
  79927. }
  79928. }
  79929. declare module BABYLON {
  79930. /**
  79931. * Class for generating OBJ data from a Babylon scene.
  79932. */
  79933. export class OBJExport {
  79934. /**
  79935. * Exports the geometry of a Mesh array in .OBJ file format (text)
  79936. * @param mesh defines the list of meshes to serialize
  79937. * @param materials defines if materials should be exported
  79938. * @param matlibname defines the name of the associated mtl file
  79939. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  79940. * @returns the OBJ content
  79941. */
  79942. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  79943. /**
  79944. * Exports the material(s) of a mesh in .MTL file format (text)
  79945. * @param mesh defines the mesh to extract the material from
  79946. * @returns the mtl content
  79947. */
  79948. static MTL(mesh: Mesh): string;
  79949. }
  79950. }
  79951. declare module BABYLON {
  79952. /** @hidden */
  79953. export var __IGLTFExporterExtension: number;
  79954. /**
  79955. * Interface for extending the exporter
  79956. * @hidden
  79957. */
  79958. export interface IGLTFExporterExtension {
  79959. /**
  79960. * The name of this extension
  79961. */
  79962. readonly name: string;
  79963. /**
  79964. * Defines whether this extension is enabled
  79965. */
  79966. enabled: boolean;
  79967. /**
  79968. * Defines whether this extension is required
  79969. */
  79970. required: boolean;
  79971. }
  79972. }
  79973. declare module BABYLON.GLTF2.Exporter {
  79974. /** @hidden */
  79975. export var __IGLTFExporterExtensionV2: number;
  79976. /**
  79977. * Interface for a glTF exporter extension
  79978. * @hidden
  79979. */
  79980. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  79981. /**
  79982. * Define this method to modify the default behavior before exporting a texture
  79983. * @param context The context when loading the asset
  79984. * @param babylonTexture The Babylon.js texture
  79985. * @param mimeType The mime-type of the generated image
  79986. * @returns A promise that resolves with the exported texture
  79987. */
  79988. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  79989. /**
  79990. * Define this method to get notified when a texture info is created
  79991. * @param context The context when loading the asset
  79992. * @param textureInfo The glTF texture info
  79993. * @param babylonTexture The Babylon.js texture
  79994. */
  79995. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  79996. /**
  79997. * Define this method to modify the default behavior when exporting texture info
  79998. * @param context The context when loading the asset
  79999. * @param meshPrimitive glTF mesh primitive
  80000. * @param babylonSubMesh Babylon submesh
  80001. * @param binaryWriter glTF serializer binary writer instance
  80002. * @returns nullable IMeshPrimitive promise
  80003. */
  80004. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  80005. /**
  80006. * Define this method to modify the default behavior when exporting a node
  80007. * @param context The context when exporting the node
  80008. * @param node glTF node
  80009. * @param babylonNode BabylonJS node
  80010. * @returns nullable INode promise
  80011. */
  80012. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  80013. [key: number]: number;
  80014. }): Promise<Nullable<INode>>;
  80015. /**
  80016. * Define this method to modify the default behavior when exporting a material
  80017. * @param material glTF material
  80018. * @param babylonMaterial BabylonJS material
  80019. * @returns nullable IMaterial promise
  80020. */
  80021. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  80022. /**
  80023. * Define this method to return additional textures to export from a material
  80024. * @param material glTF material
  80025. * @param babylonMaterial BabylonJS material
  80026. * @returns List of textures
  80027. */
  80028. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  80029. /** Gets a boolean indicating that this extension was used */
  80030. wasUsed: boolean;
  80031. /** Gets a boolean indicating that this extension is required for the file to work */
  80032. required: boolean;
  80033. /**
  80034. * Called after the exporter state changes to EXPORTING
  80035. */
  80036. onExporting?(): void;
  80037. }
  80038. }
  80039. declare module BABYLON.GLTF2.Exporter {
  80040. /**
  80041. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  80042. * @hidden
  80043. */
  80044. export class _GLTFMaterialExporter {
  80045. /**
  80046. * Represents the dielectric specular values for R, G and B
  80047. */
  80048. private static readonly _DielectricSpecular;
  80049. /**
  80050. * Allows the maximum specular power to be defined for material calculations
  80051. */
  80052. private static readonly _MaxSpecularPower;
  80053. /**
  80054. * Mapping to store textures
  80055. */
  80056. private _textureMap;
  80057. /**
  80058. * Numeric tolerance value
  80059. */
  80060. private static readonly _Epsilon;
  80061. /**
  80062. * Reference to the glTF Exporter
  80063. */
  80064. private _exporter;
  80065. constructor(exporter: _Exporter);
  80066. /**
  80067. * Specifies if two colors are approximately equal in value
  80068. * @param color1 first color to compare to
  80069. * @param color2 second color to compare to
  80070. * @param epsilon threshold value
  80071. */
  80072. private static FuzzyEquals;
  80073. /**
  80074. * Gets the materials from a Babylon scene and converts them to glTF materials
  80075. * @param scene babylonjs scene
  80076. * @param mimeType texture mime type
  80077. * @param images array of images
  80078. * @param textures array of textures
  80079. * @param materials array of materials
  80080. * @param imageData mapping of texture names to base64 textures
  80081. * @param hasTextureCoords specifies if texture coordinates are present on the material
  80082. */
  80083. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  80084. /**
  80085. * Makes a copy of the glTF material without the texture parameters
  80086. * @param originalMaterial original glTF material
  80087. * @returns glTF material without texture parameters
  80088. */
  80089. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  80090. /**
  80091. * Specifies if the material has any texture parameters present
  80092. * @param material glTF Material
  80093. * @returns boolean specifying if texture parameters are present
  80094. */
  80095. _hasTexturesPresent(material: IMaterial): boolean;
  80096. /**
  80097. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  80098. * @param babylonStandardMaterial
  80099. * @returns glTF Metallic Roughness Material representation
  80100. */
  80101. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  80102. /**
  80103. * Computes the metallic factor
  80104. * @param diffuse diffused value
  80105. * @param specular specular value
  80106. * @param oneMinusSpecularStrength one minus the specular strength
  80107. * @returns metallic value
  80108. */
  80109. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  80110. /**
  80111. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  80112. * @param glTFMaterial glTF material
  80113. * @param babylonMaterial Babylon material
  80114. */
  80115. private static _SetAlphaMode;
  80116. /**
  80117. * Converts a Babylon Standard Material to a glTF Material
  80118. * @param babylonStandardMaterial BJS Standard Material
  80119. * @param mimeType mime type to use for the textures
  80120. * @param images array of glTF image interfaces
  80121. * @param textures array of glTF texture interfaces
  80122. * @param materials array of glTF material interfaces
  80123. * @param imageData map of image file name to data
  80124. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  80125. */
  80126. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  80127. private _finishMaterial;
  80128. /**
  80129. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  80130. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  80131. * @param mimeType mime type to use for the textures
  80132. * @param images array of glTF image interfaces
  80133. * @param textures array of glTF texture interfaces
  80134. * @param materials array of glTF material interfaces
  80135. * @param imageData map of image file name to data
  80136. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  80137. */
  80138. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  80139. /**
  80140. * Converts an image typed array buffer to a base64 image
  80141. * @param buffer typed array buffer
  80142. * @param width width of the image
  80143. * @param height height of the image
  80144. * @param mimeType mimetype of the image
  80145. * @returns base64 image string
  80146. */
  80147. private _createBase64FromCanvasAsync;
  80148. /**
  80149. * Generates a white texture based on the specified width and height
  80150. * @param width width of the texture in pixels
  80151. * @param height height of the texture in pixels
  80152. * @param scene babylonjs scene
  80153. * @returns white texture
  80154. */
  80155. private _createWhiteTexture;
  80156. /**
  80157. * 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
  80158. * @param texture1 first texture to resize
  80159. * @param texture2 second texture to resize
  80160. * @param scene babylonjs scene
  80161. * @returns resized textures or null
  80162. */
  80163. private _resizeTexturesToSameDimensions;
  80164. /**
  80165. * Converts an array of pixels to a Float32Array
  80166. * Throws an error if the pixel format is not supported
  80167. * @param pixels - array buffer containing pixel values
  80168. * @returns Float32 of pixels
  80169. */
  80170. private _convertPixelArrayToFloat32;
  80171. /**
  80172. * Convert Specular Glossiness Textures to Metallic Roughness
  80173. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  80174. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  80175. * @param diffuseTexture texture used to store diffuse information
  80176. * @param specularGlossinessTexture texture used to store specular and glossiness information
  80177. * @param factors specular glossiness material factors
  80178. * @param mimeType the mime type to use for the texture
  80179. * @returns pbr metallic roughness interface or null
  80180. */
  80181. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  80182. /**
  80183. * Converts specular glossiness material properties to metallic roughness
  80184. * @param specularGlossiness interface with specular glossiness material properties
  80185. * @returns interface with metallic roughness material properties
  80186. */
  80187. private _convertSpecularGlossinessToMetallicRoughness;
  80188. /**
  80189. * Calculates the surface reflectance, independent of lighting conditions
  80190. * @param color Color source to calculate brightness from
  80191. * @returns number representing the perceived brightness, or zero if color is undefined
  80192. */
  80193. private _getPerceivedBrightness;
  80194. /**
  80195. * Returns the maximum color component value
  80196. * @param color
  80197. * @returns maximum color component value, or zero if color is null or undefined
  80198. */
  80199. private _getMaxComponent;
  80200. /**
  80201. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  80202. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  80203. * @param mimeType mime type to use for the textures
  80204. * @param images array of glTF image interfaces
  80205. * @param textures array of glTF texture interfaces
  80206. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  80207. * @param imageData map of image file name to data
  80208. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  80209. * @returns glTF PBR Metallic Roughness factors
  80210. */
  80211. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  80212. private _getGLTFTextureSampler;
  80213. private _getGLTFTextureWrapMode;
  80214. private _getGLTFTextureWrapModesSampler;
  80215. /**
  80216. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  80217. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  80218. * @param mimeType mime type to use for the textures
  80219. * @param images array of glTF image interfaces
  80220. * @param textures array of glTF texture interfaces
  80221. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  80222. * @param imageData map of image file name to data
  80223. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  80224. * @returns glTF PBR Metallic Roughness factors
  80225. */
  80226. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  80227. /**
  80228. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  80229. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  80230. * @param mimeType mime type to use for the textures
  80231. * @param images array of glTF image interfaces
  80232. * @param textures array of glTF texture interfaces
  80233. * @param materials array of glTF material interfaces
  80234. * @param imageData map of image file name to data
  80235. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  80236. */
  80237. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  80238. private setMetallicRoughnessPbrMaterial;
  80239. private getPixelsFromTexture;
  80240. /**
  80241. * Extracts a texture from a Babylon texture into file data and glTF data
  80242. * @param babylonTexture Babylon texture to extract
  80243. * @param mimeType Mime Type of the babylonTexture
  80244. * @return glTF texture info, or null if the texture format is not supported
  80245. */
  80246. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  80247. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  80248. /**
  80249. * Builds a texture from base64 string
  80250. * @param base64Texture base64 texture string
  80251. * @param baseTextureName Name to use for the texture
  80252. * @param mimeType image mime type for the texture
  80253. * @param images array of images
  80254. * @param textures array of textures
  80255. * @param imageData map of image data
  80256. * @returns glTF texture info, or null if the texture format is not supported
  80257. */
  80258. private _getTextureInfoFromBase64;
  80259. }
  80260. }
  80261. declare module BABYLON {
  80262. /**
  80263. * Class for holding and downloading glTF file data
  80264. */
  80265. export class GLTFData {
  80266. /**
  80267. * Object which contains the file name as the key and its data as the value
  80268. */
  80269. glTFFiles: {
  80270. [fileName: string]: string | Blob;
  80271. };
  80272. /**
  80273. * Initializes the glTF file object
  80274. */
  80275. constructor();
  80276. /**
  80277. * Downloads the glTF data as files based on their names and data
  80278. */
  80279. downloadFiles(): void;
  80280. }
  80281. }
  80282. declare module BABYLON {
  80283. /**
  80284. * Holds a collection of exporter options and parameters
  80285. */
  80286. export interface IExportOptions {
  80287. /**
  80288. * Function which indicates whether a babylon node should be exported or not
  80289. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  80290. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  80291. */
  80292. shouldExportNode?(node: Node): boolean;
  80293. /**
  80294. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  80295. * @param metadata source metadata to read from
  80296. * @returns the data to store to glTF node extras
  80297. */
  80298. metadataSelector?(metadata: any): any;
  80299. /**
  80300. * The sample rate to bake animation curves
  80301. */
  80302. animationSampleRate?: number;
  80303. /**
  80304. * Begin serialization without waiting for the scene to be ready
  80305. */
  80306. exportWithoutWaitingForScene?: boolean;
  80307. /**
  80308. * Indicates if coordinate system swapping root nodes should be included in export
  80309. */
  80310. includeCoordinateSystemConversionNodes?: boolean;
  80311. }
  80312. /**
  80313. * Class for generating glTF data from a Babylon scene.
  80314. */
  80315. export class GLTF2Export {
  80316. /**
  80317. * Exports the geometry of the scene to .gltf file format asynchronously
  80318. * @param scene Babylon scene with scene hierarchy information
  80319. * @param filePrefix File prefix to use when generating the glTF file
  80320. * @param options Exporter options
  80321. * @returns Returns an object with a .gltf file and associates texture names
  80322. * as keys and their data and paths as values
  80323. */
  80324. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  80325. private static _PreExportAsync;
  80326. private static _PostExportAsync;
  80327. /**
  80328. * Exports the geometry of the scene to .glb file format asychronously
  80329. * @param scene Babylon scene with scene hierarchy information
  80330. * @param filePrefix File prefix to use when generating glb file
  80331. * @param options Exporter options
  80332. * @returns Returns an object with a .glb filename as key and data as value
  80333. */
  80334. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  80335. }
  80336. }
  80337. declare module BABYLON.GLTF2.Exporter {
  80338. /**
  80339. * @hidden
  80340. */
  80341. export class _GLTFUtilities {
  80342. /**
  80343. * Creates a buffer view based on the supplied arguments
  80344. * @param bufferIndex index value of the specified buffer
  80345. * @param byteOffset byte offset value
  80346. * @param byteLength byte length of the bufferView
  80347. * @param byteStride byte distance between conequential elements
  80348. * @param name name of the buffer view
  80349. * @returns bufferView for glTF
  80350. */
  80351. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  80352. /**
  80353. * Creates an accessor based on the supplied arguments
  80354. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  80355. * @param name The name of the accessor
  80356. * @param type The type of the accessor
  80357. * @param componentType The datatype of components in the attribute
  80358. * @param count The number of attributes referenced by this accessor
  80359. * @param byteOffset The offset relative to the start of the bufferView in bytes
  80360. * @param min Minimum value of each component in this attribute
  80361. * @param max Maximum value of each component in this attribute
  80362. * @returns accessor for glTF
  80363. */
  80364. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  80365. /**
  80366. * Calculates the minimum and maximum values of an array of position floats
  80367. * @param positions Positions array of a mesh
  80368. * @param vertexStart Starting vertex offset to calculate min and max values
  80369. * @param vertexCount Number of vertices to check for min and max values
  80370. * @returns min number array and max number array
  80371. */
  80372. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  80373. min: number[];
  80374. max: number[];
  80375. };
  80376. /**
  80377. * Converts a new right-handed Vector3
  80378. * @param vector vector3 array
  80379. * @returns right-handed Vector3
  80380. */
  80381. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  80382. /**
  80383. * Converts a Vector3 to right-handed
  80384. * @param vector Vector3 to convert to right-handed
  80385. */
  80386. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  80387. /**
  80388. * Converts a three element number array to right-handed
  80389. * @param vector number array to convert to right-handed
  80390. */
  80391. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  80392. /**
  80393. * Converts a new right-handed Vector3
  80394. * @param vector vector3 array
  80395. * @returns right-handed Vector3
  80396. */
  80397. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  80398. /**
  80399. * Converts a Vector3 to right-handed
  80400. * @param vector Vector3 to convert to right-handed
  80401. */
  80402. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  80403. /**
  80404. * Converts a three element number array to right-handed
  80405. * @param vector number array to convert to right-handed
  80406. */
  80407. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  80408. /**
  80409. * Converts a Vector4 to right-handed
  80410. * @param vector Vector4 to convert to right-handed
  80411. */
  80412. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  80413. /**
  80414. * Converts a Vector4 to right-handed
  80415. * @param vector Vector4 to convert to right-handed
  80416. */
  80417. static _GetRightHandedArray4FromRef(vector: number[]): void;
  80418. /**
  80419. * Converts a Quaternion to right-handed
  80420. * @param quaternion Source quaternion to convert to right-handed
  80421. */
  80422. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  80423. /**
  80424. * Converts a Quaternion to right-handed
  80425. * @param quaternion Source quaternion to convert to right-handed
  80426. */
  80427. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  80428. static _NormalizeTangentFromRef(tangent: Vector4): void;
  80429. }
  80430. }
  80431. declare module BABYLON.GLTF2.Exporter {
  80432. /**
  80433. * Converts Babylon Scene into glTF 2.0.
  80434. * @hidden
  80435. */
  80436. export class _Exporter {
  80437. /**
  80438. * Stores the glTF to export
  80439. */
  80440. _glTF: IGLTF;
  80441. /**
  80442. * Stores all generated buffer views, which represents views into the main glTF buffer data
  80443. */
  80444. _bufferViews: IBufferView[];
  80445. /**
  80446. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  80447. */
  80448. _accessors: IAccessor[];
  80449. /**
  80450. * Stores all the generated nodes, which contains transform and/or mesh information per node
  80451. */
  80452. _nodes: INode[];
  80453. /**
  80454. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  80455. */
  80456. private _scenes;
  80457. /**
  80458. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  80459. */
  80460. private _meshes;
  80461. /**
  80462. * Stores all the generated material information, which represents the appearance of each primitive
  80463. */
  80464. _materials: IMaterial[];
  80465. _materialMap: {
  80466. [materialID: number]: number;
  80467. };
  80468. /**
  80469. * Stores all the generated texture information, which is referenced by glTF materials
  80470. */
  80471. _textures: ITexture[];
  80472. /**
  80473. * Stores all the generated image information, which is referenced by glTF textures
  80474. */
  80475. _images: IImage[];
  80476. /**
  80477. * Stores all the texture samplers
  80478. */
  80479. _samplers: ISampler[];
  80480. /**
  80481. * Stores all the generated animation samplers, which is referenced by glTF animations
  80482. */
  80483. /**
  80484. * Stores the animations for glTF models
  80485. */
  80486. private _animations;
  80487. /**
  80488. * Stores the total amount of bytes stored in the glTF buffer
  80489. */
  80490. private _totalByteLength;
  80491. /**
  80492. * Stores a reference to the Babylon scene containing the source geometry and material information
  80493. */
  80494. _babylonScene: Scene;
  80495. /**
  80496. * Stores a map of the image data, where the key is the file name and the value
  80497. * is the image data
  80498. */
  80499. _imageData: {
  80500. [fileName: string]: {
  80501. data: Uint8Array;
  80502. mimeType: ImageMimeType;
  80503. };
  80504. };
  80505. /**
  80506. * Stores a map of the unique id of a node to its index in the node array
  80507. */
  80508. _nodeMap: {
  80509. [key: number]: number;
  80510. };
  80511. /**
  80512. * Specifies if the source Babylon scene was left handed, and needed conversion.
  80513. */
  80514. _convertToRightHandedSystem: boolean;
  80515. /**
  80516. * Specifies if a Babylon node should be converted to right-handed on export
  80517. */
  80518. _convertToRightHandedSystemMap: {
  80519. [nodeId: number]: boolean;
  80520. };
  80521. _includeCoordinateSystemConversionNodes: boolean;
  80522. /**
  80523. * Baked animation sample rate
  80524. */
  80525. private _animationSampleRate;
  80526. private _options;
  80527. private _localEngine;
  80528. _glTFMaterialExporter: _GLTFMaterialExporter;
  80529. private _extensions;
  80530. private static _ExtensionNames;
  80531. private static _ExtensionFactories;
  80532. private _applyExtension;
  80533. private _applyExtensions;
  80534. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  80535. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  80536. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  80537. [key: number]: number;
  80538. }): Promise<Nullable<INode>>;
  80539. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  80540. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  80541. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  80542. private _forEachExtensions;
  80543. private _extensionsOnExporting;
  80544. /**
  80545. * Load glTF serializer extensions
  80546. */
  80547. private _loadExtensions;
  80548. /**
  80549. * Creates a glTF Exporter instance, which can accept optional exporter options
  80550. * @param babylonScene Babylon scene object
  80551. * @param options Options to modify the behavior of the exporter
  80552. */
  80553. constructor(babylonScene: Scene, options?: IExportOptions);
  80554. dispose(): void;
  80555. /**
  80556. * Registers a glTF exporter extension
  80557. * @param name Name of the extension to export
  80558. * @param factory The factory function that creates the exporter extension
  80559. */
  80560. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  80561. /**
  80562. * Un-registers an exporter extension
  80563. * @param name The name fo the exporter extension
  80564. * @returns A boolean indicating whether the extension has been un-registered
  80565. */
  80566. static UnregisterExtension(name: string): boolean;
  80567. /**
  80568. * Lazy load a local engine
  80569. */
  80570. _getLocalEngine(): Engine;
  80571. private reorderIndicesBasedOnPrimitiveMode;
  80572. /**
  80573. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  80574. * clock-wise during export to glTF
  80575. * @param submesh BabylonJS submesh
  80576. * @param primitiveMode Primitive mode of the mesh
  80577. * @param sideOrientation the winding order of the submesh
  80578. * @param vertexBufferKind The type of vertex attribute
  80579. * @param meshAttributeArray The vertex attribute data
  80580. * @param byteOffset The offset to the binary data
  80581. * @param binaryWriter The binary data for the glTF file
  80582. * @param convertToRightHandedSystem Converts the values to right-handed
  80583. */
  80584. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  80585. /**
  80586. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  80587. * clock-wise during export to glTF
  80588. * @param submesh BabylonJS submesh
  80589. * @param primitiveMode Primitive mode of the mesh
  80590. * @param sideOrientation the winding order of the submesh
  80591. * @param vertexBufferKind The type of vertex attribute
  80592. * @param meshAttributeArray The vertex attribute data
  80593. * @param byteOffset The offset to the binary data
  80594. * @param binaryWriter The binary data for the glTF file
  80595. * @param convertToRightHandedSystem Converts the values to right-handed
  80596. */
  80597. private reorderTriangleFillMode;
  80598. /**
  80599. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  80600. * clock-wise during export to glTF
  80601. * @param submesh BabylonJS submesh
  80602. * @param primitiveMode Primitive mode of the mesh
  80603. * @param sideOrientation the winding order of the submesh
  80604. * @param vertexBufferKind The type of vertex attribute
  80605. * @param meshAttributeArray The vertex attribute data
  80606. * @param byteOffset The offset to the binary data
  80607. * @param binaryWriter The binary data for the glTF file
  80608. * @param convertToRightHandedSystem Converts the values to right-handed
  80609. */
  80610. private reorderTriangleStripDrawMode;
  80611. /**
  80612. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  80613. * clock-wise during export to glTF
  80614. * @param submesh BabylonJS submesh
  80615. * @param primitiveMode Primitive mode of the mesh
  80616. * @param sideOrientation the winding order of the submesh
  80617. * @param vertexBufferKind The type of vertex attribute
  80618. * @param meshAttributeArray The vertex attribute data
  80619. * @param byteOffset The offset to the binary data
  80620. * @param binaryWriter The binary data for the glTF file
  80621. * @param convertToRightHandedSystem Converts the values to right-handed
  80622. */
  80623. private reorderTriangleFanMode;
  80624. /**
  80625. * Writes the vertex attribute data to binary
  80626. * @param vertices The vertices to write to the binary writer
  80627. * @param byteOffset The offset into the binary writer to overwrite binary data
  80628. * @param vertexAttributeKind The vertex attribute type
  80629. * @param meshAttributeArray The vertex attribute data
  80630. * @param binaryWriter The writer containing the binary data
  80631. * @param convertToRightHandedSystem Converts the values to right-handed
  80632. */
  80633. private writeVertexAttributeData;
  80634. /**
  80635. * Writes mesh attribute data to a data buffer
  80636. * Returns the bytelength of the data
  80637. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  80638. * @param meshAttributeArray Array containing the attribute data
  80639. * @param binaryWriter The buffer to write the binary data to
  80640. * @param indices Used to specify the order of the vertex data
  80641. * @param convertToRightHandedSystem Converts the values to right-handed
  80642. */
  80643. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean): void;
  80644. /**
  80645. * Generates glTF json data
  80646. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  80647. * @param glTFPrefix Text to use when prefixing a glTF file
  80648. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  80649. * @returns json data as string
  80650. */
  80651. private generateJSON;
  80652. /**
  80653. * Generates data for .gltf and .bin files based on the glTF prefix string
  80654. * @param glTFPrefix Text to use when prefixing a glTF file
  80655. * @param dispose Dispose the exporter
  80656. * @returns GLTFData with glTF file data
  80657. */
  80658. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  80659. /**
  80660. * Creates a binary buffer for glTF
  80661. * @returns array buffer for binary data
  80662. */
  80663. private _generateBinaryAsync;
  80664. /**
  80665. * Pads the number to a multiple of 4
  80666. * @param num number to pad
  80667. * @returns padded number
  80668. */
  80669. private _getPadding;
  80670. /**
  80671. * @hidden
  80672. */
  80673. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  80674. /**
  80675. * Sets the TRS for each node
  80676. * @param node glTF Node for storing the transformation data
  80677. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  80678. * @param convertToRightHandedSystem Converts the values to right-handed
  80679. */
  80680. private setNodeTransformation;
  80681. private getVertexBufferFromMesh;
  80682. /**
  80683. * Creates a bufferview based on the vertices type for the Babylon mesh
  80684. * @param kind Indicates the type of vertices data
  80685. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  80686. * @param binaryWriter The buffer to write the bufferview data to
  80687. * @param convertToRightHandedSystem Converts the values to right-handed
  80688. */
  80689. private createBufferViewKind;
  80690. /**
  80691. * The primitive mode of the Babylon mesh
  80692. * @param babylonMesh The BabylonJS mesh
  80693. */
  80694. private getMeshPrimitiveMode;
  80695. /**
  80696. * Sets the primitive mode of the glTF mesh primitive
  80697. * @param meshPrimitive glTF mesh primitive
  80698. * @param primitiveMode The primitive mode
  80699. */
  80700. private setPrimitiveMode;
  80701. /**
  80702. * Sets the vertex attribute accessor based of the glTF mesh primitive
  80703. * @param meshPrimitive glTF mesh primitive
  80704. * @param attributeKind vertex attribute
  80705. * @returns boolean specifying if uv coordinates are present
  80706. */
  80707. private setAttributeKind;
  80708. /**
  80709. * Sets data for the primitive attributes of each submesh
  80710. * @param mesh glTF Mesh object to store the primitive attribute information
  80711. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  80712. * @param binaryWriter Buffer to write the attribute data to
  80713. * @param convertToRightHandedSystem Converts the values to right-handed
  80714. */
  80715. private setPrimitiveAttributesAsync;
  80716. /**
  80717. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  80718. * @param node The node to check
  80719. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  80720. */
  80721. private isBabylonCoordinateSystemConvertingNode;
  80722. /**
  80723. * Creates a glTF scene based on the array of meshes
  80724. * Returns the the total byte offset
  80725. * @param babylonScene Babylon scene to get the mesh data from
  80726. * @param binaryWriter Buffer to write binary data to
  80727. */
  80728. private createSceneAsync;
  80729. /**
  80730. * Creates a mapping of Node unique id to node index and handles animations
  80731. * @param babylonScene Babylon Scene
  80732. * @param nodes Babylon transform nodes
  80733. * @param binaryWriter Buffer to write binary data to
  80734. * @returns Node mapping of unique id to index
  80735. */
  80736. private createNodeMapAndAnimationsAsync;
  80737. /**
  80738. * Creates a glTF node from a Babylon mesh
  80739. * @param babylonMesh Source Babylon mesh
  80740. * @param binaryWriter Buffer for storing geometry data
  80741. * @param convertToRightHandedSystem Converts the values to right-handed
  80742. * @param nodeMap Node mapping of unique id to glTF node index
  80743. * @returns glTF node
  80744. */
  80745. private createNodeAsync;
  80746. }
  80747. /**
  80748. * @hidden
  80749. *
  80750. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  80751. */
  80752. export class _BinaryWriter {
  80753. /**
  80754. * Array buffer which stores all binary data
  80755. */
  80756. private _arrayBuffer;
  80757. /**
  80758. * View of the array buffer
  80759. */
  80760. private _dataView;
  80761. /**
  80762. * byte offset of data in array buffer
  80763. */
  80764. private _byteOffset;
  80765. /**
  80766. * Initialize binary writer with an initial byte length
  80767. * @param byteLength Initial byte length of the array buffer
  80768. */
  80769. constructor(byteLength: number);
  80770. /**
  80771. * Resize the array buffer to the specified byte length
  80772. * @param byteLength
  80773. */
  80774. private resizeBuffer;
  80775. /**
  80776. * Get an array buffer with the length of the byte offset
  80777. * @returns ArrayBuffer resized to the byte offset
  80778. */
  80779. getArrayBuffer(): ArrayBuffer;
  80780. /**
  80781. * Get the byte offset of the array buffer
  80782. * @returns byte offset
  80783. */
  80784. getByteOffset(): number;
  80785. /**
  80786. * Stores an UInt8 in the array buffer
  80787. * @param entry
  80788. * @param byteOffset If defined, specifies where to set the value as an offset.
  80789. */
  80790. setUInt8(entry: number, byteOffset?: number): void;
  80791. /**
  80792. * Gets an UInt32 in the array buffer
  80793. * @param entry
  80794. * @param byteOffset If defined, specifies where to set the value as an offset.
  80795. */
  80796. getUInt32(byteOffset: number): number;
  80797. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  80798. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  80799. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  80800. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  80801. /**
  80802. * Stores a Float32 in the array buffer
  80803. * @param entry
  80804. */
  80805. setFloat32(entry: number, byteOffset?: number): void;
  80806. /**
  80807. * Stores an UInt32 in the array buffer
  80808. * @param entry
  80809. * @param byteOffset If defined, specifies where to set the value as an offset.
  80810. */
  80811. setUInt32(entry: number, byteOffset?: number): void;
  80812. }
  80813. }
  80814. declare module BABYLON.GLTF2.Exporter {
  80815. /**
  80816. * @hidden
  80817. * Interface to store animation data.
  80818. */
  80819. export interface _IAnimationData {
  80820. /**
  80821. * Keyframe data.
  80822. */
  80823. inputs: number[];
  80824. /**
  80825. * Value data.
  80826. */
  80827. outputs: number[][];
  80828. /**
  80829. * Animation interpolation data.
  80830. */
  80831. samplerInterpolation: AnimationSamplerInterpolation;
  80832. /**
  80833. * Minimum keyframe value.
  80834. */
  80835. inputsMin: number;
  80836. /**
  80837. * Maximum keyframe value.
  80838. */
  80839. inputsMax: number;
  80840. }
  80841. /**
  80842. * @hidden
  80843. */
  80844. export interface _IAnimationInfo {
  80845. /**
  80846. * The target channel for the animation
  80847. */
  80848. animationChannelTargetPath: AnimationChannelTargetPath;
  80849. /**
  80850. * The glTF accessor type for the data.
  80851. */
  80852. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  80853. /**
  80854. * Specifies if quaternions should be used.
  80855. */
  80856. useQuaternion: boolean;
  80857. }
  80858. /**
  80859. * @hidden
  80860. * Utility class for generating glTF animation data from BabylonJS.
  80861. */
  80862. export class _GLTFAnimation {
  80863. /**
  80864. * @ignore
  80865. *
  80866. * Creates glTF channel animation from BabylonJS animation.
  80867. * @param babylonTransformNode - BabylonJS mesh.
  80868. * @param animation - animation.
  80869. * @param animationChannelTargetPath - The target animation channel.
  80870. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  80871. * @param useQuaternion - Specifies if quaternions are used.
  80872. * @returns nullable IAnimationData
  80873. */
  80874. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  80875. private static _DeduceAnimationInfo;
  80876. /**
  80877. * @ignore
  80878. * Create node animations from the transform node animations
  80879. * @param babylonNode
  80880. * @param runtimeGLTFAnimation
  80881. * @param idleGLTFAnimations
  80882. * @param nodeMap
  80883. * @param nodes
  80884. * @param binaryWriter
  80885. * @param bufferViews
  80886. * @param accessors
  80887. * @param convertToRightHandedSystem
  80888. * @param animationSampleRate
  80889. */
  80890. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  80891. [key: number]: number;
  80892. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  80893. /**
  80894. * @ignore
  80895. * Create node animations from the animation groups
  80896. * @param babylonScene
  80897. * @param glTFAnimations
  80898. * @param nodeMap
  80899. * @param nodes
  80900. * @param binaryWriter
  80901. * @param bufferViews
  80902. * @param accessors
  80903. * @param convertToRightHandedSystemMap
  80904. * @param animationSampleRate
  80905. */
  80906. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  80907. [key: number]: number;
  80908. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  80909. [nodeId: number]: boolean;
  80910. }, animationSampleRate: number): void;
  80911. private static AddAnimation;
  80912. /**
  80913. * Create a baked animation
  80914. * @param babylonTransformNode BabylonJS mesh
  80915. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  80916. * @param animationChannelTargetPath animation target channel
  80917. * @param minFrame minimum animation frame
  80918. * @param maxFrame maximum animation frame
  80919. * @param fps frames per second of the animation
  80920. * @param inputs input key frames of the animation
  80921. * @param outputs output key frame data of the animation
  80922. * @param convertToRightHandedSystem converts the values to right-handed
  80923. * @param useQuaternion specifies if quaternions should be used
  80924. */
  80925. private static _CreateBakedAnimation;
  80926. private static _ConvertFactorToVector3OrQuaternion;
  80927. private static _SetInterpolatedValue;
  80928. /**
  80929. * Creates linear animation from the animation key frames
  80930. * @param babylonTransformNode BabylonJS mesh
  80931. * @param animation BabylonJS animation
  80932. * @param animationChannelTargetPath The target animation channel
  80933. * @param frameDelta The difference between the last and first frame of the animation
  80934. * @param inputs Array to store the key frame times
  80935. * @param outputs Array to store the key frame data
  80936. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  80937. * @param useQuaternion Specifies if quaternions are used in the animation
  80938. */
  80939. private static _CreateLinearOrStepAnimation;
  80940. /**
  80941. * Creates cubic spline animation from the animation key frames
  80942. * @param babylonTransformNode BabylonJS mesh
  80943. * @param animation BabylonJS animation
  80944. * @param animationChannelTargetPath The target animation channel
  80945. * @param frameDelta The difference between the last and first frame of the animation
  80946. * @param inputs Array to store the key frame times
  80947. * @param outputs Array to store the key frame data
  80948. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  80949. * @param useQuaternion Specifies if quaternions are used in the animation
  80950. */
  80951. private static _CreateCubicSplineAnimation;
  80952. private static _GetBasePositionRotationOrScale;
  80953. /**
  80954. * Adds a key frame value
  80955. * @param keyFrame
  80956. * @param animation
  80957. * @param outputs
  80958. * @param animationChannelTargetPath
  80959. * @param basePositionRotationOrScale
  80960. * @param convertToRightHandedSystem
  80961. * @param useQuaternion
  80962. */
  80963. private static _AddKeyframeValue;
  80964. /**
  80965. * Determine the interpolation based on the key frames
  80966. * @param keyFrames
  80967. * @param animationChannelTargetPath
  80968. * @param useQuaternion
  80969. */
  80970. private static _DeduceInterpolation;
  80971. /**
  80972. * Adds an input tangent or output tangent to the output data
  80973. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  80974. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  80975. * @param outputs The animation data by keyframe
  80976. * @param animationChannelTargetPath The target animation channel
  80977. * @param interpolation The interpolation type
  80978. * @param keyFrame The key frame with the animation data
  80979. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  80980. * @param useQuaternion Specifies if quaternions are used
  80981. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  80982. */
  80983. private static AddSplineTangent;
  80984. /**
  80985. * Get the minimum and maximum key frames' frame values
  80986. * @param keyFrames animation key frames
  80987. * @returns the minimum and maximum key frame value
  80988. */
  80989. private static calculateMinMaxKeyFrames;
  80990. }
  80991. }
  80992. declare module BABYLON.GLTF2.Exporter {
  80993. /** @hidden */
  80994. export var textureTransformPixelShader: {
  80995. name: string;
  80996. shader: string;
  80997. };
  80998. }
  80999. declare module BABYLON.GLTF2.Exporter.Extensions {
  81000. /**
  81001. * @hidden
  81002. */
  81003. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  81004. private _recordedTextures;
  81005. /** Name of this extension */
  81006. readonly name: string;
  81007. /** Defines whether this extension is enabled */
  81008. enabled: boolean;
  81009. /** Defines whether this extension is required */
  81010. required: boolean;
  81011. /** Reference to the glTF exporter */
  81012. private _wasUsed;
  81013. constructor(exporter: _Exporter);
  81014. dispose(): void;
  81015. /** @hidden */
  81016. get wasUsed(): boolean;
  81017. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  81018. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  81019. /**
  81020. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  81021. * @param babylonTexture
  81022. * @param offset
  81023. * @param rotation
  81024. * @param scale
  81025. * @param scene
  81026. */
  81027. private _textureTransformTextureAsync;
  81028. }
  81029. }
  81030. declare module BABYLON.GLTF2.Exporter.Extensions {
  81031. /**
  81032. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  81033. */
  81034. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  81035. /** The name of this extension. */
  81036. readonly name: string;
  81037. /** Defines whether this extension is enabled. */
  81038. enabled: boolean;
  81039. /** Defines whether this extension is required */
  81040. required: boolean;
  81041. /** Reference to the glTF exporter */
  81042. private _exporter;
  81043. private _lights;
  81044. /** @hidden */
  81045. constructor(exporter: _Exporter);
  81046. /** @hidden */
  81047. dispose(): void;
  81048. /** @hidden */
  81049. get wasUsed(): boolean;
  81050. /** @hidden */
  81051. onExporting(): void;
  81052. /**
  81053. * Define this method to modify the default behavior when exporting a node
  81054. * @param context The context when exporting the node
  81055. * @param node glTF node
  81056. * @param babylonNode BabylonJS node
  81057. * @param nodeMap Node mapping of unique id to glTF node index
  81058. * @returns nullable INode promise
  81059. */
  81060. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  81061. [key: number]: number;
  81062. }): Promise<Nullable<INode>>;
  81063. }
  81064. }
  81065. declare module BABYLON.GLTF2.Exporter.Extensions {
  81066. /**
  81067. * @hidden
  81068. */
  81069. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  81070. /** Name of this extension */
  81071. readonly name: string;
  81072. /** Defines whether this extension is enabled */
  81073. enabled: boolean;
  81074. /** Defines whether this extension is required */
  81075. required: boolean;
  81076. /** Reference to the glTF exporter */
  81077. private _textureInfos;
  81078. private _exportedTextures;
  81079. private _wasUsed;
  81080. constructor(exporter: _Exporter);
  81081. dispose(): void;
  81082. /** @hidden */
  81083. get wasUsed(): boolean;
  81084. private _getTextureIndex;
  81085. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  81086. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  81087. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  81088. }
  81089. }
  81090. declare module BABYLON {
  81091. /**
  81092. * Class for generating STL data from a Babylon scene.
  81093. */
  81094. export class STLExport {
  81095. /**
  81096. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  81097. * @param meshes list defines the mesh to serialize
  81098. * @param download triggers the automatic download of the file.
  81099. * @param fileName changes the downloads fileName.
  81100. * @param binary changes the STL to a binary type.
  81101. * @param isLittleEndian toggle for binary type exporter.
  81102. * @returns the STL as UTF8 string
  81103. */
  81104. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  81105. }
  81106. }
  81107. declare module "babylonjs-gltf2interface" {
  81108. export = BABYLON.GLTF2;
  81109. }
  81110. /**
  81111. * Module for glTF 2.0 Interface
  81112. */
  81113. declare module BABYLON.GLTF2 {
  81114. /**
  81115. * The datatype of the components in the attribute
  81116. */
  81117. const enum AccessorComponentType {
  81118. /**
  81119. * Byte
  81120. */
  81121. BYTE = 5120,
  81122. /**
  81123. * Unsigned Byte
  81124. */
  81125. UNSIGNED_BYTE = 5121,
  81126. /**
  81127. * Short
  81128. */
  81129. SHORT = 5122,
  81130. /**
  81131. * Unsigned Short
  81132. */
  81133. UNSIGNED_SHORT = 5123,
  81134. /**
  81135. * Unsigned Int
  81136. */
  81137. UNSIGNED_INT = 5125,
  81138. /**
  81139. * Float
  81140. */
  81141. FLOAT = 5126,
  81142. }
  81143. /**
  81144. * Specifies if the attirbute is a scalar, vector, or matrix
  81145. */
  81146. const enum AccessorType {
  81147. /**
  81148. * Scalar
  81149. */
  81150. SCALAR = "SCALAR",
  81151. /**
  81152. * Vector2
  81153. */
  81154. VEC2 = "VEC2",
  81155. /**
  81156. * Vector3
  81157. */
  81158. VEC3 = "VEC3",
  81159. /**
  81160. * Vector4
  81161. */
  81162. VEC4 = "VEC4",
  81163. /**
  81164. * Matrix2x2
  81165. */
  81166. MAT2 = "MAT2",
  81167. /**
  81168. * Matrix3x3
  81169. */
  81170. MAT3 = "MAT3",
  81171. /**
  81172. * Matrix4x4
  81173. */
  81174. MAT4 = "MAT4",
  81175. }
  81176. /**
  81177. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  81178. */
  81179. const enum AnimationChannelTargetPath {
  81180. /**
  81181. * Translation
  81182. */
  81183. TRANSLATION = "translation",
  81184. /**
  81185. * Rotation
  81186. */
  81187. ROTATION = "rotation",
  81188. /**
  81189. * Scale
  81190. */
  81191. SCALE = "scale",
  81192. /**
  81193. * Weights
  81194. */
  81195. WEIGHTS = "weights",
  81196. }
  81197. /**
  81198. * Interpolation algorithm
  81199. */
  81200. const enum AnimationSamplerInterpolation {
  81201. /**
  81202. * The animated values are linearly interpolated between keyframes
  81203. */
  81204. LINEAR = "LINEAR",
  81205. /**
  81206. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  81207. */
  81208. STEP = "STEP",
  81209. /**
  81210. * The animation's interpolation is computed using a cubic spline with specified tangents
  81211. */
  81212. CUBICSPLINE = "CUBICSPLINE",
  81213. }
  81214. /**
  81215. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  81216. */
  81217. const enum CameraType {
  81218. /**
  81219. * A perspective camera containing properties to create a perspective projection matrix
  81220. */
  81221. PERSPECTIVE = "perspective",
  81222. /**
  81223. * An orthographic camera containing properties to create an orthographic projection matrix
  81224. */
  81225. ORTHOGRAPHIC = "orthographic",
  81226. }
  81227. /**
  81228. * The mime-type of the image
  81229. */
  81230. const enum ImageMimeType {
  81231. /**
  81232. * JPEG Mime-type
  81233. */
  81234. JPEG = "image/jpeg",
  81235. /**
  81236. * PNG Mime-type
  81237. */
  81238. PNG = "image/png",
  81239. }
  81240. /**
  81241. * The alpha rendering mode of the material
  81242. */
  81243. const enum MaterialAlphaMode {
  81244. /**
  81245. * The alpha value is ignored and the rendered output is fully opaque
  81246. */
  81247. OPAQUE = "OPAQUE",
  81248. /**
  81249. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  81250. */
  81251. MASK = "MASK",
  81252. /**
  81253. * 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)
  81254. */
  81255. BLEND = "BLEND",
  81256. }
  81257. /**
  81258. * The type of the primitives to render
  81259. */
  81260. const enum MeshPrimitiveMode {
  81261. /**
  81262. * Points
  81263. */
  81264. POINTS = 0,
  81265. /**
  81266. * Lines
  81267. */
  81268. LINES = 1,
  81269. /**
  81270. * Line Loop
  81271. */
  81272. LINE_LOOP = 2,
  81273. /**
  81274. * Line Strip
  81275. */
  81276. LINE_STRIP = 3,
  81277. /**
  81278. * Triangles
  81279. */
  81280. TRIANGLES = 4,
  81281. /**
  81282. * Triangle Strip
  81283. */
  81284. TRIANGLE_STRIP = 5,
  81285. /**
  81286. * Triangle Fan
  81287. */
  81288. TRIANGLE_FAN = 6,
  81289. }
  81290. /**
  81291. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  81292. */
  81293. const enum TextureMagFilter {
  81294. /**
  81295. * Nearest
  81296. */
  81297. NEAREST = 9728,
  81298. /**
  81299. * Linear
  81300. */
  81301. LINEAR = 9729,
  81302. }
  81303. /**
  81304. * Minification filter. All valid values correspond to WebGL enums
  81305. */
  81306. const enum TextureMinFilter {
  81307. /**
  81308. * Nearest
  81309. */
  81310. NEAREST = 9728,
  81311. /**
  81312. * Linear
  81313. */
  81314. LINEAR = 9729,
  81315. /**
  81316. * Nearest Mip-Map Nearest
  81317. */
  81318. NEAREST_MIPMAP_NEAREST = 9984,
  81319. /**
  81320. * Linear Mipmap Nearest
  81321. */
  81322. LINEAR_MIPMAP_NEAREST = 9985,
  81323. /**
  81324. * Nearest Mipmap Linear
  81325. */
  81326. NEAREST_MIPMAP_LINEAR = 9986,
  81327. /**
  81328. * Linear Mipmap Linear
  81329. */
  81330. LINEAR_MIPMAP_LINEAR = 9987,
  81331. }
  81332. /**
  81333. * S (U) wrapping mode. All valid values correspond to WebGL enums
  81334. */
  81335. const enum TextureWrapMode {
  81336. /**
  81337. * Clamp to Edge
  81338. */
  81339. CLAMP_TO_EDGE = 33071,
  81340. /**
  81341. * Mirrored Repeat
  81342. */
  81343. MIRRORED_REPEAT = 33648,
  81344. /**
  81345. * Repeat
  81346. */
  81347. REPEAT = 10497,
  81348. }
  81349. /**
  81350. * glTF Property
  81351. */
  81352. interface IProperty {
  81353. /**
  81354. * Dictionary object with extension-specific objects
  81355. */
  81356. extensions?: {
  81357. [key: string]: any;
  81358. };
  81359. /**
  81360. * Application-Specific data
  81361. */
  81362. extras?: any;
  81363. }
  81364. /**
  81365. * glTF Child of Root Property
  81366. */
  81367. interface IChildRootProperty extends IProperty {
  81368. /**
  81369. * The user-defined name of this object
  81370. */
  81371. name?: string;
  81372. }
  81373. /**
  81374. * Indices of those attributes that deviate from their initialization value
  81375. */
  81376. interface IAccessorSparseIndices extends IProperty {
  81377. /**
  81378. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  81379. */
  81380. bufferView: number;
  81381. /**
  81382. * The offset relative to the start of the bufferView in bytes. Must be aligned
  81383. */
  81384. byteOffset?: number;
  81385. /**
  81386. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  81387. */
  81388. componentType: AccessorComponentType;
  81389. }
  81390. /**
  81391. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  81392. */
  81393. interface IAccessorSparseValues extends IProperty {
  81394. /**
  81395. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  81396. */
  81397. bufferView: number;
  81398. /**
  81399. * The offset relative to the start of the bufferView in bytes. Must be aligned
  81400. */
  81401. byteOffset?: number;
  81402. }
  81403. /**
  81404. * Sparse storage of attributes that deviate from their initialization value
  81405. */
  81406. interface IAccessorSparse extends IProperty {
  81407. /**
  81408. * The number of attributes encoded in this sparse accessor
  81409. */
  81410. count: number;
  81411. /**
  81412. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  81413. */
  81414. indices: IAccessorSparseIndices;
  81415. /**
  81416. * 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
  81417. */
  81418. values: IAccessorSparseValues;
  81419. }
  81420. /**
  81421. * 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
  81422. */
  81423. interface IAccessor extends IChildRootProperty {
  81424. /**
  81425. * The index of the bufferview
  81426. */
  81427. bufferView?: number;
  81428. /**
  81429. * The offset relative to the start of the bufferView in bytes
  81430. */
  81431. byteOffset?: number;
  81432. /**
  81433. * The datatype of components in the attribute
  81434. */
  81435. componentType: AccessorComponentType;
  81436. /**
  81437. * Specifies whether integer data values should be normalized
  81438. */
  81439. normalized?: boolean;
  81440. /**
  81441. * The number of attributes referenced by this accessor
  81442. */
  81443. count: number;
  81444. /**
  81445. * Specifies if the attribute is a scalar, vector, or matrix
  81446. */
  81447. type: AccessorType;
  81448. /**
  81449. * Maximum value of each component in this attribute
  81450. */
  81451. max?: number[];
  81452. /**
  81453. * Minimum value of each component in this attribute
  81454. */
  81455. min?: number[];
  81456. /**
  81457. * Sparse storage of attributes that deviate from their initialization value
  81458. */
  81459. sparse?: IAccessorSparse;
  81460. }
  81461. /**
  81462. * Targets an animation's sampler at a node's property
  81463. */
  81464. interface IAnimationChannel extends IProperty {
  81465. /**
  81466. * The index of a sampler in this animation used to compute the value for the target
  81467. */
  81468. sampler: number;
  81469. /**
  81470. * The index of the node and TRS property to target
  81471. */
  81472. target: IAnimationChannelTarget;
  81473. }
  81474. /**
  81475. * The index of the node and TRS property that an animation channel targets
  81476. */
  81477. interface IAnimationChannelTarget extends IProperty {
  81478. /**
  81479. * The index of the node to target
  81480. */
  81481. node: number;
  81482. /**
  81483. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  81484. */
  81485. path: AnimationChannelTargetPath;
  81486. }
  81487. /**
  81488. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  81489. */
  81490. interface IAnimationSampler extends IProperty {
  81491. /**
  81492. * The index of an accessor containing keyframe input values, e.g., time
  81493. */
  81494. input: number;
  81495. /**
  81496. * Interpolation algorithm
  81497. */
  81498. interpolation?: AnimationSamplerInterpolation;
  81499. /**
  81500. * The index of an accessor, containing keyframe output values
  81501. */
  81502. output: number;
  81503. }
  81504. /**
  81505. * A keyframe animation
  81506. */
  81507. interface IAnimation extends IChildRootProperty {
  81508. /**
  81509. * An array of channels, each of which targets an animation's sampler at a node's property
  81510. */
  81511. channels: IAnimationChannel[];
  81512. /**
  81513. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  81514. */
  81515. samplers: IAnimationSampler[];
  81516. }
  81517. /**
  81518. * Metadata about the glTF asset
  81519. */
  81520. interface IAsset extends IChildRootProperty {
  81521. /**
  81522. * A copyright message suitable for display to credit the content creator
  81523. */
  81524. copyright?: string;
  81525. /**
  81526. * Tool that generated this glTF model. Useful for debugging
  81527. */
  81528. generator?: string;
  81529. /**
  81530. * The glTF version that this asset targets
  81531. */
  81532. version: string;
  81533. /**
  81534. * The minimum glTF version that this asset targets
  81535. */
  81536. minVersion?: string;
  81537. }
  81538. /**
  81539. * A buffer points to binary geometry, animation, or skins
  81540. */
  81541. interface IBuffer extends IChildRootProperty {
  81542. /**
  81543. * 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
  81544. */
  81545. uri?: string;
  81546. /**
  81547. * The length of the buffer in bytes
  81548. */
  81549. byteLength: number;
  81550. }
  81551. /**
  81552. * A view into a buffer generally representing a subset of the buffer
  81553. */
  81554. interface IBufferView extends IChildRootProperty {
  81555. /**
  81556. * The index of the buffer
  81557. */
  81558. buffer: number;
  81559. /**
  81560. * The offset into the buffer in bytes
  81561. */
  81562. byteOffset?: number;
  81563. /**
  81564. * The lenth of the bufferView in bytes
  81565. */
  81566. byteLength: number;
  81567. /**
  81568. * The stride, in bytes
  81569. */
  81570. byteStride?: number;
  81571. }
  81572. /**
  81573. * An orthographic camera containing properties to create an orthographic projection matrix
  81574. */
  81575. interface ICameraOrthographic extends IProperty {
  81576. /**
  81577. * The floating-point horizontal magnification of the view. Must not be zero
  81578. */
  81579. xmag: number;
  81580. /**
  81581. * The floating-point vertical magnification of the view. Must not be zero
  81582. */
  81583. ymag: number;
  81584. /**
  81585. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  81586. */
  81587. zfar: number;
  81588. /**
  81589. * The floating-point distance to the near clipping plane
  81590. */
  81591. znear: number;
  81592. }
  81593. /**
  81594. * A perspective camera containing properties to create a perspective projection matrix
  81595. */
  81596. interface ICameraPerspective extends IProperty {
  81597. /**
  81598. * The floating-point aspect ratio of the field of view
  81599. */
  81600. aspectRatio?: number;
  81601. /**
  81602. * The floating-point vertical field of view in radians
  81603. */
  81604. yfov: number;
  81605. /**
  81606. * The floating-point distance to the far clipping plane
  81607. */
  81608. zfar?: number;
  81609. /**
  81610. * The floating-point distance to the near clipping plane
  81611. */
  81612. znear: number;
  81613. }
  81614. /**
  81615. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  81616. */
  81617. interface ICamera extends IChildRootProperty {
  81618. /**
  81619. * An orthographic camera containing properties to create an orthographic projection matrix
  81620. */
  81621. orthographic?: ICameraOrthographic;
  81622. /**
  81623. * A perspective camera containing properties to create a perspective projection matrix
  81624. */
  81625. perspective?: ICameraPerspective;
  81626. /**
  81627. * Specifies if the camera uses a perspective or orthographic projection
  81628. */
  81629. type: CameraType;
  81630. }
  81631. /**
  81632. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  81633. */
  81634. interface IImage extends IChildRootProperty {
  81635. /**
  81636. * 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
  81637. */
  81638. uri?: string;
  81639. /**
  81640. * The image's MIME type
  81641. */
  81642. mimeType?: ImageMimeType;
  81643. /**
  81644. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  81645. */
  81646. bufferView?: number;
  81647. }
  81648. /**
  81649. * Material Normal Texture Info
  81650. */
  81651. interface IMaterialNormalTextureInfo extends ITextureInfo {
  81652. /**
  81653. * The scalar multiplier applied to each normal vector of the normal texture
  81654. */
  81655. scale?: number;
  81656. }
  81657. /**
  81658. * Material Occlusion Texture Info
  81659. */
  81660. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  81661. /**
  81662. * A scalar multiplier controlling the amount of occlusion applied
  81663. */
  81664. strength?: number;
  81665. }
  81666. /**
  81667. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  81668. */
  81669. interface IMaterialPbrMetallicRoughness {
  81670. /**
  81671. * The material's base color factor
  81672. */
  81673. baseColorFactor?: number[];
  81674. /**
  81675. * The base color texture
  81676. */
  81677. baseColorTexture?: ITextureInfo;
  81678. /**
  81679. * The metalness of the material
  81680. */
  81681. metallicFactor?: number;
  81682. /**
  81683. * The roughness of the material
  81684. */
  81685. roughnessFactor?: number;
  81686. /**
  81687. * The metallic-roughness texture
  81688. */
  81689. metallicRoughnessTexture?: ITextureInfo;
  81690. }
  81691. /**
  81692. * The material appearance of a primitive
  81693. */
  81694. interface IMaterial extends IChildRootProperty {
  81695. /**
  81696. * 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
  81697. */
  81698. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  81699. /**
  81700. * The normal map texture
  81701. */
  81702. normalTexture?: IMaterialNormalTextureInfo;
  81703. /**
  81704. * The occlusion map texture
  81705. */
  81706. occlusionTexture?: IMaterialOcclusionTextureInfo;
  81707. /**
  81708. * The emissive map texture
  81709. */
  81710. emissiveTexture?: ITextureInfo;
  81711. /**
  81712. * 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
  81713. */
  81714. emissiveFactor?: number[];
  81715. /**
  81716. * The alpha rendering mode of the material
  81717. */
  81718. alphaMode?: MaterialAlphaMode;
  81719. /**
  81720. * The alpha cutoff value of the material
  81721. */
  81722. alphaCutoff?: number;
  81723. /**
  81724. * Specifies whether the material is double sided
  81725. */
  81726. doubleSided?: boolean;
  81727. }
  81728. /**
  81729. * Geometry to be rendered with the given material
  81730. */
  81731. interface IMeshPrimitive extends IProperty {
  81732. /**
  81733. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  81734. */
  81735. attributes: {
  81736. [name: string]: number;
  81737. };
  81738. /**
  81739. * The index of the accessor that contains the indices
  81740. */
  81741. indices?: number;
  81742. /**
  81743. * The index of the material to apply to this primitive when rendering
  81744. */
  81745. material?: number;
  81746. /**
  81747. * The type of primitives to render. All valid values correspond to WebGL enums
  81748. */
  81749. mode?: MeshPrimitiveMode;
  81750. /**
  81751. * 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
  81752. */
  81753. targets?: {
  81754. [name: string]: number;
  81755. }[];
  81756. }
  81757. /**
  81758. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  81759. */
  81760. interface IMesh extends IChildRootProperty {
  81761. /**
  81762. * An array of primitives, each defining geometry to be rendered with a material
  81763. */
  81764. primitives: IMeshPrimitive[];
  81765. /**
  81766. * Array of weights to be applied to the Morph Targets
  81767. */
  81768. weights?: number[];
  81769. }
  81770. /**
  81771. * A node in the node hierarchy
  81772. */
  81773. interface INode extends IChildRootProperty {
  81774. /**
  81775. * The index of the camera referenced by this node
  81776. */
  81777. camera?: number;
  81778. /**
  81779. * The indices of this node's children
  81780. */
  81781. children?: number[];
  81782. /**
  81783. * The index of the skin referenced by this node
  81784. */
  81785. skin?: number;
  81786. /**
  81787. * A floating-point 4x4 transformation matrix stored in column-major order
  81788. */
  81789. matrix?: number[];
  81790. /**
  81791. * The index of the mesh in this node
  81792. */
  81793. mesh?: number;
  81794. /**
  81795. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  81796. */
  81797. rotation?: number[];
  81798. /**
  81799. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  81800. */
  81801. scale?: number[];
  81802. /**
  81803. * The node's translation along the x, y, and z axes
  81804. */
  81805. translation?: number[];
  81806. /**
  81807. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  81808. */
  81809. weights?: number[];
  81810. }
  81811. /**
  81812. * Texture sampler properties for filtering and wrapping modes
  81813. */
  81814. interface ISampler extends IChildRootProperty {
  81815. /**
  81816. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  81817. */
  81818. magFilter?: TextureMagFilter;
  81819. /**
  81820. * Minification filter. All valid values correspond to WebGL enums
  81821. */
  81822. minFilter?: TextureMinFilter;
  81823. /**
  81824. * S (U) wrapping mode. All valid values correspond to WebGL enums
  81825. */
  81826. wrapS?: TextureWrapMode;
  81827. /**
  81828. * T (V) wrapping mode. All valid values correspond to WebGL enums
  81829. */
  81830. wrapT?: TextureWrapMode;
  81831. }
  81832. /**
  81833. * The root nodes of a scene
  81834. */
  81835. interface IScene extends IChildRootProperty {
  81836. /**
  81837. * The indices of each root node
  81838. */
  81839. nodes: number[];
  81840. }
  81841. /**
  81842. * Joints and matrices defining a skin
  81843. */
  81844. interface ISkin extends IChildRootProperty {
  81845. /**
  81846. * 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
  81847. */
  81848. inverseBindMatrices?: number;
  81849. /**
  81850. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  81851. */
  81852. skeleton?: number;
  81853. /**
  81854. * 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)
  81855. */
  81856. joints: number[];
  81857. }
  81858. /**
  81859. * A texture and its sampler
  81860. */
  81861. interface ITexture extends IChildRootProperty {
  81862. /**
  81863. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  81864. */
  81865. sampler?: number;
  81866. /**
  81867. * The index of the image used by this texture
  81868. */
  81869. source: number;
  81870. }
  81871. /**
  81872. * Reference to a texture
  81873. */
  81874. interface ITextureInfo extends IProperty {
  81875. /**
  81876. * The index of the texture
  81877. */
  81878. index: number;
  81879. /**
  81880. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  81881. */
  81882. texCoord?: number;
  81883. }
  81884. /**
  81885. * The root object for a glTF asset
  81886. */
  81887. interface IGLTF extends IProperty {
  81888. /**
  81889. * An array of accessors. An accessor is a typed view into a bufferView
  81890. */
  81891. accessors?: IAccessor[];
  81892. /**
  81893. * An array of keyframe animations
  81894. */
  81895. animations?: IAnimation[];
  81896. /**
  81897. * Metadata about the glTF asset
  81898. */
  81899. asset: IAsset;
  81900. /**
  81901. * An array of buffers. A buffer points to binary geometry, animation, or skins
  81902. */
  81903. buffers?: IBuffer[];
  81904. /**
  81905. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  81906. */
  81907. bufferViews?: IBufferView[];
  81908. /**
  81909. * An array of cameras
  81910. */
  81911. cameras?: ICamera[];
  81912. /**
  81913. * Names of glTF extensions used somewhere in this asset
  81914. */
  81915. extensionsUsed?: string[];
  81916. /**
  81917. * Names of glTF extensions required to properly load this asset
  81918. */
  81919. extensionsRequired?: string[];
  81920. /**
  81921. * An array of images. An image defines data used to create a texture
  81922. */
  81923. images?: IImage[];
  81924. /**
  81925. * An array of materials. A material defines the appearance of a primitive
  81926. */
  81927. materials?: IMaterial[];
  81928. /**
  81929. * An array of meshes. A mesh is a set of primitives to be rendered
  81930. */
  81931. meshes?: IMesh[];
  81932. /**
  81933. * An array of nodes
  81934. */
  81935. nodes?: INode[];
  81936. /**
  81937. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  81938. */
  81939. samplers?: ISampler[];
  81940. /**
  81941. * The index of the default scene
  81942. */
  81943. scene?: number;
  81944. /**
  81945. * An array of scenes
  81946. */
  81947. scenes?: IScene[];
  81948. /**
  81949. * An array of skins. A skin is defined by joints and matrices
  81950. */
  81951. skins?: ISkin[];
  81952. /**
  81953. * An array of textures
  81954. */
  81955. textures?: ITexture[];
  81956. }
  81957. /**
  81958. * The glTF validation results
  81959. * @ignore
  81960. */
  81961. interface IGLTFValidationResults {
  81962. info: {
  81963. generator: string;
  81964. hasAnimations: boolean;
  81965. hasDefaultScene: boolean;
  81966. hasMaterials: boolean;
  81967. hasMorphTargets: boolean;
  81968. hasSkins: boolean;
  81969. hasTextures: boolean;
  81970. maxAttributesUsed: number;
  81971. primitivesCount: number
  81972. };
  81973. issues: {
  81974. messages: Array<string>;
  81975. numErrors: number;
  81976. numHints: number;
  81977. numInfos: number;
  81978. numWarnings: number;
  81979. truncated: boolean
  81980. };
  81981. mimeType: string;
  81982. uri: string;
  81983. validatedAt: string;
  81984. validatorVersion: string;
  81985. }
  81986. /**
  81987. * The glTF validation options
  81988. */
  81989. interface IGLTFValidationOptions {
  81990. /** Uri to use */
  81991. uri?: string;
  81992. /** Function used to load external resources */
  81993. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  81994. /** Boolean indicating that we need to validate accessor data */
  81995. validateAccessorData?: boolean;
  81996. /** max number of issues allowed */
  81997. maxIssues?: number;
  81998. /** Ignored issues */
  81999. ignoredIssues?: Array<string>;
  82000. /** Value to override severy settings */
  82001. severityOverrides?: Object;
  82002. }
  82003. /**
  82004. * The glTF validator object
  82005. * @ignore
  82006. */
  82007. interface IGLTFValidator {
  82008. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  82009. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  82010. }
  82011. }
  82012. declare module BABYLON {
  82013. /** @hidden */
  82014. export var cellPixelShader: {
  82015. name: string;
  82016. shader: string;
  82017. };
  82018. }
  82019. declare module BABYLON {
  82020. /** @hidden */
  82021. export var cellVertexShader: {
  82022. name: string;
  82023. shader: string;
  82024. };
  82025. }
  82026. declare module BABYLON {
  82027. export class CellMaterial extends BABYLON.PushMaterial {
  82028. private _diffuseTexture;
  82029. diffuseTexture: BABYLON.BaseTexture;
  82030. diffuseColor: BABYLON.Color3;
  82031. _computeHighLevel: boolean;
  82032. computeHighLevel: boolean;
  82033. private _disableLighting;
  82034. disableLighting: boolean;
  82035. private _maxSimultaneousLights;
  82036. maxSimultaneousLights: number;
  82037. constructor(name: string, scene: BABYLON.Scene);
  82038. needAlphaBlending(): boolean;
  82039. needAlphaTesting(): boolean;
  82040. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82041. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82042. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82043. getAnimatables(): BABYLON.IAnimatable[];
  82044. getActiveTextures(): BABYLON.BaseTexture[];
  82045. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82046. dispose(forceDisposeEffect?: boolean): void;
  82047. getClassName(): string;
  82048. clone(name: string): CellMaterial;
  82049. serialize(): any;
  82050. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  82051. }
  82052. }
  82053. declare module BABYLON {
  82054. export class CustomShaderStructure {
  82055. FragmentStore: string;
  82056. VertexStore: string;
  82057. constructor();
  82058. }
  82059. export class ShaderSpecialParts {
  82060. constructor();
  82061. Fragment_Begin: string;
  82062. Fragment_Definitions: string;
  82063. Fragment_MainBegin: string;
  82064. Fragment_Custom_Diffuse: string;
  82065. Fragment_Before_Lights: string;
  82066. Fragment_Before_Fog: string;
  82067. Fragment_Custom_Alpha: string;
  82068. Fragment_Before_FragColor: string;
  82069. Vertex_Begin: string;
  82070. Vertex_Definitions: string;
  82071. Vertex_MainBegin: string;
  82072. Vertex_Before_PositionUpdated: string;
  82073. Vertex_Before_NormalUpdated: string;
  82074. Vertex_After_WorldPosComputed: string;
  82075. Vertex_MainEnd: string;
  82076. }
  82077. export class CustomMaterial extends BABYLON.StandardMaterial {
  82078. static ShaderIndexer: number;
  82079. CustomParts: ShaderSpecialParts;
  82080. _isCreatedShader: boolean;
  82081. _createdShaderName: string;
  82082. _customUniform: string[];
  82083. _newUniforms: string[];
  82084. _newUniformInstances: {
  82085. [name: string]: any;
  82086. };
  82087. _newSamplerInstances: {
  82088. [name: string]: BABYLON.Texture;
  82089. };
  82090. _customAttributes: string[];
  82091. FragmentShader: string;
  82092. VertexShader: string;
  82093. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  82094. ReviewUniform(name: string, arr: string[]): string[];
  82095. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  82096. constructor(name: string, scene: BABYLON.Scene);
  82097. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  82098. AddAttribute(name: string): CustomMaterial;
  82099. Fragment_Begin(shaderPart: string): CustomMaterial;
  82100. Fragment_Definitions(shaderPart: string): CustomMaterial;
  82101. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  82102. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  82103. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  82104. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  82105. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  82106. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  82107. Vertex_Begin(shaderPart: string): CustomMaterial;
  82108. Vertex_Definitions(shaderPart: string): CustomMaterial;
  82109. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  82110. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  82111. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  82112. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  82113. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  82114. }
  82115. }
  82116. declare module BABYLON {
  82117. export class ShaderAlebdoParts {
  82118. constructor();
  82119. Fragment_Begin: string;
  82120. Fragment_Definitions: string;
  82121. Fragment_MainBegin: string;
  82122. Fragment_Custom_Albedo: string;
  82123. Fragment_Before_Lights: string;
  82124. Fragment_Custom_MetallicRoughness: string;
  82125. Fragment_Custom_MicroSurface: string;
  82126. Fragment_Before_Fog: string;
  82127. Fragment_Custom_Alpha: string;
  82128. Fragment_Before_FragColor: string;
  82129. Vertex_Begin: string;
  82130. Vertex_Definitions: string;
  82131. Vertex_MainBegin: string;
  82132. Vertex_Before_PositionUpdated: string;
  82133. Vertex_Before_NormalUpdated: string;
  82134. Vertex_After_WorldPosComputed: string;
  82135. Vertex_MainEnd: string;
  82136. }
  82137. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  82138. static ShaderIndexer: number;
  82139. CustomParts: ShaderAlebdoParts;
  82140. _isCreatedShader: boolean;
  82141. _createdShaderName: string;
  82142. _customUniform: string[];
  82143. _newUniforms: string[];
  82144. _newUniformInstances: {
  82145. [name: string]: any;
  82146. };
  82147. _newSamplerInstances: {
  82148. [name: string]: BABYLON.Texture;
  82149. };
  82150. _customAttributes: string[];
  82151. FragmentShader: string;
  82152. VertexShader: string;
  82153. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  82154. ReviewUniform(name: string, arr: string[]): string[];
  82155. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  82156. constructor(name: string, scene: BABYLON.Scene);
  82157. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  82158. AddAttribute(name: string): PBRCustomMaterial;
  82159. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  82160. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  82161. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  82162. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  82163. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  82164. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  82165. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  82166. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  82167. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  82168. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  82169. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  82170. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  82171. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  82172. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  82173. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  82174. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  82175. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  82176. }
  82177. }
  82178. declare module BABYLON {
  82179. /** @hidden */
  82180. export var firePixelShader: {
  82181. name: string;
  82182. shader: string;
  82183. };
  82184. }
  82185. declare module BABYLON {
  82186. /** @hidden */
  82187. export var fireVertexShader: {
  82188. name: string;
  82189. shader: string;
  82190. };
  82191. }
  82192. declare module BABYLON {
  82193. export class FireMaterial extends BABYLON.PushMaterial {
  82194. private _diffuseTexture;
  82195. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  82196. private _distortionTexture;
  82197. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  82198. private _opacityTexture;
  82199. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  82200. diffuseColor: BABYLON.Color3;
  82201. speed: number;
  82202. private _scaledDiffuse;
  82203. private _lastTime;
  82204. constructor(name: string, scene: BABYLON.Scene);
  82205. needAlphaBlending(): boolean;
  82206. needAlphaTesting(): boolean;
  82207. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82208. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82209. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82210. getAnimatables(): BABYLON.IAnimatable[];
  82211. getActiveTextures(): BABYLON.BaseTexture[];
  82212. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82213. getClassName(): string;
  82214. dispose(forceDisposeEffect?: boolean): void;
  82215. clone(name: string): FireMaterial;
  82216. serialize(): any;
  82217. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  82218. }
  82219. }
  82220. declare module BABYLON {
  82221. /** @hidden */
  82222. export var furPixelShader: {
  82223. name: string;
  82224. shader: string;
  82225. };
  82226. }
  82227. declare module BABYLON {
  82228. /** @hidden */
  82229. export var furVertexShader: {
  82230. name: string;
  82231. shader: string;
  82232. };
  82233. }
  82234. declare module BABYLON {
  82235. export class FurMaterial extends BABYLON.PushMaterial {
  82236. private _diffuseTexture;
  82237. diffuseTexture: BABYLON.BaseTexture;
  82238. private _heightTexture;
  82239. heightTexture: BABYLON.BaseTexture;
  82240. diffuseColor: BABYLON.Color3;
  82241. furLength: number;
  82242. furAngle: number;
  82243. furColor: BABYLON.Color3;
  82244. furOffset: number;
  82245. furSpacing: number;
  82246. furGravity: BABYLON.Vector3;
  82247. furSpeed: number;
  82248. furDensity: number;
  82249. furOcclusion: number;
  82250. furTexture: BABYLON.DynamicTexture;
  82251. private _disableLighting;
  82252. disableLighting: boolean;
  82253. private _maxSimultaneousLights;
  82254. maxSimultaneousLights: number;
  82255. highLevelFur: boolean;
  82256. _meshes: BABYLON.AbstractMesh[];
  82257. private _furTime;
  82258. constructor(name: string, scene: BABYLON.Scene);
  82259. get furTime(): number;
  82260. set furTime(furTime: number);
  82261. needAlphaBlending(): boolean;
  82262. needAlphaTesting(): boolean;
  82263. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82264. updateFur(): void;
  82265. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82266. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82267. getAnimatables(): BABYLON.IAnimatable[];
  82268. getActiveTextures(): BABYLON.BaseTexture[];
  82269. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82270. dispose(forceDisposeEffect?: boolean): void;
  82271. clone(name: string): FurMaterial;
  82272. serialize(): any;
  82273. getClassName(): string;
  82274. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  82275. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  82276. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  82277. }
  82278. }
  82279. declare module BABYLON {
  82280. /** @hidden */
  82281. export var gradientPixelShader: {
  82282. name: string;
  82283. shader: string;
  82284. };
  82285. }
  82286. declare module BABYLON {
  82287. /** @hidden */
  82288. export var gradientVertexShader: {
  82289. name: string;
  82290. shader: string;
  82291. };
  82292. }
  82293. declare module BABYLON {
  82294. export class GradientMaterial extends BABYLON.PushMaterial {
  82295. private _maxSimultaneousLights;
  82296. maxSimultaneousLights: number;
  82297. topColor: BABYLON.Color3;
  82298. topColorAlpha: number;
  82299. bottomColor: BABYLON.Color3;
  82300. bottomColorAlpha: number;
  82301. offset: number;
  82302. scale: number;
  82303. smoothness: number;
  82304. private _disableLighting;
  82305. disableLighting: boolean;
  82306. constructor(name: string, scene: BABYLON.Scene);
  82307. needAlphaBlending(): boolean;
  82308. needAlphaTesting(): boolean;
  82309. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82310. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82311. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82312. getAnimatables(): BABYLON.IAnimatable[];
  82313. dispose(forceDisposeEffect?: boolean): void;
  82314. clone(name: string): GradientMaterial;
  82315. serialize(): any;
  82316. getClassName(): string;
  82317. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  82318. }
  82319. }
  82320. declare module BABYLON {
  82321. /** @hidden */
  82322. export var gridPixelShader: {
  82323. name: string;
  82324. shader: string;
  82325. };
  82326. }
  82327. declare module BABYLON {
  82328. /** @hidden */
  82329. export var gridVertexShader: {
  82330. name: string;
  82331. shader: string;
  82332. };
  82333. }
  82334. declare module BABYLON {
  82335. /**
  82336. * The grid materials allows you to wrap any shape with a grid.
  82337. * Colors are customizable.
  82338. */
  82339. export class GridMaterial extends BABYLON.PushMaterial {
  82340. /**
  82341. * Main color of the grid (e.g. between lines)
  82342. */
  82343. mainColor: BABYLON.Color3;
  82344. /**
  82345. * Color of the grid lines.
  82346. */
  82347. lineColor: BABYLON.Color3;
  82348. /**
  82349. * The scale of the grid compared to unit.
  82350. */
  82351. gridRatio: number;
  82352. /**
  82353. * Allows setting an offset for the grid lines.
  82354. */
  82355. gridOffset: BABYLON.Vector3;
  82356. /**
  82357. * The frequency of thicker lines.
  82358. */
  82359. majorUnitFrequency: number;
  82360. /**
  82361. * The visibility of minor units in the grid.
  82362. */
  82363. minorUnitVisibility: number;
  82364. /**
  82365. * The grid opacity outside of the lines.
  82366. */
  82367. opacity: number;
  82368. /**
  82369. * Determine RBG output is premultiplied by alpha value.
  82370. */
  82371. preMultiplyAlpha: boolean;
  82372. private _opacityTexture;
  82373. opacityTexture: BABYLON.BaseTexture;
  82374. private _gridControl;
  82375. /**
  82376. * constructor
  82377. * @param name The name given to the material in order to identify it afterwards.
  82378. * @param scene The scene the material is used in.
  82379. */
  82380. constructor(name: string, scene: BABYLON.Scene);
  82381. /**
  82382. * Returns wehter or not the grid requires alpha blending.
  82383. */
  82384. needAlphaBlending(): boolean;
  82385. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  82386. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82387. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82388. /**
  82389. * Dispose the material and its associated resources.
  82390. * @param forceDisposeEffect will also dispose the used effect when true
  82391. */
  82392. dispose(forceDisposeEffect?: boolean): void;
  82393. clone(name: string): GridMaterial;
  82394. serialize(): any;
  82395. getClassName(): string;
  82396. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  82397. }
  82398. }
  82399. declare module BABYLON {
  82400. /** @hidden */
  82401. export var lavaPixelShader: {
  82402. name: string;
  82403. shader: string;
  82404. };
  82405. }
  82406. declare module BABYLON {
  82407. /** @hidden */
  82408. export var lavaVertexShader: {
  82409. name: string;
  82410. shader: string;
  82411. };
  82412. }
  82413. declare module BABYLON {
  82414. export class LavaMaterial extends BABYLON.PushMaterial {
  82415. private _diffuseTexture;
  82416. diffuseTexture: BABYLON.BaseTexture;
  82417. noiseTexture: BABYLON.BaseTexture;
  82418. fogColor: BABYLON.Color3;
  82419. speed: number;
  82420. movingSpeed: number;
  82421. lowFrequencySpeed: number;
  82422. fogDensity: number;
  82423. private _lastTime;
  82424. diffuseColor: BABYLON.Color3;
  82425. private _disableLighting;
  82426. disableLighting: boolean;
  82427. private _unlit;
  82428. unlit: boolean;
  82429. private _maxSimultaneousLights;
  82430. maxSimultaneousLights: number;
  82431. private _scaledDiffuse;
  82432. constructor(name: string, scene: BABYLON.Scene);
  82433. needAlphaBlending(): boolean;
  82434. needAlphaTesting(): boolean;
  82435. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82436. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82437. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82438. getAnimatables(): BABYLON.IAnimatable[];
  82439. getActiveTextures(): BABYLON.BaseTexture[];
  82440. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82441. dispose(forceDisposeEffect?: boolean): void;
  82442. clone(name: string): LavaMaterial;
  82443. serialize(): any;
  82444. getClassName(): string;
  82445. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  82446. }
  82447. }
  82448. declare module BABYLON {
  82449. /** @hidden */
  82450. export var mixPixelShader: {
  82451. name: string;
  82452. shader: string;
  82453. };
  82454. }
  82455. declare module BABYLON {
  82456. /** @hidden */
  82457. export var mixVertexShader: {
  82458. name: string;
  82459. shader: string;
  82460. };
  82461. }
  82462. declare module BABYLON {
  82463. export class MixMaterial extends BABYLON.PushMaterial {
  82464. /**
  82465. * Mix textures
  82466. */
  82467. private _mixTexture1;
  82468. mixTexture1: BABYLON.BaseTexture;
  82469. private _mixTexture2;
  82470. mixTexture2: BABYLON.BaseTexture;
  82471. /**
  82472. * Diffuse textures
  82473. */
  82474. private _diffuseTexture1;
  82475. diffuseTexture1: BABYLON.Texture;
  82476. private _diffuseTexture2;
  82477. diffuseTexture2: BABYLON.Texture;
  82478. private _diffuseTexture3;
  82479. diffuseTexture3: BABYLON.Texture;
  82480. private _diffuseTexture4;
  82481. diffuseTexture4: BABYLON.Texture;
  82482. private _diffuseTexture5;
  82483. diffuseTexture5: BABYLON.Texture;
  82484. private _diffuseTexture6;
  82485. diffuseTexture6: BABYLON.Texture;
  82486. private _diffuseTexture7;
  82487. diffuseTexture7: BABYLON.Texture;
  82488. private _diffuseTexture8;
  82489. diffuseTexture8: BABYLON.Texture;
  82490. /**
  82491. * Uniforms
  82492. */
  82493. diffuseColor: BABYLON.Color3;
  82494. specularColor: BABYLON.Color3;
  82495. specularPower: number;
  82496. private _disableLighting;
  82497. disableLighting: boolean;
  82498. private _maxSimultaneousLights;
  82499. maxSimultaneousLights: number;
  82500. constructor(name: string, scene: BABYLON.Scene);
  82501. needAlphaBlending(): boolean;
  82502. needAlphaTesting(): boolean;
  82503. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82504. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82505. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82506. getAnimatables(): BABYLON.IAnimatable[];
  82507. getActiveTextures(): BABYLON.BaseTexture[];
  82508. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82509. dispose(forceDisposeEffect?: boolean): void;
  82510. clone(name: string): MixMaterial;
  82511. serialize(): any;
  82512. getClassName(): string;
  82513. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  82514. }
  82515. }
  82516. declare module BABYLON {
  82517. /** @hidden */
  82518. export var normalPixelShader: {
  82519. name: string;
  82520. shader: string;
  82521. };
  82522. }
  82523. declare module BABYLON {
  82524. /** @hidden */
  82525. export var normalVertexShader: {
  82526. name: string;
  82527. shader: string;
  82528. };
  82529. }
  82530. declare module BABYLON {
  82531. export class NormalMaterial extends BABYLON.PushMaterial {
  82532. private _diffuseTexture;
  82533. diffuseTexture: BABYLON.BaseTexture;
  82534. diffuseColor: BABYLON.Color3;
  82535. private _disableLighting;
  82536. disableLighting: boolean;
  82537. private _maxSimultaneousLights;
  82538. maxSimultaneousLights: number;
  82539. constructor(name: string, scene: BABYLON.Scene);
  82540. needAlphaBlending(): boolean;
  82541. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  82542. needAlphaTesting(): boolean;
  82543. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82544. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82545. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82546. getAnimatables(): BABYLON.IAnimatable[];
  82547. getActiveTextures(): BABYLON.BaseTexture[];
  82548. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82549. dispose(forceDisposeEffect?: boolean): void;
  82550. clone(name: string): NormalMaterial;
  82551. serialize(): any;
  82552. getClassName(): string;
  82553. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  82554. }
  82555. }
  82556. declare module BABYLON {
  82557. /** @hidden */
  82558. export var shadowOnlyPixelShader: {
  82559. name: string;
  82560. shader: string;
  82561. };
  82562. }
  82563. declare module BABYLON {
  82564. /** @hidden */
  82565. export var shadowOnlyVertexShader: {
  82566. name: string;
  82567. shader: string;
  82568. };
  82569. }
  82570. declare module BABYLON {
  82571. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  82572. private _activeLight;
  82573. private _needAlphaBlending;
  82574. constructor(name: string, scene: BABYLON.Scene);
  82575. shadowColor: BABYLON.Color3;
  82576. needAlphaBlending(): boolean;
  82577. needAlphaTesting(): boolean;
  82578. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82579. get activeLight(): BABYLON.IShadowLight;
  82580. set activeLight(light: BABYLON.IShadowLight);
  82581. private _getFirstShadowLightForMesh;
  82582. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82583. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82584. clone(name: string): ShadowOnlyMaterial;
  82585. serialize(): any;
  82586. getClassName(): string;
  82587. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  82588. }
  82589. }
  82590. declare module BABYLON {
  82591. /** @hidden */
  82592. export var simplePixelShader: {
  82593. name: string;
  82594. shader: string;
  82595. };
  82596. }
  82597. declare module BABYLON {
  82598. /** @hidden */
  82599. export var simpleVertexShader: {
  82600. name: string;
  82601. shader: string;
  82602. };
  82603. }
  82604. declare module BABYLON {
  82605. export class SimpleMaterial extends BABYLON.PushMaterial {
  82606. private _diffuseTexture;
  82607. diffuseTexture: BABYLON.BaseTexture;
  82608. diffuseColor: BABYLON.Color3;
  82609. private _disableLighting;
  82610. disableLighting: boolean;
  82611. private _maxSimultaneousLights;
  82612. maxSimultaneousLights: number;
  82613. constructor(name: string, scene: BABYLON.Scene);
  82614. needAlphaBlending(): boolean;
  82615. needAlphaTesting(): boolean;
  82616. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82617. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82618. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82619. getAnimatables(): BABYLON.IAnimatable[];
  82620. getActiveTextures(): BABYLON.BaseTexture[];
  82621. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82622. dispose(forceDisposeEffect?: boolean): void;
  82623. clone(name: string): SimpleMaterial;
  82624. serialize(): any;
  82625. getClassName(): string;
  82626. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  82627. }
  82628. }
  82629. declare module BABYLON {
  82630. /** @hidden */
  82631. export var skyPixelShader: {
  82632. name: string;
  82633. shader: string;
  82634. };
  82635. }
  82636. declare module BABYLON {
  82637. /** @hidden */
  82638. export var skyVertexShader: {
  82639. name: string;
  82640. shader: string;
  82641. };
  82642. }
  82643. declare module BABYLON {
  82644. /**
  82645. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  82646. * @see https://doc.babylonjs.com/extensions/sky
  82647. */
  82648. export class SkyMaterial extends BABYLON.PushMaterial {
  82649. /**
  82650. * Defines the overall luminance of sky in interval ]0, 1[.
  82651. */
  82652. luminance: number;
  82653. /**
  82654. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  82655. */
  82656. turbidity: number;
  82657. /**
  82658. * Defines the sky appearance (light intensity).
  82659. */
  82660. rayleigh: number;
  82661. /**
  82662. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  82663. */
  82664. mieCoefficient: number;
  82665. /**
  82666. * Defines the amount of haze particles following the Mie scattering theory.
  82667. */
  82668. mieDirectionalG: number;
  82669. /**
  82670. * Defines the distance of the sun according to the active scene camera.
  82671. */
  82672. distance: number;
  82673. /**
  82674. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  82675. * "inclined".
  82676. */
  82677. inclination: number;
  82678. /**
  82679. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  82680. * an object direction and a reference direction.
  82681. */
  82682. azimuth: number;
  82683. /**
  82684. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  82685. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  82686. */
  82687. sunPosition: BABYLON.Vector3;
  82688. /**
  82689. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  82690. * .sunPosition property.
  82691. */
  82692. useSunPosition: boolean;
  82693. /**
  82694. * Defines an offset vector used to get a horizon offset.
  82695. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  82696. */
  82697. cameraOffset: BABYLON.Vector3;
  82698. private _cameraPosition;
  82699. /**
  82700. * Instantiates a new sky material.
  82701. * This material allows to create dynamic and texture free
  82702. * effects for skyboxes by taking care of the atmosphere state.
  82703. * @see https://doc.babylonjs.com/extensions/sky
  82704. * @param name Define the name of the material in the scene
  82705. * @param scene Define the scene the material belong to
  82706. */
  82707. constructor(name: string, scene: BABYLON.Scene);
  82708. /**
  82709. * Specifies if the material will require alpha blending
  82710. * @returns a boolean specifying if alpha blending is needed
  82711. */
  82712. needAlphaBlending(): boolean;
  82713. /**
  82714. * Specifies if this material should be rendered in alpha test mode
  82715. * @returns false as the sky material doesn't need alpha testing.
  82716. */
  82717. needAlphaTesting(): boolean;
  82718. /**
  82719. * Get the texture used for alpha test purpose.
  82720. * @returns null as the sky material has no texture.
  82721. */
  82722. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82723. /**
  82724. * Get if the submesh is ready to be used and all its information available.
  82725. * Child classes can use it to update shaders
  82726. * @param mesh defines the mesh to check
  82727. * @param subMesh defines which submesh to check
  82728. * @param useInstances specifies that instances should be used
  82729. * @returns a boolean indicating that the submesh is ready or not
  82730. */
  82731. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82732. /**
  82733. * Binds the submesh to this material by preparing the effect and shader to draw
  82734. * @param world defines the world transformation matrix
  82735. * @param mesh defines the mesh containing the submesh
  82736. * @param subMesh defines the submesh to bind the material to
  82737. */
  82738. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82739. /**
  82740. * Get the list of animatables in the material.
  82741. * @returns the list of animatables object used in the material
  82742. */
  82743. getAnimatables(): BABYLON.IAnimatable[];
  82744. /**
  82745. * Disposes the material
  82746. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  82747. */
  82748. dispose(forceDisposeEffect?: boolean): void;
  82749. /**
  82750. * Makes a duplicate of the material, and gives it a new name
  82751. * @param name defines the new name for the duplicated material
  82752. * @returns the cloned material
  82753. */
  82754. clone(name: string): SkyMaterial;
  82755. /**
  82756. * Serializes this material in a JSON representation
  82757. * @returns the serialized material object
  82758. */
  82759. serialize(): any;
  82760. /**
  82761. * Gets the current class name of the material e.g. "SkyMaterial"
  82762. * Mainly use in serialization.
  82763. * @returns the class name
  82764. */
  82765. getClassName(): string;
  82766. /**
  82767. * Creates a sky material from parsed material data
  82768. * @param source defines the JSON representation of the material
  82769. * @param scene defines the hosting scene
  82770. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  82771. * @returns a new sky material
  82772. */
  82773. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  82774. }
  82775. }
  82776. declare module BABYLON {
  82777. /** @hidden */
  82778. export var terrainPixelShader: {
  82779. name: string;
  82780. shader: string;
  82781. };
  82782. }
  82783. declare module BABYLON {
  82784. /** @hidden */
  82785. export var terrainVertexShader: {
  82786. name: string;
  82787. shader: string;
  82788. };
  82789. }
  82790. declare module BABYLON {
  82791. export class TerrainMaterial extends BABYLON.PushMaterial {
  82792. private _mixTexture;
  82793. mixTexture: BABYLON.BaseTexture;
  82794. private _diffuseTexture1;
  82795. diffuseTexture1: BABYLON.Texture;
  82796. private _diffuseTexture2;
  82797. diffuseTexture2: BABYLON.Texture;
  82798. private _diffuseTexture3;
  82799. diffuseTexture3: BABYLON.Texture;
  82800. private _bumpTexture1;
  82801. bumpTexture1: BABYLON.Texture;
  82802. private _bumpTexture2;
  82803. bumpTexture2: BABYLON.Texture;
  82804. private _bumpTexture3;
  82805. bumpTexture3: BABYLON.Texture;
  82806. diffuseColor: BABYLON.Color3;
  82807. specularColor: BABYLON.Color3;
  82808. specularPower: number;
  82809. private _disableLighting;
  82810. disableLighting: boolean;
  82811. private _maxSimultaneousLights;
  82812. maxSimultaneousLights: number;
  82813. constructor(name: string, scene: BABYLON.Scene);
  82814. needAlphaBlending(): boolean;
  82815. needAlphaTesting(): boolean;
  82816. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82817. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82818. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82819. getAnimatables(): BABYLON.IAnimatable[];
  82820. getActiveTextures(): BABYLON.BaseTexture[];
  82821. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82822. dispose(forceDisposeEffect?: boolean): void;
  82823. clone(name: string): TerrainMaterial;
  82824. serialize(): any;
  82825. getClassName(): string;
  82826. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  82827. }
  82828. }
  82829. declare module BABYLON {
  82830. /** @hidden */
  82831. export var triplanarPixelShader: {
  82832. name: string;
  82833. shader: string;
  82834. };
  82835. }
  82836. declare module BABYLON {
  82837. /** @hidden */
  82838. export var triplanarVertexShader: {
  82839. name: string;
  82840. shader: string;
  82841. };
  82842. }
  82843. declare module BABYLON {
  82844. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  82845. mixTexture: BABYLON.BaseTexture;
  82846. private _diffuseTextureX;
  82847. diffuseTextureX: BABYLON.BaseTexture;
  82848. private _diffuseTextureY;
  82849. diffuseTextureY: BABYLON.BaseTexture;
  82850. private _diffuseTextureZ;
  82851. diffuseTextureZ: BABYLON.BaseTexture;
  82852. private _normalTextureX;
  82853. normalTextureX: BABYLON.BaseTexture;
  82854. private _normalTextureY;
  82855. normalTextureY: BABYLON.BaseTexture;
  82856. private _normalTextureZ;
  82857. normalTextureZ: BABYLON.BaseTexture;
  82858. tileSize: number;
  82859. diffuseColor: BABYLON.Color3;
  82860. specularColor: BABYLON.Color3;
  82861. specularPower: number;
  82862. private _disableLighting;
  82863. disableLighting: boolean;
  82864. private _maxSimultaneousLights;
  82865. maxSimultaneousLights: number;
  82866. constructor(name: string, scene: BABYLON.Scene);
  82867. needAlphaBlending(): boolean;
  82868. needAlphaTesting(): boolean;
  82869. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82870. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82871. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82872. getAnimatables(): BABYLON.IAnimatable[];
  82873. getActiveTextures(): BABYLON.BaseTexture[];
  82874. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82875. dispose(forceDisposeEffect?: boolean): void;
  82876. clone(name: string): TriPlanarMaterial;
  82877. serialize(): any;
  82878. getClassName(): string;
  82879. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  82880. }
  82881. }
  82882. declare module BABYLON {
  82883. /** @hidden */
  82884. export var waterPixelShader: {
  82885. name: string;
  82886. shader: string;
  82887. };
  82888. }
  82889. declare module BABYLON {
  82890. /** @hidden */
  82891. export var waterVertexShader: {
  82892. name: string;
  82893. shader: string;
  82894. };
  82895. }
  82896. declare module BABYLON {
  82897. export class WaterMaterial extends BABYLON.PushMaterial {
  82898. renderTargetSize: BABYLON.Vector2;
  82899. private _bumpTexture;
  82900. bumpTexture: BABYLON.BaseTexture;
  82901. diffuseColor: BABYLON.Color3;
  82902. specularColor: BABYLON.Color3;
  82903. specularPower: number;
  82904. private _disableLighting;
  82905. disableLighting: boolean;
  82906. private _maxSimultaneousLights;
  82907. maxSimultaneousLights: number;
  82908. /**
  82909. * @param {number}: Represents the wind force
  82910. */
  82911. windForce: number;
  82912. /**
  82913. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  82914. */
  82915. windDirection: BABYLON.Vector2;
  82916. /**
  82917. * @param {number}: Wave height, represents the height of the waves
  82918. */
  82919. waveHeight: number;
  82920. /**
  82921. * @param {number}: Bump height, represents the bump height related to the bump map
  82922. */
  82923. bumpHeight: number;
  82924. /**
  82925. * @param {boolean}: Add a smaller moving bump to less steady waves.
  82926. */
  82927. private _bumpSuperimpose;
  82928. bumpSuperimpose: boolean;
  82929. /**
  82930. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  82931. */
  82932. private _fresnelSeparate;
  82933. fresnelSeparate: boolean;
  82934. /**
  82935. * @param {boolean}: bump Waves modify the reflection.
  82936. */
  82937. private _bumpAffectsReflection;
  82938. bumpAffectsReflection: boolean;
  82939. /**
  82940. * @param {number}: The water color blended with the refraction (near)
  82941. */
  82942. waterColor: BABYLON.Color3;
  82943. /**
  82944. * @param {number}: The blend factor related to the water color
  82945. */
  82946. colorBlendFactor: number;
  82947. /**
  82948. * @param {number}: The water color blended with the reflection (far)
  82949. */
  82950. waterColor2: BABYLON.Color3;
  82951. /**
  82952. * @param {number}: The blend factor related to the water color (reflection, far)
  82953. */
  82954. colorBlendFactor2: number;
  82955. /**
  82956. * @param {number}: Represents the maximum length of a wave
  82957. */
  82958. waveLength: number;
  82959. /**
  82960. * @param {number}: Defines the waves speed
  82961. */
  82962. waveSpeed: number;
  82963. /**
  82964. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  82965. * will avoid calculating useless pixels in the pixel shader of the water material.
  82966. */
  82967. disableClipPlane: boolean;
  82968. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  82969. private _mesh;
  82970. private _refractionRTT;
  82971. private _reflectionRTT;
  82972. private _reflectionTransform;
  82973. private _lastTime;
  82974. private _lastDeltaTime;
  82975. private _useLogarithmicDepth;
  82976. private _waitingRenderList;
  82977. private _imageProcessingConfiguration;
  82978. private _imageProcessingObserver;
  82979. /**
  82980. * Gets a boolean indicating that current material needs to register RTT
  82981. */
  82982. get hasRenderTargetTextures(): boolean;
  82983. /**
  82984. * Constructor
  82985. */
  82986. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  82987. get useLogarithmicDepth(): boolean;
  82988. set useLogarithmicDepth(value: boolean);
  82989. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  82990. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  82991. addToRenderList(node: any): void;
  82992. enableRenderTargets(enable: boolean): void;
  82993. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  82994. get renderTargetsEnabled(): boolean;
  82995. needAlphaBlending(): boolean;
  82996. needAlphaTesting(): boolean;
  82997. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82998. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82999. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83000. private _createRenderTargets;
  83001. getAnimatables(): BABYLON.IAnimatable[];
  83002. getActiveTextures(): BABYLON.BaseTexture[];
  83003. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83004. dispose(forceDisposeEffect?: boolean): void;
  83005. clone(name: string): WaterMaterial;
  83006. serialize(): any;
  83007. getClassName(): string;
  83008. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  83009. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  83010. }
  83011. }
  83012. declare module BABYLON {
  83013. /** @hidden */
  83014. export var asciiartPixelShader: {
  83015. name: string;
  83016. shader: string;
  83017. };
  83018. }
  83019. declare module BABYLON {
  83020. /**
  83021. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  83022. *
  83023. * It basically takes care rendering the font front the given font size to a texture.
  83024. * This is used later on in the postprocess.
  83025. */
  83026. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  83027. private _font;
  83028. private _text;
  83029. private _charSize;
  83030. /**
  83031. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  83032. */
  83033. get charSize(): number;
  83034. /**
  83035. * Create a new instance of the Ascii Art FontTexture class
  83036. * @param name the name of the texture
  83037. * @param font the font to use, use the W3C CSS notation
  83038. * @param text the caracter set to use in the rendering.
  83039. * @param scene the scene that owns the texture
  83040. */
  83041. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  83042. /**
  83043. * Gets the max char width of a font.
  83044. * @param font the font to use, use the W3C CSS notation
  83045. * @return the max char width
  83046. */
  83047. private getFontWidth;
  83048. /**
  83049. * Gets the max char height of a font.
  83050. * @param font the font to use, use the W3C CSS notation
  83051. * @return the max char height
  83052. */
  83053. private getFontHeight;
  83054. /**
  83055. * Clones the current AsciiArtTexture.
  83056. * @return the clone of the texture.
  83057. */
  83058. clone(): AsciiArtFontTexture;
  83059. /**
  83060. * Parses a json object representing the texture and returns an instance of it.
  83061. * @param source the source JSON representation
  83062. * @param scene the scene to create the texture for
  83063. * @return the parsed texture
  83064. */
  83065. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  83066. }
  83067. /**
  83068. * Option available in the Ascii Art Post Process.
  83069. */
  83070. export interface IAsciiArtPostProcessOptions {
  83071. /**
  83072. * The font to use following the w3c font definition.
  83073. */
  83074. font?: string;
  83075. /**
  83076. * The character set to use in the postprocess.
  83077. */
  83078. characterSet?: string;
  83079. /**
  83080. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  83081. * This number is defined between 0 and 1;
  83082. */
  83083. mixToTile?: number;
  83084. /**
  83085. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  83086. * This number is defined between 0 and 1;
  83087. */
  83088. mixToNormal?: number;
  83089. }
  83090. /**
  83091. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  83092. *
  83093. * Simmply add it to your scene and let the nerd that lives in you have fun.
  83094. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  83095. */
  83096. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  83097. /**
  83098. * The font texture used to render the char in the post process.
  83099. */
  83100. private _asciiArtFontTexture;
  83101. /**
  83102. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  83103. * This number is defined between 0 and 1;
  83104. */
  83105. mixToTile: number;
  83106. /**
  83107. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  83108. * This number is defined between 0 and 1;
  83109. */
  83110. mixToNormal: number;
  83111. /**
  83112. * Instantiates a new Ascii Art Post Process.
  83113. * @param name the name to give to the postprocess
  83114. * @camera the camera to apply the post process to.
  83115. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  83116. */
  83117. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  83118. }
  83119. }
  83120. declare module BABYLON {
  83121. /** @hidden */
  83122. export var digitalrainPixelShader: {
  83123. name: string;
  83124. shader: string;
  83125. };
  83126. }
  83127. declare module BABYLON {
  83128. /**
  83129. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  83130. *
  83131. * It basically takes care rendering the font front the given font size to a texture.
  83132. * This is used later on in the postprocess.
  83133. */
  83134. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  83135. private _font;
  83136. private _text;
  83137. private _charSize;
  83138. /**
  83139. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  83140. */
  83141. get charSize(): number;
  83142. /**
  83143. * Create a new instance of the Digital Rain FontTexture class
  83144. * @param name the name of the texture
  83145. * @param font the font to use, use the W3C CSS notation
  83146. * @param text the caracter set to use in the rendering.
  83147. * @param scene the scene that owns the texture
  83148. */
  83149. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  83150. /**
  83151. * Gets the max char width of a font.
  83152. * @param font the font to use, use the W3C CSS notation
  83153. * @return the max char width
  83154. */
  83155. private getFontWidth;
  83156. /**
  83157. * Gets the max char height of a font.
  83158. * @param font the font to use, use the W3C CSS notation
  83159. * @return the max char height
  83160. */
  83161. private getFontHeight;
  83162. /**
  83163. * Clones the current DigitalRainFontTexture.
  83164. * @return the clone of the texture.
  83165. */
  83166. clone(): DigitalRainFontTexture;
  83167. /**
  83168. * Parses a json object representing the texture and returns an instance of it.
  83169. * @param source the source JSON representation
  83170. * @param scene the scene to create the texture for
  83171. * @return the parsed texture
  83172. */
  83173. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  83174. }
  83175. /**
  83176. * Option available in the Digital Rain Post Process.
  83177. */
  83178. export interface IDigitalRainPostProcessOptions {
  83179. /**
  83180. * The font to use following the w3c font definition.
  83181. */
  83182. font?: string;
  83183. /**
  83184. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  83185. * This number is defined between 0 and 1;
  83186. */
  83187. mixToTile?: number;
  83188. /**
  83189. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  83190. * This number is defined between 0 and 1;
  83191. */
  83192. mixToNormal?: number;
  83193. }
  83194. /**
  83195. * DigitalRainPostProcess helps rendering everithing in digital rain.
  83196. *
  83197. * Simmply add it to your scene and let the nerd that lives in you have fun.
  83198. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  83199. */
  83200. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  83201. /**
  83202. * The font texture used to render the char in the post process.
  83203. */
  83204. private _digitalRainFontTexture;
  83205. /**
  83206. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  83207. * This number is defined between 0 and 1;
  83208. */
  83209. mixToTile: number;
  83210. /**
  83211. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  83212. * This number is defined between 0 and 1;
  83213. */
  83214. mixToNormal: number;
  83215. /**
  83216. * Instantiates a new Digital Rain Post Process.
  83217. * @param name the name to give to the postprocess
  83218. * @camera the camera to apply the post process to.
  83219. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  83220. */
  83221. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  83222. }
  83223. }
  83224. declare module BABYLON {
  83225. /** @hidden */
  83226. export var brickProceduralTexturePixelShader: {
  83227. name: string;
  83228. shader: string;
  83229. };
  83230. }
  83231. declare module BABYLON {
  83232. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  83233. private _numberOfBricksHeight;
  83234. private _numberOfBricksWidth;
  83235. private _jointColor;
  83236. private _brickColor;
  83237. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83238. updateShaderUniforms(): void;
  83239. get numberOfBricksHeight(): number;
  83240. set numberOfBricksHeight(value: number);
  83241. get numberOfBricksWidth(): number;
  83242. set numberOfBricksWidth(value: number);
  83243. get jointColor(): BABYLON.Color3;
  83244. set jointColor(value: BABYLON.Color3);
  83245. get brickColor(): BABYLON.Color3;
  83246. set brickColor(value: BABYLON.Color3);
  83247. /**
  83248. * Serializes this brick procedural texture
  83249. * @returns a serialized brick procedural texture object
  83250. */
  83251. serialize(): any;
  83252. /**
  83253. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  83254. * @param parsedTexture defines parsed texture data
  83255. * @param scene defines the current scene
  83256. * @param rootUrl defines the root URL containing brick procedural texture information
  83257. * @returns a parsed Brick Procedural BABYLON.Texture
  83258. */
  83259. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  83260. }
  83261. }
  83262. declare module BABYLON {
  83263. /** @hidden */
  83264. export var cloudProceduralTexturePixelShader: {
  83265. name: string;
  83266. shader: string;
  83267. };
  83268. }
  83269. declare module BABYLON {
  83270. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  83271. private _skyColor;
  83272. private _cloudColor;
  83273. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83274. updateShaderUniforms(): void;
  83275. get skyColor(): BABYLON.Color4;
  83276. set skyColor(value: BABYLON.Color4);
  83277. get cloudColor(): BABYLON.Color4;
  83278. set cloudColor(value: BABYLON.Color4);
  83279. /**
  83280. * Serializes this cloud procedural texture
  83281. * @returns a serialized cloud procedural texture object
  83282. */
  83283. serialize(): any;
  83284. /**
  83285. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  83286. * @param parsedTexture defines parsed texture data
  83287. * @param scene defines the current scene
  83288. * @param rootUrl defines the root URL containing cloud procedural texture information
  83289. * @returns a parsed Cloud Procedural BABYLON.Texture
  83290. */
  83291. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  83292. }
  83293. }
  83294. declare module BABYLON {
  83295. /** @hidden */
  83296. export var fireProceduralTexturePixelShader: {
  83297. name: string;
  83298. shader: string;
  83299. };
  83300. }
  83301. declare module BABYLON {
  83302. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  83303. private _time;
  83304. private _speed;
  83305. private _autoGenerateTime;
  83306. private _fireColors;
  83307. private _alphaThreshold;
  83308. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83309. updateShaderUniforms(): void;
  83310. render(useCameraPostProcess?: boolean): void;
  83311. static get PurpleFireColors(): BABYLON.Color3[];
  83312. static get GreenFireColors(): BABYLON.Color3[];
  83313. static get RedFireColors(): BABYLON.Color3[];
  83314. static get BlueFireColors(): BABYLON.Color3[];
  83315. get autoGenerateTime(): boolean;
  83316. set autoGenerateTime(value: boolean);
  83317. get fireColors(): BABYLON.Color3[];
  83318. set fireColors(value: BABYLON.Color3[]);
  83319. get time(): number;
  83320. set time(value: number);
  83321. get speed(): BABYLON.Vector2;
  83322. set speed(value: BABYLON.Vector2);
  83323. get alphaThreshold(): number;
  83324. set alphaThreshold(value: number);
  83325. /**
  83326. * Serializes this fire procedural texture
  83327. * @returns a serialized fire procedural texture object
  83328. */
  83329. serialize(): any;
  83330. /**
  83331. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  83332. * @param parsedTexture defines parsed texture data
  83333. * @param scene defines the current scene
  83334. * @param rootUrl defines the root URL containing fire procedural texture information
  83335. * @returns a parsed Fire Procedural BABYLON.Texture
  83336. */
  83337. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  83338. }
  83339. }
  83340. declare module BABYLON {
  83341. /** @hidden */
  83342. export var grassProceduralTexturePixelShader: {
  83343. name: string;
  83344. shader: string;
  83345. };
  83346. }
  83347. declare module BABYLON {
  83348. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  83349. private _grassColors;
  83350. private _groundColor;
  83351. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83352. updateShaderUniforms(): void;
  83353. get grassColors(): BABYLON.Color3[];
  83354. set grassColors(value: BABYLON.Color3[]);
  83355. get groundColor(): BABYLON.Color3;
  83356. set groundColor(value: BABYLON.Color3);
  83357. /**
  83358. * Serializes this grass procedural texture
  83359. * @returns a serialized grass procedural texture object
  83360. */
  83361. serialize(): any;
  83362. /**
  83363. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  83364. * @param parsedTexture defines parsed texture data
  83365. * @param scene defines the current scene
  83366. * @param rootUrl defines the root URL containing grass procedural texture information
  83367. * @returns a parsed Grass Procedural BABYLON.Texture
  83368. */
  83369. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  83370. }
  83371. }
  83372. declare module BABYLON {
  83373. /** @hidden */
  83374. export var marbleProceduralTexturePixelShader: {
  83375. name: string;
  83376. shader: string;
  83377. };
  83378. }
  83379. declare module BABYLON {
  83380. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  83381. private _numberOfTilesHeight;
  83382. private _numberOfTilesWidth;
  83383. private _amplitude;
  83384. private _jointColor;
  83385. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83386. updateShaderUniforms(): void;
  83387. get numberOfTilesHeight(): number;
  83388. set numberOfTilesHeight(value: number);
  83389. get amplitude(): number;
  83390. set amplitude(value: number);
  83391. get numberOfTilesWidth(): number;
  83392. set numberOfTilesWidth(value: number);
  83393. get jointColor(): BABYLON.Color3;
  83394. set jointColor(value: BABYLON.Color3);
  83395. /**
  83396. * Serializes this marble procedural texture
  83397. * @returns a serialized marble procedural texture object
  83398. */
  83399. serialize(): any;
  83400. /**
  83401. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  83402. * @param parsedTexture defines parsed texture data
  83403. * @param scene defines the current scene
  83404. * @param rootUrl defines the root URL containing marble procedural texture information
  83405. * @returns a parsed Marble Procedural BABYLON.Texture
  83406. */
  83407. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  83408. }
  83409. }
  83410. declare module BABYLON {
  83411. /** @hidden */
  83412. export var normalMapProceduralTexturePixelShader: {
  83413. name: string;
  83414. shader: string;
  83415. };
  83416. }
  83417. declare module BABYLON {
  83418. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  83419. private _baseTexture;
  83420. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83421. updateShaderUniforms(): void;
  83422. render(useCameraPostProcess?: boolean): void;
  83423. resize(size: any, generateMipMaps: any): void;
  83424. get baseTexture(): BABYLON.Texture;
  83425. set baseTexture(texture: BABYLON.Texture);
  83426. /**
  83427. * Serializes this normal map procedural texture
  83428. * @returns a serialized normal map procedural texture object
  83429. */
  83430. serialize(): any;
  83431. /**
  83432. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  83433. * @param parsedTexture defines parsed texture data
  83434. * @param scene defines the current scene
  83435. * @param rootUrl defines the root URL containing normal map procedural texture information
  83436. * @returns a parsed Normal Map Procedural BABYLON.Texture
  83437. */
  83438. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  83439. }
  83440. }
  83441. declare module BABYLON {
  83442. /** @hidden */
  83443. export var perlinNoiseProceduralTexturePixelShader: {
  83444. name: string;
  83445. shader: string;
  83446. };
  83447. }
  83448. declare module BABYLON {
  83449. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  83450. time: number;
  83451. timeScale: number;
  83452. translationSpeed: number;
  83453. private _currentTranslation;
  83454. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83455. updateShaderUniforms(): void;
  83456. render(useCameraPostProcess?: boolean): void;
  83457. resize(size: any, generateMipMaps: any): void;
  83458. /**
  83459. * Serializes this perlin noise procedural texture
  83460. * @returns a serialized perlin noise procedural texture object
  83461. */
  83462. serialize(): any;
  83463. /**
  83464. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  83465. * @param parsedTexture defines parsed texture data
  83466. * @param scene defines the current scene
  83467. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  83468. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  83469. */
  83470. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  83471. }
  83472. }
  83473. declare module BABYLON {
  83474. /** @hidden */
  83475. export var roadProceduralTexturePixelShader: {
  83476. name: string;
  83477. shader: string;
  83478. };
  83479. }
  83480. declare module BABYLON {
  83481. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  83482. private _roadColor;
  83483. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83484. updateShaderUniforms(): void;
  83485. get roadColor(): BABYLON.Color3;
  83486. set roadColor(value: BABYLON.Color3);
  83487. /**
  83488. * Serializes this road procedural texture
  83489. * @returns a serialized road procedural texture object
  83490. */
  83491. serialize(): any;
  83492. /**
  83493. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  83494. * @param parsedTexture defines parsed texture data
  83495. * @param scene defines the current scene
  83496. * @param rootUrl defines the root URL containing road procedural texture information
  83497. * @returns a parsed Road Procedural BABYLON.Texture
  83498. */
  83499. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  83500. }
  83501. }
  83502. declare module BABYLON {
  83503. /** @hidden */
  83504. export var starfieldProceduralTexturePixelShader: {
  83505. name: string;
  83506. shader: string;
  83507. };
  83508. }
  83509. declare module BABYLON {
  83510. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  83511. private _time;
  83512. private _alpha;
  83513. private _beta;
  83514. private _zoom;
  83515. private _formuparam;
  83516. private _stepsize;
  83517. private _tile;
  83518. private _brightness;
  83519. private _darkmatter;
  83520. private _distfading;
  83521. private _saturation;
  83522. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83523. updateShaderUniforms(): void;
  83524. get time(): number;
  83525. set time(value: number);
  83526. get alpha(): number;
  83527. set alpha(value: number);
  83528. get beta(): number;
  83529. set beta(value: number);
  83530. get formuparam(): number;
  83531. set formuparam(value: number);
  83532. get stepsize(): number;
  83533. set stepsize(value: number);
  83534. get zoom(): number;
  83535. set zoom(value: number);
  83536. get tile(): number;
  83537. set tile(value: number);
  83538. get brightness(): number;
  83539. set brightness(value: number);
  83540. get darkmatter(): number;
  83541. set darkmatter(value: number);
  83542. get distfading(): number;
  83543. set distfading(value: number);
  83544. get saturation(): number;
  83545. set saturation(value: number);
  83546. /**
  83547. * Serializes this starfield procedural texture
  83548. * @returns a serialized starfield procedural texture object
  83549. */
  83550. serialize(): any;
  83551. /**
  83552. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  83553. * @param parsedTexture defines parsed texture data
  83554. * @param scene defines the current scene
  83555. * @param rootUrl defines the root URL containing startfield procedural texture information
  83556. * @returns a parsed Starfield Procedural BABYLON.Texture
  83557. */
  83558. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  83559. }
  83560. }
  83561. declare module BABYLON {
  83562. /** @hidden */
  83563. export var woodProceduralTexturePixelShader: {
  83564. name: string;
  83565. shader: string;
  83566. };
  83567. }
  83568. declare module BABYLON {
  83569. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  83570. private _ampScale;
  83571. private _woodColor;
  83572. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83573. updateShaderUniforms(): void;
  83574. get ampScale(): number;
  83575. set ampScale(value: number);
  83576. get woodColor(): BABYLON.Color3;
  83577. set woodColor(value: BABYLON.Color3);
  83578. /**
  83579. * Serializes this wood procedural texture
  83580. * @returns a serialized wood procedural texture object
  83581. */
  83582. serialize(): any;
  83583. /**
  83584. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  83585. * @param parsedTexture defines parsed texture data
  83586. * @param scene defines the current scene
  83587. * @param rootUrl defines the root URL containing wood procedural texture information
  83588. * @returns a parsed Wood Procedural BABYLON.Texture
  83589. */
  83590. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  83591. }
  83592. }